Counterspells
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Counterspells
by 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:
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
- 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 **************************
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Counterspells
by 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
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 137 guests