mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- CheckStyle.
This commit is contained in:
@@ -82,9 +82,8 @@ public class BoosterDraftAI {
|
||||
CardPrinted pickedCard = null;
|
||||
|
||||
Predicate<CardPrinted> pred = Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, CardPrinted.FN_GET_RULES);
|
||||
Iterable<CardPrinted> aiPlayablesView = Iterables.filter(chooseFrom, pred );
|
||||
List<CardPrinted> aiPlayables = Lists.newArrayList(aiPlayablesView);
|
||||
|
||||
Iterable<CardPrinted> aiPlayablesView = Iterables.filter(chooseFrom, pred);
|
||||
List<CardPrinted> aiPlayables = Lists.newArrayList(aiPlayablesView);
|
||||
|
||||
TreeMap<Double, CardPrinted> rankedCards = rankCards(chooseFrom);
|
||||
|
||||
@@ -195,7 +194,7 @@ public class BoosterDraftAI {
|
||||
CardColor colors = CardColor.fromNames(dckColors.getColor1(), dckColors.getColor2());
|
||||
Predicate<CardRules> hasColor = Predicates.or(new GenerateDeckUtil.ContainsAllColorsFrom(colors),
|
||||
GenerateDeckUtil.COLORLESS_CARDS);
|
||||
|
||||
|
||||
Iterable<CardPrinted> colorList = Iterables.filter(aiPlayables, Predicates.compose(hasColor, CardPrinted.FN_GET_RULES));
|
||||
|
||||
// Sort playable, on-color cards by rank
|
||||
|
||||
@@ -101,8 +101,8 @@ class CCnt implements Comparable<CCnt> {
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(CCnt o) {
|
||||
int compareCount = o.getCount();
|
||||
int compareCount = o.getCount();
|
||||
return this.count - compareCount;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class GauntletMini {
|
||||
|
||||
// System.out.println("Moving from round " + currentRound + " to round " + currentRound + 1 + " of " + rounds);
|
||||
if (currentRound >= rounds) {
|
||||
currentRound = rounds-1;
|
||||
currentRound = rounds - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -142,11 +142,11 @@ public class GauntletMini {
|
||||
throw new IllegalStateException("Cannot launch Gauntlet, game mode not implemented.");
|
||||
}
|
||||
aiOpponents.clear();
|
||||
for(int i = 0; i < Math.min(gameRounds, aiDecks.size()); i++ )
|
||||
{
|
||||
for (int i = 0; i < Math.min(gameRounds, aiDecks.size()); i++) {
|
||||
|
||||
aiOpponents.add(new PlayerStartConditions(aiDecks.get(i)));
|
||||
}
|
||||
|
||||
|
||||
resetCurrentRound();
|
||||
startRound();
|
||||
}
|
||||
@@ -167,15 +167,15 @@ public class GauntletMini {
|
||||
@Override
|
||||
|
||||
public Object doInBackground() {
|
||||
|
||||
|
||||
MatchStartHelper starter = new MatchStartHelper();
|
||||
Lobby lobby = Singletons.getControl().getLobby();
|
||||
starter.addPlayer(lobby.findLocalPlayer(PlayerType.HUMAN), humanDeck);
|
||||
starter.addPlayer(lobby.findLocalPlayer(PlayerType.COMPUTER), aiOpponents.get(currentRound-1));
|
||||
|
||||
MatchController mc = Singletons.getModel().getMatch();
|
||||
starter.addPlayer(lobby.findLocalPlayer(PlayerType.COMPUTER), aiOpponents.get(currentRound - 1));
|
||||
|
||||
MatchController mc = Singletons.getModel().getMatch();
|
||||
mc.initMatch(gauntletType, starter.getPlayerMap());
|
||||
mc.startRound();
|
||||
mc.startRound();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ public class ReadDraftRankings {
|
||||
private Map<String, Map<String, Integer>> readFile(final File file) {
|
||||
|
||||
final Map<String, Map<String, Integer>> map = new HashMap<String, Map<String, Integer>>();
|
||||
for( String line : FileUtil.readFile(file)) {
|
||||
for (String line : FileUtil.readFile(file)) {
|
||||
// stop reading if end of file or blank line is read
|
||||
if(line == null || line.length() == 0) {
|
||||
if (line == null || line.length() == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ReadDraftRankings {
|
||||
final String name = s[1].trim().replaceAll("-", " ").replaceAll("[^A-Za-z ]", "");
|
||||
// final String rarity = s[2].trim();
|
||||
final String edition = s[3].trim();
|
||||
|
||||
|
||||
try {
|
||||
final int rank = Integer.parseInt(rankStr);
|
||||
if (!map.containsKey(edition)) {
|
||||
@@ -73,8 +73,8 @@ public class ReadDraftRankings {
|
||||
} catch (NumberFormatException nfe) {
|
||||
Log.warn("NumberFormatException: " + nfe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return map;
|
||||
} // readFile()
|
||||
|
||||
|
||||
@@ -29,4 +29,4 @@ public class Cleanup extends Phase {
|
||||
/** Constant <code>serialVersionUID=-6993476643509826990L</code>. */
|
||||
private static final long serialVersionUID = -6993476643509826990L;
|
||||
|
||||
} // end class Cleanup
|
||||
} // end class Cleanup
|
||||
|
||||
@@ -107,7 +107,7 @@ public class Combat {
|
||||
public final void initiatePossibleDefenders(final Iterable<Player> defenders) {
|
||||
this.defenders.clear();
|
||||
this.defenderMap.clear();
|
||||
for(Player defender : defenders) {
|
||||
for (Player defender : defenders) {
|
||||
fillDefenderMaps(defender);
|
||||
}
|
||||
}
|
||||
@@ -116,19 +116,19 @@ public class Combat {
|
||||
this.defenders.clear();
|
||||
this.defenderMap.clear();
|
||||
fillDefenderMaps(defender);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void fillDefenderMaps(final Player defender) {
|
||||
this.defenders.add(defender);
|
||||
this.defenderMap.put(defender, new ArrayList<Card>());
|
||||
List<Card> planeswalkers =
|
||||
List<Card> planeswalkers =
|
||||
CardLists.filter(defender.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS);
|
||||
for (final Card pw : planeswalkers) {
|
||||
this.defenders.add(pw);
|
||||
this.defenderMap.put(pw, new ArrayList<Card>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* nextDefender.
|
||||
@@ -387,15 +387,17 @@ public class Combat {
|
||||
GameEntity defender = getDefenderByAttacker(c);
|
||||
|
||||
// System.out.println(c.toString() + " attacks " + defender.toString());
|
||||
if ( defender instanceof Player)
|
||||
if (defender instanceof Player) {
|
||||
return (Player) defender;
|
||||
}
|
||||
|
||||
// maybe attack on a controlled planeswalker?
|
||||
if ( defender instanceof Card )
|
||||
return ((Card)defender).getController();
|
||||
// maybe attack on a controlled planeswalker?
|
||||
if (defender instanceof Card) {
|
||||
return ((Card) defender).getController();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final GameEntity getDefendingEntity(final Card c) {
|
||||
GameEntity defender = this.attackerToDefender.get(c);
|
||||
|
||||
@@ -535,7 +537,7 @@ public class Combat {
|
||||
private List<Card> getBlockingAttackerList(final Card attacker) {
|
||||
return this.attackerMap.get(attacker);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -553,9 +555,9 @@ public class Combat {
|
||||
} else if (source.isEquipment()) {
|
||||
attacker = source.getEquippingCard();
|
||||
}
|
||||
|
||||
|
||||
Player defender = getDefenderPlayerByAttacker(attacker);
|
||||
if ( null == defender ) { // too bad, have to choose now
|
||||
if (null == defender) { // too bad, have to choose now
|
||||
// don't have ui, cannot choose - have to getOpponent
|
||||
// that's inaccurate. That opponent may be not even a defender
|
||||
defender = source.getController().getOpponent();
|
||||
@@ -980,12 +982,12 @@ public class Combat {
|
||||
this.unblockedMap.put(c, new ArrayList<Card>());
|
||||
}
|
||||
|
||||
public boolean isPlayerAttacked(Player priority)
|
||||
{
|
||||
public boolean isPlayerAttacked(Player priority) {
|
||||
|
||||
// System.out.println("\nWho attacks attacks " + priority.toString() + "?");
|
||||
for(Card c : getAttackers())
|
||||
{
|
||||
if ( priority.equals(getDefenderPlayerByAttacker(c)) ) {
|
||||
for (Card c : getAttackers()) {
|
||||
|
||||
if (priority.equals(getDefenderPlayerByAttacker(c))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CombatUtil {
|
||||
if (combat == null) {
|
||||
return CombatUtil.canBlock(blocker);
|
||||
}
|
||||
|
||||
|
||||
if (!CombatUtil.canBlockMoreCreatures(blocker, combat.getAttackersBlockedBy(blocker))) {
|
||||
return false;
|
||||
}
|
||||
@@ -164,13 +164,13 @@ public class CombatUtil {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean canBlockMoreCreatures(final Card blocker, final List<Card> blockedBy) {
|
||||
// TODO(sol) expand this for the additional blocking keyword
|
||||
if (blockedBy.isEmpty() || blocker.hasKeyword("CARDNAME can block any number of creatures.")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return blocker.getKeywordAmount("CARDNAME can block an additional creature.") >= blockedBy.size();
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public class CombatUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can be blocked.
|
||||
*
|
||||
@@ -419,12 +419,12 @@ public class CombatUtil {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void orderMultipleCombatants(final Combat combat) {
|
||||
CombatUtil.orderMultipleBlockers(combat);
|
||||
CombatUtil.orderBlockingMultipleAttackers(combat);
|
||||
}
|
||||
|
||||
|
||||
private static void orderMultipleBlockers(final Combat combat) {
|
||||
// If there are multiple blockers, the Attacker declares the Assignment Order
|
||||
final Player player = combat.getAttackingPlayer();
|
||||
@@ -434,14 +434,14 @@ public class CombatUtil {
|
||||
if (blockers.size() <= 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
List<Card> orderedBlockers = null;
|
||||
if (player.isHuman()) {
|
||||
List<Card> ordered = GuiChoose.getOrderChoices("Choose Blocking Order", "Damaged First", 0, blockers, null, attacker);
|
||||
|
||||
|
||||
orderedBlockers = new ArrayList<Card>();
|
||||
for(Object o : ordered) {
|
||||
orderedBlockers.add((Card)o);
|
||||
for (Object o : ordered) {
|
||||
orderedBlockers.add((Card) o);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -452,7 +452,7 @@ public class CombatUtil {
|
||||
CombatUtil.showCombat();
|
||||
// Refresh Combat Panel
|
||||
}
|
||||
|
||||
|
||||
private static void orderBlockingMultipleAttackers(final Combat combat) {
|
||||
// If there are multiple blockers, the Attacker declares the Assignment Order
|
||||
for (final Card blocker : combat.getAllBlockers()) {
|
||||
@@ -460,14 +460,14 @@ public class CombatUtil {
|
||||
if (attackers.size() <= 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
List<Card> orderedAttacker = null;
|
||||
if (blocker.getController().isHuman()) {
|
||||
List<Card> ordered = GuiChoose.getOrderChoices("Choose Blocking Order", "Damaged First", 0, attackers, null, blocker);
|
||||
|
||||
|
||||
orderedAttacker = new ArrayList<Card>();
|
||||
for(Object o : ordered) {
|
||||
orderedAttacker.add((Card)o);
|
||||
for (Object o : ordered) {
|
||||
orderedAttacker.add((Card) o);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -478,7 +478,7 @@ public class CombatUtil {
|
||||
CombatUtil.showCombat();
|
||||
// Refresh Combat Panel
|
||||
}
|
||||
|
||||
|
||||
|
||||
// can the blocker block an attacker with a lure effect?
|
||||
/**
|
||||
@@ -530,7 +530,7 @@ public class CombatUtil {
|
||||
|
||||
if (blocker.getMustBlockCards() != null) {
|
||||
for (final Card attacker : blocker.getMustBlockCards()) {
|
||||
if (CombatUtil.canBeBlocked(attacker, combat) && CombatUtil.canBlock(attacker, blocker)
|
||||
if (CombatUtil.canBeBlocked(attacker, combat) && CombatUtil.canBlock(attacker, blocker)
|
||||
&& combat.isAttacking(attacker)) {
|
||||
boolean canBe = true;
|
||||
if (attacker.hasKeyword("CARDNAME can't be blocked except by two or more creatures.")) {
|
||||
@@ -588,7 +588,7 @@ public class CombatUtil {
|
||||
|
||||
return CombatUtil.canBlock(attacker, blocker);
|
||||
}
|
||||
|
||||
|
||||
// can the blocker block the attacker?
|
||||
/**
|
||||
* <p>
|
||||
@@ -799,8 +799,8 @@ public class CombatUtil {
|
||||
if (cntAttackers > 0 && c.hasKeyword("CARDNAME can only attack alone.")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cntAttackers > 0
|
||||
|
||||
if (cntAttackers > 0
|
||||
&& Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.onlyOneAttackerACombat)) {
|
||||
return false;
|
||||
}
|
||||
@@ -832,7 +832,7 @@ public class CombatUtil {
|
||||
}
|
||||
return CombatUtil.canAttackNextTurn(c, defender);
|
||||
}
|
||||
|
||||
|
||||
// can a creature attack if untapped and without summoning sickness?
|
||||
/**
|
||||
* <p>
|
||||
@@ -2351,7 +2351,7 @@ public class CombatUtil {
|
||||
// This needs to expand to tally up damage
|
||||
final List<Card> attackers = Singletons.getModel().getGame().getCombat().getAttackersBlockedBy(blocker);
|
||||
|
||||
for(Card attacker : attackers) {
|
||||
for (Card attacker : attackers) {
|
||||
if (CombatUtil.canDestroyBlocker(blocker, attacker, Singletons.getModel().getGame().getCombat(), true)
|
||||
&& !(attacker.hasKeyword("Wither") || attacker.hasKeyword("Infect"))) {
|
||||
return true;
|
||||
@@ -2441,7 +2441,7 @@ public class CombatUtil {
|
||||
+ CombatUtil.predictToughnessBonusOfAttacker(attacker, defender, combat);
|
||||
|
||||
if (attacker.hasKeyword("Double Strike")) {
|
||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
||||
|| defender.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
return true;
|
||||
}
|
||||
@@ -2456,7 +2456,7 @@ public class CombatUtil {
|
||||
if (defenderDamage >= attackerLife) {
|
||||
return false;
|
||||
}
|
||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
||||
|| attacker.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
return false;
|
||||
}
|
||||
@@ -2475,13 +2475,13 @@ public class CombatUtil {
|
||||
if (defenderDamage >= attackerLife) {
|
||||
return false;
|
||||
}
|
||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
||||
|| attacker.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
||||
|| defender.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it."))) {
|
||||
return true;
|
||||
}
|
||||
@@ -2545,11 +2545,11 @@ public class CombatUtil {
|
||||
final List<Card> list = attackers.get(def);
|
||||
|
||||
for (final Card attacker : list) {
|
||||
|
||||
|
||||
|
||||
defend = Singletons.getModel().getGame().getCombat().getBlockers(attacker);
|
||||
sb.append(combat.getDefenderByAttacker(attacker)).append(" assigned ");
|
||||
|
||||
|
||||
if (!defend.isEmpty()) {
|
||||
// loop through blockers
|
||||
for (final Card blocker : defend) {
|
||||
@@ -2568,7 +2568,7 @@ public class CombatUtil {
|
||||
|
||||
private static String getCombatDescription(Combat combat) {
|
||||
final StringBuilder display = new StringBuilder();
|
||||
|
||||
|
||||
// Loop through Defenders
|
||||
// Append Defending Player/Planeswalker
|
||||
final List<GameEntity> defenders = combat.getDefenders();
|
||||
@@ -2605,8 +2605,8 @@ public class CombatUtil {
|
||||
}
|
||||
return display.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* showCombat.
|
||||
@@ -2770,7 +2770,7 @@ public class CombatUtil {
|
||||
final Ability ability = new Ability(c, "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
final Player cp = crd.getController();
|
||||
final Player cp = crd.getController();
|
||||
if (cp.isHuman()) {
|
||||
final List<Card> list = cp.getOpponent().getCardsIn(ZoneType.Battlefield);
|
||||
ComputerUtil.sacrificePermanents(cp.getOpponent(), a, list, false, this);
|
||||
@@ -3088,7 +3088,7 @@ public class CombatUtil {
|
||||
final Ability ability4 = new Ability(c, "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
List<Card> enchantments =
|
||||
List<Card> enchantments =
|
||||
CardLists.filter(attacker.getController().getCardsIn(ZoneType.Library), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
private int turn = 0;
|
||||
// Start turn at 0, so first untap step will turn it to 1
|
||||
|
||||
transient private final Stack<ExtraTurn> extraTurns = new Stack<ExtraTurn>();
|
||||
private final transient Stack<ExtraTurn> extraTurns = new Stack<ExtraTurn>();
|
||||
|
||||
private int extraCombats = 0;
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
private Player playerTurn = null;
|
||||
|
||||
// priority player
|
||||
|
||||
|
||||
private Player pPlayerPriority = null;
|
||||
private Player pFirstPriority = null;
|
||||
private boolean bPhaseEffects = true;
|
||||
@@ -74,13 +74,13 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
/** The need to next phase. */
|
||||
private boolean isPlayerPriorityAllowed = false;
|
||||
|
||||
transient private final GameState game;
|
||||
|
||||
public PhaseHandler(final GameState game0)
|
||||
{
|
||||
private final transient GameState game;
|
||||
|
||||
public PhaseHandler(final GameState game0) {
|
||||
|
||||
game = game0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isPlayerTurn.
|
||||
@@ -230,8 +230,10 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
* </p>
|
||||
*/
|
||||
public final void handleBeginPhase() {
|
||||
if ( null == playerTurn ) return;
|
||||
|
||||
if (null == playerTurn) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setPhaseEffects(false);
|
||||
// Handle effects that happen at the beginning of phases
|
||||
game.getAction().checkStateEffects();
|
||||
@@ -247,7 +249,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
if (this.getPlayerTurn().hasKeyword("Skip your upkeep step.")) {
|
||||
// Slowtrips all say "on the next turn's upkeep" if there is no
|
||||
// upkeep next turn, the trigger will never occur.
|
||||
for( Player p : game.getPlayers() ) {
|
||||
for (Player p : game.getPlayers()) {
|
||||
p.clearSlowtripList();
|
||||
}
|
||||
this.setPlayerMayHavePriority(false);
|
||||
@@ -258,10 +260,11 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
break;
|
||||
|
||||
case DRAW:
|
||||
if (getTurn() == 1 || PhaseUtil.skipDraw(this.getPlayerTurn()))
|
||||
if (getTurn() == 1 || PhaseUtil.skipDraw(this.getPlayerTurn())) {
|
||||
this.setPlayerMayHavePriority(false);
|
||||
else
|
||||
} else {
|
||||
this.getPlayerTurn().drawCards(1, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case COMBAT_BEGIN:
|
||||
@@ -411,8 +414,8 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
* </p>
|
||||
*/
|
||||
public final void nextPhase() {
|
||||
|
||||
this.setPlayerMayHavePriority(true);// PlayerPriorityAllowed = false;
|
||||
|
||||
this.setPlayerMayHavePriority(true); // PlayerPriorityAllowed = false;
|
||||
|
||||
// If the Stack isn't empty why is nextPhase being called?
|
||||
if (game.getStack().size() != 0) {
|
||||
@@ -445,13 +448,13 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
case COMBAT_DECLARE_BLOCKERS:
|
||||
game.getStack().unfreezeStack();
|
||||
break;
|
||||
|
||||
|
||||
case COMBAT_END:
|
||||
//SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
||||
game.getCombat().reset();
|
||||
this.resetAttackedThisCombat(this.getPlayerTurn());
|
||||
this.bCombat = false;
|
||||
|
||||
|
||||
// TODO: ExtraCombat needs to be changed for other spell/abilities
|
||||
// that give extra combat can do it like ExtraTurn stack ExtraPhases
|
||||
if (this.extraCombats > 0) {
|
||||
@@ -464,7 +467,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
this.phase = PhaseType.COMBAT_BEGIN;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CLEANUP:
|
||||
this.bPreventCombatDamageThisTurn = false;
|
||||
if (!this.bRepeat) {
|
||||
@@ -510,14 +513,14 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
|
||||
game.getStack().setCardsCastLastTurn();
|
||||
game.getStack().clearCardsCastThisTurn();
|
||||
|
||||
|
||||
for (final Player p1 : game.getPlayers()) {
|
||||
for (final ZoneType z : Player.ALL_ZONES) {
|
||||
p1.getZone(z).resetCardsAddedThisTurn();
|
||||
}
|
||||
}
|
||||
for( Player p : game.getPlayers() )
|
||||
{
|
||||
for (Player p : game.getPlayers()) {
|
||||
|
||||
p.resetProwl();
|
||||
p.setLifeLostThisTurn(0);
|
||||
|
||||
@@ -698,11 +701,13 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
*/
|
||||
public final void passPriority() {
|
||||
// stop game if it's outcome is clear
|
||||
if ( game.isGameOver() ) return;
|
||||
|
||||
if (game.isGameOver()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player actingPlayer = this.getPriorityPlayer();
|
||||
final Player firstAction = this.getFirstPriority();
|
||||
|
||||
|
||||
// actingPlayer is the player who may act
|
||||
// the firstAction is the player who gained Priority First in this segment
|
||||
// of Priority
|
||||
@@ -711,7 +716,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
if (firstAction.equals(nextPlayer)) {
|
||||
if (game.getStack().isEmpty()) {
|
||||
this.setPriority(this.getPlayerTurn()); // this needs to be set early as we exit the phase
|
||||
// end phase
|
||||
// end phase
|
||||
setPlayerMayHavePriority(true);
|
||||
nextPhase();
|
||||
return;
|
||||
@@ -724,7 +729,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
Singletons.getModel().getMatch().getInput().resetInput();
|
||||
|
||||
}
|
||||
game.getStack().chooseOrderOfSimultaneousStackEntryAll();
|
||||
game.getStack().chooseOrderOfSimultaneousStackEntryAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -738,7 +743,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
public final void setPlayerMayHavePriority(final boolean mayHavePriority) {
|
||||
this.isPlayerPriorityAllowed = mayHavePriority;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isNeedToNextPhase.
|
||||
|
||||
@@ -29,9 +29,9 @@ public enum PhaseType {
|
||||
|
||||
public static final List<PhaseType> ALL_PHASES = Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
UNTAP, UPKEEP, DRAW, MAIN1,
|
||||
COMBAT_BEGIN, COMBAT_DECLARE_ATTACKERS, COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY,
|
||||
COMBAT_DECLARE_BLOCKERS, COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY,
|
||||
UNTAP, UPKEEP, DRAW, MAIN1,
|
||||
COMBAT_BEGIN, COMBAT_DECLARE_ATTACKERS, COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY,
|
||||
COMBAT_DECLARE_BLOCKERS, COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY,
|
||||
COMBAT_FIRST_STRIKE_DAMAGE, COMBAT_DAMAGE, COMBAT_END,
|
||||
MAIN2, END_OF_TURN, CLEANUP
|
||||
)
|
||||
@@ -110,8 +110,9 @@ public enum PhaseType {
|
||||
*/
|
||||
public PhaseType getNextPhase() {
|
||||
int iNext = ALL_PHASES.indexOf(this) + 1;
|
||||
while ( iNext >= ALL_PHASES.size() )
|
||||
while (iNext >= ALL_PHASES.size()) {
|
||||
iNext = 0;
|
||||
}
|
||||
return ALL_PHASES.get(iNext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ public class PhaseUtil {
|
||||
p.removeKeyword("Skip your next untap step.");
|
||||
return true;
|
||||
}
|
||||
if (p.hasKeyword("Skip the untap step of this turn.") ||
|
||||
p.hasKeyword("Skip your untap step.")) {
|
||||
if (p.hasKeyword("Skip the untap step of this turn.")
|
||||
|| p.hasKeyword("Skip your untap step.")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,8 @@ public class PhaseUtil {
|
||||
PhaseLabel lbl = matchUi.getFieldViewFor(player).getLabelFor(phase);
|
||||
|
||||
matchUi.resetAllPhaseButtons();
|
||||
if (lbl != null)
|
||||
if (lbl != null) {
|
||||
lbl.setActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class Untap extends Phase {
|
||||
private static void doUntap() {
|
||||
final Player player = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn();
|
||||
final Predicate<Card> tappedCanUntap = Predicates.and(Presets.TAPPED, Presets.CANUNTAP);
|
||||
|
||||
|
||||
List<Card> list = new ArrayList<Card>(player.getCardsIn(ZoneType.Battlefield));
|
||||
|
||||
for (final Card c : list) {
|
||||
@@ -192,12 +192,12 @@ public class Untap extends Phase {
|
||||
// end opponent untapping during your untap phase
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Untap.canOnlyUntapOneLand()) {
|
||||
if (player.isComputer()) {
|
||||
// search for lands the computer has and only untap 1
|
||||
List<Card> landList = player.getLandsInPlay();
|
||||
|
||||
|
||||
landList = CardLists.filter(landList, tappedCanUntap);
|
||||
if (landList.size() > 0) {
|
||||
landList.get(0).untap();
|
||||
@@ -234,7 +234,7 @@ public class Untap extends Phase {
|
||||
}
|
||||
}
|
||||
if (Singletons.getModel().getGame().isCardInPlay("Damping Field") || Singletons.getModel().getGame().isCardInPlay("Imi Statue")) {
|
||||
final Player turnOwner = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn();
|
||||
final Player turnOwner = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn();
|
||||
if (turnOwner.isComputer()) {
|
||||
List<Card> artList = new ArrayList<Card>(turnOwner.getCardsIn(ZoneType.Battlefield));
|
||||
artList = CardLists.filter(artList, Presets.ARTIFACTS);
|
||||
|
||||
@@ -141,8 +141,9 @@ public class Upkeep extends Phase {
|
||||
public void resolve() {
|
||||
c.addCounter(CounterType.AGE, 1, true);
|
||||
StringBuilder rs = new StringBuilder("R");
|
||||
for(int ageCounters = c.getCounters(CounterType.AGE); ageCounters > 1; ageCounters-- )
|
||||
for (int ageCounters = c.getCounters(CounterType.AGE); ageCounters > 1; ageCounters--) {
|
||||
rs.append(" R");
|
||||
}
|
||||
Map<String, String> produced = new HashMap<String, String>();
|
||||
produced.put("Produced", rs.toString());
|
||||
final AbilityManaPart abMana = new AbilityManaPart(c, produced);
|
||||
@@ -230,11 +231,13 @@ public class Upkeep extends Phase {
|
||||
*/
|
||||
private static void upkeepSlowtrips() {
|
||||
Player turnOwner = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn();
|
||||
|
||||
|
||||
// does order matter here?
|
||||
drawForSlowtrips(turnOwner);
|
||||
for(Player p : Singletons.getModel().getGame().getPlayers()) {
|
||||
if ( p == turnOwner ) continue;
|
||||
for (Player p : Singletons.getModel().getGame().getPlayers()) {
|
||||
if (p == turnOwner) {
|
||||
continue;
|
||||
}
|
||||
drawForSlowtrips(p);
|
||||
}
|
||||
}
|
||||
@@ -490,8 +493,8 @@ public class Upkeep extends Phase {
|
||||
protected boolean isValidChoice(Card choice) {
|
||||
return choice.isCreature() && !choice.isArtifact() && canTarget(choice) && choice.getController() == player;
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
protected Input onDone() {
|
||||
Singletons.getModel().getGame().getAction().destroyNoRegeneration(selected.get(0));
|
||||
return null;
|
||||
@@ -637,7 +640,7 @@ public class Upkeep extends Phase {
|
||||
} // end resolve()
|
||||
}; // end noPay ability
|
||||
|
||||
final Player cp = c.getController();
|
||||
final Player cp = c.getController();
|
||||
if (cp.isHuman()) {
|
||||
final String question = "Pay Demonic Hordes upkeep cost?";
|
||||
if (GameActionUtil.showYesNoDialog(c, question)) {
|
||||
@@ -1223,8 +1226,8 @@ public class Upkeep extends Phase {
|
||||
List<Card> computerCreatures = player.getCreaturesInPlay();
|
||||
computerCreatures = CardLists.getValidCards(computerCreatures, smallCreatures, k.getController(), k);
|
||||
computerCreatures = CardLists.getNotKeyword(computerCreatures, "Indestructible");
|
||||
|
||||
|
||||
|
||||
|
||||
if (humanCreatures.size() > computerCreatures.size()) {
|
||||
final String title = "Computer reveals";
|
||||
this.revealTopCard(title);
|
||||
@@ -1946,9 +1949,9 @@ public class Upkeep extends Phase {
|
||||
oathFlag = false;
|
||||
}
|
||||
} else { // if player == Computer
|
||||
final List<Card> creaturesInLibrary =
|
||||
final List<Card> creaturesInLibrary =
|
||||
CardLists.filter(player.getCardsIn(ZoneType.Library), CardPredicates.Presets.CREATURES);
|
||||
final List<Card> creaturesInBattlefield =
|
||||
final List<Card> creaturesInBattlefield =
|
||||
CardLists.filter(player.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);
|
||||
|
||||
// if there are at least 3 creatures in library,
|
||||
@@ -2015,7 +2018,7 @@ public class Upkeep extends Phase {
|
||||
final Ability ability = new Ability(oathList.get(0), "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
final List<Card> graveyardCreatures =
|
||||
final List<Card> graveyardCreatures =
|
||||
CardLists.filter(player.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES);
|
||||
|
||||
if (GameState.compareTypeAmountInGraveyard(player, "Creature") > 0) {
|
||||
@@ -2055,7 +2058,7 @@ public class Upkeep extends Phase {
|
||||
*/
|
||||
private static void upkeepKarma() {
|
||||
final Player player = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn();
|
||||
final List<Card> karmas =
|
||||
final List<Card> karmas =
|
||||
CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Karma"));
|
||||
final List<Card> swamps = CardLists.getType(player.getCardsIn(ZoneType.Battlefield), "Swamp");
|
||||
|
||||
@@ -2147,7 +2150,7 @@ public class Upkeep extends Phase {
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (player.isComputer()) {
|
||||
Card toTap = CardFactoryUtil.getWorstPermanentAI(list, false, false, false, false);
|
||||
// try to find non creature cards without tap abilities
|
||||
// try to find non creature cards without tap abilities
|
||||
List<Card> betterList = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -2155,7 +2158,7 @@ public class Upkeep extends Phase {
|
||||
return false;
|
||||
}
|
||||
for (SpellAbility sa : c.getAllSpellAbilities()) {
|
||||
if ( sa.getPayCosts() != null && sa.getPayCosts().getTap()) {
|
||||
if (sa.getPayCosts() != null && sa.getPayCosts().getTap()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2261,7 +2264,7 @@ public class Upkeep extends Phase {
|
||||
@Override
|
||||
public void resolve() {
|
||||
final List<Card> enchantmentsAttached = new ArrayList<Card>(source.getEnchantingPlayer().getEnchantedBy());
|
||||
List<Card> enchantmentsInLibrary =
|
||||
List<Card> enchantmentsInLibrary =
|
||||
CardLists.filter(source.getController().getCardsIn(ZoneType.Library), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
|
||||
Reference in New Issue
Block a user