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