It is currently 29 Oct 2025, 07:35
   
Text Size

New keyword: stPump

Post MTG Forge Related Programming Questions Here

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

Re: New keyword: stPumpAll

Postby Sloth » 20 Sep 2010, 18:26

Rob Cashwalker wrote:I think those should be handled specifically by the enchantment itself. "enPump", if it doesn't exist already, because putting the enchantment or equipment on a particular permanent needs AI anyway, so while some of the code may be redundant, there is a logical difference between a Glorious Anthem and an Aura.
There are already about a dozen of cards like that with the StaticEffect keyword, mostly the "God Auras"

Code: Select all
Name:Runes of the Deus
ManaCost:4 RG
Types:Enchantment Aura
Text:no text
K:Enchant creature
K:enPump:+0/+0
K:StaticEffect:Play:Enchanted Permanent:PTBonus/1/1!Keyword/Double Strike:Color.red:As long as enchanted creature is red, it gets +1/+1 and has double strike. (It deals both first-strike and regular combat damage.)
K:StaticEffect:Play:Enchanted Permanent:PTBonus/1/1!Keyword/Trample:Color.green:As long as enchanted creature is green, it gets +1/+1 and has trample.
I would convert them to stPumpEnchanted.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPumpAll

Postby Rob Cashwalker » 20 Sep 2010, 19:11

See, I look at that, and think that it's the enPump keyword that needs to be made more dynamic to handle this.
Without looking further at it, the enPump AI wouldn't know to play it on a Red and/or Green creature. It may play it on a black creature, and get no benefit at all.

I would fix enPump to handle "+X/+X" and provide an xCount parser that would return 0, 1 or 2 depending on the color. However, I don't know how I would do the keyword part....

Again, my answer is to try to handle only the cases that can be easily handled. Extreme cases with dedicated code or dedicated keywords would be better than complicating otherwise simple cards. Like these "god" auras, they all follow the same format - "enchanted card gets +1/+1/+K1 for color A and +1/+1/+K2 for color b" - prime candidate for its own keyword. Even though it's only 10 cards, that's 9 fewer blocks of code to implement those 10 cards, and there might be other cards this specific variant of the pump effect might apply to.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: New keyword: stPumpAll

Postby Sloth » 20 Sep 2010, 20:16

Rob Cashwalker wrote:I would fix enPump to handle "+X/+X" and provide an xCount parser that would return 0, 1 or 2 depending on the color. However, I don't know how I would do the keyword part....
The problem here is, that the creature might change its colors and the bonus has to adapt. I don't think enPump is written in a way to handle this.

PS: Armored Ascension is a card with a similar problem.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPumpAll

Postby Rob Cashwalker » 20 Sep 2010, 20:53

True. This isn't to say that with a little bit of work it couldn't be made to perform this task, or a similar keyword could handle it.

My point is simply that it's a very distinct effect from the orginal prupose of the keyword of this topic - "PumpAll" or at least "PumpOthers". "PumpSelf" is close enough to not cause issue. "PumpEnchanted" requires AI, while all the other effects just happen.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: New keyword: stPumpAll

Postby slapshot5 » 21 Sep 2010, 04:50

I've run into a problem using stPumpAll (though the problem probably exists for other keywords, where the keyword to add contains a ":".

For Example, I'm trying to do Energy Flux like this:

Code: Select all
Name:Energy Flux
ManaCost:2 U
Types:Enchantment
Text:no text
K:stPumpAll:Artifact:All Permanents:0/0/"At the beginning of your upkeep, sacrifice CARDNAME unless you pay:2":No Condition:All artifacts have "At the beginning of your upkeep, sacrifice this artifact unless you pay 2."
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/energy_flux.jpg
End
The card text ends up being "No Condition".

Is there a way to escape the ":", or do we need to find a different way to parse one or the other?

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: New keyword: stPumpAll

Postby Sloth » 21 Sep 2010, 05:30

slapshot5 wrote:I've run into a problem using stPumpAll (though the problem probably exists for other keywords, where the keyword to add contains a ":".

For Example, I'm trying to do Energy Flux like this:

Code: Select all
Name:Energy Flux
ManaCost:2 U
Types:Enchantment
Text:no text
K:stPumpAll:Artifact:All Permanents:0/0/"At the beginning of your upkeep, sacrifice CARDNAME unless you pay:2":No Condition:All artifacts have "At the beginning of your upkeep, sacrifice this artifact unless you pay 2."
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/energy_flux.jpg
End
The card text ends up being "No Condition".

Is there a way to escape the ":", or do we need to find a different way to parse one or the other?

-slapshot5
There are plans to change ":" delimited parameters to named parameters in the future. For now, you might want to change "At the beginning of your upkeep, sacrifice CARDNAME unless you pay" to work without ":". This keyword is pretty easy to split without.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPumpAll

Postby Sloth » 21 Sep 2010, 09:25

OK, I'M now starting to convert the syntax of stPumpAll to stPump. stPumpEnchanted and stPumpEquipped will be supported as an interim solution, until someone writes dedicated keywords.

I will also try to implement "YouCtrl" and "YouDontCtrl" as qualifiers for isValidCard in a simple way (they have to be at the start of the first entry of the Restriction Array). I count on you Rob, to come up with a more elegant solution.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPumpAll

Postby Rob Cashwalker » 21 Sep 2010, 11:31

Yep, I'm going to do the isValidCard method as proposed above...
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: New keyword: stPumpAll

Postby Sloth » 21 Sep 2010, 11:55

Rob Cashwalker wrote:Yep, I'm going to do the isValidCard method as proposed above...
Err, I just submitted my version. Feel free to overwrite it:

Code: Select all
    public boolean isValidCard(String Restrictions[], String Controller) {
       String Restriction[] = Restrictions;
       if (Restrictions[0].startsWith("YouCtrl")) {
          if (!controller.equals(Controller)) return false;
          Restriction[0] = Restriction[0].replaceFirst("YouCtrl ", "");
       }
       if (Restrictions[0].startsWith("YouDontCtrl")) {
          if (controller.equals(Controller)) return false;
          Restriction[0] = Restriction[0].replaceFirst("YouDontCtrl ", "");
       }
       return isValidCard(Restriction);
    }
Edit: The " " after YouCtrl is highly debatable, but "," doesn't fit, because it means "or" in the Restriction Array.

Example:
Code: Select all
Name:Mindwrack Liege
ManaCost:3 UR UR UR
Types:Creature Horror
Text:UR UR UR UR: You may put a blue or red creature card from your hand onto the battlefield.
PT:4/4
K:stPumpOther:YouCtrl Creature.Blue:1/1:No Condition:Other blue creatures you control get +1/+1.
K:stPumpOther:YouCtrl Creature.Red:1/1:No Condition:Other red creatures you control get +1/+1.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPumpAll

Postby Rob Cashwalker » 21 Sep 2010, 15:41

I was going to make it work more like this:

"Creature.Blue.YouCtrl"

I was going to iterate through the restrictions, checking each for the controller qualification. If found, replace it before passing the rest of the restriction down. (as you're doing)

Code: Select all
public boolean isValidCard(String Restrictions[], String Controller) {
    for (int i=0; i<Restrictions.length; i++)
    {
        if (Restrictions[i].contains("YouCtrl")
        {
            if (!getController().equals(Controller))
               return false;
            Restrictions[i].replaceAll(".YouCtrl", "");
        }
        else if (Restrictions[i].contains("YouDontCtrl")
        }
            if (getController().equals(Controller))
               return false;
            Restrictions[i].replaceAll(".YouDontCtrl");
        }
    }

    return isValidCard(Restrictions);
}
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: New keyword: stPumpAll

Postby Sloth » 21 Sep 2010, 16:08

Rob Cashwalker wrote:I was going to make it work more like this:

"Creature.Blue.YouCtrl"

I was going to iterate through the restrictions, checking each for the controller qualification. If found, replace it before passing the rest of the restriction down. (as you're doing)

Code: Select all
public boolean isValidCard(String Restrictions[], String Controller) {
    for (int i=0; i<Restrictions.length; i++)
    {
        if (Restrictions[i].contains("YouCtrl")
        {
            if (!getController().equals(Controller))
               return false;
            Restrictions[i].replaceAll(".YouCtrl", "");
        }
        else if (Restrictions[i].contains("YouDontCtrl")
        }
            if (getController().equals(Controller))
               return false;
            Restrictions[i].replaceAll(".YouDontCtrl");
        }
    }

    return isValidCard(Restrictions);
}
Ah, I see what you want. Actually this would be more in line with the other restrictions:

Creature.Blue+YouCtrl

PS: Creature.Blue+YouCtrl,Creature.Green would not work as expexted (one YouCtrl in any entry of the array is the same as in every entry), but I think there are no cards that need something like that yet.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPumpAll

Postby Rob Cashwalker » 21 Sep 2010, 16:34

Right... for whatever reason I always forget that I made it "+". Though if it's "Creature.YouCtrl" then it would need to adapt accordingly.

Yeah, I know... I realized it would be pointless while I was writing the code.

When they write restrictions on the cards, the conditions are in an odd hierarchy. While it reads well in english, I realize they may change the order completely for other languages. "Creature.YouCtrl" without question reads as "creature you control", while "YouDontCtrl Creature.Blue" reads more like "you don't control a creature which is blue"; it also reads like a question, where in the future, we may have some syntax to parse functions like "if YouDontCtrl(Creature.Blue) then do X". Just thinking about this before it becomes critical....
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: New keyword: stPumpAll

Postby Sloth » 21 Sep 2010, 18:26

Rob Cashwalker wrote:Right... for whatever reason I always forget that I made it "+". Though if it's "Creature.YouCtrl" then it would need to adapt accordingly.

Yeah, I know... I realized it would be pointless while I was writing the code.

When they write restrictions on the cards, the conditions are in an odd hierarchy. While it reads well in english, I realize they may change the order completely for other languages. "Creature.YouCtrl" without question reads as "creature you control", while "YouDontCtrl Creature.Blue" reads more like "you don't control a creature which is blue"; it also reads like a question, where in the future, we may have some syntax to parse functions like "if YouDontCtrl(Creature.Blue) then do X". Just thinking about this before it becomes critical....
So... should the code look like this?

Code: Select all
public boolean isValidCard(String Restrictions[], String Controller) {
    for (int i=0; i<Restrictions.length; i++)
    {
        if (Restrictions[i].contains("YouCtrl")
        {
            if (!getController().equals(Controller))
               return false;
            Restrictions[i].replaceAll(".YouCtrl", "");
            Restrictions[i].replaceAll("+YouCtrl", "");
        }
        else if (Restrictions[i].contains("YouDontCtrl")
        }
            if (getController().equals(Controller))
               return false;
            Restrictions[i].replaceAll(".YouDontCtrl", "");
            Restrictions[i].replaceAll("+YouDontCtrl", "");
        }
    }

    return isValidCard(Restrictions);
}
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPumpAll

Postby Rob Cashwalker » 21 Sep 2010, 19:22

Actually, I don't think so. replaceAll takes a regex, (like split) so there are actually two answers, a - "\\.YouCtrl" and "\\+YouCtrl" OR b - there's gotta be a wildcard shortcut to represent the character... though "[\\.\\+]YouCtrl" would do it too.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: New keyword: stPumpAll

Postby Sloth » 21 Sep 2010, 19:33

Rob Cashwalker wrote:Actually, I don't think so. replaceAll takes a regex, (like split) so there are actually two answers, a - "\\.YouCtrl" and "\\+YouCtrl" OR b - there's gotta be a wildcard shortcut to represent the character... though "[\\.\\+]YouCtrl" would do it too.
There's someone who knows his cup of java. Thanks Rob! I will test it right away.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 14 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 14 users online :: 0 registered, 0 hidden and 14 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 14 guests

Login Form