Page 1 of 1

Cromat

PostPosted: 01 Jul 2009, 19:20
by zerker2000
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.

Re: Cromat

PostPosted: 02 Jul 2009, 07:18
by DennisBergkamp
Nice!
But... I think something must've gone wrong in the copying and pasting of the code, since both abilities are empty?

Re: Cromat

PostPosted: 02 Jul 2009, 07:41
by zerker2000
OOPS!... fixed it :P (I think I did middle click instead of ^C or something...:?)