allow multiple damage actions to take place if target is both planeswalker and creature

master
melvin 2013-02-26 13:42:03 +08:00
parent c088116676
commit 6d2f5f1ffa
1 changed files with 20 additions and 6 deletions

View File

@ -80,6 +80,17 @@ public class MagicDealDamageAction extends MagicAction {
return; return;
} }
target = damage.getTarget();
/*
119.1. Objects can deal damage to creatures, planeswalkers, and players.
*/
if (!target.isCreature() &&
!target.isPlaneswalker() &&
!target.isPlayer()) {
return;
}
game.executeTrigger(MagicTriggerType.IfDamageWouldBeDealt,damage); game.executeTrigger(MagicTriggerType.IfDamageWouldBeDealt,damage);
damage.setDealtAmount(0); damage.setDealtAmount(0);
int dealtAmount=damage.getAmount(); int dealtAmount=damage.getAmount();
@ -87,18 +98,19 @@ public class MagicDealDamageAction extends MagicAction {
return; return;
} }
target = damage.getTarget();
dealtAmount=preventDamage(game,dealtAmount); dealtAmount=preventDamage(game,dealtAmount);
if (dealtAmount<=0) { if (dealtAmount<=0) {
return; return;
} }
final MagicSource source=damage.getSource(); final MagicSource source=damage.getSource();
if (target.isPermanent() && target.hasType(MagicType.Planeswalker)) {
if (target.isPlaneswalker()) {
final MagicPermanent targetPermanent=(MagicPermanent)target; final MagicPermanent targetPermanent=(MagicPermanent)target;
game.doAction(new MagicChangeCountersAction(targetPermanent,MagicCounterType.Charge,-dealtAmount,true)); game.doAction(new MagicChangeCountersAction(targetPermanent,MagicCounterType.Charge,-dealtAmount,true));
}
} else if (target.isPermanent()) { if (target.isCreature()) {
final MagicPermanent targetPermanent=(MagicPermanent)target; final MagicPermanent targetPermanent=(MagicPermanent)target;
if (damage.hasNoRegeneration()) { if (damage.hasNoRegeneration()) {
game.doAction(new MagicChangeStateAction(targetPermanent,MagicPermanentState.CannotBeRegenerated,true)); game.doAction(new MagicChangeStateAction(targetPermanent,MagicPermanentState.CannotBeRegenerated,true));
@ -112,7 +124,9 @@ public class MagicDealDamageAction extends MagicAction {
if (source.hasAbility(MagicAbility.Deathtouch)) { if (source.hasAbility(MagicAbility.Deathtouch)) {
game.doAction(new MagicChangeStateAction(targetPermanent,MagicPermanentState.Destroyed,true)); game.doAction(new MagicChangeStateAction(targetPermanent,MagicPermanentState.Destroyed,true));
} }
} else if (target.isPlayer()) { }
if (target.isPlayer()) {
final MagicPlayer targetPlayer = (MagicPlayer)target; final MagicPlayer targetPlayer = (MagicPlayer)target;
if (source.hasAbility(MagicAbility.Infect)) { if (source.hasAbility(MagicAbility.Infect)) {
game.doAction(new MagicChangePoisonAction(targetPlayer,dealtAmount)); game.doAction(new MagicChangePoisonAction(targetPlayer,dealtAmount));