mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
Large cleanup in game; fix some small bugs and make a lot of methods static where applicable.
This commit is contained in:
@@ -169,12 +169,25 @@ public class Game {
|
||||
* Gets the players who are still fighting to win, in turn order.
|
||||
*/
|
||||
public final FCollectionView<Player> getPlayersInTurnOrder() {
|
||||
if (turnOrder.isDefaultDirection()) {
|
||||
return ingamePlayers;
|
||||
}
|
||||
FCollection<Player> players = new FCollection<Player>(ingamePlayers);
|
||||
Collections.reverse(players);
|
||||
return players;
|
||||
if (turnOrder.isDefaultDirection()) {
|
||||
return ingamePlayers;
|
||||
}
|
||||
final FCollection<Player> players = new FCollection<Player>(ingamePlayers);
|
||||
Collections.reverse(players);
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nonactive players who are still fighting to win, in turn order.
|
||||
*/
|
||||
public final FCollectionView<Player> getNonactivePlayers() {
|
||||
// Don't use getPlayersInTurnOrder to prevent copying the player collection twice
|
||||
final FCollection<Player> players = new FCollection<Player>(ingamePlayers);;
|
||||
players.remove(phaseHandler.getPlayerTurn());
|
||||
if (!turnOrder.isDefaultDirection()) {
|
||||
Collections.reverse(players);
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -572,7 +585,7 @@ public class Game {
|
||||
|
||||
List<CardRarity> validRarities = new ArrayList<>(Arrays.asList(CardRarity.values()));
|
||||
for (final Player player : getPlayers()) {
|
||||
Set<CardRarity> playerRarity = getValidRarities(player.getCardsIn(ZoneType.Library));
|
||||
final Set<CardRarity> playerRarity = getValidRarities(player.getCardsIn(ZoneType.Library));
|
||||
if (onePlayerHasTimeShifted == false) {
|
||||
onePlayerHasTimeShifted = playerRarity.contains(CardRarity.Special);
|
||||
}
|
||||
@@ -652,9 +665,9 @@ public class Game {
|
||||
anteed.put(player, ante);
|
||||
}
|
||||
|
||||
private Set<CardRarity> getValidRarities(final Iterable<Card> cards) {
|
||||
Set<CardRarity> rarities = new HashSet<>();
|
||||
for (Card card : cards) {
|
||||
private static Set<CardRarity> getValidRarities(final Iterable<Card> cards) {
|
||||
final Set<CardRarity> rarities = new HashSet<>();
|
||||
for (final Card card : cards) {
|
||||
if (card.getRarity() == CardRarity.Rare || card.getRarity() == CardRarity.MythicRare) {
|
||||
//Since both rare and mythic rare are considered the same, adding both rarities
|
||||
//massively increases the odds chances of the game picking rare cards to ante.
|
||||
|
||||
@@ -312,7 +312,7 @@ public class GameAction {
|
||||
return copied;
|
||||
}
|
||||
|
||||
private void unattachCardLeavingBattlefield(Card copied) {
|
||||
private static void unattachCardLeavingBattlefield(final Card copied) {
|
||||
// Handle unequipping creatures
|
||||
if (copied.isEquipped()) {
|
||||
for (final Card equipment : copied.getEquippedBy(true)) {
|
||||
|
||||
@@ -66,14 +66,14 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
return new GameLogEntry(GameLogEntryType.STACK_ADD, sb.toString());
|
||||
}
|
||||
|
||||
private GameLogEntry generateSummary(List<GameOutcome> gamesPlayed) {
|
||||
GameOutcome outcome1 = gamesPlayed.get(0);
|
||||
List<Player> players = outcome1.getPlayers();
|
||||
private static GameLogEntry generateSummary(final List<GameOutcome> gamesPlayed) {
|
||||
final GameOutcome outcome1 = gamesPlayed.get(0);
|
||||
final List<Player> players = outcome1.getPlayers();
|
||||
|
||||
final int[] wins = new int[players.size()];
|
||||
|
||||
// Calculate total games each player has won.
|
||||
for (GameOutcome game : gamesPlayed) {
|
||||
for (final GameOutcome game : gamesPlayed) {
|
||||
int i = 0;
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p.getOutcome().hasWon()) {
|
||||
@@ -83,26 +83,24 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < wins.length; i++) {
|
||||
Player player = players.get(i);
|
||||
String playerName = player.getName();
|
||||
final Player player = players.get(i);
|
||||
final String playerName = player.getName();
|
||||
sb.append(playerName).append(": ").append(wins[i]).append(" ");
|
||||
}
|
||||
return new GameLogEntry(GameLogEntryType.MATCH_RESULTS, sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameLogEntry visit(GameEventPlayerControl event) {
|
||||
// TODO Auto-generated method stub
|
||||
LobbyPlayer newController = event.newController;
|
||||
Player p = event.player;
|
||||
public GameLogEntry visit(final GameEventPlayerControl event) {
|
||||
final LobbyPlayer newController = event.newController;
|
||||
final Player p = event.player;
|
||||
|
||||
final String message;
|
||||
if (newController == null) {
|
||||
message = p.getName() + " has restored control over themself";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
message = String.format("%s is controlled by %s", p.getName(), newController.getName());
|
||||
}
|
||||
return new GameLogEntry(GameLogEntryType.PLAYER_CONROL, message);
|
||||
|
||||
@@ -17,6 +17,13 @@
|
||||
*/
|
||||
package forge.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.player.Player;
|
||||
@@ -25,8 +32,6 @@ import forge.game.spellability.AbilityStatic;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* StaticEffects class.
|
||||
@@ -38,16 +43,16 @@ import java.util.*;
|
||||
public class StaticEffects {
|
||||
|
||||
// **************** StaticAbility system **************************
|
||||
private final ArrayList<StaticEffect> staticEffects = new ArrayList<StaticEffect>();
|
||||
private final List<StaticEffect> staticEffects = new ArrayList<StaticEffect>();
|
||||
//Global rule changes
|
||||
private final EnumSet<GlobalRuleChange> ruleChanges = EnumSet.noneOf(GlobalRuleChange.class);
|
||||
private final Set<GlobalRuleChange> ruleChanges = EnumSet.noneOf(GlobalRuleChange.class);
|
||||
|
||||
public final void clearStaticEffects(Set<Card> affectedCards) {
|
||||
public final void clearStaticEffects(final Set<Card> affectedCards) {
|
||||
ruleChanges.clear();
|
||||
|
||||
// remove all static effects
|
||||
for (StaticEffect se : staticEffects) {
|
||||
affectedCards.addAll(this.removeStaticEffect(se));
|
||||
for (final StaticEffect se : staticEffects) {
|
||||
affectedCards.addAll(removeStaticEffect(se));
|
||||
}
|
||||
this.staticEffects.clear();
|
||||
}
|
||||
@@ -61,22 +66,22 @@ public class StaticEffects {
|
||||
}
|
||||
|
||||
/**
|
||||
* addStaticEffect. TODO Write javadoc for this method.
|
||||
* Add a static effect to the list of static effects.
|
||||
*
|
||||
* @param staticEffect
|
||||
* a StaticEffect
|
||||
* a {@link StaticEffect}.
|
||||
*/
|
||||
public final void addStaticEffect(final StaticEffect staticEffect) {
|
||||
this.staticEffects.add(staticEffect);
|
||||
}
|
||||
|
||||
/**
|
||||
* removeStaticEffect TODO Write javadoc for this method.
|
||||
* Remove a static effect from the list of static effects and undo everything that was changed by the effect.
|
||||
*
|
||||
* @param se
|
||||
* a StaticEffect
|
||||
* a {@link StaticEffect}.
|
||||
*/
|
||||
private final List<Card> removeStaticEffect(final StaticEffect se) {
|
||||
private static final List<Card> removeStaticEffect(final StaticEffect se) {
|
||||
final List<Card> affectedCards = se.getAffectedCards();
|
||||
final ArrayList<Player> affectedPlayers = se.getAffectedPlayers();
|
||||
final Map<String, String> params = se.getParams();
|
||||
|
||||
@@ -134,8 +134,8 @@ public class AbilityUtils {
|
||||
final Object crd = root.getTriggeringObject(defined.substring(9));
|
||||
if (crd instanceof Card) {
|
||||
c = game.getCardState((Card) crd);
|
||||
} else if (crd instanceof List<?>) {
|
||||
for (final Card cardItem : (CardCollection) crd) {
|
||||
} else if (crd instanceof Iterable) {
|
||||
for (final Card cardItem : Iterables.filter((Iterable<?>) crd, Card.class)) {
|
||||
cards.add(cardItem);
|
||||
}
|
||||
}
|
||||
@@ -956,13 +956,13 @@ public class AbilityUtils {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
if (o instanceof List<?>) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<Player> pList = (List<Player>) o;
|
||||
if (o instanceof List) {
|
||||
final List<?> pList = (List<?>)o;
|
||||
if (!pList.isEmpty() && pList.get(0) instanceof Player) {
|
||||
for (final Player p : pList) {
|
||||
for (final Object p : pList) {
|
||||
if (!players.contains(p)) {
|
||||
players.add(p);
|
||||
// We now know each p in o to be an instance of Player, so cast is safe
|
||||
players.add((Player) p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SaTargetRoutines {
|
||||
protected CardCollection getDefinedCardsOrTargeted(SpellAbility sa) { return getCards(true, "Defined", sa); }
|
||||
protected CardCollection getDefinedCardsOrTargeted(SpellAbility sa, String definedParam) { return getCards(true, definedParam, sa); }
|
||||
|
||||
private CardCollection getCards(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
private static CardCollection getCards(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam))
|
||||
&& sa.getTargets() != null && (sa.getTargets().isTargetingAnyCard() || sa.getTargets().getTargets().isEmpty());
|
||||
return useTargets ? new CardCollection(sa.getTargets().getTargetCards())
|
||||
@@ -32,7 +32,7 @@ public class SaTargetRoutines {
|
||||
protected FCollection<Player> getDefinedPlayersOrTargeted(SpellAbility sa ) { return getPlayers(true, "Defined", sa); }
|
||||
protected FCollection<Player> getDefinedPlayersOrTargeted(SpellAbility sa, String definedParam) { return getPlayers(true, definedParam, sa); }
|
||||
|
||||
private FCollection<Player> getPlayers(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
private static FCollection<Player> getPlayers(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
return useTargets ? new FCollection<Player>(sa.getTargets().getTargetPlayers())
|
||||
: AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
@@ -43,7 +43,7 @@ public class SaTargetRoutines {
|
||||
protected List<SpellAbility> getTargetSpells(SpellAbility sa, String definedParam) { return getSpells(false, definedParam, sa); }
|
||||
protected List<SpellAbility> getDefinedSpellsOrTargeted(SpellAbility sa, String definedParam) { return getSpells(true, definedParam, sa); }
|
||||
|
||||
private List<SpellAbility> getSpells(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
private static List<SpellAbility> getSpells(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
return useTargets ? Lists.newArrayList(sa.getTargets().getTargetSpells())
|
||||
: AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
@@ -54,7 +54,7 @@ public class SaTargetRoutines {
|
||||
protected List<GameObject> getTargets(SpellAbility sa, String definedParam) { return getTargetables(false, definedParam, sa); }
|
||||
protected List<GameObject> getDefinedOrTargeted(SpellAbility sa, String definedParam) { return getTargetables(true, definedParam, sa); }
|
||||
|
||||
private List<GameObject> getTargetables(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
private static List<GameObject> getTargetables(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
return useTargets ? Lists.newArrayList(sa.getTargets().getTargets())
|
||||
: AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package forge.game.ability;
|
||||
|
||||
import forge.game.GameObject;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,105 +20,113 @@ import java.util.StringTokenizer;
|
||||
* @version $Id: AbilityFactoryAlterLife.java 17656 2012-10-22 19:32:56Z Max mtg $
|
||||
*/
|
||||
|
||||
public abstract class SpellAbilityEffect extends SaTargetRoutines {
|
||||
public abstract class SpellAbilityEffect extends SaTargetRoutines {
|
||||
|
||||
public abstract void resolve(final SpellAbility sa);
|
||||
public abstract void resolve(SpellAbility sa);
|
||||
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
// Unless overriden, let the spell description also be the stack description
|
||||
return sa.getDescription();
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
// Unless overriden, let the spell description also be the stack description
|
||||
return sa.getDescription();
|
||||
}
|
||||
|
||||
protected static final void resolveSubAbility(final SpellAbility sa) {
|
||||
// if mana production has any type of SubAbility, undoable=false
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
sa.setUndoable(false);
|
||||
AbilityUtils.resolve(abSub);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this effect description with needed prelude and epilogue.
|
||||
* @param params
|
||||
* @param commonSpell
|
||||
* @return
|
||||
*/
|
||||
public final String getStackDescriptionWithSubs(final Map<String, String> params, final SpellAbility sa) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
protected void resolveDrawback(final SpellAbility sa) {
|
||||
|
||||
// if mana production has any type of SubAbility, undoable=false
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
sa.setUndoable(false);
|
||||
AbilityUtils.resolve(abSub);
|
||||
}
|
||||
// prelude for when this is root ability
|
||||
if (!(sa instanceof AbilitySub)) {
|
||||
sb.append(sa.getHostCard()).append(" -");
|
||||
}
|
||||
sb.append(" ");
|
||||
|
||||
/**
|
||||
* Returns this effect description with needed prelude and epilogue.
|
||||
* @param params
|
||||
* @param commonSpell
|
||||
* @return
|
||||
*/
|
||||
public final String getStackDescriptionWithSubs(final Map<String, String> params, final SpellAbility sa) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// prelude for when this is root ability
|
||||
if (!(sa instanceof AbilitySub)) {
|
||||
sb.append(sa.getHostCard()).append(" -");
|
||||
}
|
||||
sb.append(" ");
|
||||
|
||||
// Own description
|
||||
String stackDesc = params.get("StackDescription");
|
||||
if (stackDesc != null) {
|
||||
if ("SpellDescription".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output
|
||||
sb.append(params.get("SpellDescription").replace("CARDNAME", sa.getHostCard().getName()));
|
||||
if (sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
|
||||
sb.append(" (Targeting: " + sa.getTargets().getTargets() + ")");
|
||||
}
|
||||
} else if (!"None".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output
|
||||
makeSpellDescription(sa, sb, stackDesc);
|
||||
// Own description
|
||||
String stackDesc = params.get("StackDescription");
|
||||
if (stackDesc != null) {
|
||||
if ("SpellDescription".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output
|
||||
sb.append(params.get("SpellDescription").replace("CARDNAME", sa.getHostCard().getName()));
|
||||
if (sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
|
||||
sb.append(" (Targeting: " + sa.getTargets().getTargets() + ")");
|
||||
}
|
||||
} else if (!"None".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output
|
||||
makeSpellDescription(sa, sb, stackDesc);
|
||||
}
|
||||
} else {
|
||||
final String conditionDesc = sa.getParam("ConditionDescription");
|
||||
final String baseDesc = this.getStackDescription(sa);
|
||||
if (conditionDesc != null) {
|
||||
sb.append(conditionDesc).append(" ");
|
||||
}
|
||||
sb.append(baseDesc);
|
||||
}
|
||||
|
||||
// This includes all subAbilities
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
sb.append(abSub.getStackDescription());
|
||||
}
|
||||
|
||||
if (sa.hasParam("Announce")) {
|
||||
String svar = sa.getParam("Announce");
|
||||
int amount = CardFactoryUtil.xCount(sa.getHostCard(), sa.getSVar(svar));
|
||||
sb.append(String.format(" (%s=%d)", svar, amount));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the description of a {@link SpellAbility} to a
|
||||
* {@link StringBuilder}.
|
||||
*
|
||||
* @param sa
|
||||
* a {@link SpellAbility}.
|
||||
* @param sb
|
||||
* a {@link StringBuilder}.
|
||||
* @param stackDesc
|
||||
* the stack description of sa, formatted so that text appearing
|
||||
* between braces <code>{ }</code> is replaced with defined
|
||||
* {@link Player}, {@link SpellAbility}, and {@link Card}
|
||||
* objects.
|
||||
*/
|
||||
private static void makeSpellDescription(final SpellAbility sa, final StringBuilder sb, final String stackDesc) {
|
||||
final StringTokenizer st = new StringTokenizer(stackDesc, "{}", true);
|
||||
boolean isPlainText = true;
|
||||
|
||||
while (st.hasMoreTokens()) {
|
||||
final String t = st.nextToken();
|
||||
if ("{".equals(t)) { isPlainText = false; continue; }
|
||||
if ("}".equals(t)) { isPlainText = true; continue; }
|
||||
|
||||
if (isPlainText) {
|
||||
sb.append(t.replace("CARDNAME", sa.getHostCard().getName()));
|
||||
} else {
|
||||
final String conditionDesc = sa.getParam("ConditionDescription");
|
||||
final String baseDesc = this.getStackDescription(sa);
|
||||
if (conditionDesc != null) {
|
||||
sb.append(conditionDesc).append(" ");
|
||||
}
|
||||
sb.append(baseDesc);
|
||||
}
|
||||
|
||||
// This includes all subAbilities
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
sb.append(abSub.getStackDescription());
|
||||
}
|
||||
|
||||
if (sa.hasParam("Announce")) {
|
||||
String svar = sa.getParam("Announce");
|
||||
int amount = CardFactoryUtil.xCount(sa.getHostCard(), sa.getSVar(svar));
|
||||
sb.append(String.format(" (%s=%d)", svar, amount));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param sa
|
||||
* @param sb
|
||||
* @param stackDesc
|
||||
*/
|
||||
private void makeSpellDescription(final SpellAbility sa, StringBuilder sb, String stackDesc) {
|
||||
StringTokenizer st = new StringTokenizer(stackDesc, "{}", true);
|
||||
boolean isPlainText = true;
|
||||
while( st.hasMoreTokens() )
|
||||
{
|
||||
String t = st.nextToken();
|
||||
if ( "{".equals(t) ) { isPlainText = false; continue; }
|
||||
if ( "}".equals(t) ) { isPlainText = true; continue; }
|
||||
if ( isPlainText )
|
||||
sb.append(t.replace("CARDNAME", sa.getHostCard().getName()));
|
||||
else {
|
||||
List<?> objs = null;
|
||||
if ( t.startsWith("p:") )
|
||||
objs = AbilityUtils.getDefinedPlayers(sa.getHostCard(), t.substring(2), sa);
|
||||
else if ( t.startsWith("s:"))
|
||||
objs = AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), t.substring(2), sa);
|
||||
else if ( t.startsWith("c:"))
|
||||
objs = AbilityUtils.getDefinedCards(sa.getHostCard(), t.substring(2), sa);
|
||||
else
|
||||
objs = AbilityUtils.getDefinedObjects(sa.getHostCard(), t, sa);
|
||||
|
||||
sb.append(StringUtils.join(objs, ", "));
|
||||
final List<? extends GameObject> objs;
|
||||
if (t.startsWith("p:")) {
|
||||
objs = AbilityUtils.getDefinedPlayers(sa.getHostCard(), t.substring(2), sa);
|
||||
} else if (t.startsWith("s:")) {
|
||||
objs = AbilityUtils.getDefinedSpellAbilities(sa.getHostCard(), t.substring(2), sa);
|
||||
} else if (t.startsWith("c:")) {
|
||||
objs = AbilityUtils.getDefinedCards(sa.getHostCard(), t.substring(2), sa);
|
||||
} else {
|
||||
objs = AbilityUtils.getDefinedObjects(sa.getHostCard(), t, sa);
|
||||
}
|
||||
|
||||
sb.append(StringUtils.join(objs, ", "));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
|
||||
final Card o = p.getController().chooseSingleEntityForEffect(list, aura, source + " - Select a card to attach to.");
|
||||
if (o != null) {
|
||||
handleAura(source, (Card) o);
|
||||
handleAura(source, o);
|
||||
//source.enchantEntity((Card) o);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
private void changeHiddenOriginResolve(final SpellAbility sa) {
|
||||
private static void changeHiddenOriginResolve(final SpellAbility sa) {
|
||||
List<Player> fetchers;
|
||||
|
||||
if (sa.hasParam("DefinedPlayer")) {
|
||||
@@ -595,8 +595,8 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
changeZonePlayerInvariant(decider, sa, player);
|
||||
}
|
||||
}
|
||||
|
||||
private void changeZonePlayerInvariant(Player decider, SpellAbility sa, Player player) {
|
||||
|
||||
private static void changeZonePlayerInvariant(Player decider, SpellAbility sa, Player player) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
final List<Player> players = Lists.newArrayList(sa.getTargets().getTargetPlayers());
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
|
||||
if (siSpellAbility.getTriggeringObjects() != null) {
|
||||
for (Object c : siSpellAbility.getTriggeringObjects().values()) {
|
||||
if (c instanceof Card) {
|
||||
if (!stackSources.contains((Card) c)) {
|
||||
if (!stackSources.contains(c)) {
|
||||
referencedSources.add((Card) c);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
|
||||
if (siSpellAbility.getReplacingObjects() != null) {
|
||||
for (Object c : siSpellAbility.getReplacingObjects().values()) {
|
||||
if (c instanceof Card) {
|
||||
if (!stackSources.contains((Card) c)) {
|
||||
if (!stackSources.contains(c)) {
|
||||
referencedSources.add((Card) c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
return sa.getHostCard().getName() + " - Clash with an opponent.";
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
* @see forge.card.abilityfactory.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final boolean victory = clashWithOpponent(sa);
|
||||
|
||||
// Run triggers
|
||||
@@ -70,7 +70,7 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
private final boolean clashWithOpponent(final SpellAbility sa) {
|
||||
private static boolean clashWithOpponent(final SpellAbility sa) {
|
||||
/*
|
||||
* Each clashing player reveals the top card of his or her library, then
|
||||
* puts that card on the top or bottom. A player wins if his or her card
|
||||
@@ -129,13 +129,12 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
|
||||
public final void clashMoveToTopOrBottom(final Player p, final Card c) {
|
||||
GameAction action = p.getGame().getAction();
|
||||
boolean putOnTop = p.getController().willPutCardOnTop(c);
|
||||
private static void clashMoveToTopOrBottom(final Player p, final Card c) {
|
||||
final GameAction action = p.getGame().getAction();
|
||||
final boolean putOnTop = p.getController().willPutCardOnTop(c);
|
||||
if (putOnTop) {
|
||||
action.moveToLibrary(c);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
action.moveToBottomOfLibrary(c);
|
||||
}
|
||||
// computer just puts the card back until such time it can make a smarter decision
|
||||
|
||||
@@ -198,7 +198,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
game.fireEvent(new GameEventCardStatsChanged(tgtCard));
|
||||
} // cloneResolve
|
||||
|
||||
private void addExtraCharacteristics(final Card tgtCard, final SpellAbility sa, final Map<String, String> origSVars) {
|
||||
private static void addExtraCharacteristics(final Card tgtCard, final SpellAbility sa, final Map<String, String> origSVars) {
|
||||
// additional types to clone
|
||||
if (sa.hasParam("AddTypes")) {
|
||||
for (final String type : Arrays.asList(sa.getParam("AddTypes").split(","))) {
|
||||
|
||||
@@ -49,8 +49,9 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void doLoseControl(final Card c, final Card host, final boolean tapOnLose,
|
||||
final List<String> addedKeywords, final long tStamp) {
|
||||
private static void doLoseControl(final Card c, final Card host,
|
||||
final boolean tapOnLose, final List<String> addedKeywords,
|
||||
final long tStamp) {
|
||||
if (null == c || c.hasKeyword("Other players can't gain control of CARDNAME.")) {
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +186,7 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
* a int.
|
||||
* @return a {@link forge.GameCommand} object.
|
||||
*/
|
||||
private GameCommand getDestroyCommand(final Card c, final Card hostCard, final boolean bNoRegen) {
|
||||
private static GameCommand getDestroyCommand(final Card c, final Card hostCard, final boolean bNoRegen) {
|
||||
final GameCommand destroy = new GameCommand() {
|
||||
private static final long serialVersionUID = 878543373519872418L;
|
||||
|
||||
@@ -228,8 +229,9 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @return a {@link forge.GameCommand} object.
|
||||
*/
|
||||
private GameCommand getLoseControlCommand(final Card c, final long tStamp,
|
||||
final boolean bTapOnLose, final Card hostCard, final List<String> kws) {
|
||||
private static GameCommand getLoseControlCommand(final Card c,
|
||||
final long tStamp, final boolean bTapOnLose, final Card hostCard,
|
||||
final List<String> kws) {
|
||||
final GameCommand loseControl = new GameCommand() {
|
||||
private static final long serialVersionUID = 878543373519872418L;
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
} // end foreach Card
|
||||
} // end resolve
|
||||
|
||||
private void registerDelayedTrigger(final SpellAbility sa, final String location, final List<Card> crds) {
|
||||
private static void registerDelayedTrigger(final SpellAbility sa, final String location, final List<Card> crds) {
|
||||
String delTrig = "Mode$ Phase | Phase$ End Of Turn | TriggerDescription$ "
|
||||
+ location + " " + crds + " at the beginning of the next end step.";
|
||||
final Trigger trig = TriggerHandler.parseTrigger(delTrig, sa.getHostCard(), true);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
final Card tgtSACard = tgtSA.getHostCard();
|
||||
// should remember even that spell cannot be countered, e.g. Dovescape
|
||||
if (sa.hasParam("RememberCounteredCMC")) {
|
||||
sa.getHostCard().addRemembered((Integer) tgtSACard.getCMC());
|
||||
sa.getHostCard().addRemembered(Integer.valueOf(tgtSACard.getCMC()));
|
||||
}
|
||||
|
||||
if (tgtSA.isSpell() && !CardFactoryUtil.isCounterableBy(tgtSACard, sa)) {
|
||||
@@ -112,7 +112,7 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.removeFromStack(tgtSA, sa, si);
|
||||
removeFromStack(tgtSA, sa, si);
|
||||
|
||||
// Destroy Permanent may be able to be turned into a SubAbility
|
||||
if (tgtSA.isAbility() && sa.hasParam("DestroyPermanent")) {
|
||||
@@ -147,7 +147,8 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
* object.
|
||||
* @param sa
|
||||
*/
|
||||
private void removeFromStack(final SpellAbility tgtSA, final SpellAbility srcSA, final SpellAbilityStackInstance si) {
|
||||
private static void removeFromStack(final SpellAbility tgtSA,
|
||||
final SpellAbility srcSA, final SpellAbilityStackInstance si) {
|
||||
final Game game = tgtSA.getActivatingPlayer().getGame();
|
||||
// Run any applicable replacement effects.
|
||||
final HashMap<String, Object> repParams = new HashMap<String, Object>();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class DelayedTriggerEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("RememberNumber")) {
|
||||
for (final Object o : sa.getHostCard().getRemembered()) {
|
||||
if (o instanceof Integer) {
|
||||
delTrig.addRemembered((Integer) o);
|
||||
delTrig.addRemembered(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
|
||||
// returns a List<Card> that is a subset of list with cards that share a name
|
||||
// with a permanent on the battlefield
|
||||
private CardCollection sharesNameWithCardOnBattlefield(final Game game, final List<Card> list) {
|
||||
private static CardCollection sharesNameWithCardOnBattlefield(final Game game, final List<Card> list) {
|
||||
final CardCollection toReturn = new CardCollection();
|
||||
final CardCollectionView play = game.getCardsIn(ZoneType.Battlefield);
|
||||
for (final Card c : list) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DrainManaEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("RememberDrainedMana")) {
|
||||
sa.getHostCard().addRemembered((Integer) drained.size());
|
||||
sa.getHostCard().addRemembered(Integer.valueOf(drained.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
||||
// Run triggers
|
||||
HashMap<String,Object> runParams = new HashMap<String,Object>();
|
||||
runParams.put("Player", caller);
|
||||
runParams.put("Result", (Boolean) result);
|
||||
runParams.put("Result", Boolean.valueOf(result));
|
||||
caller.getGame().getTriggerHandler().runTrigger(TriggerType.FlippedCoin, runParams, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ManaReflectedEffect extends SpellAbilityEffect {
|
||||
ma.produceMana(generated, player, sa);
|
||||
}
|
||||
|
||||
resolveDrawback(sa);
|
||||
resolveSubAbility(sa);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ManaReflectedEffect extends SpellAbilityEffect {
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
private String generatedReflectedMana(final SpellAbility sa, final Collection<String> colors, final Player player) {
|
||||
private static String generatedReflectedMana(final SpellAbility sa, final Collection<String> colors, final Player player) {
|
||||
// Calculate generated mana here for stack description and resolving
|
||||
final int amount = sa.hasParam("Amount") ? AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa) : 1;
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PumpAllEffect extends SpellAbilityEffect {
|
||||
private void applyPumpAll(final SpellAbility sa, final List<Card> list, final int a,
|
||||
final int d, final List<String> keywords, final ArrayList<ZoneType> affectedZones) {
|
||||
private static void applyPumpAll(final SpellAbility sa,
|
||||
final List<Card> list, final int a, final int d,
|
||||
final List<String> keywords, final ArrayList<ZoneType> affectedZones) {
|
||||
|
||||
final Game game = sa.getActivatingPlayer().getGame();
|
||||
final long timestamp = game.getNextTimestamp();
|
||||
@@ -103,8 +104,9 @@ public class PumpAllEffect extends SpellAbilityEffect {
|
||||
game.fireEvent(new GameEventCardStatsChanged(tgtC));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
String desc = "";
|
||||
@@ -120,7 +122,7 @@ public class PumpAllEffect extends SpellAbilityEffect {
|
||||
} // pumpAllStackDescription()
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
final ArrayList<ZoneType> affectedZones = new ArrayList<ZoneType>();
|
||||
final Game game = sa.getActivatingPlayer().getGame();
|
||||
@@ -162,7 +164,7 @@ public class PumpAllEffect extends SpellAbilityEffect {
|
||||
String[] restrictions = sa.hasParam("SharedRestrictions") ? sa.getParam("SharedRestrictions").split(",") : new String[] {"Card"};
|
||||
keywords = CardFactoryUtil.sharedKeywords(sa.getParam("KW").split(" & "), restrictions, zones, sa.getHostCard());
|
||||
}
|
||||
this.applyPumpAll(sa, list, a, d, keywords, affectedZones);
|
||||
applyPumpAll(sa, list, a, d, keywords, affectedZones);
|
||||
} // pumpAllResolve()
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PumpEffect extends SpellAbilityEffect {
|
||||
|
||||
private void applyPump(final SpellAbility sa, final Card applyTo, final int a, final int d, final List<String> keywords, final long timestamp) {
|
||||
private static void applyPump(final SpellAbility sa, final Card applyTo,
|
||||
final int a, final int d, final List<String> keywords,
|
||||
final long timestamp) {
|
||||
//if host is not on the battlefield don't apply
|
||||
if (sa.hasParam("UntilLoseControlOfHost")
|
||||
&& !sa.getHostCard().isInPlay()) {
|
||||
@@ -96,7 +98,8 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
game.fireEvent(new GameEventCardStatsChanged(applyTo));
|
||||
}
|
||||
|
||||
private void applyPump(final SpellAbility sa, final Player p, final List<String> keywords, final long timestamp) {
|
||||
private static void applyPump(final SpellAbility sa, final Player p,
|
||||
final List<String> keywords, final long timestamp) {
|
||||
final Game game = p.getGame();
|
||||
p.addChangedKeywords(keywords, ImmutableList.<String>of(), timestamp);
|
||||
|
||||
@@ -126,7 +129,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
List<GameEntity> tgts = new ArrayList<GameEntity>();
|
||||
@@ -181,7 +184,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
} // pumpStackDescription()
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
|
||||
final ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
@@ -314,7 +317,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.applyPump(sa, tgtC, a, d, keywords, timestamp);
|
||||
applyPump(sa, tgtC, a, d, keywords, timestamp);
|
||||
}
|
||||
|
||||
for (final Card tgtC : untargetedCards) {
|
||||
@@ -323,7 +326,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.applyPump(sa, tgtC, a, d, keywords, timestamp);
|
||||
applyPump(sa, tgtC, a, d, keywords, timestamp);
|
||||
}
|
||||
|
||||
for (Player p : tgtPlayers) {
|
||||
@@ -331,7 +334,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.applyPump(sa, p, keywords, timestamp);
|
||||
applyPump(sa, p, keywords, timestamp);
|
||||
}
|
||||
} // pumpResolve()
|
||||
}
|
||||
|
||||
@@ -101,7 +101,9 @@ public class RearrangeTopOfLibraryEffect extends SpellAbilityEffect {
|
||||
* @param mayshuffle
|
||||
* a boolean.
|
||||
*/
|
||||
private void rearrangeTopOfLibrary(final Card src, final Player player, final int numCards, final boolean mayshuffle, final SpellAbility sa) {
|
||||
private static void rearrangeTopOfLibrary(final Card src,
|
||||
final Player player, final int numCards, final boolean mayshuffle,
|
||||
final SpellAbility sa) {
|
||||
final Player activator = sa.hasParam("RearrangePlayer") ? Iterables.getFirst(AbilityUtils.getDefinedPlayers(src, sa.getParam("RearrangePlayer"), sa), null)
|
||||
: sa.getActivatingPlayer();
|
||||
if (activator == null) {
|
||||
|
||||
@@ -17,12 +17,12 @@ import forge.util.Expressions;
|
||||
public class RepeatEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
return "Repeat something. Somebody should really write a better StackDescription!";
|
||||
} // end repeatStackDescription()
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
Card source = sa.getHostCard();
|
||||
|
||||
// setup subability to repeat
|
||||
@@ -65,7 +65,7 @@ public class RepeatEffect extends SpellAbilityEffect {
|
||||
* @param SA
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
private boolean checkRepeatConditions(final SpellAbility sa) {
|
||||
private static boolean checkRepeatConditions(final SpellAbility sa) {
|
||||
//boolean doAgain = false;
|
||||
final Player activator = sa.getActivatingPlayer();
|
||||
final Game game = activator.getGame();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SacrificeEffect extends SpellAbilityEffect {
|
||||
sa, "Pay Echo", ManaPaymentPurpose.Echo);
|
||||
}
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("EchoPaid", (Boolean) isPaid);
|
||||
runParams.put("EchoPaid", Boolean.valueOf(isPaid));
|
||||
runParams.put("Card", card);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.PayEcho, runParams, false);
|
||||
if (isPaid || !card.getController().equals(activator)) {
|
||||
|
||||
@@ -54,20 +54,20 @@ public class ScryEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
|
||||
public final void scry(Player p, int numScry) {
|
||||
private static void scry(final Player p, final int numScry) {
|
||||
final CardCollection topN = new CardCollection();
|
||||
final PlayerZone library = p.getZone(ZoneType.Library);
|
||||
numScry = Math.min(numScry, library.size());
|
||||
final int actualNumScry = Math.min(numScry, library.size());
|
||||
|
||||
if (numScry == 0) { return; }
|
||||
if (actualNumScry == 0) { return; }
|
||||
|
||||
for (int i = 0; i < numScry; i++) {
|
||||
for (int i = 0; i < actualNumScry; i++) {
|
||||
topN.add(library.get(i));
|
||||
}
|
||||
|
||||
ImmutablePair<CardCollection, CardCollection> lists = p.getController().arrangeForScry(topN);
|
||||
CardCollection toTop = lists.getLeft();
|
||||
CardCollection toBottom = lists.getRight();
|
||||
final ImmutablePair<CardCollection, CardCollection> lists = p.getController().arrangeForScry(topN);
|
||||
final CardCollection toTop = lists.getLeft();
|
||||
final CardCollection toBottom = lists.getRight();
|
||||
|
||||
if (toBottom != null) {
|
||||
for(Card c : toBottom) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
public class SetStateEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
final List<Card> tgtCards = getTargetCards(sa);
|
||||
@@ -37,7 +37,7 @@ public class SetStateEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
|
||||
final Card host = sa.getHostCard();
|
||||
final Game game = host.getGame();
|
||||
@@ -60,7 +60,7 @@ public class SetStateEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean changeCardState(final Card tgt, final String mode, final String customState) {
|
||||
private static boolean changeCardState(final Card tgt, final String mode, final String customState) {
|
||||
if (mode == null)
|
||||
return tgt.changeToState(CardStateName.smartValueOf(customState));
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.List;
|
||||
|
||||
public class UnattachAllEffect extends SpellAbilityEffect {
|
||||
private void handleUnattachment(final GameEntity o, final Card cardToUnattach) {
|
||||
private static void handleUnattachment(final GameEntity o, final Card cardToUnattach) {
|
||||
if (o instanceof Card) {
|
||||
final Card c = (Card) o;
|
||||
if (cardToUnattach.isAura()) {
|
||||
@@ -136,7 +136,7 @@ public class UnattachAllEffect extends SpellAbilityEffect {
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unattach all valid Equipment and Auras from ");
|
||||
final List<GameObject> targets = getTargets(sa);
|
||||
@@ -145,7 +145,7 @@ public class UnattachAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
Card source = sa.getHostCard();
|
||||
final Game game = sa.getActivatingPlayer().getGame();
|
||||
final List<GameObject> targets = getTargets(sa);
|
||||
|
||||
@@ -28,8 +28,8 @@ public class VoteEffect extends SpellAbilityEffect {
|
||||
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
protected String getStackDescription(final SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(StringUtils.join(getDefinedPlayersOrTargeted(sa), ", "));
|
||||
sb.append(" vote ");
|
||||
if (sa.hasParam("VoteType")) {
|
||||
@@ -44,7 +44,7 @@ public class VoteEffect extends SpellAbilityEffect {
|
||||
* @see forge.card.abilityfactory.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final List<Player> tgtPlayers = getDefinedPlayersOrTargeted(sa);
|
||||
final List<Object> voteType = new ArrayList<Object>();
|
||||
final Card host = sa.getHostCard();
|
||||
@@ -107,11 +107,11 @@ public class VoteEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object> getMostVotes(ArrayListMultimap<Object, Player> votes) {
|
||||
List<Object> most = Lists.newArrayList();
|
||||
private static List<Object> getMostVotes(final ArrayListMultimap<Object, Player> votes) {
|
||||
final List<Object> most = Lists.newArrayList();
|
||||
int amount = 0;
|
||||
for (Object voteType : votes.keySet()) {
|
||||
int voteAmount = votes.get(voteType).size();
|
||||
for (final Object voteType : votes.keySet()) {
|
||||
final int voteAmount = votes.get(voteType).size();
|
||||
if (voteAmount == amount) {
|
||||
most.add(voteType);
|
||||
} else if (voteAmount > amount) {
|
||||
|
||||
@@ -89,7 +89,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Card extends GameEntity implements Comparable<Card>, IIdentifiable {
|
||||
public class Card extends GameEntity implements Comparable<Card> {
|
||||
private static HashMap<Integer, Card> cardCache = new HashMap<Integer, Card>();
|
||||
public static Card get(CardView cardView) {
|
||||
if (cardView == null) { return null; }
|
||||
@@ -1398,24 +1398,24 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getTextForKwCantBeBlockedByAmount(String keyword) {
|
||||
String restriction = keyword.split(" ", 2)[1];
|
||||
boolean isLT = "LT".equals(restriction.substring(0,2));
|
||||
private static String getTextForKwCantBeBlockedByAmount(final String keyword) {
|
||||
final String restriction = keyword.split(" ", 2)[1];
|
||||
final boolean isLT = "LT".equals(restriction.substring(0,2));
|
||||
final String byClause = isLT ? "except by " : "by more than ";
|
||||
int cnt = Integer.parseInt(restriction.substring(2));
|
||||
final int cnt = Integer.parseInt(restriction.substring(2));
|
||||
return byClause + Lang.nounWithNumeral(cnt, isLT ? "or more creature" : "creature");
|
||||
}
|
||||
|
||||
private String getTextForKwCantBeBlockedByType(String keyword) {
|
||||
private static String getTextForKwCantBeBlockedByType(final String keyword) {
|
||||
boolean negative = true;
|
||||
List<String> subs = Lists.newArrayList(TextUtil.split(keyword.split(" ", 2)[1], ','));
|
||||
List<List<String>> subsAnd = Lists.newArrayList();
|
||||
List<String> orClauses = new ArrayList<String>();
|
||||
final List<String> subs = Lists.newArrayList(TextUtil.split(keyword.split(" ", 2)[1], ','));
|
||||
final List<List<String>> subsAnd = Lists.newArrayList();
|
||||
final List<String> orClauses = new ArrayList<String>();
|
||||
for (int iOr = 0; iOr < subs.size(); iOr++) {
|
||||
String expession = subs.get(iOr);
|
||||
List<String> parts = Lists.newArrayList(expession.split("[.+]"));
|
||||
final String expession = subs.get(iOr);
|
||||
final List<String> parts = Lists.newArrayList(expession.split("[.+]"));
|
||||
for (int p = 0; p < parts.size(); p++) {
|
||||
String part = parts.get(p);
|
||||
final String part = parts.get(p);
|
||||
if (part.equalsIgnoreCase("creature")) {
|
||||
parts.remove(p--);
|
||||
continue;
|
||||
@@ -1438,9 +1438,9 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
||||
};
|
||||
|
||||
for (int iOr = 0; iOr < subsAnd.size(); iOr++) {
|
||||
List<String> andOperands = subsAnd.get(iOr);
|
||||
List<Pair<Boolean, String>> prependedAdjectives = Lists.newArrayList();
|
||||
List<Pair<Boolean, String>> postponedAdjectives = Lists.newArrayList();
|
||||
final List<String> andOperands = subsAnd.get(iOr);
|
||||
final List<Pair<Boolean, String>> prependedAdjectives = Lists.newArrayList();
|
||||
final List<Pair<Boolean, String>> postponedAdjectives = Lists.newArrayList();
|
||||
String creatures = null;
|
||||
|
||||
for (String part : andOperands) {
|
||||
@@ -4747,10 +4747,8 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
|
||||
} else if (property.equals("attackedBySourceThisCombat")) {
|
||||
if (null == combat) return false;
|
||||
final GameEntity defender = combat.getDefenderByAttacker(source);
|
||||
if (defender instanceof Card) {
|
||||
if (!equals((Card) defender)) {
|
||||
return false;
|
||||
}
|
||||
if (defender instanceof Card && !equals(defender)) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("blocking")) {
|
||||
if (null == combat) return false;
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ManaCostBeingPaid {
|
||||
private class ManaCostBeingPaidIterator implements IParserManaCost, Iterator<ManaCostShard> {
|
||||
private class ManaCostBeingPaidIterator implements IParserManaCost {
|
||||
private Iterator<ManaCostShard> mch;
|
||||
private ManaCostShard nextShard = null;
|
||||
private int remainingShards = 0;
|
||||
@@ -404,7 +404,7 @@ public class ManaCostBeingPaid {
|
||||
return chosenShard;
|
||||
}
|
||||
|
||||
private int getPayPriority(ManaCostShard bill, byte paymentColor) {
|
||||
private static int getPayPriority(final ManaCostShard bill, final byte paymentColor) {
|
||||
if (bill == ManaCostShard.COLORLESS) {
|
||||
return 0;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class ManaCostBeingPaid {
|
||||
return 5;
|
||||
}
|
||||
|
||||
private boolean canBePaidWith(ManaCostShard shard, Mana mana, ManaPool pool) {
|
||||
private static boolean canBePaidWith(final ManaCostShard shard, final Mana mana, final ManaPool pool) {
|
||||
if (shard.isSnow() && !mana.isSnow()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class Upkeep extends Phase {
|
||||
this.setCumulativeupkeep(true);
|
||||
boolean isPaid = controller.getController().payManaOptional(c, upkeepCost, this, sb.toString(), ManaPaymentPurpose.CumulativeUpkeep);
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("CumulativeUpkeepPaid", (Boolean) isPaid);
|
||||
runParams.put("CumulativeUpkeepPaid", Boolean.valueOf(isPaid));
|
||||
runParams.put("Card", this.getHostCard());
|
||||
runParams.put("PayingMana", StringUtils.join(this.getPayingMana(), ""));
|
||||
game.getTriggerHandler().runTrigger(TriggerType.PayCumulativeUpkeep, runParams, false);
|
||||
|
||||
@@ -1229,8 +1229,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
return dredge;
|
||||
}
|
||||
|
||||
protected final int getDredgeNumber(final Card c) {
|
||||
for (String s : c.getKeywords()) {
|
||||
private static int getDredgeNumber(final Card c) {
|
||||
for (final String s : c.getKeywords()) {
|
||||
if (s.startsWith("Dredge")) {
|
||||
return Integer.parseInt("" + s.charAt(s.length() - 1));
|
||||
}
|
||||
@@ -1300,7 +1300,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
runParams.put("Player", this);
|
||||
runParams.put("Card", c);
|
||||
runParams.put("Cause", cause);
|
||||
runParams.put("IsMadness", (Boolean) discardMadness);
|
||||
runParams.put("IsMadness", Boolean.valueOf(discardMadness));
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Discarded, runParams, false);
|
||||
game.getGameLog().add(GameLogEntryType.DISCARD, sb.toString());
|
||||
return newCard;
|
||||
|
||||
@@ -204,7 +204,7 @@ public class PlayerView extends GameEntityView {
|
||||
TrackableCollection<CardView> cards = get(zoneProp);
|
||||
return cards == null ? 0 : cards.size();
|
||||
}
|
||||
private TrackableProperty getZoneProp(final ZoneType zone) {
|
||||
private static TrackableProperty getZoneProp(final ZoneType zone) {
|
||||
switch (zone) {
|
||||
case Ante:
|
||||
return TrackableProperty.Ante;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class StaticAbility extends CardTraitBase {
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a {@link java.util.HashMap} object.
|
||||
*/
|
||||
public final HashMap<String, String> parseParams(final String abString, final Card hostCard) {
|
||||
private static HashMap<String, String> parseParams(final String abString, final Card hostCard) {
|
||||
final HashMap<String, String> mapParameters = new HashMap<String, String>();
|
||||
|
||||
if (!(abString.length() > 0)) {
|
||||
@@ -174,7 +174,7 @@ public class StaticAbility extends CardTraitBase {
|
||||
* the host
|
||||
*/
|
||||
public StaticAbility(final String params, final Card host) {
|
||||
final Map<String, String> parsedParams = this.parseParams(params, host);
|
||||
final Map<String, String> parsedParams = parseParams(params, host);
|
||||
this.originalMapParams.putAll(parsedParams);
|
||||
this.mapParams.putAll(parsedParams);
|
||||
this.hostCard = host;
|
||||
|
||||
@@ -98,7 +98,7 @@ public class TriggerChangesZone extends Trigger {
|
||||
final String comparator = condition.length < 2 ? "GE1" : condition[1];
|
||||
final int referenceValue = AbilityUtils.calculateAmount(host, comparator.substring(2), this);
|
||||
final Card triggered = (Card)runParams2.get("Card");
|
||||
final int actualValue = CardFactoryUtil.xCount((Card)triggered, host.getSVar(condition[0]));
|
||||
final int actualValue = CardFactoryUtil.xCount(triggered, host.getSVar(condition[0]));
|
||||
if (!Expressions.compare(actualValue, comparator.substring(0, 2), referenceValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TriggerHandler {
|
||||
private final List<TriggerWaiting> waitingTriggers = Collections.synchronizedList(new ArrayList<TriggerWaiting>());
|
||||
private final Game game;
|
||||
|
||||
public TriggerHandler(Game gameState) {
|
||||
public TriggerHandler(final Game gameState) {
|
||||
game = gameState;
|
||||
}
|
||||
|
||||
@@ -86,10 +86,10 @@ public class TriggerHandler {
|
||||
delayedTriggers.clear();
|
||||
}
|
||||
|
||||
public final void clearDelayedTrigger(Card card) {
|
||||
ArrayList<Trigger> deltrigs = new ArrayList<Trigger>(delayedTriggers);
|
||||
public final void clearDelayedTrigger(final Card card) {
|
||||
final List<Trigger> deltrigs = new ArrayList<Trigger>(delayedTriggers);
|
||||
|
||||
for (Trigger trigger : deltrigs) {
|
||||
for (final Trigger trigger : deltrigs) {
|
||||
if (trigger.getHostCard().equals(card)) {
|
||||
delayedTriggers.remove(trigger);
|
||||
}
|
||||
@@ -184,25 +184,25 @@ public class TriggerHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public final void clearInstrinsicActiveTriggers(Card c) {
|
||||
Iterator<?> itr = activeTriggers.iterator();
|
||||
public final void clearInstrinsicActiveTriggers(final Card c) {
|
||||
final Iterator<Trigger> itr = activeTriggers.iterator();
|
||||
Trigger t;
|
||||
ArrayList<Trigger> toBeRemoved = new ArrayList<>();
|
||||
final List<Trigger> toBeRemoved = new ArrayList<Trigger>();
|
||||
|
||||
while(itr.hasNext()) {
|
||||
t = (Trigger)itr.next();
|
||||
t = itr.next();
|
||||
if (c.getId() == t.getHostCard().getId() && t.isIntrinsic()) {
|
||||
toBeRemoved.add(t);
|
||||
}
|
||||
}
|
||||
|
||||
for (Trigger removed : toBeRemoved) {
|
||||
for (final Trigger removed : toBeRemoved) {
|
||||
activeTriggers.remove(removed);
|
||||
}
|
||||
}
|
||||
|
||||
public final void registerActiveTrigger(Card c, boolean onlyExtrinsic) {
|
||||
for (final Trigger t: c.getTriggers()) {
|
||||
public final void registerActiveTrigger(final Card c, final boolean onlyExtrinsic) {
|
||||
for (final Trigger t : c.getTriggers()) {
|
||||
if (!onlyExtrinsic || c.isCloned() || !t.isIntrinsic() || t instanceof TriggerAlways) {
|
||||
if (isTriggerActive(t)) {
|
||||
activeTriggers.add(t);
|
||||
@@ -241,21 +241,21 @@ public class TriggerHandler {
|
||||
}
|
||||
|
||||
public final boolean runWaitingTriggers() {
|
||||
ArrayList<TriggerWaiting> waiting = new ArrayList<TriggerWaiting>(waitingTriggers);
|
||||
final List<TriggerWaiting> waiting = new ArrayList<TriggerWaiting>(waitingTriggers);
|
||||
waitingTriggers.clear();
|
||||
if (waiting.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean haveWaiting = false;
|
||||
for (TriggerWaiting wt : waiting) {
|
||||
for (final TriggerWaiting wt : waiting) {
|
||||
haveWaiting |= runWaitingTrigger(wt);
|
||||
}
|
||||
|
||||
return haveWaiting;
|
||||
}
|
||||
|
||||
public final boolean runWaitingTrigger(TriggerWaiting wt) {
|
||||
public final boolean runWaitingTrigger(final TriggerWaiting wt) {
|
||||
final TriggerType mode = wt.getMode();
|
||||
final Map<String, Object> runParams = wt.getParams();
|
||||
|
||||
@@ -266,7 +266,7 @@ public class TriggerHandler {
|
||||
}
|
||||
|
||||
// Copy triggers here, so things can be modified just in case
|
||||
final ArrayList<Trigger> delayedTriggersWorkingCopy = new ArrayList<Trigger>(delayedTriggers);
|
||||
final List<Trigger> delayedTriggersWorkingCopy = new ArrayList<Trigger>(delayedTriggers);
|
||||
|
||||
boolean checkStatics = false;
|
||||
|
||||
@@ -280,7 +280,7 @@ public class TriggerHandler {
|
||||
|
||||
if (runParams.containsKey("Destination")) {
|
||||
// Check static abilities when a card enters the battlefield
|
||||
String type = (String) runParams.get("Destination");
|
||||
final String type = (String) runParams.get("Destination");
|
||||
checkStatics |= type.equals("Battlefield");
|
||||
}
|
||||
|
||||
@@ -288,16 +288,14 @@ public class TriggerHandler {
|
||||
checkStatics |= runNonStaticTriggersForPlayer(playerAP, mode, runParams, delayedTriggersWorkingCopy);
|
||||
|
||||
// NAPs
|
||||
for (Player nap : game.getPlayers()) {
|
||||
if (!nap.equals(playerAP)) {
|
||||
checkStatics |= runNonStaticTriggersForPlayer(nap, mode, runParams, delayedTriggersWorkingCopy);
|
||||
}
|
||||
for (final Player nap : game.getNonactivePlayers()) {
|
||||
checkStatics |= runNonStaticTriggersForPlayer(nap, mode, runParams, delayedTriggersWorkingCopy);
|
||||
}
|
||||
return checkStatics;
|
||||
}
|
||||
|
||||
private boolean runNonStaticTriggersForPlayer(final Player player, final TriggerType mode,
|
||||
final Map<String, Object> runParams, final ArrayList<Trigger> delayedTriggersWorkingCopy ) {
|
||||
final Map<String, Object> runParams, final List<Trigger> delayedTriggersWorkingCopy ) {
|
||||
|
||||
Card card = null;
|
||||
boolean checkStatics = false;
|
||||
@@ -319,7 +317,7 @@ public class TriggerHandler {
|
||||
}
|
||||
}
|
||||
|
||||
for (Trigger deltrig : delayedTriggersWorkingCopy) {
|
||||
for (final Trigger deltrig : delayedTriggersWorkingCopy) {
|
||||
if (deltrig.getHostCard().getController().equals(player)) {
|
||||
if (isTriggerActive(deltrig) && canRunTrigger(deltrig, mode, runParams)) {
|
||||
runSingleTrigger(deltrig, runParams);
|
||||
@@ -385,9 +383,9 @@ public class TriggerHandler {
|
||||
if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noCreatureETBTriggers)
|
||||
&& !regtrig.isStatic() && mode.equals(TriggerType.ChangesZone)) {
|
||||
if (runParams.get("Destination") instanceof String) {
|
||||
String dest = (String) runParams.get("Destination");
|
||||
final String dest = (String) runParams.get("Destination");
|
||||
if (dest.equals("Battlefield") && runParams.get("Card") instanceof Card) {
|
||||
Card card = (Card) runParams.get("Card");
|
||||
final Card card = (Card) runParams.get("Card");
|
||||
if (card.isCreature()) {
|
||||
return false;
|
||||
}
|
||||
@@ -415,7 +413,7 @@ public class TriggerHandler {
|
||||
|
||||
SpellAbility sa = null;
|
||||
Card host = regtrig.getHostCard();
|
||||
Card trigCard = regtrig.getRunParams().containsKey("Card") ? (Card)regtrig.getRunParams().get("Card") : null;
|
||||
final Card trigCard = regtrig.getRunParams().containsKey("Card") ? (Card)regtrig.getRunParams().get("Card") : null;
|
||||
|
||||
if (trigCard != null && (host.getId() == trigCard.getId())) {
|
||||
host = trigCard;
|
||||
@@ -493,7 +491,7 @@ public class TriggerHandler {
|
||||
}
|
||||
final boolean isMandatory = mand;
|
||||
|
||||
WrappedAbility wrapperAbility = new WrappedAbility(regtrig, sa, decider);
|
||||
final WrappedAbility wrapperAbility = new WrappedAbility(regtrig, sa, decider);
|
||||
wrapperAbility.setTrigger(true);
|
||||
wrapperAbility.setMandatory(isMandatory);
|
||||
wrapperAbility.setDescription(wrapperAbility.getStackDescription());
|
||||
@@ -505,7 +503,7 @@ public class TriggerHandler {
|
||||
game.getStack().addSimultaneousStackEntry(wrapperAbility);
|
||||
}
|
||||
regtrig.setTriggeredSA(wrapperAbility);
|
||||
|
||||
|
||||
if (triggerParams.containsKey("OneOff")) {
|
||||
if (regtrig.getHostCard().isImmutable()) {
|
||||
Player p = regtrig.getHostCard().getController();
|
||||
|
||||
@@ -20,9 +20,8 @@ package forge.game.trigger;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.util.FCollection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -56,7 +55,7 @@ public class TriggerVote extends Trigger {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final boolean performTest(final java.util.Map<String, Object> runParams2) {
|
||||
public final boolean performTest(final Map<String, Object> runParams2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,22 +63,20 @@ public class TriggerVote extends Trigger {
|
||||
@Override
|
||||
public final void setTriggeringObjects(final SpellAbility sa) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayListMultimap<Object, Player> votes = (ArrayListMultimap<Object, Player>) this.getRunParams().get("AllVotes");
|
||||
final ArrayListMultimap<Object, Player> votes = (ArrayListMultimap<Object, Player>) this.getRunParams().get("AllVotes");
|
||||
sa.setTriggeringObject("OtherVoters", getVoters(this.getHostCard().getController(), votes, true, true));
|
||||
}
|
||||
|
||||
private List<Player> getVoters(Player player, ArrayListMultimap<Object, Player> votes,
|
||||
boolean isOpponent, boolean votedOtherchoice) {
|
||||
List<Player> voters = new ArrayList<Player>();
|
||||
for (Object voteType : votes.keySet()) {
|
||||
List<Player> players = votes.get(voteType);
|
||||
private static FCollection<Player> getVoters(final Player player,
|
||||
final ArrayListMultimap<Object, Player> votes,
|
||||
final boolean isOpponent, final boolean votedOtherchoice) {
|
||||
final FCollection<Player> voters = new FCollection<Player>();
|
||||
for (final Object voteType : votes.keySet()) {
|
||||
final List<Player> players = votes.get(voteType);
|
||||
if (votedOtherchoice ^ players.contains(player)) {
|
||||
voters.addAll(players);
|
||||
}
|
||||
}
|
||||
HashSet<Player> set = new HashSet<Player>(voters);
|
||||
voters.clear();
|
||||
voters.addAll(set); // clear duplicated players, sometime a player votes more than once
|
||||
if (isOpponent) {
|
||||
voters.retainAll(player.getOpponents());
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.google.common.collect.Lists;
|
||||
// possible corner cases.
|
||||
// (The trigger can have a hardcoded OverridingAbility which can make
|
||||
// use of any of the methods)
|
||||
public class WrappedAbility extends Ability implements ISpellAbility {
|
||||
public class WrappedAbility extends Ability {
|
||||
|
||||
private final SpellAbility sa;
|
||||
private final Trigger regtrig;
|
||||
|
||||
@@ -54,7 +54,6 @@ import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* MagicStack class.
|
||||
@@ -784,7 +783,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
}
|
||||
}
|
||||
|
||||
private void execute(final List<GameCommand> c) {
|
||||
private static void execute(final List<GameCommand> c) {
|
||||
final int length = c.size();
|
||||
for (int i = 0; i < length; i++) {
|
||||
c.remove(0).run();
|
||||
|
||||
@@ -166,15 +166,15 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
return getCardsAdded(cardsAddedLastTurn, origin);
|
||||
}
|
||||
|
||||
private final CardCollectionView getCardsAdded(final MapOfLists<ZoneType, Card> cardsAdded, final ZoneType origin) {
|
||||
private static CardCollectionView getCardsAdded(final MapOfLists<ZoneType, Card> cardsAdded, final ZoneType origin) {
|
||||
if (origin != null) {
|
||||
Collection<Card> cards = cardsAdded.get(origin);
|
||||
final Collection<Card> cards = cardsAdded.get(origin);
|
||||
return cards == null ? CardCollection.EMPTY : new CardCollection(cards);
|
||||
}
|
||||
|
||||
// all cards if key == null
|
||||
final CardCollection ret = new CardCollection();
|
||||
for (Collection<Card> kv : cardsAdded.values()) {
|
||||
for (final Collection<Card> kv : cardsAdded.values()) {
|
||||
ret.addAll(kv);
|
||||
}
|
||||
return ret;
|
||||
@@ -182,7 +182,7 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
|
||||
public final void resetCardsAddedThisTurn() {
|
||||
cardsAddedLastTurn.clear();
|
||||
for (Entry<ZoneType, Collection<Card>> entry : cardsAddedThisTurn.entrySet()) {
|
||||
for (final Entry<ZoneType, Collection<Card>> entry : cardsAddedThisTurn.entrySet()) {
|
||||
cardsAddedLastTurn.addAll(entry.getKey(), entry.getValue());
|
||||
}
|
||||
cardsAddedThisTurn.clear();
|
||||
|
||||
Reference in New Issue
Block a user