From d36a9685793cd778bd0b2ca633cd7b1e7ed81fc9 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 3 Sep 2013 23:42:34 +0200 Subject: [PATCH] * Thraximundar - Fixed that the second ability to sacrifice a creature didn't trigger. --- .../src/mage/sets/alarareborn/MageSlayer.java | 2 +- .../mage/sets/alarareborn/Thraximundar.java | 5 ++-- .../mage/sets/alarareborn/VedalkenGhoul.java | 2 +- .../sets/dragonsmaze/MasterOfCruelties.java | 2 +- .../sets/innistrad/GrimgrinCorpseBorn.java | 2 +- .../mage/sets/innistrad/TrepanationBlade.java | 2 +- .../mage/sets/magic2011/AncientHellkite.java | 2 +- .../mage/sets/magic2011/CyclopsGladiator.java | 2 +- .../magic2013/NefaroxOverlordOfGrixis.java | 2 +- .../mage/sets/magic2014/ColossalWhale.java | 2 +- .../sets/magic2014/MasterOfDiversion.java | 2 +- .../mage/sets/returntoravnica/SkymarkRoc.java | 2 +- .../LordOfShatterskullPass.java | 2 +- .../sets/scarsofmirrodin/MyrBattlesphere.java | 2 +- .../src/mage/sets/zendikar/GoblinGuide.java | 2 +- .../DefendingPlayerControlsCondition.java | 2 +- .../abilities/keyword/AnnihilatorAbility.java | 2 +- .../abilities/keyword/NinjutsuAbility.java | 2 +- Mage/src/mage/game/combat/Combat.java | 26 ++++++++++++++++++- 19 files changed, 44 insertions(+), 21 deletions(-) diff --git a/Mage.Sets/src/mage/sets/alarareborn/MageSlayer.java b/Mage.Sets/src/mage/sets/alarareborn/MageSlayer.java index 2367c0d459..9b0ce9cad5 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/MageSlayer.java +++ b/Mage.Sets/src/mage/sets/alarareborn/MageSlayer.java @@ -94,7 +94,7 @@ class MageSlayerEffect extends OneShotEffect { Permanent equipment = game.getPermanent(source.getSourceId()); if (equipment != null && equipment.getAttachedTo() != null) { int power = game.getPermanent(equipment.getAttachedTo()).getPower().getValue(); - UUID defendingPlayerId = game.getCombat().getDefendingPlayer(equipment.getAttachedTo()); + UUID defendingPlayerId = game.getCombat().getDefenderId(equipment.getAttachedTo()); if (defendingPlayerId != null) { game.getPlayer(defendingPlayerId).damage(power, id, game, false, true); return true; diff --git a/Mage.Sets/src/mage/sets/alarareborn/Thraximundar.java b/Mage.Sets/src/mage/sets/alarareborn/Thraximundar.java index 0a58b590a2..29faa74d48 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/Thraximundar.java +++ b/Mage.Sets/src/mage/sets/alarareborn/Thraximundar.java @@ -110,10 +110,9 @@ class ThraximundarTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean apply(Game game, Ability source) { - Player defendingPlayer = game.getPlayer(game.getCombat().getDefendingPlayer(source.getSourceId())); + Player defendingPlayer = game.getPlayer(game.getCombat().getDefenderId(source.getSourceId())); if (defendingPlayer != null) { defendingPlayer.setLife(1, game); return true; diff --git a/Mage.Sets/src/mage/sets/innistrad/GrimgrinCorpseBorn.java b/Mage.Sets/src/mage/sets/innistrad/GrimgrinCorpseBorn.java index 675d3c65b7..99ed20c496 100644 --- a/Mage.Sets/src/mage/sets/innistrad/GrimgrinCorpseBorn.java +++ b/Mage.Sets/src/mage/sets/innistrad/GrimgrinCorpseBorn.java @@ -113,7 +113,7 @@ class GrimgrinCorpseBornAbility extends TriggeredAbilityImpl { @Override public boolean apply(Game game, Ability source) { - UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId()); + UUID defenderId = game.getCombat().getDefenderId(source.getSourceId()); if (defenderId != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls"); filter.add(new ControllerIdPredicate(defenderId)); diff --git a/Mage.Sets/src/mage/sets/magic2013/NefaroxOverlordOfGrixis.java b/Mage.Sets/src/mage/sets/magic2013/NefaroxOverlordOfGrixis.java index 35287863ca..70358ad2d5 100644 --- a/Mage.Sets/src/mage/sets/magic2013/NefaroxOverlordOfGrixis.java +++ b/Mage.Sets/src/mage/sets/magic2013/NefaroxOverlordOfGrixis.java @@ -106,7 +106,7 @@ class NefaroxOverlordOfGrixisTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls"); - UUID defenderId = game.getCombat().getDefendingPlayer(sourceId); + UUID defenderId = game.getCombat().getDefenderId(sourceId); filter.add(new ControllerIdPredicate(defenderId)); this.getTargets().clear(); diff --git a/Mage.Sets/src/mage/sets/magic2014/MasterOfDiversion.java b/Mage.Sets/src/mage/sets/magic2014/MasterOfDiversion.java index 45b4482743..4219c0fdee 100644 --- a/Mage.Sets/src/mage/sets/magic2014/MasterOfDiversion.java +++ b/Mage.Sets/src/mage/sets/magic2014/MasterOfDiversion.java @@ -73,7 +73,7 @@ public class MasterOfDiversion extends CardImpl { if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) { ability.getTargets().clear(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls"); - UUID defenderId = game.getCombat().getDefendingPlayer(ability.getSourceId()); + UUID defenderId = game.getCombat().getDefenderId(ability.getSourceId()); filter.add(new ControllerIdPredicate(defenderId)); TargetCreaturePermanent target = new TargetCreaturePermanent(filter); target.setRequired(true); diff --git a/Mage.Sets/src/mage/sets/returntoravnica/SkymarkRoc.java b/Mage.Sets/src/mage/sets/returntoravnica/SkymarkRoc.java index 79923b41ba..aeb0fd2cec 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/SkymarkRoc.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/SkymarkRoc.java @@ -93,7 +93,7 @@ class SkymarkRocAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls with toughness 2 or less"); - UUID defenderId = game.getCombat().getDefendingPlayer(sourceId); + UUID defenderId = game.getCombat().getDefenderId(sourceId); filter.add(new ControllerIdPredicate(defenderId)); filter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, 3)); diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/LordOfShatterskullPass.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/LordOfShatterskullPass.java index d7a846a5a9..8bf3add6e2 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/LordOfShatterskullPass.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/LordOfShatterskullPass.java @@ -107,7 +107,7 @@ class LordOfShatterskullPassEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId()); + UUID defenderId = game.getCombat().getDefenderId(source.getSourceId()); Player defender = game.getPlayer(defenderId); if (defender != null) { defender.damage(amount.calculate(game, source), source.getSourceId(), game, false, false); diff --git a/Mage.Sets/src/mage/sets/zendikar/GoblinGuide.java b/Mage.Sets/src/mage/sets/zendikar/GoblinGuide.java index 049e6cf093..ca1d90a51b 100644 --- a/Mage.Sets/src/mage/sets/zendikar/GoblinGuide.java +++ b/Mage.Sets/src/mage/sets/zendikar/GoblinGuide.java @@ -92,7 +92,7 @@ class GoblinGuideEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId()); + UUID defenderId = game.getCombat().getDefenderId(source.getSourceId()); Player defender = game.getPlayer(defenderId); if (defender != null) { Cards cards = new CardsImpl(); diff --git a/Mage/src/mage/abilities/condition/common/DefendingPlayerControlsCondition.java b/Mage/src/mage/abilities/condition/common/DefendingPlayerControlsCondition.java index ae71599abf..1cd344175f 100644 --- a/Mage/src/mage/abilities/condition/common/DefendingPlayerControlsCondition.java +++ b/Mage/src/mage/abilities/condition/common/DefendingPlayerControlsCondition.java @@ -47,7 +47,7 @@ public class DefendingPlayerControlsCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - UUID defendingPlayer = game.getCombat().getDefendingPlayer(source.getSourceId()); + UUID defendingPlayer = game.getCombat().getDefenderId(source.getSourceId()); return defendingPlayer != null && game.getBattlefield().countAll(filter, defendingPlayer, game) > 0; } } diff --git a/Mage/src/mage/abilities/keyword/AnnihilatorAbility.java b/Mage/src/mage/abilities/keyword/AnnihilatorAbility.java index 8c8fd4dc75..48c982f88d 100644 --- a/Mage/src/mage/abilities/keyword/AnnihilatorAbility.java +++ b/Mage/src/mage/abilities/keyword/AnnihilatorAbility.java @@ -109,7 +109,7 @@ class AnnihilatorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId()); + UUID defenderId = game.getCombat().getDefenderId(source.getSourceId()); Player player = game.getPlayer(defenderId); //Defender may be a planeswalker. diff --git a/Mage/src/mage/abilities/keyword/NinjutsuAbility.java b/Mage/src/mage/abilities/keyword/NinjutsuAbility.java index 010de9c680..5972cd091a 100644 --- a/Mage/src/mage/abilities/keyword/NinjutsuAbility.java +++ b/Mage/src/mage/abilities/keyword/NinjutsuAbility.java @@ -161,7 +161,7 @@ class ReturnAttackerToHandTargetCost extends CostImpl { return false; } - public UUID getDefendingPlayer(UUID attackerId) { + /** + * + * @param attackerId + * @return uuid of defending player or planeswalker + */ + public UUID getDefenderId(UUID attackerId) { UUID defenderId = null; for (CombatGroup group : groups) { if (group.getAttackers().contains(attackerId)) { @@ -537,6 +542,25 @@ public class Combat implements Serializable, Copyable { return defenderId; } + public UUID getDefendingPlayerId(UUID attackerId, Game game) { + UUID defenderId = null; + for (CombatGroup group : groups) { + if (group.getAttackers().contains(attackerId)) { + defenderId = group.getDefenderId(); + if (group.defenderIsPlaneswalker) { + Permanent permanent = game.getPermanent(defenderId); + if (permanent != null) { + defenderId = permanent.getControllerId(); + } else { + defenderId = null; + } + } + break; + } + } + return defenderId; + } + public Set getPlayerDefenders(Game game) { Set playerDefenders = new HashSet(); for (CombatGroup group : groups) {