mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Merge branch 'NPE' into 'master'
Add NPE Guards when checking for adding to combat See merge request core-developers/forge!5846
This commit is contained in:
@@ -1764,7 +1764,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
@Override
|
@Override
|
||||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
||||||
// Called when attaching Aura to player or adding creature to combat
|
// Called when attaching Aura to player or adding creature to combat
|
||||||
if (params.containsKey("Attacker")) {
|
if (params != null && params.containsKey("Attacker")) {
|
||||||
return (Player) ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
return (Player) ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
||||||
}
|
}
|
||||||
return AttachAi.attachToPlayerAIPreferences(ai, sa, true, (List<Player>)options);
|
return AttachAi.attachToPlayerAIPreferences(ai, sa, true, (List<Player>)options);
|
||||||
@@ -1772,7 +1772,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GameEntity chooseSinglePlayerOrPlaneswalker(Player ai, SpellAbility sa, Iterable<GameEntity> options, Map<String, Object> params) {
|
protected GameEntity chooseSinglePlayerOrPlaneswalker(Player ai, SpellAbility sa, Iterable<GameEntity> options, Map<String, Object> params) {
|
||||||
if (params.containsKey("Attacker")) {
|
if (params != null && params.containsKey("Attacker")) {
|
||||||
return ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
return ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
||||||
}
|
}
|
||||||
// should not be reached
|
// should not be reached
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
protected Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
||||||
if (params.containsKey("Attacker")) {
|
if (params != null && params.containsKey("Attacker")) {
|
||||||
return (Player) ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
return (Player) ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
||||||
}
|
}
|
||||||
final List<Card> cards = new PlayerCollection(options).getCreaturesInPlay();
|
final List<Card> cards = new PlayerCollection(options).getCreaturesInPlay();
|
||||||
@@ -257,7 +257,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GameEntity chooseSinglePlayerOrPlaneswalker(Player ai, SpellAbility sa, Iterable<GameEntity> options, Map<String, Object> params) {
|
protected GameEntity chooseSinglePlayerOrPlaneswalker(Player ai, SpellAbility sa, Iterable<GameEntity> options, Map<String, Object> params) {
|
||||||
if (params.containsKey("Attacker")) {
|
if (params != null && params.containsKey("Attacker")) {
|
||||||
return ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
return ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
||||||
}
|
}
|
||||||
// should not be reached
|
// should not be reached
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public class DigAi extends SpellAbilityAi {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
||||||
if (params.containsKey("Attacker")) {
|
if (params != null && params.containsKey("Attacker")) {
|
||||||
return (Player) ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
return (Player) ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
||||||
}
|
}
|
||||||
// an opponent choose a card from
|
// an opponent choose a card from
|
||||||
@@ -198,7 +198,7 @@ public class DigAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GameEntity chooseSinglePlayerOrPlaneswalker(Player ai, SpellAbility sa, Iterable<GameEntity> options, Map<String, Object> params) {
|
protected GameEntity chooseSinglePlayerOrPlaneswalker(Player ai, SpellAbility sa, Iterable<GameEntity> options, Map<String, Object> params) {
|
||||||
if (params.containsKey("Attacker")) {
|
if (params != null && params.containsKey("Attacker")) {
|
||||||
return ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
return ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
||||||
}
|
}
|
||||||
// should not be reached
|
// should not be reached
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ public class TokenAi extends SpellAbilityAi {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
protected Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> options, Map<String, Object> params) {
|
||||||
if (params.containsKey("Attacker")) {
|
if (params != null && params.containsKey("Attacker")) {
|
||||||
return (Player) ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
return (Player) ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
||||||
}
|
}
|
||||||
return Iterables.getFirst(options, null);
|
return Iterables.getFirst(options, null);
|
||||||
@@ -325,7 +325,7 @@ public class TokenAi extends SpellAbilityAi {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected GameEntity chooseSinglePlayerOrPlaneswalker(Player ai, SpellAbility sa, Iterable<GameEntity> options, Map<String, Object> params) {
|
protected GameEntity chooseSinglePlayerOrPlaneswalker(Player ai, SpellAbility sa, Iterable<GameEntity> options, Map<String, Object> params) {
|
||||||
if (params.containsKey("Attacker")) {
|
if (params != null && params.containsKey("Attacker")) {
|
||||||
return ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
return ComputerUtilCombat.addAttackerToCombat(sa, (Card) params.get("Attacker"), new FCollection<GameEntity>(options));
|
||||||
}
|
}
|
||||||
// should not be reached
|
// should not be reached
|
||||||
|
|||||||
Reference in New Issue
Block a user