Page 1 of 1

TgtV code

PostPosted: 22 Oct 2010, 00:29
by slapshot5
Is there a way to tell TgtV that a card's ability cannot target itself?

I'd like to be able to do:

Code: Select all
Target target = new Target("TgtV", "Select another target Creature.", "Creature.notSelf"};
or something like that.

-slapshot5

Re: TgtV code

PostPosted: 22 Oct 2010, 01:26
by friarsol
This is an IsValidCard parameter. I don't believe it exists right now since the activating card isn't sent down the chain. I think Sloth has done the most work on that stuff, if he wants to add the ability for .Other ?

Re: TgtV code

PostPosted: 22 Oct 2010, 05:29
by Sloth
This is not supported for the reasons Sol mentioned, but we can just add it to the isValidCard check that also needs a Player and make another isValidCard that only needs a Card as argument in addtion to the restrictions.

I think I proposed this before, for the stPump keyword. Maybe I can add something today.

Re: TgtV code

PostPosted: 22 Oct 2010, 10:36
by Sloth
I have added isValidCard(String Restris[], Card source) and isValidCard(String Restris[], Player You, Card source) to support the restrictions "Other" and "Self". Validation is done for each entry of Restris, which means "Skeleton.YouCtrl,Zombie.Other+YouCtrl" is now possible.

I'm gooing to update stPump to use this.

Re: TgtV code

PostPosted: 05 Nov 2010, 04:57
by slapshot5
How can I update AbilityFactory to use this?

And while I'm on the topic, there are a lot of different entry points for getValidCards(). This makes behavior different depending on where you are using valid cards. Would it be possible to have more consistency? (I'm not sure if all places that call it can pass in getValidCards(String[], Player, Card))

For example, Creature.Vampire+Other does not work in AbilityFactory_Regenerate.

-slapshot5

Re: TgtV code

PostPosted: 05 Nov 2010, 09:03
by Sloth
slapshot5 wrote:How can I update AbilityFactory to use this?
AbilityFactory already uses it with the parameter ValidTgts. Example:

Code: Select all
Name:Elven Fortress
ManaCost:G
Types:enchantment
Text:no text
A:AB$Pump|Cost$1 G|ValidTgts$Creature.blocking|NumDef$+1|SpellDescription$Target blocking creature gets +0/+1 until end of turn.|TgtPrompt$Select target blocking creature.
End
slapshot5 wrote:And while I'm on the topic, there are a lot of different entry points for getValidCards(). This makes behavior different depending on where you are using valid cards. Would it be possible to have more consistency? (I'm not sure if all places that call it can pass in getValidCards(String[], Player, Card))
All places that can, should use getValidCards(String[], Player, Card). If there is no card as a source using Other or Self wouldn't make sense anyway.

slapshot5 wrote:For example, Creature.Vampire+Other does not work in AbilityFactory_Regenerate.
Did you try ValidTgts?

Re: TgtV code

PostPosted: 05 Nov 2010, 14:30
by slapshot5
Sloth wrote:
slapshot5 wrote:How can I update AbilityFactory to use this?

slapshot5 wrote:For example, Creature.Vampire+Other does not work in AbilityFactory_Regenerate.
Did you try ValidTgts?
Here is what I used:
Code: Select all
A:AB$Regenerate|ValidTgts$Creature.Vampire+Other|TgtPrompt$Select another target Vampire|Cost$T|SpellDescription$Regenerate another target vampire.
This doesn't let me target anything. Tracing it through AbilityFactory, and then to Target_Selection gets me to Target_Selection.input_targetValid(), which has:

Code: Select all
CardList choices = AllZoneUtil.getCardsInZone(zone).getValidCards(Tgts, sa.getSourceCard().getController());
which doesn't pass in Source Card, but it obviously could. Is it just a matter of adding this third parameter? I added it locally, but saw strange (inconsistent) behavior. I wanted to ask before assuming this was correct and breaking a lot of stuff.

-slapshot5

Re: TgtV code

PostPosted: 05 Nov 2010, 14:56
by friarsol
How was the behavior inconsistent? Did you try .Other instead of +Other?

Re: TgtV code

PostPosted: 05 Nov 2010, 19:39
by Sloth
slapshot5 wrote:
Code: Select all
CardList choices = AllZoneUtil.getCardsInZone(zone).getValidCards(Tgts, sa.getSourceCard().getController());
which doesn't pass in Source Card, but it obviously could. Is it just a matter of adding this third parameter? I added it locally, but saw strange (inconsistent) behavior. I wanted to ask before assuming this was correct and breaking a lot of stuff.
There should be no problem. Commit it and I will test it.

friarsol wrote:How was the behavior inconsistent? Did you try .Other instead of +Other?
There should be no problem with +Other. (in Creature.Vampire.Other the "Other" would be ignored i think).

Re: TgtV code

PostPosted: 05 Nov 2010, 19:48
by friarsol
Sloth wrote:There should be no problem with +Other. (in Creature.Vampire.Other the "Other" would be ignored i think).
Well, the Other code is stripped first, but it only strips ".Other", even though it looks for "Other" this may lead to +Other being left behind, although I don't know if that would cause any issues.

Re: TgtV code

PostPosted: 05 Nov 2010, 20:39
by Sloth
friarsol wrote:Well, the Other code is stripped first, but it only strips ".Other", even though it looks for "Other" this may lead to +Other being left behind, although I don't know if that would cause any issues.
Rob had to convince me too, but using "." in the replace string will trigger off and replace some other special characters (including "+").

Re: TgtV code

PostPosted: 05 Nov 2010, 20:41
by friarsol
Oh I keep forgetting that Replace is a regex. Stupid Java.

Re: TgtV code

PostPosted: 05 Nov 2010, 20:43
by slapshot5
I've checked this in. My example test today seems to be working fine with a clean tree. Must have had some cruft in my tree yesterday.

-slapshot5

Re: TgtV code

PostPosted: 05 Nov 2010, 20:54
by slapshot5
Ok, Baron Sengir and Ezuri, Renegade Leader are making use of this change.