From 78938459b5ef4ff604a9eea9bc51dea074aa3641 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Tue, 25 Jun 2013 05:56:01 +0000 Subject: [PATCH] fixed 'blocked' variable of AttackingBand for propper Ninjutsu --- .../java/forge/game/combat/AttackingBand.java | 6 +++--- src/main/java/forge/game/combat/Combat.java | 15 ++++++++------- .../java/forge/gui/match/controllers/CCombat.java | 12 +++++++----- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/forge/game/combat/AttackingBand.java b/src/main/java/forge/game/combat/AttackingBand.java index 59869bf1832..9660ec84ecc 100644 --- a/src/main/java/forge/game/combat/AttackingBand.java +++ b/src/main/java/forge/game/combat/AttackingBand.java @@ -14,7 +14,7 @@ import forge.GameEntity; public class AttackingBand { private List attackers = new ArrayList(); // private GameEntity defender = null; - private boolean blocked = false; // even if all blockers were killed before FS or CD, band remains blocked + private Boolean blocked = null; // even if all blockers were killed before FS or CD, band remains blocked public AttackingBand(List band, GameEntity def) { attackers.addAll(band); @@ -84,7 +84,7 @@ public class AttackingBand { return attackers.contains(c); } - public boolean isBlocked() { return blocked; } + public Boolean isBlocked() { return blocked; } public void setBlocked(boolean value) { blocked = value; } /** @@ -101,7 +101,7 @@ public class AttackingBand { */ @Override public String toString() { - return String.format("%s %s", attackers.toString(), blocked ? ">||" : ">>>" ); + return String.format("%s %s", attackers.toString(), blocked == null ? " ? " : blocked.booleanValue() ? ">||" : ">>>" ); } } diff --git a/src/main/java/forge/game/combat/Combat.java b/src/main/java/forge/game/combat/Combat.java index 1e35e7cd971..27e0ef56e2e 100644 --- a/src/main/java/forge/game/combat/Combat.java +++ b/src/main/java/forge/game/combat/Combat.java @@ -206,7 +206,7 @@ public class Combat { public final boolean isBlocked(final Card attacker) { AttackingBand band = getBandOfAttacker(attacker); - return band == null ? false : band.isBlocked(); + return band == null ? false : Boolean.TRUE.equals(band.isBlocked()); } @@ -403,9 +403,9 @@ public class Combat { for(AttackingBand ab : abs) { Collection blockers = blockedBands.get(ab); boolean isBlocked = blockers != null && !blockers.isEmpty(); - if (isBlocked) - ab.setBlocked(true); - else + ab.setBlocked(isBlocked); + + if (!isBlocked ) for (Card attacker : ab.getAttackers()) { // Run Unblocked Trigger final HashMap runParams = new HashMap(); @@ -473,7 +473,7 @@ public class Combat { assignedDamage = true; // If the Attacker is unblocked, or it's a trampler and has 0 blockers, deal damage to defender if (orderedBlockers == null || orderedBlockers.isEmpty()) { - if (trampler || !band.isBlocked()) { + if (trampler || !band.isBlocked()) { // this is called after declare blockers, no worries 'bout nulls in isBlocked this.addDefendingDamage(damageDealt, attacker); } // No damage happens if blocked but no blockers left } else { @@ -615,7 +615,8 @@ public class Combat { * @return a boolean. */ public final boolean isUnblocked(final Card att) { - return !isBlocked(att); + AttackingBand band = getBandOfAttacker(att); + return band == null ? false : Boolean.FALSE.equals(band.isBlocked()); } /** @@ -629,7 +630,7 @@ public class Combat { List unblocked = new ArrayList(); for (Collection abs : attackedEntities.values()) for (AttackingBand ab : abs) - if ( ab.isBlocked() ) + if ( Boolean.TRUE.equals(ab.isBlocked()) ) unblocked.addAll(ab.getAttackers()); return unblocked; diff --git a/src/main/java/forge/gui/match/controllers/CCombat.java b/src/main/java/forge/gui/match/controllers/CCombat.java index 065b69d350e..735b7df782d 100644 --- a/src/main/java/forge/gui/match/controllers/CCombat.java +++ b/src/main/java/forge/gui/match/controllers/CCombat.java @@ -88,13 +88,15 @@ public enum CCombat implements ICDoc { display.append("\n"); } + Boolean blocked = band.isBlocked(); boolean isBand = band.getAttackers().size() > 1; if (isBand) { // Only print Band data if it's actually a band display.append(" > BAND"); - if (band.isBlocked()) { - display.append(" (blocked)"); - } + + if( blocked != null ) + display.append(blocked.booleanValue() ? " (blocked)" : " >>>"); + display.append("\n"); } @@ -106,8 +108,8 @@ public enum CCombat implements ICDoc { List blockers = combat.getBlockers(band); if (!isBand && blockers.isEmpty()) { // if single creature is blocked, but no longer has blockers, tell the user! - if (band.isBlocked()) - display.append(" (blocked)\n"); + if (blocked != null) + display.append(blocked.booleanValue() ? " (blocked)\n" : " >>>\n"); } for (final Card element : blockers) {