mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Fix NPE in tryToAutoChoose when auto-choose is set to "Most"
This commit is contained in:
parent
a94c837ad0
commit
7ca7e10d80
1 changed files with 7 additions and 1 deletions
|
@ -612,6 +612,10 @@ public abstract class TargetImpl implements Target {
|
|||
|
||||
@Override
|
||||
public UUID tryToAutoChoose(UUID abilityControllerId, Ability source, Game game, Collection<UUID> possibleTargets) {
|
||||
if (possibleTargets == null || game == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Player player = game.getPlayer(abilityControllerId);
|
||||
if (player == null) {
|
||||
return null;
|
||||
|
@ -626,7 +630,8 @@ public abstract class TargetImpl implements Target {
|
|||
boolean canAutoChoose = this.getMinNumberOfTargets() == this.getMaxNumberOfTargets() && // Targets must be picked
|
||||
possibleTargets.size() == this.getNumberOfTargets() - this.getSize() && // Available targets are equal to the number that must be picked
|
||||
!strictModeEnabled && // Test AI is not set to strictChooseMode(true)
|
||||
playerAutoTargetLevel > 0; // Human player has enabled auto-choose in settings
|
||||
playerAutoTargetLevel > 0 && // Human player has enabled auto-choose in settings
|
||||
!(playerAutoTargetLevel == 1 && source == null); // Is source is null, then the
|
||||
|
||||
if (canAutoChoose) {
|
||||
boolean autoTargetAll = playerAutoTargetLevel == 2;
|
||||
|
@ -664,6 +669,7 @@ public abstract class TargetImpl implements Target {
|
|||
if (targetingOwnThing) {
|
||||
String abilityText = source.getRule(true).toLowerCase();
|
||||
|
||||
|
||||
if (abilityText.contains("discard")
|
||||
|| abilityText.contains("sacrifice")
|
||||
|| abilityText.contains("destroy")
|
||||
|
|
Loading…
Reference in a new issue