It is currently 24 Apr 2024, 10:25
   
Text Size

Counterspells

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

Counterspells

Postby DennisBergkamp » 24 Sep 2008, 17:10

In this topic, I will post some different counterspells I coded. I made a bunch, but they're on different computers, so I'll probably post them one at a time.
I know these can't be used by the AI, but you can always use them against the computer.

The first card I'll post is Mystic Snake.
In my version of MTG Forge, there's an issue with "Flash" creature cards, so I get a copy of Mystic Snake in my graveyard whenever I play this spell. This might have been fixed in the newest version though.
Anyway, I had some trouble with this card at first, but now I fixed it so that one could play it at any time, even if there's no other spells on the stack.

In cards.txt:

Code: Select all
Mystic Snake
1 G U U
Creature Snake
You may play Mystic Snake any time you could play an instant. When Mystic Snake comes into play, counter target spell.
2/2
Flash
in CardFactory.java:

Code: Select all
//*************** START *********** START **************************
    if(cardName.equals("Mystic Snake"))
    {
      final SpellAbility ability = new Ability(card, "0")
      {
        public void resolve()
        {
          if(AllZone.Stack.size() > 0) {
             SpellAbility sa = AllZone.Stack.peek();
             if (sa.isSpell()) {
                sa = AllZone.Stack.pop();
                AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
             }
          }
        }//resolve()
      };//SpellAbility
      Command intoPlay = new Command()
      {
        public void execute()
        {
          if(AllZone.Stack.size() > 0) {
           ability.setStackDescription("Mystic Snake counters " +AllZone.Stack.peek().getSourceCard().getName());
           AllZone.Stack.add(ability);
          }
        }
      };
     
      card.setComesIntoPlay(intoPlay);
    }//*************** END ************ END **************************
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Counterspells

Postby jpb » 24 Sep 2008, 18:28

Sweet! I was thinking about making it so whenever priority is passed there is a null put into the stack. Just for reasons like this. Guess I don't have to.
jpb
 
Posts: 132
Joined: 05 Sep 2008, 13:12
Has thanked: 0 time
Been thanked: 0 time


Return to Forge

Who is online

Users browsing this forum: No registered users and 75 guests


Who is online

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

Login Form