mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
fixed 'blocked' variable of AttackingBand for propper Ninjutsu
This commit is contained in:
@@ -14,7 +14,7 @@ import forge.GameEntity;
|
|||||||
public class AttackingBand {
|
public class AttackingBand {
|
||||||
private List<Card> attackers = new ArrayList<Card>();
|
private List<Card> attackers = new ArrayList<Card>();
|
||||||
// private GameEntity defender = null;
|
// 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) {
|
public AttackingBand(List<Card> band, GameEntity def) {
|
||||||
attackers.addAll(band);
|
attackers.addAll(band);
|
||||||
@@ -84,7 +84,7 @@ public class AttackingBand {
|
|||||||
return attackers.contains(c);
|
return attackers.contains(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlocked() { return blocked; }
|
public Boolean isBlocked() { return blocked; }
|
||||||
public void setBlocked(boolean value) { blocked = value; }
|
public void setBlocked(boolean value) { blocked = value; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,7 +101,7 @@ public class AttackingBand {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s %s", attackers.toString(), blocked ? ">||" : ">>>" );
|
return String.format("%s %s", attackers.toString(), blocked == null ? " ? " : blocked.booleanValue() ? ">||" : ">>>" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ public class Combat {
|
|||||||
|
|
||||||
public final boolean isBlocked(final Card attacker) {
|
public final boolean isBlocked(final Card attacker) {
|
||||||
AttackingBand band = getBandOfAttacker(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) {
|
for(AttackingBand ab : abs) {
|
||||||
Collection<Card> blockers = blockedBands.get(ab);
|
Collection<Card> blockers = blockedBands.get(ab);
|
||||||
boolean isBlocked = blockers != null && !blockers.isEmpty();
|
boolean isBlocked = blockers != null && !blockers.isEmpty();
|
||||||
if (isBlocked)
|
ab.setBlocked(isBlocked);
|
||||||
ab.setBlocked(true);
|
|
||||||
else
|
if (!isBlocked )
|
||||||
for (Card attacker : ab.getAttackers()) {
|
for (Card attacker : ab.getAttackers()) {
|
||||||
// Run Unblocked Trigger
|
// Run Unblocked Trigger
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
@@ -473,7 +473,7 @@ public class Combat {
|
|||||||
assignedDamage = true;
|
assignedDamage = true;
|
||||||
// If the Attacker is unblocked, or it's a trampler and has 0 blockers, deal damage to defender
|
// If the Attacker is unblocked, or it's a trampler and has 0 blockers, deal damage to defender
|
||||||
if (orderedBlockers == null || orderedBlockers.isEmpty()) {
|
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);
|
this.addDefendingDamage(damageDealt, attacker);
|
||||||
} // No damage happens if blocked but no blockers left
|
} // No damage happens if blocked but no blockers left
|
||||||
} else {
|
} else {
|
||||||
@@ -615,7 +615,8 @@ public class Combat {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean isUnblocked(final Card att) {
|
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>();
|
List<Card> unblocked = new ArrayList<Card>();
|
||||||
for (Collection<AttackingBand> abs : attackedEntities.values())
|
for (Collection<AttackingBand> abs : attackedEntities.values())
|
||||||
for (AttackingBand ab : abs)
|
for (AttackingBand ab : abs)
|
||||||
if ( ab.isBlocked() )
|
if ( Boolean.TRUE.equals(ab.isBlocked()) )
|
||||||
unblocked.addAll(ab.getAttackers());
|
unblocked.addAll(ab.getAttackers());
|
||||||
|
|
||||||
return unblocked;
|
return unblocked;
|
||||||
|
|||||||
@@ -88,13 +88,15 @@ public enum CCombat implements ICDoc {
|
|||||||
display.append("\n");
|
display.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Boolean blocked = band.isBlocked();
|
||||||
boolean isBand = band.getAttackers().size() > 1;
|
boolean isBand = band.getAttackers().size() > 1;
|
||||||
if (isBand) {
|
if (isBand) {
|
||||||
// Only print Band data if it's actually a band
|
// Only print Band data if it's actually a band
|
||||||
display.append(" > BAND");
|
display.append(" > BAND");
|
||||||
if (band.isBlocked()) {
|
|
||||||
display.append(" (blocked)");
|
if( blocked != null )
|
||||||
}
|
display.append(blocked.booleanValue() ? " (blocked)" : " >>>");
|
||||||
|
|
||||||
display.append("\n");
|
display.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +108,8 @@ public enum CCombat implements ICDoc {
|
|||||||
List<Card> blockers = combat.getBlockers(band);
|
List<Card> blockers = combat.getBlockers(band);
|
||||||
if (!isBand && blockers.isEmpty()) {
|
if (!isBand && blockers.isEmpty()) {
|
||||||
// if single creature is blocked, but no longer has blockers, tell the user!
|
// if single creature is blocked, but no longer has blockers, tell the user!
|
||||||
if (band.isBlocked())
|
if (blocked != null)
|
||||||
display.append(" (blocked)\n");
|
display.append(blocked.booleanValue() ? " (blocked)\n" : " >>>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Card element : blockers) {
|
for (final Card element : blockers) {
|
||||||
|
|||||||
Reference in New Issue
Block a user