Code from slapshot5
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
55 posts
• Page 4 of 4 • 1, 2, 3, 4
Re: Code from slapshot5
by slapshot5 » 18 Apr 2010, 23:30
Here is Consume the Meek from Rise of the Eldrazi:
cards.txt:
-slapshot5
cards.txt:
- Code: Select all
Consume the Meek
3 B B
Instant
Destroy each creature with converted mana cost 3 or less. They can't be regenerated.
- Code: Select all
consume_the_meek.jpg http://www.wizards.com/global/images/magic/general/consume_the_meek.jpg
- Code: Select all
//*************** START *********** START **************************
else if(cardName.equals("Consume the Meek")) {
/* Destroy each creature with converted mana cost 3 or less.
* They can't be regenerated.
*/
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 9127892501403187034L;
@Override
public void resolve() {
CardList all = new CardList();
all.addAll(getHumanCreatures().toArray());
all.addAll(getComputerCreatures().toArray());
for(int i = 0; i < all.size(); i++) {
Card c = all.get(i);
System.out.println("Consume the Meek: " + c);
AllZone.GameAction.destroyNoRegeneration(c);
}
}// resolve()
CardListFilter filter = new CardListFilter() {
public boolean addCard(Card c) {
return c.isCreature() && CardUtil.getConvertedManaCost(c) <= 3;
}
};
private CardList getHumanCreatures() {
CardList human = new CardList();
human.addAll(AllZone.Human_Play.getCards());
human = human.filter(filter);
return human;
}
private CardList getComputerCreatures() {
CardList comp = new CardList();
comp.addAll(AllZone.Computer_Play.getCards());
comp = comp.filter(filter);
return comp;
}
@Override
public boolean canPlayAI() {
CardList human = getHumanCreatures();
CardList computer = getComputerCreatures();
// the computer will at least destroy 2 more human creatures
return AllZone.Phase.getPhase().equals(Constant.Phase.Main2) &&
(computer.size() < human.size() - 1
|| (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty()));
}
};// SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);
}// *************** END ************ END **************************
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Code from slapshot5
by slapshot5 » 19 Apr 2010, 00:10
Here is Near-Death Experience - also from Rise of the Eldrazi.
cards.txt:
-slapshto5
cards.txt:
- Code: Select all
Near-Death Experience
2 W W W
Enchantment
At the beginning of your upkeep, if you have exactly 1 life, you win the game.
- Code: Select all
near_death_experience.jpg http://www.wizards.com/global/images/magic/general/near_death_experience.jpg
- Code: Select all
upkeep_Near_Death_Experience();
- Code: Select all
private static void upkeep_Near_Death_Experience() {
final String player = AllZone.Phase.getActivePlayer();
PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player);
PlayerLife life = AllZone.GameAction.getPlayerLife(player);
CardList list = new CardList(playZone.getCards());
list = list.getName("Near-Death Experience");
if(0 < list.size() && life.getLife() == 1) {
Ability ability = new Ability(list.get(0), "0") {
@Override
public void resolve() {
String opponent = AllZone.GameAction.getOpponent(player);
PlayerLife oppLife = AllZone.GameAction.getPlayerLife(opponent);
int gameNumber = 0;
if (Constant.Runtime.WinLose.getWin()==1)
gameNumber = 1;
Constant.Runtime.WinLose.setWinMethod(gameNumber,"Near-Death Experience");
oppLife.setLife(0);
}
};// Ability
ability.setStackDescription("Near-Death Experience - " + player + " wins the game");
AllZone.Stack.add(ability);
}// if
}// upkeep_Near_Death_Experience
-slapshto5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Code from slapshot5
by slapshot5 » 19 Apr 2010, 00:44
Here's Giant Tortoise from Arabian Nights:
cards.txt:
-slapshot5
Edit:
Crap. I think this needs to be added to StaticEffects.java also:
cards.txt:
- Code: Select all
Giant Tortoise
1 U
Creature Turtle
As long as Giant Tortoise is untapped, it gets +0/+3.
1/1
- Code: Select all
commands.put("Giant_Tortoise", Giant_Tortoise);
- Code: Select all
public static Command Giant_Tortoise = new Command() {
private static final long serialVersionUID = -8191148876633239167L;
CardList old = new CardList();
int pump = 3;
public void execute() {
Card c;
// reset all previous cards stats
for(int i = 0; i < old.size(); i++) {
c = old.get(i);
c.addSemiPermanentDefenseBoost(-pump);
}
old.clear();
CardList list = getCard("Giant Tortoise");
for(int i = 0; i < list.size(); i++) {
c = list.get(i);
// only add boost if card is untapped
if(c.isUntapped()) {
c.addSemiPermanentDefenseBoost(pump);
old.add(c);
}
}// for
}// execute()
CardList getCard(String name) {
CardList list = new CardList();
list.addAll(AllZone.Human_Play.getCards());
list.addAll(AllZone.Computer_Play.getCards());
list = list.getName(name);
return list;
}// getCard()
}; // Giant Tortoise
-slapshot5
Edit:
Crap. I think this needs to be added to StaticEffects.java also:
- Code: Select all
cardToEffectsList.put("Giant Tortoise", new String[] {"Giant_Tortoise"});
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Code from slapshot5
by slapshot5 » 19 Apr 2010, 04:06
Here's Fracturing Gust from Shadowmoor:
-slapshot5
- Code: Select all
cards.txt:
Fracturing Gust
2 GW GW GW
Instant
Destroy all artifacts and enchantments. You gain 2 life for each permanent destroyed this way.
- Code: Select all
http://www.wizards.com/global/images/magic/general/fracturing_gust.jpg
- Code: Select all
//*************** START *********** START **************************
else if(cardName.equals("Fracturing Gust")) {
/*
* Destroy all artifacts and enchantments.
* You gain 2 life for each permanent destroyed this way.
*/
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 6940814538785932457L;
@Override
public void resolve() {
final String player = AllZone.Phase.getActivePlayer();
CardList all = new CardList();
all.addAll(AllZone.Human_Play.getCards());
all.addAll(AllZone.Computer_Play.getCards());
all = all.filter(artAndEn);
for(int i = 0; i < all.size(); i++) {
Card c = all.get(i);
AllZone.GameAction.destroy(c);
}
AllZone.GameAction.addLife(player, all.size()*2);
}// resolve()
@Override
public boolean canPlayAI() {
CardList human = new CardList(AllZone.Human_Play.getCards());
CardList computer = new CardList(AllZone.Computer_Play.getCards());
human = human.filter(artAndEn);
computer = computer.filter(artAndEn);
if(human.size() == 0) return false;
// the computer will at least destroy 2 more human enchantments
return computer.size() < human.size() - 1
|| (AllZone.Computer_Life.getLife() < 7 && !human.isEmpty());
}//canPlayAI
private CardListFilter artAndEn = new CardListFilter() {
public boolean addCard(Card c) {
return c.isArtifact() || c.isEnchantment();
}
};
};// SpellAbility
spell.setStackDescription(card.getName() + " - destroy all artifacts and enchantments.");
card.clearSpellAbility();
card.addSpellAbility(spell);
}// *************** END ************ END **************************
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Code from slapshot5
by slapshot5 » 19 Apr 2010, 15:15
Dennis or Rob -
I'm happy to keep posting code for others to commit.
-or-
I do feel comfortable now committing changes myself. I've got everything set up. If you're willing to grant me commit privileges, please PM me with questions or needed info.
-slapshot5
I'm happy to keep posting code for others to commit.
-or-
I do feel comfortable now committing changes myself. I've got everything set up. If you're willing to grant me commit privileges, please PM me with questions or needed info.
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Code from slapshot5
by Rob Cashwalker » 19 Apr 2010, 15:17
Doing a one-shot upkeep effect should be easy as-is. I was considering adding the "draw a card on next upkeep" as a "drawback" for other keywords.
We already have a Command list for upkeep effects. Just create a Command to draw the card, then deletes itself when executed.
We already have a Command list for upkeep effects. Just create a Command to draw the card, then deletes itself when executed.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Code from slapshot5
by DennisBergkamp » 19 Apr 2010, 16:14
Just pm me your email address (I think it has to be associated with a Google account). That's all I needslapshot5 wrote:Dennis or Rob -
I'm happy to keep posting code for others to commit.
-or-
I do feel comfortable now committing changes myself. I've got everything set up. If you're willing to grant me commit privileges, please PM me with questions or needed info.
-slapshot5

-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Code from slapshot5
by slapshot5 » 20 Apr 2010, 03:57
Thanks Dennis. Looking forward to all the fun.DennisBergkamp wrote:
Just pm me your email address (I think it has to be associated with a Google account). That's all I need

- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Code from slapshot5
by Chris H. » 20 Apr 2010, 10:42
`slapshot5 wrote:Looking forward to all the fun.
I see that you have had a busy night at the SVN.

-
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
55 posts
• Page 4 of 4 • 1, 2, 3, 4
Who is online
Users browsing this forum: No registered users and 51 guests