From ff9c789f3946f55c03589029a92a8068fcf944f3 Mon Sep 17 00:00:00 2001 From: beholder Date: Sun, 4 Sep 2011 13:27:51 +0200 Subject: [PATCH] added MagicTargetType.Hand. added Quicksilver Amulet --- resources/magic/data/cards.txt | 9 +++ src/magic/card/Quicksilver_Amulet.java | 56 +++++++++++++++++++ src/magic/model/MagicGame.java | 15 +++++ src/magic/model/choice/MagicTargetChoice.java | 2 + src/magic/model/target/MagicTargetFilter.java | 10 ++++ src/magic/model/target/MagicTargetType.java | 3 +- 6 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 src/magic/card/Quicksilver_Amulet.java diff --git a/resources/magic/data/cards.txt b/resources/magic/data/cards.txt index 341fc20f0e..051109717c 100644 --- a/resources/magic/data/cards.txt +++ b/resources/magic/data/cards.txt @@ -7670,6 +7670,15 @@ converted=1 cost={1} timing=artifact +>Quicksilver Amulet +image=http://magiccards.info/scans/en/m12/214.jpg +value=4 +rarity=R +type=Artifact +converted=4 +cost={4} +timing=artifact + >Sylvok Lifestaff image=http://magiccards.info/scans/en/som/209.jpg value=2 diff --git a/src/magic/card/Quicksilver_Amulet.java b/src/magic/card/Quicksilver_Amulet.java new file mode 100644 index 0000000000..eb89235c41 --- /dev/null +++ b/src/magic/card/Quicksilver_Amulet.java @@ -0,0 +1,56 @@ +package magic.card; + +import magic.model.*; +import magic.model.action.MagicCardAction; +import magic.model.action.MagicPlayCardAction; +import magic.model.action.MagicRemoveCardAction; +import magic.model.choice.MagicTargetChoice; +import magic.model.condition.MagicCondition; +import magic.model.event.*; +import magic.model.target.MagicGraveyardTargetPicker; + +public class Quicksilver_Amulet { + + public static final MagicPermanentActivation A1 = new MagicPermanentActivation( + new MagicCondition[]{ + MagicCondition.CAN_TAP_CONDITION, + MagicManaCost.FOUR.getCondition()}, + new MagicActivationHints(MagicTiming.Token), + "Token") { + @Override + public MagicEvent[] getCostEvent(final MagicSource source) { + final MagicPermanent permanent=(MagicPermanent)source; + return new MagicEvent[]{ + new MagicTapEvent(permanent), + new MagicPayManaCostEvent(source,source.getController(),MagicManaCost.FOUR)}; + } + + @Override + public MagicEvent getPermanentEvent( + final MagicPermanent source, + final MagicPayedCost payedCost) { + return new MagicEvent( + source, + source.getController(), + MagicTargetChoice.TARGET_CREATURE_CARD_FROM_HAND, + MagicGraveyardTargetPicker.getInstance(), + new Object[]{source.getController()}, + this, + "Put a creature card$ from your hand onto the battlefield."); + } + + @Override + public void executeEvent( + final MagicGame game, + final MagicEvent event, + final Object[] data, + final Object[] choiceResults) { + event.processTargetCard(game,choiceResults,0,new MagicCardAction() { + public void doAction(final MagicCard card) { + game.doAction(new MagicRemoveCardAction(card,MagicLocationType.OwnersHand)); + game.doAction(new MagicPlayCardAction(card,(MagicPlayer)data[0],MagicPlayCardAction.NONE)); + } + }); + } + }; +} diff --git a/src/magic/model/MagicGame.java b/src/magic/model/MagicGame.java index e6c32a215d..626e4cd3c2 100644 --- a/src/magic/model/MagicGame.java +++ b/src/magic/model/MagicGame.java @@ -910,6 +910,15 @@ public class MagicGame { } } + // Cards in hand + if (targetFilter.acceptType(MagicTargetType.Hand)) { + for (final MagicCard targetCard : player.getHand()) { + if (targetFilter.accept(this,player,targetCard)) { + targets.add(targetCard); + } + } + } + return targets; } @@ -998,6 +1007,12 @@ public class MagicGame { return true; } + // Card in hand + if (targetFilter.acceptType(MagicTargetType.Hand) && + player.getHand().contains(target)) { + return true; + } + return false; } diff --git a/src/magic/model/choice/MagicTargetChoice.java b/src/magic/model/choice/MagicTargetChoice.java index ce5c3ad807..676d4ed373 100644 --- a/src/magic/model/choice/MagicTargetChoice.java +++ b/src/magic/model/choice/MagicTargetChoice.java @@ -188,6 +188,8 @@ public class MagicTargetChoice extends MagicChoice { new MagicTargetChoice(MagicTargetFilter.TARGET_ARTIFACT_OR_CREATURE_CARD_FROM_ALL_GRAVEYARDS,false,MagicTargetHint.None,"target artifact or creature card from a graveyard"); public static final MagicTargetChoice TARGET_GOBLIN_CARD_FROM_GRAVEYARD= new MagicTargetChoice(MagicTargetFilter.TARGET_GOBLIN_CARD_FROM_GRAVEYARD,false,MagicTargetHint.None,"target Goblin card from your graveyard"); + public static final MagicTargetChoice TARGET_CREATURE_CARD_FROM_HAND = + new MagicTargetChoice(MagicTargetFilter.TARGET_CREATURE_CARD_FROM_HAND,false,MagicTargetHint.None,"target creature card from your hand"); private final String targetDescription; private final MagicTargetFilter targetFilter; diff --git a/src/magic/model/target/MagicTargetFilter.java b/src/magic/model/target/MagicTargetFilter.java index fca0eec68a..f86671e44c 100644 --- a/src/magic/model/target/MagicTargetFilter.java +++ b/src/magic/model/target/MagicTargetFilter.java @@ -882,7 +882,17 @@ public interface MagicTargetFilter { return targetType==MagicTargetType.Graveyard; } }; + + public static final MagicTargetFilter TARGET_CREATURE_CARD_FROM_HAND = new MagicTargetFilter() { + public boolean accept(final MagicGame game,final MagicPlayer player,final MagicTarget target) { + return ((MagicCard)target).getCardDefinition().isCreature(); + } + public boolean acceptType(final MagicTargetType targetType) { + return targetType == MagicTargetType.Hand; + } + }; + // Permanent reference can not be used because game is copied. public static final class MagicOtherPermanentTargetFilter implements MagicTargetFilter { diff --git a/src/magic/model/target/MagicTargetType.java b/src/magic/model/target/MagicTargetType.java index 16fb3a58ac..1d8631fbe7 100644 --- a/src/magic/model/target/MagicTargetType.java +++ b/src/magic/model/target/MagicTargetType.java @@ -5,6 +5,7 @@ public enum MagicTargetType { Permanent, Stack, Graveyard, - OpponentsGraveyard + OpponentsGraveyard, + Hand ; }