It is currently 29 Oct 2025, 14:12
   
Text Size

TgtV code

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

TgtV code

Postby 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:

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

-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

Postby 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

Postby 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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: TgtV code

Postby 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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: TgtV code

Postby 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
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

Postby Sloth » 05 Nov 2010, 09:03

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?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: TgtV code

Postby slapshot5 » 05 Nov 2010, 14:30

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
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

Postby 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

Postby Sloth » 05 Nov 2010, 19:39

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).
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: TgtV code

Postby friarsol » 05 Nov 2010, 19:48

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: TgtV code

Postby Sloth » 05 Nov 2010, 20:39

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 "+").
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: TgtV code

Postby 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

Postby 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
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: TgtV code

Postby 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


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 19 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 19 users online :: 0 registered, 0 hidden and 19 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 19 guests

Login Form