added MagicPermanentState.NoCombatDamage. corrected Ophidian

master
beholder 2011-10-31 10:12:51 +01:00
parent 41d1523822
commit 97f032151d
3 changed files with 14 additions and 23 deletions

View File

@ -1,28 +1,22 @@
package magic.card; package magic.card;
import magic.model.MagicDamage;
import magic.model.MagicGame; import magic.model.MagicGame;
import magic.model.MagicPermanent; import magic.model.MagicPermanent;
import magic.model.MagicPermanentState;
import magic.model.MagicPlayer; import magic.model.MagicPlayer;
import magic.model.action.MagicDealDamageAction; import magic.model.action.MagicChangeStateAction;
import magic.model.action.MagicDrawAction; import magic.model.action.MagicDrawAction;
import magic.model.choice.MagicMayChoice; import magic.model.choice.MagicMayChoice;
import magic.model.choice.MagicSimpleMayChoice; import magic.model.choice.MagicSimpleMayChoice;
import magic.model.event.MagicEvent; import magic.model.event.MagicEvent;
import magic.model.target.MagicTarget; import magic.model.trigger.MagicWhenAttacksUnblockedTrigger;
import magic.model.trigger.MagicIfDamageWouldBeDealtTrigger;
public class Ophidian { public class Ophidian {
public static final MagicIfDamageWouldBeDealtTrigger T = new MagicIfDamageWouldBeDealtTrigger(1) { public static final MagicWhenAttacksUnblockedTrigger T = new MagicWhenAttacksUnblockedTrigger() {
@Override @Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicDamage damage) { public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent creature) {
if (damage.getSource() == permanent && if (creature == permanent) {
damage.isCombat() &&
damage.getTarget().isPlayer() &&
!permanent.isBlocked()) {
final MagicPlayer player = permanent.getController(); final MagicPlayer player = permanent.getController();
final int amount = damage.getAmount();
damage.setAmount(0);
return new MagicEvent( return new MagicEvent(
permanent, permanent,
player, player,
@ -31,7 +25,7 @@ public class Ophidian {
MagicSimpleMayChoice.DRAW_CARDS, MagicSimpleMayChoice.DRAW_CARDS,
1, 1,
MagicSimpleMayChoice.DEFAULT_NONE), MagicSimpleMayChoice.DEFAULT_NONE),
new Object[]{player,permanent,damage.getTarget(),amount}, new Object[]{player,permanent},
this, this,
player + " may draw a card."); player + " may draw a card.");
} }
@ -46,13 +40,9 @@ public class Ophidian {
final Object[] choiceResults) { final Object[] choiceResults) {
if (MagicMayChoice.isYesChoice(choiceResults[0])) { if (MagicMayChoice.isYesChoice(choiceResults[0])) {
game.doAction(new MagicDrawAction((MagicPlayer)data[0],1)); game.doAction(new MagicDrawAction((MagicPlayer)data[0],1));
} else { game.doAction(new MagicChangeStateAction(
final MagicDamage damage = new MagicDamage(
(MagicPermanent)data[1], (MagicPermanent)data[1],
(MagicTarget)data[2], MagicPermanentState.NoCombatDamage,true));
(Integer)data[3],
false);
game.doAction(new MagicDealDamageAction(damage));
} }
} }
}; };

View File

@ -23,7 +23,8 @@ public enum MagicPermanentState {
ReturnToHandOfOwnerAtEndOfCombat("return to owner's hand at end of combat",""), ReturnToHandOfOwnerAtEndOfCombat("return to owner's hand at end of combat",""),
ExileAtEndOfCombat("exile at end of combat",""), ExileAtEndOfCombat("exile at end of combat",""),
DestroyAtEndOfCombat("destroy 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 = public static final int CLEANUP_MASK =

View File

@ -66,7 +66,7 @@ public class MagicCombatDamageAction extends MagicAction {
if (dealsCombatDamage(flags)) { if (dealsCombatDamage(flags)) {
// Checks if attacker has power > 0. // Checks if attacker has power > 0.
int power=attacker.getPower(game); int power=attacker.getPower(game);
if (power>0) { if (power>0 && !attacker.hasState(MagicPermanentState.NoCombatDamage)) {
if (attacker.hasState(MagicPermanentState.Blocked)) { if (attacker.hasState(MagicPermanentState.Blocked)) {
// Determine what damage must be dealt to each blocker. // Determine what damage must be dealt to each blocker.
final boolean deathtouch=MagicAbility.Deathtouch.hasAbility(flags); final boolean deathtouch=MagicAbility.Deathtouch.hasAbility(flags);