It is currently 19 Apr 2024, 06:19
   
Text Size

Targeted KPump, v1

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

Targeted KPump, v1

Postby Rob Cashwalker » 29 Jan 2009, 22:05

CardFactory, near the other "should___" methods:
Code: Select all
    //"TgtKPump" - targeted keyword adding abilities
    private final int shouldTgtKPumpCard(Card c)
    {
      ArrayList a = c.getKeyword();
      for (int i = 0; i < a.size(); i++)
        if(a.get(i).toString().startsWith("TgtKPump"))
          return i;

      return -1;
    }
CardFactory, near the other keyword code:
Code: Select all
      //Creatures with simple, targeted keyword adding abilities
      // costs may include "T" to indicate a tap cost
      //-1 means not found
      while(shouldTgtKPumpCard(card) != -1)
      {
        int n = shouldTgtKPumpCard(card);
        if(n != -1)
        {
          String parse = card.getKeyword().get(n).toString();
          card.removeKeyword(parse);

          String k[] = parse.split(":");

          String tmpCost = k[0].substring(9);
          final String keyword = k[1];
         
          boolean tapCost = false;
          boolean tapOnlyCost = false;
         
          if (tmpCost.contains("T"))
          {
             tapCost = true;
             tmpCost = tmpCost.replace("T", "");
             tmpCost = tmpCost.trim();
             if (tmpCost.length() == 0)
                tapOnlyCost = true;
          }
         
          final String manaCost = tmpCost;
         
          String tmpDesc = new String();
          tempDesc = cardName + " gains " + keyword + " until end of turn.";
          final String Desc = tempDesc;
         
          if (! tapCost)
          {
              final SpellAbility ability = new Ability_Activated(card, manaCost)
              {
                public boolean canPlayAI()
                {
                  if(CardFactoryUtil.AI_doesCreatureAttack(card))
                    return false;
                 
                  return getCreature().size() != 0;
                }
                public boolean canPlay()
                {
                   if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card))
                      return true;
                   else
                      return false;
                }
                public void chooseTargetAI()
                {
                  Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
                  setTargetCard(target);
                }
                CardList getCreature()
                {
                  CardList list = new CardList(AllZone.Computer_Play.getCards());
                  list = list.filter(new CardListFilter()
                  {
                    public boolean addCard(Card c)
                    {
                      return c.isCreature() && (!CardFactoryUtil.AI_doesCreatureAttack(c)) &&
                             (! c.getKeyword().contains(keyword));
                    }
                  });
                  // list.remove(card);      // if mana-only cost, allow self-target
                  return list;
                }//getCreature()
                public void resolve()
                {
                  if(AllZone.GameAction.isCardInPlay(getTargetCard()))
                  {
                    final Card[] creature = new Card[1];
                    final Command EOT = new Command()
                    {
                      public void execute()
                      {
                        if(AllZone.GameAction.isCardInPlay(creature[0]))
                          creature[0].removeKeyword(keyword);
                      }
                    };
                    creature[0] = getTargetCard();
                    creature[0].addKeyword(keyword);
                    AllZone.EndOfTurn.addUntil(EOT);
                  }//if (card is in play)
                }//resolve()
              };//SpellAbility
             
              ability.setDescription(manacost + ":" & Desc);
              ability.setStackDescription(Desc);

              ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
              card.addSpellAbility(ability);
          }
          if (tapOnlyCost)
          {
              final SpellAbility ability = new Ability_Tap(card)
              {
                public boolean canPlayAI()
                {
                  if(CardFactoryUtil.AI_doesCreatureAttack(card))
                    return false;
                 
                  return getCreature().size() != 0;
                }
                public boolean canPlay()
                {
                   if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card))
                      return true;
                   else
                      return false;
                }
                public void chooseTargetAI()
                {
                   card.tap();
                   Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
                   setTargetCard(target);
                }
                CardList getCreature()
                {
                  CardList list = new CardList(AllZone.Computer_Play.getCards());
                  list = list.filter(new CardListFilter()
                  {
                    public boolean addCard(Card c)
                    {
                      return c.isCreature() && (!CardFactoryUtil.AI_doesCreatureAttack(c)) &&
                             (! c.getKeyword().contains(keyword));
                    }
                  });
                  list.remove(card);
                  return list;
                }//getCreature()
                public void resolve()
                {
                  if(AllZone.GameAction.isCardInPlay(getTargetCard()))
                  {
                    final Card[] creature = new Card[1];
                    final Command EOT = new Command()
                    {
                      public void execute()
                      {
                        if(AllZone.GameAction.isCardInPlay(creature[0]))
                          creature[0].removeKeyword(keyword);
                      }
                    };
                    creature[0] = getTargetCard();
                    creature[0].addKeyword(keyword);
                    AllZone.EndOfTurn.addUntil(EOT);
                  }//if (card is in play)
                }//resolve()
              };//SpellAbility
             
              ability.setDescription("tap:" & Desc);
              ability.setStackDescription(Desc);

              ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
              card.addSpellAbility(ability);
          }
          if (! tapOnlyCost && tapCost)
          {
              final SpellAbility ability = new Ability_Tap(card, manacost)
              {
                public boolean canPlayAI()
                {
                  if(CardFactoryUtil.AI_doesCreatureAttack(card))
                    return false;
                 
                  return getCreature().size() != 0;
                }
                public boolean canPlay()
                {
                   if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card))
                      return true;
                   else
                      return false;
                }
                public void chooseTargetAI()
                {
                   card.tap();
                   Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
                   setTargetCard(target);
                }
                CardList getCreature()
                {
                  CardList list = new CardList(AllZone.Computer_Play.getCards());
                  list = list.filter(new CardListFilter()
                  {
                    public boolean addCard(Card c)
                    {
                      return c.isCreature() && (!CardFactoryUtil.AI_doesCreatureAttack(c)) &&
                             (! c.getKeyword().contains(keyword));
                    }
                  });
                  list.remove(card);
                  return list;
                }//getCreature()
                public void resolve()
                {
                  if(AllZone.GameAction.isCardInPlay(getTargetCard()))
                  {
                    final Card[] creature = new Card[1];
                    final Command EOT = new Command()
                    {
                      public void execute()
                      {
                        if(AllZone.GameAction.isCardInPlay(creature[0]))
                          creature[0].removeKeyword(keyword);
                      }
                    };
                    creature[0] = getTargetCard();
                    creature[0].addKeyword(keyword);
                    AllZone.EndOfTurn.addUntil(EOT);
                  }//if (card is in play)
                }//resolve()
              };//SpellAbility
             
              ability.setDescription(manacost + ", tap:" & Desc);
              ability.setStackDescription(Desc);

              ability.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability));
              card.addSpellAbility(ability);
          }
        }
      }
This will of course be extended to TgtPTPump, and TgtPTKPump.

Usage:
TgtKPump {manacost} {tap}:{Keyword}
Examples:
TgtKPump U:Flying
TgtKPump 1 G T:Trample
TgtKPump T:Haste

Hope this works!
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: Targeted KPump, v1

Postby DennisBergkamp » 29 Jan 2009, 22:27

Awesome, I will add this and test!
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Targeted KPump, v1

Postby Chris H. » 29 Jan 2009, 22:41

Thank you.

Our fingers are crossed and we are hopping that it will as expected. :D
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Targeted KPump, v1

Postby Rob Cashwalker » 31 Jan 2009, 16:07

Obvious bug:

Code: Select all
          String tmpDesc = new String();
          tempDesc = cardName + " gains " + keyword + " until end of turn.";
          final String Desc = tempDesc;
It should be
Code: Select all
          String tmpDesc = new String();
          tempDesc = "Target creature gains " + keyword + " until end of turn.";
          final String Desc = tempDesc;
Also, I'm a little curious about the logic in getCreature():
Code: Select all
               CardList getCreature()
                {
                  CardList list = new CardList(AllZone.Computer_Play.getCards());
                  list = list.filter(new CardListFilter()
                  {
                    public boolean addCard(Card c)
                    {
                      return c.isCreature() && (!CardFactoryUtil.AI_doesCreatureAttack(c)) &&
                             (! c.getKeyword().contains(keyword));
                    }
                  });
                  // list.remove(card);      // if mana-only cost, allow self-target
                  return list;
                }//getCreature()
Specifically, (!CardFactoryUtil.AI_doesCreatureAttack(c)).

The basic effect code was taken from Disciple of Kangee. Anyone have any experience with the computer playing that card correctly?
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: Targeted KPump, v1

Postby Chris H. » 31 Jan 2009, 21:09

The computer used a Disciple of Kangee to give another Disciple of Kangee flying.

I had non flying walls in play and the flying Disciple of Kangee attacked and I was unable to block it.

I put a single Wall of Air in play and the computer stopped giving the flying ability and it stopped attacking. The computer had 6 Disciple of Kangee in play and I had just a single Wall of Air in play.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Targeted KPump, v1

Postby DennisBergkamp » 06 Feb 2009, 23:26

Rob, I've successfully added your code! =D>

It had a couple of minor compile errors, but those were easily fixed. I've tested this with Advance Scout and Dauthi Trapper, and everything works as expected. I also added:

Code: Select all
 public boolean canPlay()
                {
                   if (CardFactoryUtil.canUseAbility(card) && AllZone.GameAction.isCardInPlay(card) && !card.hasSickness())
                      return true;
                   else
                      return false;
                }
"&& !card.hasSickness()" because I could use my Dauthi Trapper the same turn it came into play.
Now, I'm not sure if this will work with cards that have both tap and mana as part of their abilities' costs. Something that has to be tested.

Good job!
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Targeted KPump, v1

Postby Rob Cashwalker » 07 Feb 2009, 16:41

There are three different sets of the code, one for mana-only, one for tap-only and one for tap + mana, so the change needs to be in both.
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: Targeted KPump, v1

Postby Chris H. » 17 Feb 2009, 01:49

I was curious to see if the TgtKPump would work with with lands, so I tried to enter this card into cards.txt:

Sunhome, Fortress of the Legion
no cost
Land
no text
tap: add 1
TgtKPump 2 R W T:Double Strike


I selected this card in the Deck Editor and all it states for this card is:

tap: add 1


I see nothing in reference to the Targeted KPump, not even a text string. Does this command include lands or did I make some sort of a mistake and I just can't see it at this time?
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Targeted KPump, v1

Postby Chris H. » 17 Feb 2009, 03:16

Chris H. wrote:I see nothing in reference to the Targeted KPump, not even a text string. Does this command include lands or did I make some sort of a mistake and I just can't see it at this time?
I went back and play tested this land. I clicked on the land and was able to pay the mana costs to activate the targeted pump. I guess that we need a few lines of code to print this command on this card.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Targeted KPump, v1

Postby Rob Cashwalker » 17 Feb 2009, 04:23

There's gotta be some code that adds the text for abilities to cards. Lands are brought into play differently, I wouldn't be surprised if the code for applying the ability descriptions was a little different too.

I'm looking at the man-land code... nothing looks terribly weird. The only basic stuff that isn't in any pump code so far is this: (the man lands are basically a PTKPump ability... plus the creature type)
Code: Select all

      card.clearSpellAbility();
      card.addSpellAbility(a1);
      a1.setStackDescription(card +" becomes a 3/3 creature with trample until EOT");

      Command paid1 = new Command() {public void execute() {AllZone.Stack.add(a1);}};

      a1.setBeforePayMana(new Input_PayManaCost_Ability(a1.getManaCost(), paid1));
Some cards have the clearSpellAbility() before the addSpellAbility(). This is to make sure that each card starts clean, I guess. However this isn't desirable for keyword scripting, because then we couldn't have Pump and Regenerate on the same card.

Up at the top of getCard2, we have the following line:
Code: Select all
    //may have to change the spell
    //this is so permanents like creatures and artifacts have a "default" spell
    if(! card.isLand())
      card.addSpellAbility(new Spell_Permanent(card));
This means that lands are not considered permanents?

Vitu-Ghazi, the City-Tree:
Code: Select all
     ability.setDescription("2 G W, tap: Put a 1/1 green Saproling creature token into play.");
     ability.setStackDescription(card.getName() + " - Put a 1/1 green Saproling creature token named into play.");
    
     card.addSpellAbility(ability);
    
     //not sure what's going on here, maybe because it's a land it doesn't add the ability to the text?
     //anyway, this does the trick:
     card.removeKeyword("tap: add 1");
     card.setText(card.getText() +  "\r\n 2 G W, tap: Put a 1/1 green Saproling creature token into play.");
     card.addKeyword("tap: add 1");
So there's a land with a secondary ability, and some notes on why lands would be different. Though I wonder why the man lands don't have this.

I'm not sure if I like having to add that sort of code... if it's worth it for the handful of lands with a pump ability like this....
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: Targeted KPump, v1

Postby DennisBergkamp » 17 Feb 2009, 08:44

Maybe the reason it doesn't work is because lands aren't considered spells? Meh, it's late I'm not sure I'm thinking straight.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Targeted KPump, v1

Postby Rob Cashwalker » 17 Feb 2009, 13:43

DennisBergkamp wrote:Maybe the reason it doesn't work is because lands aren't considered spells? Meh, it's late I'm not sure I'm thinking straight.
Well, basically, yeah, I think that's a big part of it. Don't know what can be done about it, but it's probably buried in the code wherever ability descriptions get tacked onto the card text.
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: Targeted KPump, v1

Postby Chris H. » 17 Feb 2009, 14:47

I changed the Sunhome, Fortress of the Legion card to this:


Sunhome, Fortress of the Legion
no cost
Land
2 R W, tap:Target creature gains Double Strike until end of turn.
tap: add 1
TgtKPump 2 R W T:Double Strike


The card will now display the descriptive text string and will use the TgtKPump command.

While playing the 2 R W mana cost for this TgtKPump ability I discovered that I could tap this land for one of the needed colorless mana.

I also Beta Tested the Flying Carpet artifact which would also use the TgtKPump keyword. The Flying Carpet and the Sunhome, Fortress of the Legion come into play with summoning sickness. I can't use the TgtKPump ability on the turn the card comes into play. I can use the TgtKPump ability on subsequent turns.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Targeted KPump, v1

Postby Rob Cashwalker » 17 Feb 2009, 15:36

Chris H. wrote:While playing the 2 R W mana cost for this TgtKPump ability I discovered that I could tap this land for one of the needed colorless mana.

I also Beta Tested the Flying Carpet artifact which would also use the TgtKPump keyword. The Flying Carpet and the Sunhome, Fortress of the Legion come into play with summoning sickness. I can't use the TgtKPump ability on the turn the card comes into play. I can use the TgtKPump ability on subsequent turns.
Those are some tough bugs.... I don't know if we can deal with them in any sensible manner from the pump code.
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: Targeted KPump, v1

Postby Chris H. » 17 Feb 2009, 16:28

Those are some tough bugs.... I don't know if we can deal with them in any sensible manner from the pump code.
I will move this part of my report over to the bug forum.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times


Return to Forge

Who is online

Users browsing this forum: No registered users and 80 guests


Who is online

In total there are 80 users online :: 0 registered, 0 hidden and 80 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 80 guests

Login Form