It is currently 08 Sep 2025, 12:49
   
Text Size

New keyword: stPump

Post MTG Forge Related Programming Questions Here

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

Re: New keyword: stPumpAll

Postby Rob Cashwalker » 21 Sep 2010, 20:12

Not really... but I do know where my towel is. 8) :mrgreen:
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, 20:36

You were right, replaceAll doesn't like "+". Even when I use "[\\.\\+]YouCtrl" it works for ".YouCtrl" but not for "+YouCtrl". I am at a loss here.

Maybe we should just stick to "Creature.Blue.YouCtrl".
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, 20:41

Try "[\\\\.\\\\+]YouCtrl"

Actually, if I'm reading the doc right, ".YouCtrl" should cover any instance of "{AnyCharacter}YouCtrl"
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, 20:53

Rob Cashwalker wrote:Try "[\\\\.\\\\+]YouCtrl"

Actually, if I'm reading the doc right, ".YouCtrl" should cover any instance of "{AnyCharacter}YouCtrl"
No success with either option. I will call it a day. Maybe an idea will strike me tomorrow.
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 » 22 Sep 2010, 12:37

EDIT: This does not work

This works:

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);
    }
The trick is, that Creature.Blue+ will be treated the same as Creature.Blue, so the "+" doesn't have to be removed at all.
Last edited by Sloth on 22 Sep 2010, 15:12, edited 1 time in total.
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 » 22 Sep 2010, 13:56

This works just fine for me:
Code: Select all
       String tmp = "Creature.YouCtrl Creature.Blue+YouCtrl";
       ErrorViewer.showError(tmp.replaceAll(".YouCtrl", "MATCH"));
I stuck it in to ReadCard.run() just to have it in an early part of the code, that I happened to have up on the screen.
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 » 22 Sep 2010, 15:13

OK, the problem lies somewhere else. I just found out that Creature.Blue+nonArtifact also doesn't work for some reason. There must be some other part that does not like the "+". I'm gonna search for it.

EDIT: Creature.Blue+nonArtifact does work. I must have made atesting mistake.
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 » 23 Sep 2010, 15:25

I finally found a way to make it work. I used split instead of replaceAll to get rid of "+YouCtrl":
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] = Restrictions[i].split("\\+YouCtrl")[0];
                Restrictions[i].replaceAll(".YouCtrl", "");
            }
            else if (Restrictions[i].contains("YouDontCtrl"))
            {
                if (getController().equals(Controller))
                   return false;
                Restrictions[i] = Restrictions[i].split("\\+YouDontCtrl")[0];
                Restrictions[i].replaceAll(".YouDontCtrl", "");
            }
        }
        return isValidCard(Restrictions);
    }
I don't know why, but everything I tried with replaceAll didn't work.

EDIT: Actually this caused .YouDontCtrl to malfunction #-o
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPump

Postby silly freak » 23 Sep 2010, 20:39

damn, now I'm seeing it too! strings are immutable ;) that's why yourdoesn't work for ".YouControl"

Code: Select all
Restrictions[i] = Restrictions[i].replaceAll("[+\\.]YouCtrl", "");
as long as you don't forget the assignment, the regex should work as intended ;)
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: New keyword: stPump

Postby Rob Cashwalker » 23 Sep 2010, 21:31

DOH... that's what I get for typing code in a forum text box off my head. #-o
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: stPump

Postby Sloth » 24 Sep 2010, 07:04

I also figured it out this morning, but thanks for the help silly freak. And Rob was right ".YouCtrl" catches both.

By the way: I added Metalcraft as a condition today. I guess Scars is going to be an easy set.

I still have to change the syntax of the boni to P/T/ keyword & keyword & ...

EDIT: ^ Done! ^
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New keyword: stPump

Postby Sloth » 24 Sep 2010, 11:58

I also added Enchanted as <Range> to stPump, because there are some auras that have additional effects when Threshold or Hellbent is reached. Those Auras don't need any special AI.

Examples:
Code: Select all
Name:Kamahl's Desire
ManaCost:1 R
Types:Enchantment Aura
Text:Enchanted creature has first strike.
K:Enchant creature
K:enPump:First Strike
K:stPumpEnchanted:Creature:3/0:Threshold:Threshold - Enchanted creature gets +3/+0 as long as seven or more cards are in your graveyard.
Code: Select all
Name:Taste for Mayhem
ManaCost:R
Types:Enchantment Aura
Text:Enchanted creature gets +2/+0.
K:Enchant creature
K:enPump:+2/+0
K:stPumpEnchanted:Creature:2/0:Hellbent:Hellbent - Enchanted creature gets an additional +2/+0 as long as you have no cards in hand.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 41 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 41 users online :: 0 registered, 0 hidden and 41 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 41 guests

Login Form