From 97f032151d59fecc8dbee3415d578636ed6be02e Mon Sep 17 00:00:00 2001 From: beholder Date: Mon, 31 Oct 2011 10:12:51 +0100 Subject: [PATCH] added MagicPermanentState.NoCombatDamage. corrected Ophidian --- src/magic/card/Ophidian.java | 32 +++++++------------ src/magic/model/MagicPermanentState.java | 3 +- .../model/action/MagicCombatDamageAction.java | 2 +- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/magic/card/Ophidian.java b/src/magic/card/Ophidian.java index 9af04efd94..369a972beb 100644 --- a/src/magic/card/Ophidian.java +++ b/src/magic/card/Ophidian.java @@ -1,28 +1,22 @@ package magic.card; -import magic.model.MagicDamage; import magic.model.MagicGame; import magic.model.MagicPermanent; +import magic.model.MagicPermanentState; import magic.model.MagicPlayer; -import magic.model.action.MagicDealDamageAction; +import magic.model.action.MagicChangeStateAction; import magic.model.action.MagicDrawAction; import magic.model.choice.MagicMayChoice; import magic.model.choice.MagicSimpleMayChoice; import magic.model.event.MagicEvent; -import magic.model.target.MagicTarget; -import magic.model.trigger.MagicIfDamageWouldBeDealtTrigger; +import magic.model.trigger.MagicWhenAttacksUnblockedTrigger; public class Ophidian { - public static final MagicIfDamageWouldBeDealtTrigger T = new MagicIfDamageWouldBeDealtTrigger(1) { + public static final MagicWhenAttacksUnblockedTrigger T = new MagicWhenAttacksUnblockedTrigger() { @Override - public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicDamage damage) { - if (damage.getSource() == permanent && - damage.isCombat() && - damage.getTarget().isPlayer() && - !permanent.isBlocked()) { - final MagicPlayer player = permanent.getController(); - final int amount = damage.getAmount(); - damage.setAmount(0); + public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent creature) { + if (creature == permanent) { + final MagicPlayer player = permanent.getController(); return new MagicEvent( permanent, player, @@ -31,7 +25,7 @@ public class Ophidian { MagicSimpleMayChoice.DRAW_CARDS, 1, MagicSimpleMayChoice.DEFAULT_NONE), - new Object[]{player,permanent,damage.getTarget(),amount}, + new Object[]{player,permanent}, this, player + " may draw a card."); } @@ -46,14 +40,10 @@ public class Ophidian { final Object[] choiceResults) { if (MagicMayChoice.isYesChoice(choiceResults[0])) { game.doAction(new MagicDrawAction((MagicPlayer)data[0],1)); - } else { - final MagicDamage damage = new MagicDamage( + game.doAction(new MagicChangeStateAction( (MagicPermanent)data[1], - (MagicTarget)data[2], - (Integer)data[3], - false); - game.doAction(new MagicDealDamageAction(damage)); - } + MagicPermanentState.NoCombatDamage,true)); + } } }; } diff --git a/src/magic/model/MagicPermanentState.java b/src/magic/model/MagicPermanentState.java index da916d9429..a9005c55c6 100644 --- a/src/magic/model/MagicPermanentState.java +++ b/src/magic/model/MagicPermanentState.java @@ -23,7 +23,8 @@ public enum MagicPermanentState { ReturnToHandOfOwnerAtEndOfCombat("return to owner's hand at end of combat",""), ExileAtEndOfCombat("exile at end of combat",""), DestroyAtEndOfCombat("destroy at end of combat",""), - CannotAttack("can't attack","") + CannotAttack("can't attack",""), + NoCombatDamage("assigns no combat damage","") ; public static final int CLEANUP_MASK = diff --git a/src/magic/model/action/MagicCombatDamageAction.java b/src/magic/model/action/MagicCombatDamageAction.java index 1f01ddb051..25a987a449 100644 --- a/src/magic/model/action/MagicCombatDamageAction.java +++ b/src/magic/model/action/MagicCombatDamageAction.java @@ -66,7 +66,7 @@ public class MagicCombatDamageAction extends MagicAction { if (dealsCombatDamage(flags)) { // Checks if attacker has power > 0. int power=attacker.getPower(game); - if (power>0) { + if (power>0 && !attacker.hasState(MagicPermanentState.NoCombatDamage)) { if (attacker.hasState(MagicPermanentState.Blocked)) { // Determine what damage must be dealt to each blocker. final boolean deathtouch=MagicAbility.Deathtouch.hasAbility(flags);