Code from slapshot5

Rather than burying code in the Card Requests thread or the Bugs thread, I'll start my own thread and post back here when I have code to contribute. I'll start in the following posts...
-slapshot5
-slapshot5
High Quality Resources for Collectible Card Games
https://www.slightlymagic.net/forum/
https://www.slightlymagic.net/forum/viewtopic.php?f=52&t=2477
private static void upkeep_Karma() {
final String player = AllZone.Phase.getActivePlayer();
String opponent = AllZone.GameAction.getOpponent(player);
PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Play, opponent);
CardList karma = new CardList(opponentPlayZone.getCards());
karma = karma.getName("Karma");
PlayerZone activePlayZone = AllZone.getZone(Constant.Zone.Play, player);
CardList swamps = new CardList(activePlayZone.getCards());
swamps = swamps.getType("Swamp");
// determine how much damage to deal the current player
final int damage = swamps.size();
// if there are 1 or more Karmas owned by the opponent of the
// current player have each of them deal damage.
if(0 < karma.size()) {
for(int i = 0; i < karma.size(); i++) {
Ability ability = new Ability(karma.get(0), "0") {
@Override
public void resolve() {
if(damage>0){
PlayerLife life = AllZone.GameAction.getPlayerLife(player);
life.setLife(life.getLife() - damage);
}
}
};// Ability
if(damage>0){
ability.setStackDescription("Karma deals " + damage + " damage to " + player);
AllZone.Stack.add(ability);
}
}
}// if
}// upkeep_Karma()
Karma
2 W W
Enchantment
At the beginning of each player's upkeep, Karma deals damage to that player equal to the number of Swamps he or she controls.
http://www.wizards.com/global/images/magic/general/karma.jpg
//*************** START *********** START **************************
else if(cardName.equals("Flashfires")) {
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -5951776277564352958L;
@Override
public void resolve() {
CardList all = new CardList();
all.addAll(AllZone.Human_Play.getCards());
all.addAll(AllZone.Computer_Play.getCards());
for(int i = 0; i < all.size(); i++) {
Card c = all.get(i);
if(c.getType().contains("Plains")) AllZone.GameAction.destroy(c);
}
}//resolve()
@Override
public boolean canPlayAI() {
CardList list = new CardList(AllZone.Human_Play.getCards());
list = list.getType("Plains");
return 3 < list.size();
}
};//SpellAbility
spell.setStackDescription(card.getName() + " - destroy all Plains.");
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
Flashfires
3 R
Sorcery
Destroy all Plains.
http://www.wizards.com/global/images/magic/general/flashfires.jpg
//*************** START *********** START **************************
else if(cardName.equals("Crumble")) {
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 4752943254606319269L;
@Override
public void resolve() {
if(AllZone.GameAction.isCardInPlay(getTargetCard())
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
//add life
String player = getTargetCard().getController();
PlayerLife life = AllZone.GameAction.getPlayerLife(player);
life.addLife(CardUtil.getConvertedManaCost(getTargetCard()));
//remove card from play
AllZone.GameAction.removeFromGame(getTargetCard());
}
}//resolve()
@Override
public boolean canPlayAI() {
CardList artifacts = new CardList(AllZone.Human_Play.getCards());
artifacts = artifacts.getType("Artifact");
artifacts = artifacts.filter(new CardListFilter() {
public boolean addCard(Card c) {
return CardFactoryUtil.canTarget(card, c);
}
});
return artifacts.size() != 0 && (AllZone.Phase.getTurn() > 4);
}
@Override
public void chooseTargetAI() {
CardList play = new CardList(AllZone.Human_Play.getCards());
Card target = CardFactoryUtil.AI_getBestArtifact(play);
if(target != null) setTargetCard(target);
}
};
spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell, "Artifact"));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
Crumble
G
Instant
Destroy target artifact. It can't be regenerated. That artifact's controller gains life equal to its converted mana cost.
http://www.wizards.com/global/images/magic/general/crumble.jpg
//*************** START *********** START **************************
else if(cardName.equals("Channel the Suns")) {
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -8509187529151755266L;
@Override
public void resolve() {
Card mp = AllZone.ManaPool;
mp.addExtrinsicKeyword("ManaPool:W");
mp.addExtrinsicKeyword("ManaPool:U");
mp.addExtrinsicKeyword("ManaPool:B");
mp.addExtrinsicKeyword("ManaPool:R");
mp.addExtrinsicKeyword("ManaPool:G");
}
@Override
public boolean canPlayAI() {
return false;
}
};
spell.setStackDescription(cardName + " adds W U B R G to your mana pool");
card.clearSpellAbility();
card.addSpellAbility(spell);
return card;
}//*************** END ************ END **************************
Channel the Suns
3 G
Sorcery
Add W U B R G to your mana pool.
http://www.wizards.com/global/images/magic/general/channel_the_suns.jpg
Just mindlessly copied Dark Ritual. The Mana Pool stuff is all new to me. I haven't dug into it enough to do anything intelligent.zerker2000 wrote:Why not "mp.addMana("WUBRG");"?
public static void executeTapSideEffects(Card c) {
/* cards with Tap side effects can be listed here, just like in
* the CardFactory classes
*/
if(c.getName().equals("City of Brass")) {
final String player = c.getOwner();
Ability ability = new Ability(c, "0") {
@Override
public void resolve() {
PlayerLife life = AllZone.GameAction.getPlayerLife(player);
life.setLife(life.getLife() - 1);
}
};// Ability
ability.setStackDescription("City of Brass deals 1 damage to " + player);
AllZone.Stack.add(ability);
}//end City of Brass
}
public void tap() {
GameActionUtil.executeTapSideEffects(this);
setTapped(true);
}
City of Brass
no cost
Land
Whenever City of Brass becomes tapped, it deals 1 damage to you.
tap: add W
tap: add B
tap: add U
tap: add R
tap: add G
http://www.wizards.com/global/images/magic/general/city_of_brass.jpg
//*************** START *********** START **************************
else if(cardName.equals("Storm Seeker")) {
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -5456164079435151319L;
@Override
public void resolve() {
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, getTargetPlayer());
int damage = hand.size();
//sanity check
if( damage < 0 )
damage = 0;
PlayerLife life = AllZone.GameAction.getPlayerLife(getTargetPlayer());
life.setLife(life.getLife() - damage);
}
};
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman());
spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell));
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
Storm Seeker
3 G
Instant
Storm Seeker deals damage equal to the number of cards in target player's hand to that player.
http://www.wizards.com/global/images/magic/general/storm_seeker.jpg
else if(b.getName().equals("AEther Membrane") || b.getName().equals("Aether Membrane") || b.getName().equals("Wall of Tears")) {
Wall of Tears
1 U
Creature Wall
Whenever Wall of Tears blocks a creature, return that creature to its owner's hand at end of combat.
0/4
Defender
http://www.wizards.com/global/images/magic/general/wall_of_tears.jpg
Thanks Rob. I haven't dug into the keyword stuff yet. Probably a good chance to learn and see what's there. I'll futz with it tonight and see if I can get the same functionality working in keywords.Rob Cashwalker wrote:. Storm Seeker should be done by tweaking the spDamageTgt keyword and adding "TgtPHand" or something to CardFactoryUtil.xCount().