TgtV code
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
14 posts
• Page 1 of 1
TgtV code
by slapshot5 » 22 Oct 2010, 00:29
Is there a way to tell TgtV that a card's ability cannot target itself?
I'd like to be able to do:
-slapshot5
I'd like to be able to do:
- Code: Select all
Target target = new Target("TgtV", "Select another target Creature.", "Creature.notSelf"};
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: TgtV code
by friarsol » 22 Oct 2010, 01:26
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 ?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: TgtV code
by Sloth » 22 Oct 2010, 05:29
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.
I think I proposed this before, for the stPump keyword. Maybe I can add something today.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: TgtV code
by Sloth » 22 Oct 2010, 10:36
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.
I'm gooing to update stPump to use this.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: TgtV code
by slapshot5 » 05 Nov 2010, 04:57
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
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
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: TgtV code
by Sloth » 05 Nov 2010, 09:03
AbilityFactory already uses it with the parameter ValidTgts. Example:slapshot5 wrote:How can I update AbilityFactory to use this?
- 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
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: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))
Did you try ValidTgts?slapshot5 wrote:For example, Creature.Vampire+Other does not work in AbilityFactory_Regenerate.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: TgtV code
by slapshot5 » 05 Nov 2010, 14:30
Here is what I used:Sloth wrote:slapshot5 wrote:How can I update AbilityFactory to use this?Did you try ValidTgts?slapshot5 wrote:For example, Creature.Vampire+Other does not work in AbilityFactory_Regenerate.
- Code: Select all
A:AB$Regenerate|ValidTgts$Creature.Vampire+Other|TgtPrompt$Select another target Vampire|Cost$T|SpellDescription$Regenerate another target vampire.
- Code: Select all
CardList choices = AllZoneUtil.getCardsInZone(zone).getValidCards(Tgts, sa.getSourceCard().getController());
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: TgtV code
by friarsol » 05 Nov 2010, 14:56
How was the behavior inconsistent? Did you try .Other instead of +Other?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: TgtV code
by Sloth » 05 Nov 2010, 19:39
There should be no problem. Commit it and I will test it.slapshot5 wrote: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.
- Code: Select all
CardList choices = AllZoneUtil.getCardsInZone(zone).getValidCards(Tgts, sa.getSourceCard().getController());
There should be no problem with +Other. (in Creature.Vampire.Other the "Other" would be ignored i think).friarsol wrote:How was the behavior inconsistent? Did you try .Other instead of +Other?
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: TgtV code
by friarsol » 05 Nov 2010, 19:48
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.Sloth wrote:There should be no problem with +Other. (in Creature.Vampire.Other the "Other" would be ignored i think).
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: TgtV code
by Sloth » 05 Nov 2010, 20:39
Rob had to convince me too, but using "." in the replace string will trigger off and replace some other special characters (including "+").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.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: TgtV code
by friarsol » 05 Nov 2010, 20:41
Oh I keep forgetting that Replace is a regex. Stupid Java.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: TgtV code
by slapshot5 » 05 Nov 2010, 20:43
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
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: TgtV code
by slapshot5 » 05 Nov 2010, 20:54
Ok, Baron Sengir and Ezuri, Renegade Leader are making use of this change.
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
14 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 14 guests