fixed 'blocked' variable of AttackingBand for propper Ninjutsu

This commit is contained in:
Maxmtg
2013-06-25 05:56:01 +00:00
parent e2ef4b497c
commit 78938459b5
3 changed files with 18 additions and 15 deletions

View File

@@ -14,7 +14,7 @@ import forge.GameEntity;
public class AttackingBand {
private List<Card> attackers = new ArrayList<Card>();
// 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<Card> 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() ? ">||" : ">>>" );
}
}

View File

@@ -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<Card> 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<String, Object> runParams = new HashMap<String, Object>();
@@ -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<Card> unblocked = new ArrayList<Card>();
for (Collection<AttackingBand> abs : attackedEntities.values())
for (AttackingBand ab : abs)
if ( ab.isBlocked() )
if ( Boolean.TRUE.equals(ab.isBlocked()) )
unblocked.addAll(ab.getAttackers());
return unblocked;

View File

@@ -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<Card> 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) {