From bb9ed7a9d04da7c0cce4a9e685097fa12e25f540 Mon Sep 17 00:00:00 2001 From: beholder Date: Wed, 24 Aug 2011 20:55:04 +0200 Subject: [PATCH] added Call to the Grave --- resources/magic/data/cards.txt | 10 +++ src/magic/card/Call_to_the_Grave.java | 63 +++++++++++++++++++ src/magic/model/choice/MagicTargetChoice.java | 2 + src/magic/model/target/MagicTargetFilter.java | 15 +++++ 4 files changed, 90 insertions(+) create mode 100644 src/magic/card/Call_to_the_Grave.java diff --git a/resources/magic/data/cards.txt b/resources/magic/data/cards.txt index 35c98e0b28..542394b34e 100644 --- a/resources/magic/data/cards.txt +++ b/resources/magic/data/cards.txt @@ -3959,6 +3959,16 @@ cost={1}{W}{W} static=player timing=enchantment +>Call to the Grave +image=http://magiccards.info/scans/en/m12/85.jpg +value=4 +rarity=R +type=Enchantment +color=b +converted=5 +cost={4}{B} +timing=enchantment + >Glory of Warfare image=http://magiccards.info/scans/en/arb/98.jpg value=4 diff --git a/src/magic/card/Call_to_the_Grave.java b/src/magic/card/Call_to_the_Grave.java new file mode 100644 index 0000000000..91bf3669c5 --- /dev/null +++ b/src/magic/card/Call_to_the_Grave.java @@ -0,0 +1,63 @@ +package magic.card; + +import java.util.Collection; + +import magic.model.*; +import magic.model.action.MagicSacrificeAction; +import magic.model.choice.MagicTargetChoice; +import magic.model.event.MagicEvent; +import magic.model.event.MagicSacrificePermanentEvent; +import magic.model.target.MagicTarget; +import magic.model.target.MagicTargetFilter; +import magic.model.trigger.MagicTrigger; +import magic.model.trigger.MagicTriggerType; + +public class Call_to_the_Grave { + public static final MagicTrigger T1 = new MagicTrigger(MagicTriggerType.AtUpkeep) { + @Override + public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final Object data) { + final MagicPlayer player = (MagicPlayer)data; + return new MagicEvent( + permanent, + player, + new Object[]{permanent,player}, + this, + player + " sacrifices a non-Zombie creature."); + } + + @Override + public void executeEvent( + final MagicGame game, + final MagicEvent event, + final Object data[], + final Object[] choiceResults) { + final MagicPlayer player = (MagicPlayer)data[1]; + if (player.controlsPermanentWithType(MagicType.Creature)) { + game.addEvent(new MagicSacrificePermanentEvent( + (MagicPermanent)data[0], + player, + MagicTargetChoice.SACRIFICE_NON_ZOMBIE)); + } + } + }; + + public static final MagicTrigger T2 = new MagicTrigger(MagicTriggerType.AtEndOfTurn) { + @Override + public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final Object data) { + final Collection targets = + game.filterTargets(permanent.getController(),MagicTargetFilter.TARGET_CREATURE); + if (targets.size() == 0) { + game.doAction(new MagicSacrificeAction(permanent)); + } + return null; + } + + @Override + public void executeEvent( + final MagicGame game, + final MagicEvent event, + final Object data[], + final Object[] choiceResults) { + } + }; +} diff --git a/src/magic/model/choice/MagicTargetChoice.java b/src/magic/model/choice/MagicTargetChoice.java index 07532d064a..de86c4ed44 100644 --- a/src/magic/model/choice/MagicTargetChoice.java +++ b/src/magic/model/choice/MagicTargetChoice.java @@ -147,6 +147,8 @@ public class MagicTargetChoice extends MagicChoice { new MagicTargetChoice(MagicTargetFilter.TARGET_BEAST_YOU_CONTROL,false,MagicTargetHint.None,"a Beast to sacrifice"); public static final MagicTargetChoice SACRIFICE_GOBLIN= new MagicTargetChoice(MagicTargetFilter.TARGET_GOBLIN_YOU_CONTROL,false,MagicTargetHint.None,"a Goblin to sacrifice"); + public static final MagicTargetChoice SACRIFICE_NON_ZOMBIE= + new MagicTargetChoice(MagicTargetFilter.TARGET_NON_ZOMBIE_YOU_CONTROL,false,MagicTargetHint.None,"a non-Zombie creature to sacrifice"); public static final MagicTargetChoice TARGET_CREATURE_CARD_FROM_GRAVEYARD= new MagicTargetChoice(MagicTargetFilter.TARGET_CREATURE_CARD_FROM_GRAVEYARD,false,MagicTargetHint.None,"target creature card from your graveyard"); public static final MagicTargetChoice TARGET_PERMANENT_CARD_CMC_LEQ_3_FROM_GRAVEYARD= diff --git a/src/magic/model/target/MagicTargetFilter.java b/src/magic/model/target/MagicTargetFilter.java index e2c2c6696d..e814ce9935 100644 --- a/src/magic/model/target/MagicTargetFilter.java +++ b/src/magic/model/target/MagicTargetFilter.java @@ -442,6 +442,21 @@ public interface MagicTargetFilter { return targetType==MagicTargetType.Permanent; } }; + + public static final MagicTargetFilter TARGET_NON_ZOMBIE_YOU_CONTROL = new MagicTargetFilter() { + + public boolean accept(final MagicGame game,final MagicPlayer player,final MagicTarget target) { + + return target.getController() == player && + ((MagicPermanent)target).isCreature() && + !((MagicPermanent)target).hasSubType(MagicSubType.Zombie); + } + + public boolean acceptType(final MagicTargetType targetType) { + + return targetType == MagicTargetType.Permanent; + } + }; public static final MagicTargetFilter TARGET_CREATURE_YOUR_OPPONENT_CONTROLS=new MagicTargetFilter() {