It is currently 19 Apr 2024, 11:51
   
Text Size

Cromat

Post MTG Forge Related Programming Questions Here

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

Cromat

Postby zerker2000 » 01 Jul 2009, 19:20

Finally got Cromat coded :). Spent a bunch of the time hunting a bug in the last ability... here's the code:
Code: Select all
Cromat
W U B R G
Legendary Creature Illusion
no text
5/5
KPump U R:Flying
RegenerateMe:B G
PTPump R W:+1/+1
Code: Select all
    if (cardName.equals("Cromat")){
   
    //LibBounce Ability
    final Ability a1 = new Ability(card, "G U")
    {
      public boolean canPlayAI() {return false;}

      public void resolve()
      {
        if(AllZone.GameAction.isCardInPlay(card) )
        {
          card.setBaseAttack(5);
          card.setBaseDefense(5);

          card.setAssignedDamage(0);
          card.setDamage(0);
          card.untap();
          AllZone.getZone(card).remove(card);

          //put card on top of library
          PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getOwner());
          library.add(card, 0);
        }
      }//resolve()
    };//SpellAbility

    Input runtime1 = new Input()
    {
      private static final long serialVersionUID = 1469011418219527227L;

      public void showMessage()
      {
        a1.setStackDescription("Put " +card +" on top of its owner's library");

        stopSetNext(new Input_PayManaCost(a1));
      }
    };
    a1.setDescription("G U: Put Cromat on top of its owner's library.");
    a1.setStackDescription("Put Cromat on top of its owner's library.");
    card.addSpellAbility(a1);
    a1.setBeforePayMana(runtime1);
    //Kill ability
   
    final Ability a2 = new Ability(card, "W B"){
       public boolean canPlay()
       {
          return (AllZone.GameAction.isCardInPlay(card) && (AllZone.Combat.isBlocked(card) || AllZone.Combat.getAllBlockers().contains(card)));
       }
        public boolean canPlayAI()
        {
          return false;
          //TODO
        }
       public void resolve()
       {
          AllZone.GameAction.destroy(getTargetCard());
       }//resolve()
    };
    Input runtime2 = new Input()
    {
       /**
       *
       */
      private static final long serialVersionUID = 1L;

      public void showMessage()
       {
          CardList targets = new CardList();
          if(AllZone.Combat.isBlocked(card) || AllZone.Combat.getAllBlockers().contains(card)){
             if (AllZone.Combat.isBlocked(card)){ targets = AllZone.Combat.getBlockers(card); }
             else {
                targets = new CardList();
                for (Card c : AllZone.Combat.getAttackers()){
                   if (AllZone.Combat.isBlocked(c))
                      if (AllZone.Combat.getBlockers(c).contains(card)) targets.add(c);
                }
             }
          }
          stopSetNext(CardFactoryUtil.input_targetSpecific(a2, targets, "Select target blocking or blocked by Cromat.", true));
       }
    };
    card.addSpellAbility(a2);
    a2.setBeforePayMana(runtime2);
    a2.setDescription("W B: Destroy target creature blocking or blocked by Cromat.");
  }
... TODO: make canPlayAI's, then catch all the bugs that are bound to happen / are already there.
Now it's back in/to the mana pool for me :P.
Last edited by zerker2000 on 02 Jul 2009, 07:39, edited 1 time in total.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Cromat

Postby DennisBergkamp » 02 Jul 2009, 07:18

Nice!
But... I think something must've gone wrong in the copying and pasting of the code, since both abilities are empty?
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Cromat

Postby zerker2000 » 02 Jul 2009, 07:41

OOPS!... fixed it :P (I think I did middle click instead of ^C or something...:?)
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 56 guests


Who is online

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

Login Form