diff --git a/Mage/src/mage/util/trace/TraceUtil.java b/Mage/src/mage/util/trace/TraceUtil.java index 351b8efba20..7fee4769623 100644 --- a/Mage/src/mage/util/trace/TraceUtil.java +++ b/Mage/src/mage/util/trace/TraceUtil.java @@ -16,6 +16,8 @@ import mage.game.permanent.Permanent; import org.apache.log4j.Logger; import java.util.UUID; +import mage.abilities.keyword.IntimidateAbility; +import mage.constants.CardType; /** * @author magenoxx_at_gmail.com @@ -31,22 +33,41 @@ public class TraceUtil { * No test managed to reproduce it, but it happens in the games time to time and was reported by different players. * * The idea: is to catch such cases manually and print out as much information from game state that may help as possible. + * @param game + * @param combat */ public static void traceCombatIfNeeded(Game game, Combat combat) { - // trace non-flying vs flying + // trace non-flying vs flying for (CombatGroup group : combat.getGroups()) { for (UUID attackerId : group.getAttackers()) { Permanent attacker = game.getPermanent(attackerId); if (attacker != null) { if (hasFlying(attacker)) { +// boolean traceDone = false; + for (UUID blockerId : group.getBlockers()) { Permanent blocker = game.getPermanent(blockerId); if (blocker != null && !hasFlying(blocker) && !hasReach(blocker)) { log.warn("Found non-flying non-reach creature blocking creature with flying"); - traceCombat(game, attacker, blocker); + traceCombat(game, attacker, blocker); +// traceDone = true; + } + } +// if (!traceDone) { +// traceCombat(game, attacker, null); +// } + } + if (hasIntimidate(attacker)) { + for (UUID blockerId : group.getBlockers()) { + Permanent blocker = game.getPermanent(blockerId); + if (blocker != null && !blocker.getCardType().contains(CardType.ARTIFACT) + && attacker.getColor().shares(blocker.getColor())) { + log.warn("Found creature with intimidate blocked by non artifact not sharing color creature"); + traceCombat(game, attacker, blocker); } } } + if (hasUnblockable(attacker)) { if (group.getBlockers().size() > 0) { Permanent blocker = game.getPermanent(group.getBlockers().get(0)); @@ -74,6 +95,15 @@ public class TraceUtil { return false; } + private static boolean hasIntimidate(Permanent permanent) { + for (Ability ability : permanent.getAbilities()) { + if (ability instanceof IntimidateAbility) { + return true; + } + } + return false; + } + private static boolean hasReach(Permanent permanent) { for (Ability ability : permanent.getAbilities()) { if (ability instanceof ReachAbility) { @@ -95,17 +125,20 @@ public class TraceUtil { private static void traceCombat(Game game, Permanent attacker, Permanent blocker) { String uuid = "[" + UUID.randomUUID() + "] "; log.error(uuid+"Tracing game state..."); - log.error(uuid+blocker.getName() + " could block " + attacker.getName()); + if (blocker != null) { + log.error(uuid+blocker.getName() + " could block " + attacker.getName()); + } log.error(uuid); log.error(uuid+"Attacker abilities: "); for (Ability ability : attacker.getAbilities()) { log.error(uuid+" " + ability.toString() + ", id=" + ability.getId()); } - - log.error(uuid+"Blocker abilities: "); - for (Ability ability : blocker.getAbilities()) { - log.error(uuid+" " + ability.toString() + ", id=" + ability.getId()); + if (blocker != null) { + log.error(uuid+"Blocker abilities: "); + for (Ability ability : blocker.getAbilities()) { + log.error(uuid+" " + ability.toString() + ", id=" + ability.getId()); + } } log.error(uuid); @@ -120,11 +153,15 @@ public class TraceUtil { log.error(uuid+" " + effect); log.error(uuid+" id=" + effect.getId()); log.error(uuid+" applies to attacker=" + effect.applies(attacker, ability, game)); - log.error(uuid+" applies to blocker=" + effect.applies(blocker, ability, game)); + if (blocker != null) { + log.error(uuid+" applies to blocker=" + effect.applies(blocker, ability, game)); + } } traceForPermanent(game, attacker, uuid, restrictionEffects); - traceForPermanent(game, blocker, uuid, restrictionEffects); + if (blocker != null) { + traceForPermanent(game, blocker, uuid, restrictionEffects); + } log.error(uuid); }