mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Prevent NPE in getDefenderByAttacker.
This commit is contained in:
@@ -6654,10 +6654,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*/
|
*/
|
||||||
public final boolean isAttacking(GameEntity ge) {
|
public final boolean isAttacking(GameEntity ge) {
|
||||||
Combat combat = getGame().getCombat();
|
Combat combat = getGame().getCombat();
|
||||||
if (!combat.isAttacking(this)) {
|
GameEntity defender = combat.getDefenderByAttacker(this);
|
||||||
|
if (!combat.isAttacking(this) || defender == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return combat.getDefenderByAttacker(this).equals(ge);
|
return defender.equals(ge);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -272,6 +272,9 @@ public class Combat {
|
|||||||
* @return a {@link java.lang.Object} object.
|
* @return a {@link java.lang.Object} object.
|
||||||
*/
|
*/
|
||||||
public final GameEntity getDefenderByAttacker(final Card c) {
|
public final GameEntity getDefenderByAttacker(final Card c) {
|
||||||
|
if (!this.attackerToBandMap.containsKey(c)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return this.attackerToBandMap.get(c).getDefender();
|
return this.attackerToBandMap.get(c).getDefender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user