mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
one less call to isHuman
This commit is contained in:
@@ -148,19 +148,15 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
tgtCards = CardLists.filter(tgtCards, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
List<SpellAbility> sas = new ArrayList<SpellAbility>();
|
||||
for (SpellAbility s : c.getBasicSpells()) {
|
||||
Spell spell = (Spell) s;
|
||||
s.setActivatingPlayer(controller);
|
||||
// timing restrictions still apply
|
||||
if (s.getRestrictions().checkTimingRestrictions(c, s) && spell.canPlayFromEffectAI(false, true)) {
|
||||
sas.add(s);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (sas.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
tgtCard = ComputerUtilCard.getBestAI(tgtCards);
|
||||
@@ -175,8 +171,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
}
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Do you want to play " + tgtCard + "?");
|
||||
if (controller.isHuman() && optional
|
||||
&& !GuiDialog.confirm(source, sb.toString())) {
|
||||
if (controller.isHuman() && optional && !GuiDialog.confirm(source, sb.toString())) {
|
||||
// i--; // This causes an infinite loop (ArsenalNut)
|
||||
if (wasFaceDown) {
|
||||
tgtCard.setState(CardCharacteristicName.FaceDown);
|
||||
@@ -229,13 +224,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
tgtCards.remove(tgtCard);
|
||||
SpellAbility tgtSA = null;
|
||||
// only one mode can be used
|
||||
if (sas.size() == 1) {
|
||||
tgtSA = sas.get(0);
|
||||
} else if (sa.getActivatingPlayer().isHuman()) {
|
||||
tgtSA = GuiChoose.one("Select a spell to cast", sas);
|
||||
} else {
|
||||
tgtSA = sas.get(0);
|
||||
}
|
||||
tgtSA = sa.getActivatingPlayer().getController().getAbilityToPlay(sas);
|
||||
|
||||
if (tgtSA.getTarget() != null && !optional) {
|
||||
tgtSA.getTarget().setMandatory(true);
|
||||
|
||||
@@ -373,6 +373,7 @@ public class MatchController {
|
||||
* @return
|
||||
*/
|
||||
private Player seeWhoPlaysFirstDice(final GameState game) {
|
||||
|
||||
// Play the Flip Coin sound
|
||||
game.getEvents().post(new FlipCoinEvent());
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import forge.game.ai.ComputerUtil;
|
||||
import forge.game.ai.ComputerUtilBlock;
|
||||
import forge.game.ai.ComputerUtilCombat;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
|
||||
@@ -78,11 +77,11 @@ public class PlayerControllerAi extends PlayerController {
|
||||
public SpellAbility getAbilityToPlay(List<SpellAbility> abilities) {
|
||||
if (abilities.size() == 0) {
|
||||
return null;
|
||||
} else if (abilities.size() == 1) {
|
||||
} else
|
||||
return abilities.get(0);
|
||||
} else {
|
||||
return GuiChoose.oneOrNone("Choose ability for AI to play", abilities); // some day network interaction will be here
|
||||
}
|
||||
// } else {
|
||||
// return GuiChoose.oneOrNone("Choose ability for AI to play", abilities); // some day network interaction will be here
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
} else if (abilities.size() == 1) {
|
||||
return abilities.get(0);
|
||||
} else {
|
||||
return GuiChoose.oneOrNone("Choose", abilities); // some day network interaction will be here
|
||||
return GuiChoose.oneOrNone("Choose ability to play", abilities);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user