mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Merge branch 'master' into 'start_trigger_run_params_refactor'
# Conflicts: # forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/GameWrapper.java
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>forge</artifactId>
|
||||
<groupId>forge</groupId>
|
||||
<version>1.6.28-SNAPSHOT</version>
|
||||
<version>1.6.29-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>forge-game</artifactId>
|
||||
|
||||
@@ -27,7 +27,7 @@ package forge;
|
||||
*/
|
||||
public interface GameCommand extends java.io.Serializable, Runnable {
|
||||
/** Constant <code>Blank</code>. */
|
||||
public final GameCommand BLANK = new GameCommand() {
|
||||
GameCommand BLANK = new GameCommand() {
|
||||
|
||||
private static final long serialVersionUID = 2689172297036001710L;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.game;
|
||||
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaAtom;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
@@ -16,6 +17,8 @@ import forge.util.Expressions;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
@@ -159,9 +162,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView {
|
||||
*/
|
||||
public final boolean isSecondary() {
|
||||
if (this.mapParams.containsKey("Secondary")) {
|
||||
if (this.mapParams.get("Secondary").equals("True")) {
|
||||
return true;
|
||||
}
|
||||
return this.mapParams.get("Secondary").equals("True");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -252,6 +253,16 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView {
|
||||
if (params.containsKey("Blessing")) {
|
||||
if ("True".equalsIgnoreCase(params.get("Blessing")) != hostController.hasBlessing()) return false;
|
||||
}
|
||||
|
||||
if (params.containsKey("Adamant")) {
|
||||
if (hostCard.getCastSA() == null) {
|
||||
return false;
|
||||
}
|
||||
final String payingMana = StringUtils.join(hostCard.getCastSA().getPayingMana());
|
||||
if (StringUtils.countMatches(payingMana, MagicColor.toShortString(params.get("Adamant"))) < 3) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("Presence")) {
|
||||
if (hostCard.getCastFrom() == null || hostCard.getCastSA() == null)
|
||||
@@ -451,9 +462,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView {
|
||||
|
||||
if (params.containsKey("ActivateNoLoyaltyAbilitiesCondition")) {
|
||||
final Player active = game.getPhaseHandler().getPlayerTurn();
|
||||
if (active.getActivateLoyaltyAbilityThisTurn()) {
|
||||
return false;
|
||||
}
|
||||
return !active.getActivateLoyaltyAbilityThisTurn();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ public class ForgeScript {
|
||||
|
||||
int desiredColor = MagicColor.fromName(colorName);
|
||||
boolean hasColor = colors.hasAnyColor(desiredColor);
|
||||
if (mustHave != hasColor)
|
||||
return false;
|
||||
return mustHave == hasColor;
|
||||
|
||||
} else if (property.contains("Colorless")) { // ... Card is colorless
|
||||
boolean non = property.startsWith("non");
|
||||
@@ -38,66 +37,48 @@ public class ForgeScript {
|
||||
if (non && withSource && isColorlessSource) {
|
||||
return false;
|
||||
}
|
||||
if (non == colors.isColorless()) return false;
|
||||
return non != colors.isColorless();
|
||||
|
||||
} else if (property.contains("MultiColor")) {
|
||||
// ... Card is multicolored
|
||||
if (property.endsWith("Source") && isColorlessSource)
|
||||
return false;
|
||||
if (property.startsWith("non") == colors.isMulticolor())
|
||||
return false;
|
||||
return property.startsWith("non") != colors.isMulticolor();
|
||||
|
||||
} else if (property.contains("MonoColor")) { // ... Card is monocolored
|
||||
if (property.endsWith("Source") && isColorlessSource)
|
||||
return false;
|
||||
if (property.startsWith("non") == colors.isMonoColor())
|
||||
return false;
|
||||
return property.startsWith("non") != colors.isMonoColor();
|
||||
|
||||
} else if (property.startsWith("ChosenColor")) {
|
||||
if (property.endsWith("Source") && isColorlessSource)
|
||||
return false;
|
||||
if (!source.hasChosenColor() || !colors.hasAnyColor(MagicColor.fromName(source.getChosenColor())))
|
||||
return false;
|
||||
return source.hasChosenColor() && colors.hasAnyColor(MagicColor.fromName(source.getChosenColor()));
|
||||
|
||||
} else if (property.startsWith("AnyChosenColor")) {
|
||||
if (property.endsWith("Source") && isColorlessSource)
|
||||
return false;
|
||||
if (!source.hasChosenColor()
|
||||
|| !colors.hasAnyColor(ColorSet.fromNames(source.getChosenColors()).getColor()))
|
||||
return false;
|
||||
return source.hasChosenColor()
|
||||
&& colors.hasAnyColor(ColorSet.fromNames(source.getChosenColors()).getColor());
|
||||
|
||||
} else if (property.startsWith("non")) {
|
||||
// ... Other Card types
|
||||
if (cardState.getTypeWithChanges().hasStringType(property.substring(3))) {
|
||||
return false;
|
||||
}
|
||||
return !cardState.getTypeWithChanges().hasStringType(property.substring(3));
|
||||
} else if (property.equals("CostsPhyrexianMana")) {
|
||||
if (!cardState.getManaCost().hasPhyrexian()) {
|
||||
return false;
|
||||
}
|
||||
return cardState.getManaCost().hasPhyrexian();
|
||||
} else if (property.startsWith("HasSVar")) {
|
||||
final String svar = property.substring(8);
|
||||
if (!cardState.hasSVar(svar)) {
|
||||
return false;
|
||||
}
|
||||
return cardState.hasSVar(svar);
|
||||
} else if (property.equals("ChosenType")) {
|
||||
if (!cardState.getTypeWithChanges().hasStringType(source.getChosenType())) {
|
||||
return false;
|
||||
}
|
||||
return cardState.getTypeWithChanges().hasStringType(source.getChosenType());
|
||||
} else if (property.equals("IsNotChosenType")) {
|
||||
if (cardState.getTypeWithChanges().hasStringType(source.getChosenType())) {
|
||||
return false;
|
||||
}
|
||||
return !cardState.getTypeWithChanges().hasStringType(source.getChosenType());
|
||||
} else if (property.startsWith("HasSubtype")) {
|
||||
final String subType = property.substring(11);
|
||||
if (!cardState.getTypeWithChanges().hasSubtype(subType)) {
|
||||
return false;
|
||||
}
|
||||
return cardState.getTypeWithChanges().hasSubtype(subType);
|
||||
} else if (property.startsWith("HasNoSubtype")) {
|
||||
final String subType = property.substring(13);
|
||||
if (cardState.getTypeWithChanges().hasSubtype(subType)) {
|
||||
return false;
|
||||
}
|
||||
return !cardState.getTypeWithChanges().hasSubtype(subType);
|
||||
} else if (property.equals("hasActivatedAbilityWithTapCost")) {
|
||||
for (final SpellAbility sa : cardState.getSpellAbilities()) {
|
||||
if (sa.isAbility() && (sa.getPayCosts() != null) && sa.getPayCosts().hasTapCost()) {
|
||||
@@ -136,80 +117,47 @@ public class ForgeScript {
|
||||
x = AbilityUtils.calculateAmount(source, rhs, spellAbility);
|
||||
}
|
||||
|
||||
if (!Expressions.compare(y, property, x)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!cardState.getTypeWithChanges().hasStringType(property)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
return Expressions.compare(y, property, x);
|
||||
} else return cardState.getTypeWithChanges().hasStringType(property);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static boolean spellAbilityHasProperty(SpellAbility sa, String property, Player sourceController,
|
||||
Card source, SpellAbility spellAbility) {
|
||||
if (property.equals("ManaAbility")) {
|
||||
if (!sa.isManaAbility()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isManaAbility();
|
||||
} else if (property.equals("nonManaAbility")) {
|
||||
if (sa.isManaAbility()) {
|
||||
return false;
|
||||
}
|
||||
return !sa.isManaAbility();
|
||||
} else if (property.equals("Buyback")) {
|
||||
if (!sa.isBuyBackAbility()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isBuyBackAbility();
|
||||
} else if (property.equals("Cycling")) {
|
||||
if (!sa.isCycling()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isCycling();
|
||||
} else if (property.equals("Dash")) {
|
||||
if (!sa.isDash()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isDash();
|
||||
} else if (property.equals("Flashback")) {
|
||||
if (!sa.isFlashBackAbility()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isFlashBackAbility();
|
||||
} else if (property.equals("Jumpstart")) {
|
||||
if (!sa.isJumpstart()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isJumpstart();
|
||||
} else if (property.equals("Kicked")) {
|
||||
if (!sa.isKicked()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isKicked();
|
||||
} else if (property.equals("Loyalty")) {
|
||||
if (!sa.isPwAbility()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isPwAbility();
|
||||
} else if (property.equals("Aftermath")) {
|
||||
if (!sa.isAftermath()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isAftermath();
|
||||
} else if (property.equals("MorphUp")) {
|
||||
if (!sa.isMorphUp()) {
|
||||
return false;
|
||||
}
|
||||
return sa.isMorphUp();
|
||||
} else if (property.equals("Equip")) {
|
||||
if (!sa.hasParam("Equip")) {
|
||||
return false;
|
||||
}
|
||||
return sa.hasParam("Equip");
|
||||
} else if (property.equals("MayPlaySource")) {
|
||||
StaticAbility m = sa.getMayPlay();
|
||||
if (m == null) {
|
||||
return false;
|
||||
}
|
||||
if (!source.equals(m.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
return source.equals(m.getHostCard());
|
||||
} else if (property.startsWith("IsTargeting")) {
|
||||
String k[] = property.split(" ", 2);
|
||||
String[] k = property.split(" ", 2);
|
||||
boolean found = false;
|
||||
for (GameObject o : AbilityUtils.getDefinedObjects(source, k[1], spellAbility)) {
|
||||
if (sa.isTargeting(o)) {
|
||||
@@ -217,15 +165,11 @@ public class ForgeScript {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
return found;
|
||||
} else if (property.equals("YouCtrl")) {
|
||||
return sa.getActivatingPlayer().equals(sourceController);
|
||||
} else if (sa.getHostCard() != null) {
|
||||
if (!sa.getHostCard().hasProperty(property, sourceController, source, spellAbility)) {
|
||||
return false;
|
||||
}
|
||||
return sa.getHostCard().hasProperty(property, sourceController, source, spellAbility);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -713,7 +713,7 @@ public class Game {
|
||||
ingamePlayers.remove(p);
|
||||
lostPlayers.add(p);
|
||||
|
||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||
final Map<String, Object> runParams = new TreeMap<>();
|
||||
runParams.put("Player", p);
|
||||
getTriggerHandler().runTriggerOld(TriggerType.LosesGame, runParams, false);
|
||||
}
|
||||
@@ -845,7 +845,7 @@ public class Game {
|
||||
}
|
||||
}
|
||||
|
||||
library.removeAll((Collection<?>)toRemove);
|
||||
library.removeAll(toRemove);
|
||||
|
||||
if (library.size() > 0) { //Make sure that matches were found. If not, use the original method to choose antes
|
||||
Card ante = library.get(MyRandom.getRandom().nextInt(library.size()));
|
||||
|
||||
@@ -763,7 +763,7 @@ public class GameAction {
|
||||
checkStaticAbilities(true);
|
||||
}
|
||||
public final void checkStaticAbilities(final boolean runEvents) {
|
||||
checkStaticAbilities(runEvents, Sets.<Card>newHashSet(), CardCollection.EMPTY);
|
||||
checkStaticAbilities(runEvents, Sets.newHashSet(), CardCollection.EMPTY);
|
||||
}
|
||||
public final void checkStaticAbilities(final boolean runEvents, final Set<Card> affectedCards, final CardCollectionView preList) {
|
||||
if (isCheckingStaticAbilitiesOnHold()) {
|
||||
@@ -787,7 +787,7 @@ public class GameAction {
|
||||
}
|
||||
|
||||
// search for cards with static abilities
|
||||
final FCollection<StaticAbility> staticAbilities = new FCollection<StaticAbility>();
|
||||
final FCollection<StaticAbility> staticAbilities = new FCollection<>();
|
||||
final CardCollection staticList = new CardCollection();
|
||||
|
||||
game.forEachCardInGame(new Visitor<Card>() {
|
||||
@@ -880,6 +880,10 @@ public class GameAction {
|
||||
c.getStaticCommandList().removeAll(toRemove);
|
||||
}
|
||||
// Exclude cards in hidden zones from update
|
||||
/*
|
||||
* Refactoring this code to affectedCards.removeIf((Card c) -> c.isInZone(ZoneType.Library));
|
||||
* causes Android build not to compile
|
||||
* */
|
||||
Iterator<Card> it = affectedCards.iterator();
|
||||
while (it.hasNext()) {
|
||||
Card c = it.next();
|
||||
@@ -929,7 +933,7 @@ public class GameAction {
|
||||
}
|
||||
|
||||
public final void checkStateEffects(final boolean runEvents) {
|
||||
checkStateEffects(runEvents, Sets.<Card>newHashSet());
|
||||
checkStateEffects(runEvents, Sets.newHashSet());
|
||||
}
|
||||
public final void checkStateEffects(final boolean runEvents, final Set<Card> affectedCards) {
|
||||
// sol(10/29) added for Phase updates, state effects shouldn't be
|
||||
|
||||
@@ -234,7 +234,7 @@ public final class GameActionUtil {
|
||||
|
||||
// there is a flashback cost (and not the cards cost)
|
||||
if (keyword.contains(":")) {
|
||||
final String k[] = keyword.split(":");
|
||||
final String[] k = keyword.split(":");
|
||||
flashback.setPayCosts(new Cost(k[1], false));
|
||||
}
|
||||
alternatives.add(flashback);
|
||||
|
||||
@@ -407,11 +407,7 @@ public abstract class GameEntity extends GameObject implements IIdentifiable {
|
||||
}
|
||||
|
||||
// true for all
|
||||
if (hasProtectionFrom(attach, checkSBA)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !hasProtectionFrom(attach, checkSBA);
|
||||
}
|
||||
|
||||
protected boolean canBeEquippedBy(final Card aura) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
import forge.trackable.TrackableObject;
|
||||
|
||||
public class GameEntityCache<Entity extends IIdentifiable, View extends TrackableObject> {
|
||||
private HashMap<Integer, Entity> entityCache = new HashMap<Integer, Entity>();
|
||||
private HashMap<Integer, Entity> entityCache = new HashMap<>();
|
||||
|
||||
public void put(Integer id, Entity entity) {
|
||||
entityCache.put(id, entity);
|
||||
@@ -33,7 +33,7 @@ public class GameEntityCache<Entity extends IIdentifiable, View extends Trackabl
|
||||
}
|
||||
|
||||
public List<Entity> getList(Iterable<View> views) {
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
List<Entity> list = new ArrayList<>();
|
||||
addToList(views, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class GameEntityView extends TrackableObject {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
TrackableCollection<GameEntityView> collection = new TrackableCollection<GameEntityView>();
|
||||
TrackableCollection<GameEntityView> collection = new TrackableCollection<>();
|
||||
for (GameEntity e : entities) {
|
||||
collection.add(e.getView());
|
||||
}
|
||||
|
||||
@@ -101,14 +101,14 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
allowedSetCodes = Lists.newArrayList(parsedSets);
|
||||
}else{
|
||||
allowedSetCodes = new ArrayList<String>();
|
||||
allowedSetCodes = new ArrayList<>();
|
||||
}
|
||||
|
||||
bannedCardNames = bannedCards == null ? new ArrayList<String>() : Lists.newArrayList(bannedCards);
|
||||
restrictedCardNames = restrictedCards == null ? new ArrayList<String>() : Lists.newArrayList(restrictedCards);
|
||||
allowedRarities = rarities == null ? new ArrayList<CardRarity>() : rarities;
|
||||
bannedCardNames = bannedCards == null ? new ArrayList<>() : Lists.newArrayList(bannedCards);
|
||||
restrictedCardNames = restrictedCards == null ? new ArrayList<>() : Lists.newArrayList(restrictedCards);
|
||||
allowedRarities = rarities == null ? new ArrayList<>() : rarities;
|
||||
this.restrictedLegendary = restrictedLegendary;
|
||||
additionalCardNames = additionalCards == null ? new ArrayList<String>() : Lists.newArrayList(additionalCards);
|
||||
additionalCardNames = additionalCards == null ? new ArrayList<>() : Lists.newArrayList(additionalCards);
|
||||
|
||||
this.allowedSetCodes_ro = Collections.unmodifiableList(allowedSetCodes);
|
||||
this.bannedCardNames_ro = Collections.unmodifiableList(bannedCardNames);
|
||||
@@ -195,7 +195,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public List<PaperCard> getAllCards() {
|
||||
List<PaperCard> cards = new ArrayList<PaperCard>();
|
||||
List<PaperCard> cards = new ArrayList<>();
|
||||
CardDb commonCards = StaticData.instance().getCommonCards();
|
||||
for (String setCode : allowedSetCodes_ro) {
|
||||
CardEdition edition = StaticData.instance().getEditions().get(setCode);
|
||||
@@ -285,7 +285,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public static class Reader extends StorageReaderRecursiveFolderWithUserFolder<GameFormat> {
|
||||
List<GameFormat> naturallyOrdered = new ArrayList<GameFormat>();
|
||||
List<GameFormat> naturallyOrdered = new ArrayList<>();
|
||||
boolean includeHistoric;
|
||||
private List<String> coreFormats = new ArrayList<>();
|
||||
{
|
||||
@@ -368,7 +368,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
if ( strCars != null ) {
|
||||
CardRarity cr;
|
||||
rarities = Lists.newArrayList();
|
||||
for (String s: Arrays.asList(strCars.split(", "))) {
|
||||
for (String s: strCars.split(", ")) {
|
||||
cr = CardRarity.smartValueOf(s);
|
||||
if (!cr.name().equals("Unknown")) {
|
||||
rarities.add(cr);
|
||||
@@ -403,6 +403,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
naturallyOrdered = reader.naturallyOrdered;
|
||||
reverseDateOrdered = new ArrayList<>(naturallyOrdered);
|
||||
Collections.sort(naturallyOrdered);
|
||||
//Why this refactor doesnt work on some android phones? -> reverseDateOrdered.sort(new InverseDateComparator());
|
||||
Collections.sort(reverseDateOrdered, new InverseDateComparator());
|
||||
}
|
||||
|
||||
@@ -484,7 +485,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public Set<GameFormat> getAllFormatsOfCard(PaperCard card) {
|
||||
Set<GameFormat> result = new HashSet<GameFormat>();
|
||||
Set<GameFormat> result = new HashSet<>();
|
||||
for (GameFormat gf : naturallyOrdered) {
|
||||
if (gf.getFilterRules().apply(card)) {
|
||||
result.add(gf);
|
||||
@@ -501,7 +502,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public Set<GameFormat> getAllFormatsOfDeck(Deck deck, Boolean exhaustive) {
|
||||
SortedSet<GameFormat> result = new TreeSet<GameFormat>();
|
||||
SortedSet<GameFormat> result = new TreeSet<>();
|
||||
Set<FormatSubType> coveredTypes = new HashSet<>();
|
||||
CardPool allCards = deck.getAllCardsInASinglePool();
|
||||
for(GameFormat gf : reverseDateOrdered) {
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.Observable;
|
||||
public class GameLog extends Observable implements Serializable {
|
||||
private static final long serialVersionUID = 6465283802022948827L;
|
||||
|
||||
private final List<GameLogEntry> log = new ArrayList<GameLogEntry>();
|
||||
private final List<GameLogEntry> log = new ArrayList<>();
|
||||
|
||||
private final transient GameLogFormatter formatter = new GameLogFormatter(this);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class GameLog extends Observable implements Serializable {
|
||||
* @return the log text
|
||||
*/
|
||||
public List<GameLogEntry> getLogEntries(final GameLogEntryType logLevel) { // null to fetch all
|
||||
final List<GameLogEntry> result = new ArrayList<GameLogEntry>();
|
||||
final List<GameLogEntry> result = new ArrayList<>();
|
||||
|
||||
for (int i = log.size() - 1; i >= 0; i--) {
|
||||
GameLogEntry le = log.get(i);
|
||||
@@ -82,7 +82,7 @@ public class GameLog extends Observable implements Serializable {
|
||||
}
|
||||
|
||||
public List<GameLogEntry> getLogEntriesExact(final GameLogEntryType logLevel) { // null to fetch all
|
||||
final List<GameLogEntry> result = new ArrayList<GameLogEntry>();
|
||||
final List<GameLogEntry> result = new ArrayList<>();
|
||||
|
||||
for (int i = log.size() - 1; i >= 0; i--) {
|
||||
GameLogEntry le = log.get(i);
|
||||
|
||||
@@ -20,7 +20,7 @@ public enum GameLogEntryType {
|
||||
PHASE("Phase");
|
||||
|
||||
private final String caption;
|
||||
private GameLogEntryType(String name) {
|
||||
GameLogEntryType(String name) {
|
||||
this.caption = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
private static GameLogEntry generateSummary(final List<GameOutcome> gamesPlayed) {
|
||||
final GameOutcome outcome1 = gamesPlayed.get(0);
|
||||
final HashMap<RegisteredPlayer, String> players = outcome1.getPlayerNames();
|
||||
final HashMap<RegisteredPlayer, Integer> winCount = new HashMap<RegisteredPlayer, Integer>();
|
||||
final HashMap<RegisteredPlayer, Integer> winCount = new HashMap<>();
|
||||
|
||||
// Calculate total games each player has won.
|
||||
for (final GameOutcome game : gamesPlayed) {
|
||||
@@ -182,7 +182,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
if (event.type == DamageType.LoyaltyLoss) {
|
||||
additionalLog = " (Removing " + Lang.nounWithAmount(event.amount, "loyalty counter") + ")";
|
||||
}
|
||||
String message = event.source.toString() + " deals " + String.valueOf(event.amount) + " damage" + additionalLog + " to " + event.card.toString() + ".";
|
||||
String message = event.source.toString() + " deals " + event.amount + " damage" + additionalLog + " to " + event.card.toString() + ".";
|
||||
return new GameLogEntry(GameLogEntryType.DAMAGE, message);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
|
||||
@Override
|
||||
public GameLogEntry visit(GameEventTurnBegan event) {
|
||||
String message = "Turn " + String.valueOf(event.turnNumber) + " (" + event.turnOwner.toString() + ")";
|
||||
String message = "Turn " + event.turnNumber + " (" + event.turnOwner.toString() + ")";
|
||||
return new GameLogEntry(GameLogEntryType.TURN, message);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
public GameLogEntry visit(GameEventPlayerDamaged ev) {
|
||||
String extra = ev.infect ? " (as poison counters)" : "";
|
||||
String damageType = ev.combat ? "combat" : "non-combat";
|
||||
String message = ev.source.toString() + " deals " + String.valueOf(ev.amount) + " " + damageType + " damage to " + ev.target.toString() + extra + ".";
|
||||
String message = ev.source.toString() + " deals " + ev.amount + " " + damageType + " damage to " + ev.target.toString() + extra + ".";
|
||||
return new GameLogEntry(GameLogEntryType.DAMAGE, message);
|
||||
}
|
||||
|
||||
@@ -229,11 +229,11 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
continue;
|
||||
}
|
||||
if (sb.length() > 0) sb.append("\n");
|
||||
sb.append(ev.player + " assigned " + Lang.joinHomogenous(attackers));
|
||||
sb.append(" to attack " + k + ".");
|
||||
sb.append(ev.player).append(" assigned ").append(Lang.joinHomogenous(attackers));
|
||||
sb.append(" to attack ").append(k).append(".");
|
||||
}
|
||||
if (sb.length() == 0) {
|
||||
sb.append(ev.player + " didn't attack this turn.");
|
||||
sb.append(ev.player).append(" didn't attack this turn.");
|
||||
}
|
||||
return new GameLogEntry(GameLogEntryType.COMBAT, sb.toString());
|
||||
}
|
||||
@@ -265,10 +265,10 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
|
||||
blockers = att.getValue();
|
||||
if (blockers.isEmpty()) {
|
||||
sb.append(controllerName + " didn't block ");
|
||||
sb.append(controllerName).append(" didn't block ");
|
||||
}
|
||||
else {
|
||||
sb.append(controllerName + " assigned " + Lang.joinHomogenous(blockers) + " to block ");
|
||||
sb.append(controllerName).append(" assigned ").append(Lang.joinHomogenous(blockers)).append(" to block ");
|
||||
}
|
||||
|
||||
sb.append(att.getKey()).append(".");
|
||||
@@ -281,7 +281,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
|
||||
@Override
|
||||
public GameLogEntry visit(GameEventMulligan ev) {
|
||||
String message = ev.player.toString() + " has mulliganed down to " + String.valueOf(ev.player.getZone(ZoneType.Hand).size()) + " cards.";
|
||||
String message = ev.player.toString() + " has mulliganed down to " + ev.player.getZone(ZoneType.Hand).size() + " cards.";
|
||||
return new GameLogEntry(GameLogEntryType.MULLIGAN, message);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public abstract class GameObjectMap {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends GameObject> List<T> mapList(final List<T> objects) {
|
||||
final List<T> result = new ArrayList<T>();
|
||||
final List<T> result = new ArrayList<>();
|
||||
for (final T o : objects) {
|
||||
result.add((T) map(o));
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ public enum GameStage {
|
||||
Mulligan,
|
||||
Play,
|
||||
RestartedByKarn,
|
||||
GameOver;
|
||||
GameOver
|
||||
}
|
||||
@@ -71,11 +71,11 @@ public enum GameType {
|
||||
private final String name, description;
|
||||
private final Function<RegisteredPlayer, Deck> deckAutoGenerator;
|
||||
|
||||
private GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0) {
|
||||
GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0) {
|
||||
|
||||
this(deckFormat0, isCardPoolLimited0, canSideboard0, addWonCardsMidgame0, name0, description0, null);
|
||||
}
|
||||
private GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0, Function<RegisteredPlayer, Deck> deckAutoGenerator0) {
|
||||
GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0, Function<RegisteredPlayer, Deck> deckAutoGenerator0) {
|
||||
final Localizer localizer = forge.util.Localizer.getInstance();
|
||||
deckFormat = deckFormat0;
|
||||
isCardPoolLimited = isCardPoolLimited0;
|
||||
|
||||
@@ -40,7 +40,7 @@ public enum GlobalRuleChange {
|
||||
|
||||
private final String ruleText;
|
||||
|
||||
private GlobalRuleChange(String text) {
|
||||
GlobalRuleChange(String text) {
|
||||
ruleText = text;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package forge.game;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public interface IIdentifiable {
|
||||
public abstract int getId();
|
||||
public static final Function<IIdentifiable, Integer> FN_GET_ID = new Function<IIdentifiable, Integer>() {
|
||||
int getId();
|
||||
Function<IIdentifiable, Integer> FN_GET_ID = new Function<IIdentifiable, Integer>() {
|
||||
@Override
|
||||
public Integer apply(final IIdentifiable input) {
|
||||
return Integer.valueOf(input.getId());
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Match {
|
||||
private final GameRules rules;
|
||||
private final String title;
|
||||
|
||||
private final List<GameOutcome> gamesPlayed = new ArrayList<GameOutcome>();
|
||||
private final List<GameOutcome> gamesPlayed = new ArrayList<>();
|
||||
private final List<GameOutcome> gamesPlayedRo;
|
||||
|
||||
public Match(final GameRules rules0, final List<RegisteredPlayer> players0, final String title) {
|
||||
@@ -171,7 +171,7 @@ public class Match {
|
||||
|
||||
private static Set<PaperCard> getRemovedAnteCards(Deck toUse) {
|
||||
final String keywordToRemove = "Remove CARDNAME from your deck before playing if you're not playing for ante.";
|
||||
Set<PaperCard> myRemovedAnteCards = new HashSet<PaperCard>();
|
||||
Set<PaperCard> myRemovedAnteCards = new HashSet<>();
|
||||
for (Entry<DeckSection, CardPool> ds : toUse) {
|
||||
for (Entry<PaperCard, Integer> cp : ds.getValue()) {
|
||||
if (Iterables.contains(cp.getKey().getRules().getMainPart().getKeywords(), keywordToRemove)) {
|
||||
@@ -184,7 +184,7 @@ public class Match {
|
||||
|
||||
private static void preparePlayerLibrary(Player player, final ZoneType zoneType, CardPool section, boolean canRandomFoil) {
|
||||
PlayerZone library = player.getZone(zoneType);
|
||||
List<Card> newLibrary = new ArrayList<Card>();
|
||||
List<Card> newLibrary = new ArrayList<>();
|
||||
for (final Entry<PaperCard, Integer> stackOfCards : section) {
|
||||
final PaperCard cp = stackOfCards.getKey();
|
||||
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
||||
@@ -304,7 +304,7 @@ public class Match {
|
||||
GameOutcome outcome = lastGame.getOutcome();
|
||||
|
||||
// remove all the lost cards from owners' decks
|
||||
List<PaperCard> losses = new ArrayList<PaperCard>();
|
||||
List<PaperCard> losses = new ArrayList<>();
|
||||
int cntPlayers = players.size();
|
||||
int iWinner = -1;
|
||||
for (int i = 0; i < cntPlayers; i++) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public enum PlanarDice {
|
||||
trigRes = Chaos;
|
||||
}
|
||||
|
||||
HashMap<String,Object> runParams = new HashMap<String,Object>();
|
||||
HashMap<String,Object> runParams = new HashMap<>();
|
||||
runParams.put("Player", roller);
|
||||
runParams.put("Result", trigRes);
|
||||
roller.getGame().getTriggerHandler().runTriggerOld(TriggerType.PlanarDice, runParams,false);
|
||||
|
||||
@@ -47,13 +47,9 @@ public class StaticEffect {
|
||||
|
||||
private final Card source;
|
||||
private StaticAbility ability;
|
||||
private int keywordNumber = 0;
|
||||
private CardCollectionView affectedCards = new CardCollection();
|
||||
private List<Player> affectedPlayers = Lists.newArrayList();
|
||||
private int xValue = 0;
|
||||
private int yValue = 0;
|
||||
private long timestamp = -1;
|
||||
private Map<Card, Integer> xValueMap = Maps.newTreeMap();
|
||||
|
||||
private String chosenType;
|
||||
private Map<String, String> mapParams = Maps.newTreeMap();
|
||||
@@ -89,13 +85,9 @@ public class StaticEffect {
|
||||
private StaticEffect makeMappedCopy(GameObjectMap map) {
|
||||
StaticEffect copy = new StaticEffect(map.map(this.source));
|
||||
copy.ability = this.ability;
|
||||
copy.keywordNumber = this.keywordNumber;
|
||||
copy.affectedCards = map.mapCollection(this.affectedCards);
|
||||
copy.affectedPlayers = map.mapList(this.affectedPlayers);
|
||||
copy.xValue = this.xValue;
|
||||
copy.yValue = this.yValue;
|
||||
copy.timestamp = this.timestamp;
|
||||
copy.xValueMap = this.xValueMap;
|
||||
copy.chosenType = this.chosenType;
|
||||
copy.mapParams = this.mapParams;
|
||||
copy.overwriteTypes = this.overwriteTypes;
|
||||
@@ -168,7 +160,7 @@ public class StaticEffect {
|
||||
*/
|
||||
public final void addOriginalAbilities(final Card c, final SpellAbility sa) {
|
||||
if (!this.originalAbilities.containsKey(c)) {
|
||||
final List<SpellAbility> list = new ArrayList<SpellAbility>();
|
||||
final List<SpellAbility> list = new ArrayList<>();
|
||||
list.add(sa);
|
||||
this.originalAbilities.put(c, list);
|
||||
} else {
|
||||
@@ -187,7 +179,7 @@ public class StaticEffect {
|
||||
* a {@link java.util.List} object.
|
||||
*/
|
||||
public final void addOriginalAbilities(final Card c, final List<SpellAbility> s) {
|
||||
final List<SpellAbility> list = new ArrayList<SpellAbility>(s);
|
||||
final List<SpellAbility> list = new ArrayList<>(s);
|
||||
if (!this.originalAbilities.containsKey(c)) {
|
||||
this.originalAbilities.put(c, list);
|
||||
} else {
|
||||
@@ -206,7 +198,7 @@ public class StaticEffect {
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public final List<SpellAbility> getOriginalAbilities(final Card c) {
|
||||
final List<SpellAbility> returnList = new ArrayList<SpellAbility>();
|
||||
final List<SpellAbility> returnList = new ArrayList<>();
|
||||
if (this.originalAbilities.containsKey(c)) {
|
||||
returnList.addAll(this.originalAbilities.get(c));
|
||||
}
|
||||
@@ -273,7 +265,7 @@ public class StaticEffect {
|
||||
*/
|
||||
public final void addOriginalKeyword(final Card c, final String s) {
|
||||
if (!this.originalKeywords.containsKey(c)) {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(s);
|
||||
this.originalKeywords.put(c, list);
|
||||
} else {
|
||||
@@ -292,7 +284,7 @@ public class StaticEffect {
|
||||
* a {@link List} object.
|
||||
*/
|
||||
public final void addOriginalKeywords(final Card c, final List<String> s) {
|
||||
final List<String> list = new ArrayList<String>(s);
|
||||
final List<String> list = new ArrayList<>(s);
|
||||
if (!this.originalKeywords.containsKey(c)) {
|
||||
this.originalKeywords.put(c, list);
|
||||
} else {
|
||||
@@ -311,7 +303,7 @@ public class StaticEffect {
|
||||
* @return a {@link List} object.
|
||||
*/
|
||||
public final List<String> getOriginalKeywords(final Card c) {
|
||||
final List<String> returnList = new ArrayList<String>();
|
||||
final List<String> returnList = new ArrayList<>();
|
||||
if (this.originalKeywords.containsKey(c)) {
|
||||
returnList.addAll(this.originalKeywords.get(c));
|
||||
}
|
||||
@@ -426,7 +418,7 @@ public class StaticEffect {
|
||||
*/
|
||||
public final void addOriginalType(final Card c, final String s) {
|
||||
if (!this.originalTypes.containsKey(c)) {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(s);
|
||||
this.originalTypes.put(c, list);
|
||||
} else {
|
||||
@@ -445,7 +437,7 @@ public class StaticEffect {
|
||||
* a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final void addOriginalTypes(final Card c, final List<String> s) {
|
||||
final List<String> list = new ArrayList<String>(s);
|
||||
final List<String> list = new ArrayList<>(s);
|
||||
if (!this.originalTypes.containsKey(c)) {
|
||||
this.originalTypes.put(c, list);
|
||||
} else {
|
||||
@@ -464,7 +456,7 @@ public class StaticEffect {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final List<String> getOriginalTypes(final Card c) {
|
||||
final List<String> returnList = new ArrayList<String>();
|
||||
final List<String> returnList = new ArrayList<>();
|
||||
if (this.originalTypes.containsKey(c)) {
|
||||
returnList.addAll(this.originalTypes.get(c));
|
||||
}
|
||||
@@ -507,7 +499,7 @@ public class StaticEffect {
|
||||
*/
|
||||
public final void addType(final Card c, final String s) {
|
||||
if (!this.types.containsKey(c)) {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(s);
|
||||
this.types.put(c, list);
|
||||
} else {
|
||||
@@ -525,7 +517,7 @@ public class StaticEffect {
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public final List<String> getTypes(final Card c) {
|
||||
final List<String> returnList = new ArrayList<String>();
|
||||
final List<String> returnList = new ArrayList<>();
|
||||
if (this.types.containsKey(c)) {
|
||||
returnList.addAll(this.types.get(c));
|
||||
}
|
||||
@@ -629,29 +621,6 @@ public class StaticEffect {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Setter for the field <code>keywordNumber</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param i
|
||||
* a int.
|
||||
*/
|
||||
public final void setKeywordNumber(final int i) {
|
||||
this.keywordNumber = i;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>keywordNumber</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getKeywordNumber() {
|
||||
return this.keywordNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>affectedCards</code>.
|
||||
@@ -694,75 +663,6 @@ public class StaticEffect {
|
||||
this.affectedPlayers = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Setter for the field <code>xValue</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param x
|
||||
* a int.
|
||||
*/
|
||||
public final void setXValue(final int x) {
|
||||
this.xValue = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>xValue</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getXValue() {
|
||||
return this.xValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Setter for the field <code>yValue</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param y
|
||||
* a int.
|
||||
*/
|
||||
public final void setYValue(final int y) {
|
||||
this.yValue = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>yValue</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getYValue() {
|
||||
return this.yValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store xValue relative to a specific card.
|
||||
* @param affectedCard the card affected
|
||||
* @param xValue the xValue
|
||||
*/
|
||||
public final void addXMapValue(final Card affectedCard, final Integer xValue) {
|
||||
if (this.xValueMap.containsKey(affectedCard)) {
|
||||
if (!this.xValueMap.get(affectedCard).equals(xValue)) {
|
||||
this.xValueMap.remove(affectedCard);
|
||||
}
|
||||
}
|
||||
this.xValueMap.put(affectedCard, xValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the xValue for specific card.
|
||||
* @param affectedCard the affected card
|
||||
* @return an int.
|
||||
*/
|
||||
public int getXMapValue(Card affectedCard) {
|
||||
return this.xValueMap.get(affectedCard);
|
||||
}
|
||||
|
||||
/**
|
||||
* setParams. TODO Write javadoc for this method.
|
||||
*
|
||||
@@ -813,11 +713,6 @@ public class StaticEffect {
|
||||
|
||||
String changeColorWordsTo = null;
|
||||
|
||||
int powerBonus = 0;
|
||||
String addP = "";
|
||||
int toughnessBonus = 0;
|
||||
String addT = "";
|
||||
int keywordMultiplier = 1;
|
||||
boolean setPT = false;
|
||||
String[] addHiddenKeywords = null;
|
||||
String addColors = null;
|
||||
@@ -834,37 +729,6 @@ public class StaticEffect {
|
||||
setPT = true;
|
||||
}
|
||||
|
||||
if (params.containsKey("AddPower")) {
|
||||
addP = params.get("AddPower");
|
||||
if (addP.matches("[0-9][0-9]?")) {
|
||||
powerBonus = Integer.valueOf(addP);
|
||||
} else if (addP.equals("AffectedX")) {
|
||||
// gets calculated at runtime
|
||||
} else {
|
||||
powerBonus = getXValue();
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("AddToughness")) {
|
||||
addT = params.get("AddToughness");
|
||||
if (addT.matches("[0-9][0-9]?")) {
|
||||
toughnessBonus = Integer.valueOf(addT);
|
||||
} else if (addT.equals("AffectedX")) {
|
||||
// gets calculated at runtime
|
||||
} else {
|
||||
toughnessBonus = getYValue();
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("KeywordMultiplier")) {
|
||||
String multiplier = params.get("KeywordMultiplier");
|
||||
if (multiplier.equals("X")) {
|
||||
keywordMultiplier = getXValue();
|
||||
} else {
|
||||
keywordMultiplier = Integer.valueOf(multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("AddHiddenKeyword")) {
|
||||
addHiddenKeywords = params.get("AddHiddenKeyword").split(" & ");
|
||||
}
|
||||
@@ -874,7 +738,7 @@ public class StaticEffect {
|
||||
if (colors.equals("ChosenColor")) {
|
||||
addColors = CardUtil.getShortColorsString(getSource().getChosenColors());
|
||||
} else {
|
||||
addColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(" & "))));
|
||||
addColors = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(" & "))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,7 +747,7 @@ public class StaticEffect {
|
||||
if (colors.equals("ChosenColor")) {
|
||||
addColors = CardUtil.getShortColorsString(getSource().getChosenColors());
|
||||
} else {
|
||||
addColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(" & "))));
|
||||
addColors = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(" & "))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -934,15 +798,9 @@ public class StaticEffect {
|
||||
}
|
||||
|
||||
// remove P/T bonus
|
||||
if (addP.startsWith("AffectedX")) {
|
||||
powerBonus = getXMapValue(affectedCard);
|
||||
}
|
||||
if (addT.startsWith("AffectedX")) {
|
||||
toughnessBonus = getXMapValue(affectedCard);
|
||||
}
|
||||
affectedCard.removePTBoost(getTimestamp());
|
||||
|
||||
// the view is updated in GameAction#checkStaticAbilities to avoid flickering
|
||||
affectedCard.addSemiPermanentPowerBoost(powerBonus * -1, false);
|
||||
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus * -1, false);
|
||||
|
||||
// remove keywords
|
||||
// TODO regular keywords currently don't try to use keyword multiplier
|
||||
@@ -963,9 +821,7 @@ public class StaticEffect {
|
||||
|
||||
if (addHiddenKeywords != null) {
|
||||
for (final String k : addHiddenKeywords) {
|
||||
for (int j = 0; j < keywordMultiplier; j++) {
|
||||
affectedCard.removeHiddenExtrinsicKeyword(k);
|
||||
}
|
||||
affectedCard.removeHiddenExtrinsicKeyword(k);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1006,6 +862,13 @@ public class StaticEffect {
|
||||
affectedCard.removeGoad(getTimestamp());
|
||||
}
|
||||
|
||||
if (params.containsKey("CanBlockAny")) {
|
||||
affectedCard.removeCanBlockAny(getTimestamp());
|
||||
}
|
||||
if (params.containsKey("CanBlockAmount")) {
|
||||
affectedCard.removeCanBlockAdditional(getTimestamp());
|
||||
}
|
||||
|
||||
affectedCard.updateAbilityTextForView(); // only update keywords and text for view to avoid flickering
|
||||
}
|
||||
return affectedCards;
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class AbilityFactory {
|
||||
SubAbility("DB");
|
||||
|
||||
private final String prefix;
|
||||
private AbilityRecordType(String prefix) {
|
||||
AbilityRecordType(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
public String getPrefix() {
|
||||
|
||||
@@ -35,7 +35,6 @@ import io.sentry.event.BreadcrumbBuilder;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -150,9 +149,7 @@ public class AbilityUtils {
|
||||
if (crd instanceof Card) {
|
||||
c = game.getCardState((Card) crd);
|
||||
} else if (crd instanceof Iterable) {
|
||||
for (final Card cardItem : Iterables.filter((Iterable<?>) crd, Card.class)) {
|
||||
cards.add(cardItem);
|
||||
}
|
||||
cards.addAll(Iterables.filter((Iterable<?>) crd, Card.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,9 +159,7 @@ public class AbilityUtils {
|
||||
if (crd instanceof Card) {
|
||||
c = game.getCardState((Card) crd);
|
||||
} else if (crd instanceof List<?>) {
|
||||
for (final Card cardItem : (CardCollection) crd) {
|
||||
cards.add(cardItem);
|
||||
}
|
||||
cards.addAll((CardCollection) crd);
|
||||
}
|
||||
}
|
||||
else if (defined.equals("Remembered") || defined.equals("RememberedCard")) {
|
||||
@@ -433,7 +428,7 @@ public class AbilityUtils {
|
||||
val = CardFactoryUtil.doXMath(AbilityUtils.calculateAmount(card, l[0], ability), m, card);
|
||||
} else if (calcX[0].startsWith("PlayerCount")) {
|
||||
final String hType = calcX[0].substring(11);
|
||||
final FCollection<Player> players = new FCollection<Player>();
|
||||
final FCollection<Player> players = new FCollection<>();
|
||||
if (hType.equals("Players") || hType.equals("")) {
|
||||
players.addAll(game.getPlayers());
|
||||
val = CardFactoryUtil.playerXCount(players, calcX[1], card);
|
||||
@@ -531,9 +526,7 @@ public class AbilityUtils {
|
||||
}
|
||||
|
||||
if (calcX[0].endsWith("LKI")) { // last known information
|
||||
for (final Card c : newCard.getImprintedCards()) {
|
||||
list.add(c);
|
||||
}
|
||||
list.addAll(newCard.getImprintedCards());
|
||||
}
|
||||
else {
|
||||
for (final Card c : newCard.getImprintedCards()) {
|
||||
@@ -578,7 +571,7 @@ public class AbilityUtils {
|
||||
|
||||
// Player attribute counting
|
||||
if (calcX[0].startsWith("TargetedPlayer")) {
|
||||
final List<Player> players = new ArrayList<Player>();
|
||||
final List<Player> players = new ArrayList<>();
|
||||
final SpellAbility saTargeting = sa.getSATargetingPlayer();
|
||||
if (null != saTargeting) {
|
||||
Iterables.addAll(players, saTargeting.getTargets().getTargetPlayers());
|
||||
@@ -586,12 +579,12 @@ public class AbilityUtils {
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
if (calcX[0].startsWith("ThisTargetedPlayer")) {
|
||||
final List<Player> players = new ArrayList<Player>();
|
||||
final List<Player> players = new ArrayList<>();
|
||||
Iterables.addAll(players, sa.getTargets().getTargetPlayers());
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
if (calcX[0].startsWith("TargetedObjects")) {
|
||||
final List<GameObject> objects = new ArrayList<GameObject>();
|
||||
final List<GameObject> objects = new ArrayList<>();
|
||||
// Make list of all targeted objects starting with the root SpellAbility
|
||||
SpellAbility loopSA = sa.getRootAbility();
|
||||
while (loopSA != null) {
|
||||
@@ -603,7 +596,7 @@ public class AbilityUtils {
|
||||
return CardFactoryUtil.objectXCount(objects, calcX[1], card) * multiplier;
|
||||
}
|
||||
if (calcX[0].startsWith("TargetedController")) {
|
||||
final List<Player> players = new ArrayList<Player>();
|
||||
final List<Player> players = new ArrayList<>();
|
||||
final CardCollection list = getDefinedCards(card, "Targeted", sa);
|
||||
final List<SpellAbility> sas = AbilityUtils.getDefinedSpellAbilities(card, "Targeted", sa);
|
||||
|
||||
@@ -642,7 +635,7 @@ public class AbilityUtils {
|
||||
if (calcX[0].startsWith("TriggeredPlayers")) {
|
||||
key = "Triggered" + key.substring(16);
|
||||
}
|
||||
final List<Player> players = new ArrayList<Player>();
|
||||
final List<Player> players = new ArrayList<>();
|
||||
Iterables.addAll(players, getDefinedPlayers(card, key, sa));
|
||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||
}
|
||||
@@ -752,7 +745,7 @@ public class AbilityUtils {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public static FCollection<GameObject> getDefinedObjects(final Card card, final String def, final SpellAbility sa) {
|
||||
final FCollection<GameObject> objects = new FCollection<GameObject>();
|
||||
final FCollection<GameObject> objects = new FCollection<>();
|
||||
final String defined = (def == null) ? "Self" : def;
|
||||
|
||||
objects.addAll(AbilityUtils.getDefinedPlayers(card, defined, sa));
|
||||
@@ -1063,7 +1056,7 @@ public class AbilityUtils {
|
||||
}
|
||||
else if (defined.startsWith("OppNon")) {
|
||||
players.addAll(player.getOpponents());
|
||||
players.removeAll((Collection<?>)getDefinedPlayers(card, defined.substring(6), sa));
|
||||
players.removeAll(getDefinedPlayers(card, defined.substring(6), sa));
|
||||
}
|
||||
else if (defined.startsWith("Replaced")) {
|
||||
final SpellAbility root = sa.getRootAbility();
|
||||
@@ -1224,7 +1217,7 @@ public class AbilityUtils {
|
||||
*/
|
||||
public static FCollection<SpellAbility> getDefinedSpellAbilities(final Card card, final String def,
|
||||
final SpellAbility sa) {
|
||||
final FCollection<SpellAbility> sas = new FCollection<SpellAbility>();
|
||||
final FCollection<SpellAbility> sas = new FCollection<>();
|
||||
final String defined = (def == null) ? "Self" : applyAbilityTextChangeEffects(def, sa); // default to Self
|
||||
final Game game = card.getGame();
|
||||
|
||||
@@ -1624,6 +1617,13 @@ public class AbilityUtils {
|
||||
return count;
|
||||
}
|
||||
|
||||
// Count$Adamant.<Color>.<True>.<False>
|
||||
if (sq[0].startsWith("Adamant")) {
|
||||
final String payingMana = StringUtils.join(sa.getRootAbility().getPayingMana());
|
||||
final boolean adamant = StringUtils.countMatches(payingMana, MagicColor.toShortString(sq[1])) >= 3;
|
||||
return CardFactoryUtil.doXMath(Integer.parseInt(sq[adamant ? 2 : 3]), expr, c);
|
||||
}
|
||||
|
||||
if (l[0].startsWith("LastStateBattlefield")) {
|
||||
final String[] k = l[0].split(" ");
|
||||
CardCollectionView list = null;
|
||||
@@ -1691,7 +1691,7 @@ public class AbilityUtils {
|
||||
}
|
||||
|
||||
public static final List<SpellAbility> getBasicSpellsFromPlayEffect(final Card tgtCard, final Player controller) {
|
||||
List<SpellAbility> sas = new ArrayList<SpellAbility>();
|
||||
List<SpellAbility> sas = new ArrayList<>();
|
||||
for (SpellAbility s : tgtCard.getBasicSpells()) {
|
||||
final Spell newSA = (Spell) s.copy();
|
||||
newSA.setActivatingPlayer(controller);
|
||||
@@ -1800,7 +1800,7 @@ public class AbilityUtils {
|
||||
public static final String getSVar(final CardTraitBase ability, final String sVarName) {
|
||||
String val = null;
|
||||
if (ability instanceof SpellAbility) {
|
||||
val = ((SpellAbility) ability).getSVar(sVarName);
|
||||
val = ability.getSVar(sVarName);
|
||||
}
|
||||
if (StringUtils.isEmpty(val)) {
|
||||
Card host = null;
|
||||
@@ -1857,7 +1857,7 @@ public class AbilityUtils {
|
||||
public boolean apply(Card input) {
|
||||
for (final KeywordInterface inst : input.getKeywords(Keyword.SPLICE)) {
|
||||
String k = inst.getOriginal();
|
||||
final String n[] = k.split(":");
|
||||
final String[] n = k.split(":");
|
||||
if (source.isValid(n[1].split(","), player, input, sa)) {
|
||||
return true;
|
||||
}
|
||||
@@ -1890,7 +1890,7 @@ public class AbilityUtils {
|
||||
// This Function thinks that Splice exist only once on the card
|
||||
for (final KeywordInterface inst : c.getKeywords(Keyword.SPLICE)) {
|
||||
final String k = inst.getOriginal();
|
||||
final String n[] = k.split(":");
|
||||
final String[] n = k.split(":");
|
||||
spliceCost = new Cost(n[2], false);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class SpellAbilityEffect {
|
||||
"CARDNAME", sa.getHostCard().getName()));
|
||||
}
|
||||
if (sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
|
||||
sb.append(" (Targeting: " + sa.getTargets().getTargets() + ")");
|
||||
sb.append(" (Targeting: ").append(sa.getTargets().getTargets()).append(")");
|
||||
}
|
||||
} else if (!"None".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output
|
||||
makeSpellDescription(sa, sb, stackDesc);
|
||||
@@ -186,7 +186,7 @@ public abstract class SpellAbilityEffect {
|
||||
|
||||
private static FCollection<Player> getPlayers(final boolean definedFirst, final String definedParam, final SpellAbility sa) {
|
||||
final boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
return useTargets ? new FCollection<Player>(sa.getTargets().getTargetPlayers())
|
||||
return useTargets ? new FCollection<>(sa.getTargets().getTargetPlayers())
|
||||
: AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ public abstract class SpellAbilityEffect {
|
||||
if (your) {
|
||||
delTrig.append("| ValidPlayer$ You ");
|
||||
}
|
||||
delTrig.append("| TriggerDescription$ " + desc);
|
||||
delTrig.append("| TriggerDescription$ ").append(desc);
|
||||
|
||||
final Trigger trig = TriggerHandler.parseTrigger(delTrig.toString(), sa.getHostCard(), intrinsic);
|
||||
for (final Card c : crds) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ActivateAbilityEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
SpellAbility manaAb = p.getController().chooseSingleSpellForEffect(
|
||||
possibleAb, sa, "Choose a mana ability:", ImmutableMap.<String, Object>of());
|
||||
possibleAb, sa, "Choose a mana ability:", ImmutableMap.of());
|
||||
p.getController().playChosenSpellAbility(manaAb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,17 +71,17 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
types.add(host.getChosenType());
|
||||
}
|
||||
|
||||
final List<String> keywords = new ArrayList<String>();
|
||||
final List<String> keywords = new ArrayList<>();
|
||||
if (sa.hasParam("Keywords")) {
|
||||
keywords.addAll(Arrays.asList(sa.getParam("Keywords").split(" & ")));
|
||||
}
|
||||
|
||||
final List<String> removeKeywords = new ArrayList<String>();
|
||||
final List<String> removeKeywords = new ArrayList<>();
|
||||
if (sa.hasParam("RemoveKeywords")) {
|
||||
removeKeywords.addAll(Arrays.asList(sa.getParam("RemoveKeywords").split(" & ")));
|
||||
}
|
||||
|
||||
final List<String> hiddenKeywords = new ArrayList<String>();
|
||||
final List<String> hiddenKeywords = new ArrayList<>();
|
||||
if (sa.hasParam("HiddenKeywords")) {
|
||||
hiddenKeywords.addAll(Arrays.asList(sa.getParam("HiddenKeywords").split(" & ")));
|
||||
}
|
||||
@@ -101,29 +101,29 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
if (colors.equals("ChosenColor")) {
|
||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColors());
|
||||
} else {
|
||||
tmpDesc = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(","))));
|
||||
tmpDesc = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(","))));
|
||||
}
|
||||
}
|
||||
final String finalDesc = tmpDesc;
|
||||
|
||||
// abilities to add to the animated being
|
||||
final List<String> abilities = new ArrayList<String>();
|
||||
final List<String> abilities = new ArrayList<>();
|
||||
if (sa.hasParam("Abilities")) {
|
||||
abilities.addAll(Arrays.asList(sa.getParam("Abilities").split(",")));
|
||||
}
|
||||
// replacement effects to add to the animated being
|
||||
final List<String> replacements = new ArrayList<String>();
|
||||
final List<String> replacements = new ArrayList<>();
|
||||
if (sa.hasParam("Replacements")) {
|
||||
replacements.addAll(Arrays.asList(sa.getParam("Replacements").split(",")));
|
||||
}
|
||||
// triggers to add to the animated being
|
||||
final List<String> triggers = new ArrayList<String>();
|
||||
final List<String> triggers = new ArrayList<>();
|
||||
if (sa.hasParam("Triggers")) {
|
||||
triggers.addAll(Arrays.asList(sa.getParam("Triggers").split(",")));
|
||||
}
|
||||
|
||||
// sVars to add to the animated being
|
||||
final List<String> sVars = new ArrayList<String>();
|
||||
final List<String> sVars = new ArrayList<>();
|
||||
if (sa.hasParam("sVars")) {
|
||||
sVars.addAll(Arrays.asList(sa.getParam("sVars").split(",")));
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
keywords, removeKeywords, hiddenKeywords, timestamp);
|
||||
|
||||
// give abilities
|
||||
final List<SpellAbility> addedAbilities = new ArrayList<SpellAbility>();
|
||||
final List<SpellAbility> addedAbilities = new ArrayList<>();
|
||||
if (abilities.size() > 0) {
|
||||
for (final String s : abilities) {
|
||||
final String actualAbility = host.getSVar(s);
|
||||
@@ -165,7 +165,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// remove abilities
|
||||
final List<SpellAbility> removedAbilities = new ArrayList<SpellAbility>();
|
||||
final List<SpellAbility> removedAbilities = new ArrayList<>();
|
||||
if (sa.hasParam("OverwriteAbilities") || removeAll || removeIntrinsic) {
|
||||
for (final SpellAbility ab : c.getSpellAbilities()) {
|
||||
if (ab.isAbility()) {
|
||||
@@ -178,7 +178,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
}
|
||||
// give replacement effects
|
||||
final List<ReplacementEffect> addedReplacements = new ArrayList<ReplacementEffect>();
|
||||
final List<ReplacementEffect> addedReplacements = new ArrayList<>();
|
||||
if (replacements.size() > 0) {
|
||||
for (final String s : replacements) {
|
||||
final String actualReplacement = host.getSVar(s);
|
||||
@@ -187,7 +187,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
}
|
||||
// Grant triggers
|
||||
final List<Trigger> addedTriggers = new ArrayList<Trigger>();
|
||||
final List<Trigger> addedTriggers = new ArrayList<>();
|
||||
if (triggers.size() > 0) {
|
||||
for (final String s : triggers) {
|
||||
final String actualTrigger = host.getSVar(s);
|
||||
@@ -197,7 +197,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// suppress triggers from the animated card
|
||||
final List<Trigger> removedTriggers = new ArrayList<Trigger>();
|
||||
final List<Trigger> removedTriggers = new ArrayList<>();
|
||||
if (sa.hasParam("OverwriteTriggers") || removeAll || removeIntrinsic) {
|
||||
final FCollectionView<Trigger> triggersToRemove = c.getTriggers();
|
||||
for (final Trigger trigger : triggersToRemove) {
|
||||
@@ -210,7 +210,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// suppress static abilities from the animated card
|
||||
final List<StaticAbility> removedStatics = new ArrayList<StaticAbility>();
|
||||
final List<StaticAbility> removedStatics = new ArrayList<>();
|
||||
if (sa.hasParam("OverwriteStatics") || removeAll || removeIntrinsic) {
|
||||
for (final StaticAbility stAb : c.getStaticAbilities()) {
|
||||
if (removeIntrinsic && !stAb.isIntrinsic()) {
|
||||
@@ -222,7 +222,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
// suppress static abilities from the animated card
|
||||
final List<ReplacementEffect> removedReplacements = new ArrayList<ReplacementEffect>();
|
||||
final List<ReplacementEffect> removedReplacements = new ArrayList<>();
|
||||
if (sa.hasParam("OverwriteReplacements") || removeAll || removeIntrinsic) {
|
||||
for (final ReplacementEffect re : c.getReplacementEffects()) {
|
||||
if (removeIntrinsic && !re.isIntrinsic()) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AssignGroupEffect extends SpellAbilityEffect {
|
||||
|
||||
List<GameObject> defined = getDefinedOrTargeted(sa, "Defined");
|
||||
|
||||
final List<SpellAbility> abilities = Lists.<SpellAbility>newArrayList(sa.getAdditionalAbilityList("Choices"));
|
||||
final List<SpellAbility> abilities = Lists.newArrayList(sa.getAdditionalAbilityList("Choices"));
|
||||
|
||||
Player chooser = sa.getActivatingPlayer();
|
||||
if (sa.hasParam("Chooser")) {
|
||||
|
||||
@@ -166,7 +166,7 @@ public class AttachEffect extends SpellAbilityEffect {
|
||||
|
||||
Player p = source.getController();
|
||||
if (tgt.canTgtPlayer()) {
|
||||
final FCollection<Player> players = new FCollection<Player>();
|
||||
final FCollection<Player> players = new FCollection<>();
|
||||
|
||||
for (Player player : game.getPlayers()) {
|
||||
if (player.isValid(tgt.getValidTgts(), aura.getActivatingPlayer(), source, null)) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BalanceEffect extends SpellAbilityEffect {
|
||||
int min = Integer.MAX_VALUE;
|
||||
|
||||
final FCollectionView<Player> players = game.getPlayersInTurnOrder();
|
||||
final List<CardCollection> validCards = new ArrayList<CardCollection>(players.size());
|
||||
final List<CardCollection> validCards = new ArrayList<>(players.size());
|
||||
|
||||
for(int i = 0; i < players.size(); i++) {
|
||||
// Find the minimum of each Valid per player
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BidLifeEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getHostCard();
|
||||
final Player activator = sa.getActivatingPlayer();
|
||||
final FCollection<Player> bidPlayers = new FCollection<Player>();
|
||||
final FCollection<Player> bidPlayers = new FCollection<>();
|
||||
final int startBidding;
|
||||
if (sa.hasParam("StartBidding")) {
|
||||
String start = sa.getParam("StartBidding");
|
||||
@@ -54,7 +54,7 @@ public class BidLifeEffect extends SpellAbilityEffect {
|
||||
willBid = false;
|
||||
for (final Player p : bidPlayers) {
|
||||
final boolean result = p.getController().confirmBidAction(sa, PlayerActionConfirmMode.BidLife,
|
||||
"Do you want to top bid? Current Bid =" + String.valueOf(bid), bid, winner);
|
||||
"Do you want to top bid? Current Bid =" + bid, bid, winner);
|
||||
willBid |= result;
|
||||
if (result) { // a different choose number
|
||||
bid += p.getController().chooseNumber(sa, "Bid life:", 1, 9);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BlockEffect extends SpellAbilityEffect {
|
||||
final Game game = host.getGame();
|
||||
final Combat combat = game.getPhaseHandler().getCombat();
|
||||
|
||||
List<Card> attackers = new ArrayList<Card>();
|
||||
List<Card> attackers = new ArrayList<>();
|
||||
if (sa.hasParam("DefinedAttacker")) {
|
||||
for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) {
|
||||
if (combat.isAttacking(attacker))
|
||||
@@ -30,7 +30,7 @@ public class BlockEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
|
||||
List<Card> blockers = new ArrayList<Card>();
|
||||
List<Card> blockers = new ArrayList<>();
|
||||
if (sa.hasParam("DefinedBlocker")) {
|
||||
for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) {
|
||||
if (blocker.isCreature() && blocker.isInZone(ZoneType.Battlefield))
|
||||
@@ -90,14 +90,14 @@ public class BlockEffect extends SpellAbilityEffect {
|
||||
|
||||
// end standard pre-
|
||||
|
||||
List<String> attackers = new ArrayList<String>();
|
||||
List<String> attackers = new ArrayList<>();
|
||||
if (sa.hasParam("DefinedAttacker")) {
|
||||
for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) {
|
||||
attackers.add(attacker.toString());
|
||||
}
|
||||
}
|
||||
|
||||
List<String> blockers = new ArrayList<String>();
|
||||
List<String> blockers = new ArrayList<>();
|
||||
if (sa.hasParam("DefinedBlocker")) {
|
||||
for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) {
|
||||
blockers.add(blocker.toString());
|
||||
|
||||
@@ -71,13 +71,13 @@ public class ChangeTextEffect extends SpellAbilityEffect {
|
||||
validTypes.addAll(CardType.Constant.CREATURE_TYPES);
|
||||
kindOfType = "creature";
|
||||
}
|
||||
changedTypeWordOriginal = sa.getActivatingPlayer().getController().chooseSomeType(kindOfType, sa, validTypes, Lists.<String>newArrayList());
|
||||
changedTypeWordOriginal = sa.getActivatingPlayer().getController().chooseSomeType(kindOfType, sa, validTypes, Lists.newArrayList());
|
||||
} else {
|
||||
changedTypeWordOriginal = changedTypeWordsArray[0];
|
||||
}
|
||||
|
||||
validTypes.clear();
|
||||
final List<String> forbiddenTypes = sa.hasParam("ForbiddenNewTypes") ? Lists.newArrayList(sa.getParam("ForbiddenNewTypes").split(",")) : Lists.<String>newArrayList();
|
||||
final List<String> forbiddenTypes = sa.hasParam("ForbiddenNewTypes") ? Lists.newArrayList(sa.getParam("ForbiddenNewTypes").split(",")) : Lists.newArrayList();
|
||||
forbiddenTypes.add(changedTypeWordOriginal);
|
||||
if (changedTypeWordsArray[1].startsWith("Choose")) {
|
||||
if (changedTypeWordsArray[1].equals("ChooseBasicLandType")) {
|
||||
|
||||
@@ -641,7 +641,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
|
||||
// for things like Gaea's Blessing
|
||||
if (destination.equals(ZoneType.Library) && sa.hasParam("Shuffle") && "True".equals(sa.getParam("Shuffle"))) {
|
||||
FCollection<Player> pl = new FCollection<Player>();
|
||||
FCollection<Player> pl = new FCollection<>();
|
||||
// use defined controller. it does need to work even without Targets.
|
||||
if (sa.hasParam("TargetsWithDefinedController")) {
|
||||
pl.addAll(AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("TargetsWithDefinedController"), sa));
|
||||
@@ -876,9 +876,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
selectedCards = decider.getController().chooseCardsForZoneChange(destination, origin, sa, fetchList, 0, changeNum, delayedReveal, selectPrompt, decider);
|
||||
} while (selectedCards != null && selectedCards.size() > changeNum);
|
||||
if (selectedCards != null) {
|
||||
for (Card card : selectedCards) {
|
||||
chosenCards.add(card);
|
||||
}
|
||||
chosenCards.addAll(selectedCards);
|
||||
}
|
||||
// maybe prompt the user if they selected fewer than the maximum possible?
|
||||
} else {
|
||||
@@ -908,7 +906,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
if (totalcmc != null) {
|
||||
if (totcmc >= 0) {
|
||||
fetchList = CardLists.getValidCards(fetchList, "Card.cmcLE" + Integer.toString(totcmc), source.getController(), source);
|
||||
fetchList = CardLists.getValidCards(fetchList, "Card.cmcLE" + totcmc, source.getController(), source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ChooseCardEffect extends SpellAbilityEffect {
|
||||
int chosenP = 0;
|
||||
while (!creature.isEmpty()) {
|
||||
Card c = p.getController().chooseSingleEntityForEffect(creature, sa,
|
||||
"Select creature(s) with total power less than or equal to " + Integer.toString(totP - chosenP - negativeNum)
|
||||
"Select creature(s) with total power less than or equal to " + (totP - chosenP - negativeNum)
|
||||
+ "\r\n(Selected:" + chosenPool + ")\r\n" + "(Total Power: " + chosenP + ")", chosenP <= totP);
|
||||
if (c == null) {
|
||||
if (p.getController().confirmAction(sa, PlayerActionConfirmMode.OptionalChoose, "Cancel Choose?")) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ChooseColorEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card card = sa.getHostCard();
|
||||
|
||||
List<String> colorChoices = new ArrayList<String>(MagicColor.Constant.ONLY_COLORS);
|
||||
List<String> colorChoices = new ArrayList<>(MagicColor.Constant.ONLY_COLORS);
|
||||
if (sa.hasParam("Choices")) {
|
||||
String[] restrictedChoices = sa.getParam("Choices").split(",");
|
||||
colorChoices = Arrays.asList(restrictedChoices);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ChooseDirectionEffect extends SpellAbilityEffect {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
final FCollection<Player> left = new FCollection<Player>(game.getPlayers());
|
||||
final FCollection<Player> left = new FCollection<>(game.getPlayers());
|
||||
// TODO: We'd better set up turn order UI here
|
||||
final String info = "Left (clockwise): " + left + "\r\nRight (anticlockwise):" + Lists.reverse(left);
|
||||
sa.getActivatingPlayer().getController().notifyOfValue(sa, source, info);
|
||||
|
||||
@@ -30,14 +30,14 @@ public class ChooseGenericEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getHostCard();
|
||||
|
||||
final List<SpellAbility> abilities = Lists.<SpellAbility>newArrayList(sa.getAdditionalAbilityList("Choices"));
|
||||
final List<SpellAbility> abilities = Lists.newArrayList(sa.getAdditionalAbilityList("Choices"));
|
||||
final SpellAbility fallback = sa.getAdditionalAbility("FallbackAbility");
|
||||
|
||||
final List<Player> tgtPlayers = getDefinedPlayersOrTargeted(sa);
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
// determine if any of the choices are not valid
|
||||
List<SpellAbility> saToRemove = Lists.<SpellAbility>newArrayList();
|
||||
List<SpellAbility> saToRemove = Lists.newArrayList();
|
||||
|
||||
for (SpellAbility saChoice : abilities) {
|
||||
if (!saChoice.getRestrictions().checkOtherRestrictions(host, saChoice, sa.getActivatingPlayer()) ) {
|
||||
|
||||
@@ -29,9 +29,9 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card card = sa.getHostCard();
|
||||
final String type = sa.getParam("Type");
|
||||
final List<String> invalidTypes = sa.hasParam("InvalidTypes") ? Arrays.asList(sa.getParam("InvalidTypes").split(",")) : new ArrayList<String>();
|
||||
final List<String> invalidTypes = sa.hasParam("InvalidTypes") ? Arrays.asList(sa.getParam("InvalidTypes").split(",")) : new ArrayList<>();
|
||||
|
||||
final List<String> validTypes = new ArrayList<String>();
|
||||
final List<String> validTypes = new ArrayList<>();
|
||||
if (sa.hasParam("ValidTypes")) {
|
||||
validTypes.addAll(Arrays.asList(sa.getParam("ValidTypes").split(",")));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
final boolean victory = clashWithOpponent(sa);
|
||||
|
||||
// Run triggers
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> runParams = new HashMap<>();
|
||||
runParams.put("Player", sa.getHostCard().getController());
|
||||
|
||||
if (victory) {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
sb.append(tgtCard);
|
||||
sb.append(" becomes a copy of " + cardToCopy + ".");
|
||||
sb.append(" becomes a copy of ").append(cardToCopy).append(".");
|
||||
|
||||
return sb.toString();
|
||||
} // end cloneStackDescription()
|
||||
@@ -124,7 +124,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (!pumpKeywords.isEmpty()) {
|
||||
tgtCard.addChangedCardKeywords(pumpKeywords, Lists.<String>newArrayList(), false, false, ts);
|
||||
tgtCard.addChangedCardKeywords(pumpKeywords, Lists.newArrayList(), false, false, ts);
|
||||
}
|
||||
|
||||
tgtCard.updateStateForView();
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
|
||||
Card object1 = null;
|
||||
Card object2 = null;
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
List<Card> tgts = tgt == null ? new ArrayList<Card>() : Lists.newArrayList(sa.getTargets().getTargetCards());
|
||||
List<Card> tgts = tgt == null ? new ArrayList<>() : Lists.newArrayList(sa.getTargets().getTargetCards());
|
||||
if (tgts.size() > 0) {
|
||||
object1 = tgts.get(0);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
|
||||
Card object1 = null;
|
||||
Card object2 = null;
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
List<Card> tgts = tgt == null ? new ArrayList<Card>() : Lists.newArrayList(sa.getTargets().getTargetCards());
|
||||
List<Card> tgts = tgt == null ? new ArrayList<>() : Lists.newArrayList(sa.getTargets().getTargetCards());
|
||||
if (tgts.size() > 0) {
|
||||
object1 = tgts.get(0);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ControlGainEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (!kws.isEmpty()) {
|
||||
tgtC.addChangedCardKeywords(kws, Lists.<String>newArrayList(), false, false, tStamp);
|
||||
tgtC.addChangedCardKeywords(kws, Lists.newArrayList(), false, false, tStamp);
|
||||
game.fireEvent(new GameEventCardStatsChanged(tgtC));
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
|
||||
copyInPlay.setCloneOrigin(host);
|
||||
if (!pumpKeywords.isEmpty()) {
|
||||
copyInPlay.addChangedCardKeywords(pumpKeywords, Lists.<String>newArrayList(), false, false, timestamp);
|
||||
copyInPlay.addChangedCardKeywords(pumpKeywords, Lists.newArrayList(), false, false, timestamp);
|
||||
}
|
||||
crds.add(copyInPlay);
|
||||
if (sa.hasParam("RememberCopied")) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
boolean mayChooseNewTargets = true;
|
||||
List<SpellAbility> copies = new ArrayList<SpellAbility>();
|
||||
List<SpellAbility> copies = new ArrayList<>();
|
||||
|
||||
if (sa.hasParam("CopyMultipleSpells")) {
|
||||
final int spellCount = Integer.parseInt(sa.getParam("CopyMultipleSpells"));
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
|
||||
int amount = 0;
|
||||
if (!num.equals("All") && !num.equals("Remembered")) {
|
||||
amount = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa);
|
||||
};
|
||||
}
|
||||
|
||||
sb.append("Remove ");
|
||||
if (sa.hasParam("UpTo")) {
|
||||
|
||||
@@ -108,10 +108,8 @@ public class DamageDealEffect extends DamageBaseEffect {
|
||||
}
|
||||
// Can't radiate from a player
|
||||
if (origin != null) {
|
||||
for (final Card c : CardUtil.getRadiance(hostCard, origin,
|
||||
sa.getParam("ValidTgts").split(","))) {
|
||||
tgts.add(c);
|
||||
}
|
||||
tgts.addAll(CardUtil.getRadiance(hostCard, origin,
|
||||
sa.getParam("ValidTgts").split(",")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
||||
int numDam = AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa);
|
||||
|
||||
final List<GameObject> tgts = getTargets(sa);
|
||||
final List<Card> untargetedCards = new ArrayList<Card>();
|
||||
final List<Card> untargetedCards = new ArrayList<>();
|
||||
|
||||
if (sa.hasParam("Radiance") && (sa.usesTargeting())) {
|
||||
Card origin = null;
|
||||
@@ -81,9 +81,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
||||
}
|
||||
if (origin != null) {
|
||||
// Can't radiate from a player
|
||||
for (final Card c : CardUtil.getRadiance(host, origin, sa.getParam("ValidTgts").split(","))) {
|
||||
untargetedCards.add(c);
|
||||
}
|
||||
untargetedCards.addAll(CardUtil.getRadiance(host, origin, sa.getParam("ValidTgts").split(",")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,12 +94,12 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
||||
final Card c = (Card) o;
|
||||
if (c.isInPlay() && (!targeted || c.canBeTargetedBy(sa))) {
|
||||
if (preventionWithEffect) {
|
||||
Map<String, String> effectMap = new TreeMap<String, String>();
|
||||
Map<String, String> effectMap = new TreeMap<>();
|
||||
effectMap.put("EffectString", sa.getSVar(sa.getParam("PreventionSubAbility")));
|
||||
effectMap.put("ShieldAmount", String.valueOf(numDam));
|
||||
if (sa.hasParam("ShieldEffectTarget")) {
|
||||
String effTgtString = "";
|
||||
List<GameObject> effTgts = new ArrayList<GameObject>();
|
||||
List<GameObject> effTgts = new ArrayList<>();
|
||||
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
|
||||
for (final Object effTgt : effTgts) {
|
||||
if (effTgt instanceof Card) {
|
||||
@@ -123,12 +121,12 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
||||
final Player p = (Player) o;
|
||||
if (!targeted || p.canBeTargetedBy(sa)) {
|
||||
if (preventionWithEffect) {
|
||||
Map<String, String> effectMap = new TreeMap<String, String>();
|
||||
Map<String, String> effectMap = new TreeMap<>();
|
||||
effectMap.put("EffectString", sa.getSVar(sa.getParam("PreventionSubAbility")));
|
||||
effectMap.put("ShieldAmount", String.valueOf(numDam));
|
||||
if (sa.hasParam("ShieldEffectTarget")) {
|
||||
String effTgtString = "";
|
||||
List<GameObject> effTgts = new ArrayList<GameObject>();
|
||||
List<GameObject> effTgts = new ArrayList<>();
|
||||
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
|
||||
for (final Object effTgt : effTgts) {
|
||||
if (effTgt instanceof Card) {
|
||||
|
||||
@@ -30,9 +30,7 @@ public class DelayedTriggerEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
Map<String, String> mapParams = Maps.newHashMap(sa.getMapParams());
|
||||
if (mapParams.containsKey("Cost")) {
|
||||
mapParams.remove("Cost");
|
||||
}
|
||||
mapParams.remove("Cost");
|
||||
|
||||
if (mapParams.containsKey("SpellDescription")) {
|
||||
mapParams.put("TriggerDescription", mapParams.get("SpellDescription"));
|
||||
|
||||
@@ -78,10 +78,8 @@ public class DestroyEffect extends SpellAbilityEffect {
|
||||
CardCollection untargetedCards = new CardCollection();
|
||||
|
||||
if (sa.hasParam("Radiance")) {
|
||||
for (final Card c : CardUtil.getRadiance(card, tgtCards.get(0),
|
||||
sa.getParam("ValidTgts").split(","))) {
|
||||
untargetedCards.add(c);
|
||||
}
|
||||
untargetedCards.addAll(CardUtil.getRadiance(card, tgtCards.get(0),
|
||||
sa.getParam("ValidTgts").split(",")));
|
||||
}
|
||||
|
||||
if (tgtCards.size() > 1) {
|
||||
|
||||
@@ -167,9 +167,7 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
|
||||
if (!noMove) {
|
||||
CardCollection movedCards;
|
||||
for (final Card c : top) {
|
||||
rest.add(c);
|
||||
}
|
||||
rest.addAll(top);
|
||||
CardCollection valid;
|
||||
if (mitosis) {
|
||||
valid = sharesNameWithCardOnBattlefield(game, top);
|
||||
@@ -264,7 +262,7 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
if ( p == chooser ) { // the digger can still see all the dug cards when choosing
|
||||
chooser.getController().tempShowCards(top);
|
||||
}
|
||||
List<Card> chosen = new ArrayList<Card>();
|
||||
List<Card> chosen = new ArrayList<>();
|
||||
|
||||
int max = anyNumber ? valid.size() : Math.min(valid.size(),destZone1ChangeNum);
|
||||
int min = (anyNumber || optional) ? 0 : max;
|
||||
|
||||
@@ -108,7 +108,7 @@ public class DiscardEffect extends SpellAbilityEffect {
|
||||
final Game game = source.getGame();
|
||||
//final boolean anyNumber = sa.hasParam("AnyNumber");
|
||||
|
||||
final List<Card> discarded = new ArrayList<Card>();
|
||||
final List<Card> discarded = new ArrayList<>();
|
||||
final List<Player> targets = getTargetPlayers(sa),
|
||||
discarders;
|
||||
Player firstTarget = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DrainManaEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
List<Mana> drained = new ArrayList<Mana>();
|
||||
List<Mana> drained = new ArrayList<>();
|
||||
|
||||
for (final Player p : getTargetPlayers(sa)) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class EncodeEffect extends SpellAbilityEffect {
|
||||
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Do you want to exile " + host + " and encode it onto a creature you control?");
|
||||
sb.append("Do you want to exile ").append(host).append(" and encode it onto a creature you control?");
|
||||
if (!player.getController().confirmAction(sa, null, sb.toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ public class FightEffect extends DamageBaseEffect {
|
||||
List<Card> fighters = getFighters(sa);
|
||||
|
||||
if (fighters.size() > 1) {
|
||||
sb.append(fighters.get(0) + " fights " + fighters.get(1));
|
||||
sb.append(fighters.get(0)).append(" fights ").append(fighters.get(1));
|
||||
}
|
||||
else if (fighters.size() == 1) {
|
||||
sb.append(fighters.get(0) + " fights unknown");
|
||||
sb.append(fighters.get(0)).append(" fights unknown");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
||||
|
||||
sb.append(player).append(" flips a coin.");
|
||||
if (tgts != null && !tgts.isEmpty()) {
|
||||
sb.append(" Targeting: " + tgts + ".");
|
||||
sb.append(" Targeting: ").append(tgts).append(".");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ public class ImmediateTriggerEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
Map<String, String> mapParams = Maps.newHashMap(sa.getMapParams());
|
||||
|
||||
if (mapParams.containsKey("Cost")) {
|
||||
mapParams.remove("Cost");
|
||||
}
|
||||
mapParams.remove("Cost");
|
||||
|
||||
if (mapParams.containsKey("SpellDescription")) {
|
||||
mapParams.put("TriggerDescription", mapParams.get("SpellDescription"));
|
||||
|
||||
@@ -43,12 +43,12 @@ public class LifeLoseEffect extends SpellAbilityEffect {
|
||||
lifeLost += p.loseLife(lifeAmount);
|
||||
}
|
||||
}
|
||||
sa.getHostCard().setSVar("AFLifeLost", "Number$" + Integer.toString(lifeLost));
|
||||
sa.getHostCard().setSVar("AFLifeLost", "Number$" + lifeLost);
|
||||
|
||||
// Exceptional case for Extort: must propagate the amount of life lost to subability,
|
||||
// otherwise the first Extort trigger per game won't work
|
||||
if (sa.getSubAbility() != null && ApiType.GainLife.equals(sa.getSubAbility().getApi())) {
|
||||
sa.getSubAbility().setSVar("AFLifeLost", "Number$" + Integer.toString(lifeLost));
|
||||
sa.getSubAbility().setSVar("AFLifeLost", "Number$" + lifeLost);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class LifeSetEffect extends SpellAbilityEffect {
|
||||
final boolean redistribute = sa.hasParam("Redistribute");
|
||||
final int lifeAmount = redistribute ? 20 : AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("LifeAmount"), sa);
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final List<Integer> lifetotals = new ArrayList<Integer>();
|
||||
final List<Integer> lifetotals = new ArrayList<>();
|
||||
|
||||
if (redistribute) {
|
||||
for (final Player p : getTargetPlayers(sa)) {
|
||||
|
||||
@@ -105,7 +105,7 @@ public class MillEffect extends SpellAbilityEffect {
|
||||
sb.append("s");
|
||||
}
|
||||
final String millPosition = sa.hasParam("FromBottom") ? "bottom" : "top";
|
||||
sb.append(" from the " + millPosition + " of their library.");
|
||||
sb.append(" from the ").append(millPosition).append(" of their library.");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
|
||||
@@ -23,7 +23,7 @@ public class MustBlockEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("DefinedAttacker")) {
|
||||
cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa);
|
||||
} else {
|
||||
cards = new ArrayList<Card>();
|
||||
cards = new ArrayList<>();
|
||||
cards.add(host);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, cpp));
|
||||
}
|
||||
if (sa.hasParam("RandomCopied")) {
|
||||
final List<PaperCard> copysource = new ArrayList<PaperCard>(cards);
|
||||
final List<PaperCard> copysource = new ArrayList<>(cards);
|
||||
final CardCollection choice = new CardCollection();
|
||||
final String num = sa.hasParam("RandomNum") ? sa.getParam("RandomNum") : "1";
|
||||
int ncopied = AbilityUtils.calculateAmount(source, num, sa);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
||||
|
||||
final boolean isChoice = sa.getParam("Gains").contains("Choice");
|
||||
final List<String> choices = ProtectEffect.getProtectionList(sa);
|
||||
final List<String> gains = new ArrayList<String>();
|
||||
final List<String> gains = new ArrayList<>();
|
||||
if (isChoice) {
|
||||
Player choser = sa.getActivatingPlayer();
|
||||
final String choice = choser.getController().chooseProtectionType("Choose a protection", sa, choices);
|
||||
@@ -123,7 +123,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
||||
final List<Player> playerList = AbilityUtils.getDefinedPlayers(host, players, sa);
|
||||
for (final Player player : playerList) {
|
||||
for (final String gain : gains) {
|
||||
player.addChangedKeywords(ImmutableList.of("Protection from " + gain), ImmutableList.<String>of(), timestamp);
|
||||
player.addChangedKeywords(ImmutableList.of("Protection from " + gain), ImmutableList.of(), timestamp);
|
||||
}
|
||||
|
||||
if (!sa.hasParam("Permanent")) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
|
||||
final List<String> gains = getProtectionList(sa);
|
||||
final boolean choose = (sa.hasParam("Choices")) ? true : false;
|
||||
final boolean choose = sa.hasParam("Choices");
|
||||
final String joiner = choose ? "or" : "and";
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -100,7 +100,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
||||
|
||||
final boolean isChoice = sa.getParam("Gains").contains("Choice");
|
||||
final List<String> choices = getProtectionList(sa);
|
||||
final List<String> gains = new ArrayList<String>();
|
||||
final List<String> gains = new ArrayList<>();
|
||||
final List<Card> tgtCards = getTargetCards(sa);
|
||||
|
||||
if (isChoice && !choices.isEmpty()) {
|
||||
@@ -128,14 +128,12 @@ public class ProtectEffect extends SpellAbilityEffect {
|
||||
gainsKWList.add(TextUtil.concatWithSpace("Protection from", color));
|
||||
}
|
||||
|
||||
final List<Card> untargetedCards = new ArrayList<Card>();
|
||||
final List<Card> untargetedCards = new ArrayList<>();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
|
||||
if (sa.hasParam("Radiance") && (tgt != null)) {
|
||||
for (final Card c : CardUtil.getRadiance(host, tgtCards.get(0),
|
||||
sa.getParam("ValidTgts").split(","))) {
|
||||
untargetedCards.add(c);
|
||||
}
|
||||
untargetedCards.addAll(CardUtil.getRadiance(host, tgtCards.get(0),
|
||||
sa.getParam("ValidTgts").split(",")));
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +203,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
||||
|
||||
|
||||
public static List<String> getProtectionList(final SpellAbility sa) {
|
||||
final List<String> gains = new ArrayList<String>();
|
||||
final List<String> gains = new ArrayList<>();
|
||||
|
||||
final String gainStr = sa.getParam("Gains");
|
||||
if (gainStr.equals("Choice")) {
|
||||
|
||||
@@ -49,9 +49,17 @@ public class PumpAllEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
|
||||
tgtC.addTempPowerBoost(a);
|
||||
tgtC.addTempToughnessBoost(d);
|
||||
boolean redrawPT = false;
|
||||
|
||||
if (a != 0 || d != 0) {
|
||||
tgtC.addPTBoost(a, d, timestamp);
|
||||
redrawPT = true;
|
||||
}
|
||||
|
||||
tgtC.addChangedCardKeywords(kws, null, false, false, timestamp);
|
||||
if (redrawPT) {
|
||||
tgtC.updatePowerToughnessForView();
|
||||
}
|
||||
|
||||
for (String kw : hiddenkws) {
|
||||
tgtC.addHiddenExtrinsicKeyword(kw);
|
||||
@@ -68,13 +76,13 @@ public class PumpAllEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
tgtC.addTempPowerBoost(-1 * a);
|
||||
tgtC.addTempToughnessBoost(-1 * d);
|
||||
tgtC.removePTBoost(timestamp);
|
||||
tgtC.removeChangedCardKeywords(timestamp);
|
||||
|
||||
for (String kw : hiddenkws) {
|
||||
tgtC.removeHiddenExtrinsicKeyword(kw);
|
||||
}
|
||||
tgtC.updatePowerToughnessForView();
|
||||
|
||||
game.fireEvent(new GameEventCardStatsChanged(tgtC));
|
||||
}
|
||||
|
||||
@@ -55,13 +55,24 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
|
||||
gameCard.addTempPowerBoost(a);
|
||||
gameCard.addTempToughnessBoost(d);
|
||||
gameCard.addChangedCardKeywords(kws, Lists.<String>newArrayList(), false, false, timestamp);
|
||||
if (a != 0 || d != 0) {
|
||||
gameCard.addPTBoost(a, d, timestamp);
|
||||
redrawPT = true;
|
||||
}
|
||||
|
||||
gameCard.addChangedCardKeywords(kws, Lists.newArrayList(), false, false, timestamp);
|
||||
if (redrawPT) {
|
||||
gameCard.updatePowerToughnessForView();
|
||||
}
|
||||
|
||||
|
||||
if (sa.hasParam("CanBlockAny")) {
|
||||
gameCard.addCanBlockAny(timestamp);
|
||||
}
|
||||
if (sa.hasParam("CanBlockAmount")) {
|
||||
int v = AbilityUtils.calculateAmount(host, sa.getParam("CanBlockAmount"), sa, true);
|
||||
gameCard.addCanBlockAdditional(v, timestamp);
|
||||
}
|
||||
|
||||
if (sa.hasParam("LeaveBattlefield")) {
|
||||
addLeaveBattlefieldReplacement(gameCard, sa, sa.getParam("LeaveBattlefield"));
|
||||
}
|
||||
@@ -73,23 +84,24 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
gameCard.addTempPowerBoost(-1 * a);
|
||||
gameCard.addTempToughnessBoost(-1 * d);
|
||||
gameCard.removePTBoost(timestamp);
|
||||
boolean updateText = false;
|
||||
updateText = gameCard.removeCanBlockAny(timestamp) || updateText;
|
||||
updateText = gameCard.removeCanBlockAdditional(timestamp) || updateText;
|
||||
|
||||
if (keywords.size() > 0) {
|
||||
boolean redrawPT = false;
|
||||
|
||||
for (String kw : keywords) {
|
||||
redrawPT |= kw.contains("CARDNAME's power and toughness are switched");
|
||||
if (kw.startsWith("HIDDEN")) {
|
||||
gameCard.removeHiddenExtrinsicKeyword(kw);
|
||||
if (redrawPT) {
|
||||
gameCard.updatePowerToughnessForView();
|
||||
}
|
||||
}
|
||||
}
|
||||
gameCard.removeChangedCardKeywords(timestamp);
|
||||
}
|
||||
gameCard.updatePowerToughnessForView();
|
||||
if (updateText) {
|
||||
gameCard.updateAbilityTextForView();
|
||||
}
|
||||
|
||||
game.fireEvent(new GameEventCardStatsChanged(gameCard));
|
||||
}
|
||||
@@ -108,7 +120,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
&& !(host.isInPlay() || host.isInZone(ZoneType.Stack))) {
|
||||
return;
|
||||
}
|
||||
p.addChangedKeywords(keywords, ImmutableList.<String>of(), timestamp);
|
||||
p.addChangedKeywords(keywords, ImmutableList.of(), timestamp);
|
||||
|
||||
if (!sa.hasParam("Permanent")) {
|
||||
// If not Permanent, remove Pumped at EOT
|
||||
@@ -191,7 +203,12 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
final int atk = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumAtt"), sa, true);
|
||||
final int def = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumDef"), sa, true);
|
||||
|
||||
sb.append("gains ");
|
||||
boolean gains = sa.hasParam("NumAtt") || sa.hasParam("NumDef") || !keywords.isEmpty();
|
||||
|
||||
if (gains) {
|
||||
sb.append("gains ");
|
||||
}
|
||||
|
||||
if (sa.hasParam("NumAtt") || sa.hasParam("NumDef")) {
|
||||
if (atk >= 0) {
|
||||
sb.append("+");
|
||||
@@ -209,8 +226,25 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
sb.append(keywords.get(i)).append(" ");
|
||||
}
|
||||
|
||||
if (sa.hasParam("CanBlockAny")) {
|
||||
if (gains) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
sb.append("can block any number of creatures ");
|
||||
} else if (sa.hasParam("CanBlockAmount")) {
|
||||
if (gains) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
String n = sa.getParam("CanBlockAmount");
|
||||
sb.append("can block an additional ");
|
||||
sb.append("1".equals(n) ? "creature" : Lang.nounWithNumeral(n, "creature"));
|
||||
sb.append(" each combat ");
|
||||
}
|
||||
|
||||
if (!sa.hasParam("Permanent")) {
|
||||
sb.append("until end of turn.");
|
||||
} else {
|
||||
sb.append(".");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -254,7 +288,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
if (defined.equals("ChosenType")) {
|
||||
replaced = host.getChosenType();
|
||||
} else if (defined.equals("CardUIDSource")) {
|
||||
replaced = "CardUID_" + String.valueOf(host.getId());
|
||||
replaced = "CardUID_" + host.getId();
|
||||
} else if (defined.equals("ActivatorName")) {
|
||||
replaced = sa.getActivatingPlayer().getName();
|
||||
}
|
||||
@@ -279,9 +313,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("NoRepetition")) {
|
||||
for (KeywordInterface inst : tgtCards.get(0).getKeywords()) {
|
||||
final String kws = inst.getOriginal();
|
||||
if (total.contains(kws)) {
|
||||
total.remove(kws);
|
||||
}
|
||||
total.remove(kws);
|
||||
}
|
||||
}
|
||||
final int min = Math.min(total.size(), numkw);
|
||||
@@ -336,10 +368,8 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (sa.hasParam("Radiance")) {
|
||||
for (final Card c : CardUtil.getRadiance(host, tgtCards.get(0), sa.getParam("ValidTgts")
|
||||
.split(","))) {
|
||||
untargetedCards.add(c);
|
||||
}
|
||||
untargetedCards.addAll(CardUtil.getRadiance(host, tgtCards.get(0), sa.getParam("ValidTgts")
|
||||
.split(",")));
|
||||
}
|
||||
|
||||
final ZoneType pumpZone = sa.hasParam("PumpZone") ? ZoneType.smartValueOf(sa.getParam("PumpZone"))
|
||||
|
||||
@@ -29,10 +29,10 @@ public class RestartGameEffect extends SpellAbilityEffect {
|
||||
final Player activator = sa.getActivatingPlayer();
|
||||
final Game game = activator.getGame();
|
||||
FCollectionView<Player> players = game.getPlayers();
|
||||
Map<Player, List<Card>> playerLibraries = new HashMap<Player, List<Card>>();
|
||||
Map<Player, List<Card>> playerLibraries = new HashMap<>();
|
||||
|
||||
// Don't grab Ante Zones
|
||||
List<ZoneType> restartZones = new ArrayList<ZoneType>(Arrays.asList(ZoneType.Battlefield,
|
||||
List<ZoneType> restartZones = new ArrayList<>(Arrays.asList(ZoneType.Battlefield,
|
||||
ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command));
|
||||
|
||||
ZoneType leaveZone = ZoneType.smartValueOf(sa.hasParam("RestrictFromZone") ? sa.getParam("RestrictFromZone") : null);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class RunSVarAbilityEffect extends SpellAbilityEffect {
|
||||
if (sVars == null || cards.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<SpellAbility> validSA = new ArrayList<SpellAbility>();
|
||||
List<SpellAbility> validSA = new ArrayList<>();
|
||||
final boolean isTrigger = sa.hasParam("IsTrigger");
|
||||
for (final Card tgtC : cards) {
|
||||
if (!tgtC.hasSVar(sVars)) {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SacrificeEffect extends SpellAbilityEffect {
|
||||
game.updateLastStateForCard(card);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Cumulative upkeep for " + card);
|
||||
sb.append("Cumulative upkeep for ").append(card);
|
||||
|
||||
boolean isPaid = activator.getController().payManaOptional(card, payCost, sa, sb.toString(), ManaPaymentPurpose.CumulativeUpkeep);
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
|
||||
@@ -14,8 +14,8 @@ public class StoreMapEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
List<GameEntity> entity = new ArrayList<GameEntity>();
|
||||
List<Object> objects = new ArrayList<Object>();
|
||||
List<GameEntity> entity = new ArrayList<>();
|
||||
List<Object> objects = new ArrayList<>();
|
||||
|
||||
if (sa.hasParam("RememberEntity")) {
|
||||
entity.addAll(AbilityUtils.getDefinedPlayers(source, sa.getParam("RememberEntity"), sa));
|
||||
|
||||
@@ -368,14 +368,14 @@ public class TokenEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
private String parseColorForImage() {
|
||||
String originalColorDesc = "";
|
||||
StringBuilder originalColorDesc = new StringBuilder();
|
||||
for (final String col : this.tokenOriginalColors) {
|
||||
originalColorDesc += MagicColor.toShortString(col);
|
||||
if (originalColorDesc.equals("C")) {
|
||||
return originalColorDesc;
|
||||
originalColorDesc.append(MagicColor.toShortString(col));
|
||||
if (originalColorDesc.toString().equals("C")) {
|
||||
return originalColorDesc.toString();
|
||||
}
|
||||
}
|
||||
return originalColorDesc;
|
||||
return originalColorDesc.toString();
|
||||
}
|
||||
|
||||
private String determineTokenColor(Card host) {
|
||||
|
||||
@@ -106,16 +106,16 @@ public class TwoPilesEffect extends SpellAbilityEffect {
|
||||
CardCollectionView chosenPile = pile1WasChosen ? pile1 : pile2;
|
||||
CardCollectionView unchosenPile = !pile1WasChosen ? pile1 : pile2;
|
||||
|
||||
String notification = chooser + " chooses Pile " + (pile1WasChosen ? "1" : "2") + ":\n";
|
||||
StringBuilder notification = new StringBuilder(chooser + " chooses Pile " + (pile1WasChosen ? "1" : "2") + ":\n");
|
||||
if (!chosenPile.isEmpty()) {
|
||||
for (Card c : chosenPile) {
|
||||
notification += c.getName() + "\n";
|
||||
notification.append(c.getName()).append("\n");
|
||||
}
|
||||
} else {
|
||||
notification += "(Empty pile)";
|
||||
notification.append("(Empty pile)");
|
||||
}
|
||||
|
||||
p.getGame().getAction().nofityOfValue(sa, chooser, notification, chooser);
|
||||
p.getGame().getAction().nofityOfValue(sa, chooser, notification.toString(), chooser);
|
||||
|
||||
// take action on the chosen pile
|
||||
if (sa.hasParam("ChosenPile")) {
|
||||
|
||||
@@ -113,7 +113,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
private final Map<StaticAbility, CardPlayOption> mayPlay = Maps.newHashMap();
|
||||
|
||||
private final Multimap<Long, Player> withFlash = HashMultimap.<Long, Player>create();
|
||||
private final Multimap<Long, Player> withFlash = HashMultimap.create();
|
||||
|
||||
// changes by AF animate and continuous static effects - timestamp is the key of maps
|
||||
private final Map<Long, CardChangedType> changedCardTypes = Maps.newTreeMap();
|
||||
@@ -123,6 +123,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
private final NavigableMap<Long, CardCloneStates> clonedStates = Maps.newTreeMap();
|
||||
private final NavigableMap<Long, CardCloneStates> textChangeStates = Maps.newTreeMap();
|
||||
|
||||
private final Map<Long, Integer> canBlockAdditional = Maps.newTreeMap();
|
||||
private final Set<Long> canBlockAny = Sets.newHashSet();
|
||||
|
||||
// changes that say "replace each instance of one [color,type] by another - timestamp is the key of maps
|
||||
private final CardChangedWords changedTextColors = new CardChangedWords();
|
||||
@@ -195,6 +197,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
// stack of set power/toughness
|
||||
private Map<Long, Pair<Integer,Integer>> newPT = Maps.newTreeMap();
|
||||
private Map<Long, Pair<Integer,Integer>> newPTCharacterDefining = Maps.newTreeMap();
|
||||
private Map<Long, Pair<Integer,Integer>> boostPT = Maps.newTreeMap();
|
||||
|
||||
private String basePowerString = null;
|
||||
private String baseToughnessString = null;
|
||||
private String oracleText = "";
|
||||
@@ -208,12 +212,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
private int turnInZone;
|
||||
|
||||
private int tempPowerBoost = 0;
|
||||
private int tempToughnessBoost = 0;
|
||||
|
||||
private int semiPermanentPowerBoost = 0;
|
||||
private int semiPermanentToughnessBoost = 0;
|
||||
|
||||
private int xManaCostPaid = 0;
|
||||
private Map<String, Integer> xManaCostPaidByColor;
|
||||
|
||||
@@ -1200,9 +1198,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
if (type == CounterType.DREAM) {
|
||||
// need to be done extra because it is also a state based action
|
||||
if (hasKeyword("CARDNAME can't have more than seven dream counters on it.") && getCounters(CounterType.DREAM) > 6) {
|
||||
return false;
|
||||
}
|
||||
return !hasKeyword("CARDNAME can't have more than seven dream counters on it.") || getCounters(CounterType.DREAM) <= 6;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1658,13 +1654,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (!mCost.isOnlyManaCost()) {
|
||||
sbLong.append(".");
|
||||
}
|
||||
sbLong.append(" (" + inst.getReminderText() + ")");
|
||||
sbLong.append(" (").append(inst.getReminderText()).append(")");
|
||||
sbLong.append("\r\n");
|
||||
}
|
||||
} else if (keyword.startsWith("Emerge")) {
|
||||
final String[] k = keyword.split(":");
|
||||
sbLong.append(k[0]).append(" ").append(ManaCostParser.parse(k[1]));
|
||||
sbLong.append(" (" + inst.getReminderText() + ")");
|
||||
sbLong.append(" (").append(inst.getReminderText()).append(")");
|
||||
sbLong.append("\r\n");
|
||||
} else if (keyword.startsWith("Echo")) {
|
||||
sbLong.append("Echo ");
|
||||
@@ -1695,7 +1691,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
final String[] n = keyword.split(":");
|
||||
final Cost cost = new Cost(n[1], false);
|
||||
sbLong.append("Multikicker ").append(cost.toSimpleString());
|
||||
sbLong.append(" (" + inst.getReminderText() + ")").append("\r\n");
|
||||
sbLong.append(" (").append(inst.getReminderText()).append(")").append("\r\n");
|
||||
}
|
||||
} else if (keyword.startsWith("Kicker")) {
|
||||
if (!keyword.endsWith("Generic")) {
|
||||
@@ -1709,11 +1705,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
final Cost cost2 = new Cost(n[2], false);
|
||||
sbx.append(cost2.toSimpleString());
|
||||
}
|
||||
sbx.append(" (" + inst.getReminderText() + ")");
|
||||
sbx.append(" (").append(inst.getReminderText()).append(")");
|
||||
sbLong.append(sbx).append("\r\n");
|
||||
}
|
||||
} else if (keyword.startsWith("Hexproof:")) {
|
||||
final String k[] = keyword.split(":");
|
||||
final String[] k = keyword.split(":");
|
||||
sbLong.append("Hexproof from ").append(k[2])
|
||||
.append(" (").append(inst.getReminderText()).append(")").append("\r\n");
|
||||
} else if (keyword.endsWith(".") && !keyword.startsWith("Haunt")) {
|
||||
@@ -1739,10 +1735,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|| keyword.equals("Hideaway") || keyword.equals("Ascend")
|
||||
|| keyword.equals("Totem armor") || keyword.equals("Battle cry")
|
||||
|| keyword.equals("Devoid") || keyword.equals("Riot")){
|
||||
sbLong.append(keyword + " (" + inst.getReminderText() + ")");
|
||||
sbLong.append(keyword).append(" (").append(inst.getReminderText()).append(")");
|
||||
} else if (keyword.startsWith("Partner:")) {
|
||||
final String[] k = keyword.split(":");
|
||||
sbLong.append("Partner with " + k[1] + " (" + inst.getReminderText() + ")");
|
||||
sbLong.append("Partner with ").append(k[1]).append(" (").append(inst.getReminderText()).append(")");
|
||||
} else if (keyword.startsWith("Modular") || keyword.startsWith("Bloodthirst") || keyword.startsWith("Dredge")
|
||||
|| keyword.startsWith("Fabricate") || keyword.startsWith("Soulshift") || keyword.startsWith("Bushido")
|
||||
|| keyword.startsWith("Crew") || keyword.startsWith("Tribute") || keyword.startsWith("Absorb")
|
||||
@@ -1751,7 +1747,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|| keyword.startsWith("Afflict") || keyword.startsWith ("Poisonous") || keyword.startsWith("Rampage")
|
||||
|| keyword.startsWith("Renown") || keyword.startsWith("Annihilator") || keyword.startsWith("Devour")) {
|
||||
final String[] k = keyword.split(":");
|
||||
sbLong.append(k[0] + " " + k[1] + " (" + inst.getReminderText() + ")");
|
||||
sbLong.append(k[0]).append(" ").append(k[1]).append(" (").append(inst.getReminderText()).append(")");
|
||||
} else if (keyword.contains("Haunt")) {
|
||||
sb.append("\r\nHaunt (");
|
||||
if (isCreature()) {
|
||||
@@ -1772,14 +1768,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (sb.length() != 0) {
|
||||
sb.append("\r\n");
|
||||
}
|
||||
sb.append(keyword + " (" + inst.getReminderText() + ")");
|
||||
sb.append(keyword).append(" (").append(inst.getReminderText()).append(")");
|
||||
} else if (keyword.endsWith(" offering")) {
|
||||
String offeringType = keyword.split(" ")[0];
|
||||
if (sb.length() != 0) {
|
||||
sb.append("\r\n");
|
||||
}
|
||||
sbLong.append(keyword);
|
||||
sbLong.append(" (" + Keyword.getInstance("Offering:"+ offeringType).getReminderText() + ")");
|
||||
sbLong.append(" (").append(Keyword.getInstance("Offering:" + offeringType).getReminderText()).append(")");
|
||||
} else if (keyword.startsWith("Equip") || keyword.startsWith("Fortify") || keyword.startsWith("Outlast")
|
||||
|| keyword.startsWith("Unearth") || keyword.startsWith("Scavenge") || keyword.startsWith("Spectacle")
|
||||
|| keyword.startsWith("Evoke") || keyword.startsWith("Bestow") || keyword.startsWith("Dash")
|
||||
@@ -1807,7 +1803,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
} else if (keyword.equals("AllNonLegendaryCreatureNames")) {
|
||||
sbLong.append(getName()).append(" has all names of nonlegendary creature cards.\r\n");
|
||||
} else if (keyword.startsWith("IfReach")) {
|
||||
String k[] = keyword.split(":");
|
||||
String[] k = keyword.split(":");
|
||||
sbLong.append(getName()).append(" can block ")
|
||||
.append(CardType.getPluralType(k[1]))
|
||||
.append(" as though it had reach.\r\n");
|
||||
@@ -1817,7 +1813,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
String desc = AbilityFactory.getMapParams(getSVar(k[1])).get("SpellDescription");
|
||||
sbLong.append(desc);
|
||||
} else if (keyword.startsWith("Saga")) {
|
||||
String k[] = keyword.split(":");
|
||||
String[] k = keyword.split(":");
|
||||
String desc = "(As this Saga enters and after your draw step, "
|
||||
+ " add a lore counter. Sacrifice after " + Strings.repeat("I", Integer.valueOf(k[1])) + ".)";
|
||||
sbLong.append(desc);
|
||||
@@ -1941,7 +1937,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
String meld = this.getRules().getMeldWith();
|
||||
if (meld != "" && (!hasMeldEffect)) {
|
||||
sb.append("\r\n");
|
||||
sb.append("(Melds with " + meld + ".)");
|
||||
sb.append("(Melds with ").append(meld).append(".)");
|
||||
sb.append("\r\n");
|
||||
}
|
||||
}
|
||||
@@ -2048,9 +2044,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
if (isGoaded()) {
|
||||
sb.append("is goaded by: " + Lang.joinHomogenous(getGoaded()));
|
||||
sb.append("is goaded by: ").append(Lang.joinHomogenous(getGoaded()));
|
||||
sb.append("\r\n");
|
||||
}
|
||||
|
||||
// replace triple line feeds with double line feeds
|
||||
int start;
|
||||
final String s = "\r\n\r\n\r\n";
|
||||
@@ -2110,17 +2107,17 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|| keyword.equals("Undaunted") || keyword.equals("Cascade")
|
||||
|| keyword.equals("Devoid") || keyword.equals("Lifelink")
|
||||
|| keyword.equals("Split second")) {
|
||||
sbBefore.append(keyword + " (" + inst.getReminderText() + ")");
|
||||
sbBefore.append(keyword).append(" (").append(inst.getReminderText()).append(")");
|
||||
sbBefore.append("\r\n");
|
||||
} else if(keyword.equals("Conspire") || keyword.equals("Epic")
|
||||
|| keyword.equals("Suspend") || keyword.equals("Jump-start")) {
|
||||
sbAfter.append(keyword + " (" + inst.getReminderText() + ")");
|
||||
sbAfter.append(keyword).append(" (").append(inst.getReminderText()).append(")");
|
||||
sbAfter.append("\r\n");
|
||||
} else if (keyword.startsWith("Ripple")) {
|
||||
sbBefore.append(TextUtil.fastReplace(keyword, ":", " ") + " (" + inst.getReminderText() + ")");
|
||||
sbBefore.append(TextUtil.fastReplace(keyword, ":", " ")).append(" (").append(inst.getReminderText()).append(")");
|
||||
sbBefore.append("\r\n");
|
||||
} else if (keyword.startsWith("Dredge")) {
|
||||
sbAfter.append(TextUtil.fastReplace(keyword, ":", " ") + " (" + inst.getReminderText() + ")");
|
||||
sbAfter.append(TextUtil.fastReplace(keyword, ":", " ")).append(" (").append(inst.getReminderText()).append(")");
|
||||
sbAfter.append("\r\n");
|
||||
} else if (keyword.startsWith("Escalate") || keyword.startsWith("Buyback")
|
||||
|| keyword.startsWith("Prowl")) {
|
||||
@@ -2135,14 +2132,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
sbCost.append(" ");
|
||||
}
|
||||
sbCost.append(cost.toSimpleString());
|
||||
sbBefore.append(sbCost + " (" + inst.getReminderText() + ")");
|
||||
sbBefore.append(sbCost).append(" (").append(inst.getReminderText()).append(")");
|
||||
sbBefore.append("\r\n");
|
||||
} else if (keyword.startsWith("Multikicker")) {
|
||||
if (!keyword.endsWith("Generic")) {
|
||||
final String[] n = keyword.split(":");
|
||||
final Cost cost = new Cost(n[1], false);
|
||||
sbBefore.append("Multikicker ").append(cost.toSimpleString())
|
||||
.append(" (" + inst.getReminderText() + ")").append("\r\n");
|
||||
sbBefore.append("Multikicker ").append(cost.toSimpleString()).append(" (").append(inst.getReminderText()).append(")").append("\r\n");
|
||||
}
|
||||
} else if (keyword.startsWith("Kicker")) {
|
||||
if (!keyword.endsWith("Generic")) {
|
||||
@@ -2156,7 +2152,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
final Cost cost2 = new Cost(n[2], false);
|
||||
sbx.append(cost2.toSimpleString());
|
||||
}
|
||||
sbx.append(" (" + inst.getReminderText() + ")");
|
||||
sbx.append(" (").append(inst.getReminderText()).append(")");
|
||||
sbBefore.append(sbx).append("\r\n");
|
||||
}
|
||||
}else if (keyword.startsWith("AlternateAdditionalCost")) {
|
||||
@@ -2185,7 +2181,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
sbCost.append(" ");
|
||||
}
|
||||
sbCost.append(cost.toSimpleString());
|
||||
sbAfter.append(sbCost + " (" + inst.getReminderText() + ")");
|
||||
sbAfter.append(sbCost).append(" (").append(inst.getReminderText()).append(")");
|
||||
sbAfter.append("\r\n");
|
||||
} else if (keyword.equals("CARDNAME can't be countered.") ||
|
||||
keyword.equals("Remove CARDNAME from your deck before playing if you're not playing for ante.")) {
|
||||
@@ -2205,7 +2201,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (n.length > 3) {
|
||||
desc = n[3];
|
||||
} else {
|
||||
String k[] = n[1].split(",");
|
||||
String[] k = n[1].split(",");
|
||||
for (int i = 0; i < k.length; i++) {
|
||||
if (CardType.isACardType(k[i])) {
|
||||
k[i] = k[i].toLowerCase();
|
||||
@@ -2215,7 +2211,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
sbAfter.append("Splice onto ").append(desc).append(" ").append(cost.toSimpleString());
|
||||
sbAfter.append(" (" + inst.getReminderText() + ")").append("\r\n");
|
||||
sbAfter.append(" (").append(inst.getReminderText()).append(")").append("\r\n");
|
||||
} else if (keyword.equals("Storm")) {
|
||||
sbAfter.append("Storm (");
|
||||
|
||||
@@ -3343,7 +3339,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
public final StatBreakdown getUnswitchedPowerBreakdown() {
|
||||
return new StatBreakdown(getCurrentPower(), getTempPowerBoost(), getSemiPermanentPowerBoost(), getPowerBonusFromCounters());
|
||||
return new StatBreakdown(getCurrentPower(), getTempPowerBoost(), getPowerBonusFromCounters());
|
||||
}
|
||||
public final int getUnswitchedPower() {
|
||||
return getUnswitchedPowerBreakdown().getTotal();
|
||||
@@ -3380,31 +3376,28 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
public static class StatBreakdown {
|
||||
public final int currentValue;
|
||||
public final int tempBoost;
|
||||
public final int semiPermanentBoost;
|
||||
public final int bonusFromCounters;
|
||||
public StatBreakdown() {
|
||||
this.currentValue = 0;
|
||||
this.tempBoost = 0;
|
||||
this.semiPermanentBoost = 0;
|
||||
this.bonusFromCounters = 0;
|
||||
}
|
||||
public StatBreakdown(int currentValue, int tempBoost, int semiPermanentBoost, int bonusFromCounters){
|
||||
public StatBreakdown(int currentValue, int tempBoost, int bonusFromCounters){
|
||||
this.currentValue = currentValue;
|
||||
this.tempBoost = tempBoost;
|
||||
this.semiPermanentBoost = semiPermanentBoost;
|
||||
this.bonusFromCounters = bonusFromCounters;
|
||||
}
|
||||
public int getTotal() {
|
||||
return currentValue + tempBoost + semiPermanentBoost + bonusFromCounters;
|
||||
return currentValue + tempBoost + bonusFromCounters;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return TextUtil.concatWithSpace("c:"+String.valueOf(currentValue),"tb:"+String.valueOf(tempBoost), "spb:"+String.valueOf(semiPermanentBoost),"bfc:"+String.valueOf(bonusFromCounters));
|
||||
return TextUtil.concatWithSpace("c:"+ currentValue,"tb:"+ tempBoost,"bfc:"+ bonusFromCounters);
|
||||
}
|
||||
}
|
||||
|
||||
public final StatBreakdown getUnswitchedToughnessBreakdown() {
|
||||
return new StatBreakdown(getCurrentToughness(), getTempToughnessBoost(), getSemiPermanentToughnessBoost(), getToughnessBonusFromCounters());
|
||||
return new StatBreakdown(getCurrentToughness(), getTempToughnessBoost(), getToughnessBonusFromCounters());
|
||||
}
|
||||
public final int getUnswitchedToughness() {
|
||||
return getUnswitchedToughnessBreakdown().getTotal();
|
||||
@@ -3465,62 +3458,44 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
// for cards like Giant Growth, etc.
|
||||
public final int getTempPowerBoost() {
|
||||
return tempPowerBoost;
|
||||
int result = 0;
|
||||
for (Pair<Integer, Integer> pair : boostPT.values()) {
|
||||
if (pair.getLeft() != null) {
|
||||
result += pair.getLeft();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public final int getTempToughnessBoost() {
|
||||
return tempToughnessBoost;
|
||||
}
|
||||
|
||||
public final void addTempPowerBoost(final int n) {
|
||||
if (n == 0) { return; }
|
||||
tempPowerBoost += n;
|
||||
currentState.getView().updatePower(this);
|
||||
}
|
||||
|
||||
public final void addTempToughnessBoost(final int n) {
|
||||
if (n == 0) { return; }
|
||||
tempToughnessBoost += n;
|
||||
currentState.getView().updateToughness(this);
|
||||
}
|
||||
|
||||
// for cards like Glorious Anthem, etc.
|
||||
public final int getSemiPermanentPowerBoost() {
|
||||
return semiPermanentPowerBoost;
|
||||
}
|
||||
|
||||
public final int getSemiPermanentToughnessBoost() {
|
||||
return semiPermanentToughnessBoost;
|
||||
}
|
||||
|
||||
public final void addSemiPermanentPowerBoost(final int n, final boolean updateViewImmediately) {
|
||||
if (n == 0) { return; }
|
||||
semiPermanentPowerBoost += n;
|
||||
if (updateViewImmediately) {
|
||||
currentState.getView().updatePower(this);
|
||||
int result = 0;
|
||||
for (Pair<Integer, Integer> pair : boostPT.values()) {
|
||||
if (pair.getRight() != null) {
|
||||
result += pair.getRight();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public final void addSemiPermanentToughnessBoost(final int n, final boolean updateViewImmediately) {
|
||||
if (n == 0) { return; }
|
||||
semiPermanentToughnessBoost += n;
|
||||
if (updateViewImmediately) {
|
||||
currentState.getView().updateToughness(this);
|
||||
public void addPTBoost(final Integer power, final Integer toughness, final long timestamp) {
|
||||
boostPT.put(timestamp, Pair.of(power, toughness));
|
||||
}
|
||||
|
||||
public void removePTBoost(final long timestamp) {
|
||||
boostPT.remove(timestamp);
|
||||
}
|
||||
|
||||
public Map<Long, Pair<Integer, Integer>> getPTBoostMap() {
|
||||
return ImmutableMap.copyOf(boostPT);
|
||||
}
|
||||
|
||||
public void setPTBoost(Map<Long, Pair<Integer, Integer>> map) {
|
||||
this.boostPT.clear();
|
||||
for (Map.Entry<Long, Pair<Integer,Integer>> e : map.entrySet()) {
|
||||
this.boostPT.put(e.getKey(), Pair.of(e.getValue().getLeft(), e.getValue().getRight()));
|
||||
}
|
||||
}
|
||||
|
||||
public final void setSemiPermanentPowerBoost(final int n) {
|
||||
if (semiPermanentPowerBoost == n) { return; }
|
||||
semiPermanentPowerBoost = n;
|
||||
currentState.getView().updatePower(this);
|
||||
}
|
||||
|
||||
public final void setSemiPermanentToughnessBoost(final int n) {
|
||||
if (semiPermanentToughnessBoost == n) { return; }
|
||||
semiPermanentToughnessBoost = n;
|
||||
currentState.getView().updateToughness(this);
|
||||
}
|
||||
|
||||
public final boolean isUntapped() {
|
||||
return !tapped;
|
||||
}
|
||||
@@ -4810,7 +4785,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
CardCollection newCardsInCommand = (CardCollection)getGame().getCardsIn(ZoneType.Command);
|
||||
newCardsInCommand.removeAll(cardsInCommand);
|
||||
if (!newCardsInCommand.isEmpty()) {
|
||||
newCardsInCommand.get(0).setSVar("PreventedDamage", "Number$" + Integer.toString(dmgToBePrevented));
|
||||
newCardsInCommand.get(0).setSVar("PreventedDamage", "Number$" + dmgToBePrevented);
|
||||
}
|
||||
}
|
||||
subtractPreventNextDamageWithEffect(shieldSource, restDamage);
|
||||
@@ -5105,7 +5080,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
addChangedCardTypes(new CardType(Collections.singletonList("Aura")),
|
||||
new CardType(Collections.singletonList("Creature")),
|
||||
false, false, false, false, false, false, true, bestowTimestamp, updateView);
|
||||
addChangedCardKeywords(Collections.singletonList("Enchant creature"), Lists.<String>newArrayList(),
|
||||
addChangedCardKeywords(Collections.singletonList("Enchant creature"), Lists.newArrayList(),
|
||||
false, false, bestowTimestamp, updateView);
|
||||
}
|
||||
|
||||
@@ -5409,7 +5384,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
switch (kw.getOriginal()) {
|
||||
case "Shroud":
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Can target CardUID_").append(String.valueOf(getId()));
|
||||
sb.append("Can target CardUID_").append(getId());
|
||||
sb.append(" with spells and abilities as though it didn't have shroud.");
|
||||
if (sa.getActivatingPlayer() == null) {
|
||||
System.err.println("Unexpected behavior: SA activator was null when trying to determine if the activating player could target a card with Shroud. SA host card = " + source + ", SA = " + sa);
|
||||
@@ -5472,9 +5447,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
// check valid
|
||||
if (!isValid(tgt.getValidTgts(), aura.getController(), aura, sa)) {
|
||||
return false;
|
||||
}
|
||||
return isValid(tgt.getValidTgts(), aura.getController(), aura, sa);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -5482,18 +5455,12 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|
||||
@Override
|
||||
protected final boolean canBeEquippedBy(final Card equip) {
|
||||
if (!isCreature() || !isInPlay()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return isCreature() && isInPlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canBeFortifiedBy(final Card fort) {
|
||||
if (!isLand() || !isInPlay() || fort.isLand()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return isLand() && isInPlay() && !fort.isLand();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -5752,11 +5719,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
}
|
||||
|
||||
if (!getController().canSacrificeBy(source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return getController().canSacrificeBy(source);
|
||||
}
|
||||
|
||||
public CardRules getRules() {
|
||||
@@ -6155,10 +6118,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (hasKeyword(Keyword.FLASH)) {
|
||||
return true;
|
||||
}
|
||||
if (withFlash.containsValue(p)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return withFlash.containsValue(p);
|
||||
}
|
||||
|
||||
public void addWithFlash(Long timestamp, Iterable<Player> players) {
|
||||
@@ -6195,11 +6155,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getOwner().canDiscardBy(sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return getOwner().canDiscardBy(sa);
|
||||
}
|
||||
|
||||
public void addAbilityActivated(SpellAbility ability) {
|
||||
@@ -6271,4 +6227,45 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
numberTurnActivations.clear();
|
||||
numberTurnActivationsStatic.clear();
|
||||
}
|
||||
|
||||
public void addCanBlockAdditional(int n, long timestamp) {
|
||||
if (n <= 0) {
|
||||
return;
|
||||
}
|
||||
canBlockAdditional.put(timestamp, n);
|
||||
getView().updateBlockAdditional(this);
|
||||
}
|
||||
|
||||
public boolean removeCanBlockAdditional(long timestamp) {
|
||||
boolean result = canBlockAdditional.remove(timestamp) != null;
|
||||
if (result) {
|
||||
getView().updateBlockAdditional(this);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int canBlockAdditional() {
|
||||
int result = 0;
|
||||
for (Integer v : canBlockAdditional.values()) {
|
||||
result += v;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addCanBlockAny(long timestamp) {
|
||||
canBlockAny.add(timestamp);
|
||||
getView().updateBlockAdditional(this);
|
||||
}
|
||||
|
||||
public boolean removeCanBlockAny(long timestamp) {
|
||||
boolean result = canBlockAny.remove(timestamp);
|
||||
if (result) {
|
||||
getView().updateBlockAdditional(this);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean canBlockAny() {
|
||||
return !canBlockAny.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,7 +645,7 @@ public class CardFactory {
|
||||
Trigger t = null;
|
||||
if (sa.isWrapper()) {
|
||||
// copy trigger?
|
||||
t = ((WrappedAbility) sa).getTrigger();
|
||||
t = sa.getTrigger();
|
||||
} else { // some keyword ability, e.g. Exalted, Annihilator
|
||||
return sa.copy();
|
||||
}
|
||||
@@ -677,7 +677,7 @@ public class CardFactory {
|
||||
|
||||
WrappedAbility wrapperAbility = new WrappedAbility(t, trig, ((WrappedAbility) sa).getDecider());
|
||||
wrapperAbility.setTrigger(true);
|
||||
wrapperAbility.setMandatory(((WrappedAbility) sa).isMandatory());
|
||||
wrapperAbility.setMandatory(sa.isMandatory());
|
||||
wrapperAbility.setDescription(wrapperAbility.getStackDescription());
|
||||
t.setTriggeredSA(wrapperAbility);
|
||||
return wrapperAbility;
|
||||
@@ -774,7 +774,7 @@ public class CardFactory {
|
||||
|
||||
// triggers to add to clone
|
||||
if (sa.hasParam("AddTriggers")) {
|
||||
for (final String s : Arrays.asList(sa.getParam("AddTriggers").split(","))) {
|
||||
for (final String s : sa.getParam("AddTriggers").split(",")) {
|
||||
if (origSVars.containsKey(s)) {
|
||||
final String actualTrigger = origSVars.get(s);
|
||||
final Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, out, true);
|
||||
@@ -786,7 +786,7 @@ public class CardFactory {
|
||||
// SVars to add to clone
|
||||
if (sa.hasParam("AddSVars") || sa.hasParam("GainTextSVars")) {
|
||||
final String str = sa.getParamOrDefault("GainTextSVars", sa.getParam("AddSVars"));
|
||||
for (final String s : Arrays.asList(str.split(","))) {
|
||||
for (final String s : str.split(",")) {
|
||||
if (origSVars.containsKey(s)) {
|
||||
final String actualsVar = origSVars.get(s);
|
||||
state.setSVar(s, actualsVar);
|
||||
@@ -797,7 +797,7 @@ public class CardFactory {
|
||||
// abilities to add to clone
|
||||
if (sa.hasParam("AddAbilities") || sa.hasParam("GainTextAbilities")) {
|
||||
final String str = sa.getParamOrDefault("GainTextAbilities", sa.getParam("AddAbilities"));
|
||||
for (final String s : Arrays.asList(str.split(","))) {
|
||||
for (final String s : str.split(",")) {
|
||||
if (origSVars.containsKey(s)) {
|
||||
final String actualAbility = origSVars.get(s);
|
||||
final SpellAbility grantedAbility = AbilityFactory.getAbility(actualAbility, out);
|
||||
|
||||
@@ -147,7 +147,7 @@ public class CardFactoryUtil {
|
||||
sbCost.append("— ");
|
||||
}
|
||||
// get rid of the ": " at the end
|
||||
sbCost.append(costDesc.substring(0, costDesc.length() - 2));
|
||||
sbCost.append(costDesc, 0, costDesc.length() - 2);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ST$ SetState | Cost$ ").append(costStr).append(" | CostDesc$ ").append(sbCost);
|
||||
@@ -292,11 +292,7 @@ public class CardFactoryUtil {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean isCounterable(final Card c) {
|
||||
if (c.hasKeyword("CARDNAME can't be countered.") || !c.getCanCounter()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !c.hasKeyword("CARDNAME can't be countered.") && c.getCanCounter();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +314,7 @@ public class CardFactoryUtil {
|
||||
for (KeywordInterface k : c.getKeywords()) {
|
||||
final String o = k.getOriginal();
|
||||
if (o.startsWith("CantBeCounteredBy")) {
|
||||
final String m[] = o.split(":");
|
||||
final String[] m = o.split(":");
|
||||
if (sa.isValid(m[1].split(","), c.getController(), c, null)) {
|
||||
return false;
|
||||
}
|
||||
@@ -905,11 +901,11 @@ public class CardFactoryUtil {
|
||||
|
||||
if (sq[0].contains("xColorPaid")) {
|
||||
String[] attrs = sq[0].split(" ");
|
||||
String colors = "";
|
||||
StringBuilder colors = new StringBuilder();
|
||||
for (int i = 1; i < attrs.length; i++) {
|
||||
colors += attrs[i];
|
||||
colors.append(attrs[i]);
|
||||
}
|
||||
return doXMath(c.getXManaCostPaidCount(colors), m, c);
|
||||
return doXMath(c.getXManaCostPaidCount(colors.toString()), m, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -2117,7 +2113,7 @@ public class CardFactoryUtil {
|
||||
}
|
||||
|
||||
if (!zone.isEmpty()) {
|
||||
repEffsb.append(" | ActiveZones$ " + zone);
|
||||
repEffsb.append(" | ActiveZones$ ").append(zone);
|
||||
}
|
||||
|
||||
ReplacementEffect re = ReplacementHandler.parseReplacement(repEffsb.toString(), card, intrinsic);
|
||||
@@ -2186,12 +2182,12 @@ public class CardFactoryUtil {
|
||||
final String abStringAfflict = "DB$ LoseLife | Defined$ TriggeredDefendingPlayer" +
|
||||
" | LifeAmount$ " + n;
|
||||
|
||||
final Trigger afflictTrigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic);
|
||||
final Trigger afflictTrigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic);
|
||||
afflictTrigger.setOverridingAbility(AbilityFactory.getAbility(abStringAfflict, card));
|
||||
|
||||
inst.addTrigger(afflictTrigger);
|
||||
} else if (keyword.startsWith("Afterlife")) {
|
||||
final String k[] = keyword.split(":");
|
||||
final String[] k = keyword.split(":");
|
||||
final String name = StringUtils.join(k, " ");
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -2327,7 +2323,7 @@ public class CardFactoryUtil {
|
||||
|
||||
StringBuilder trig = new StringBuilder();
|
||||
trig.append("Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self");
|
||||
trig.append(" | TriggerDescription$ Champion ").append(article + " ").append(desc);
|
||||
trig.append(" | TriggerDescription$ Champion ").append(article).append(" ").append(desc);
|
||||
trig.append(" (").append(Keyword.getInstance("Champion:"+desc).getReminderText()) .append(")");
|
||||
|
||||
StringBuilder trigReturn = new StringBuilder();
|
||||
@@ -2435,7 +2431,7 @@ public class CardFactoryUtil {
|
||||
final String effect = "DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | "
|
||||
+ "CounterNum$ 1 | Evolve$ True";
|
||||
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic);
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic);
|
||||
trigger.setOverridingAbility(AbilityFactory.getAbility(effect, card));
|
||||
|
||||
inst.addTrigger(trigger);
|
||||
@@ -2681,7 +2677,7 @@ public class CardFactoryUtil {
|
||||
final StringBuilder sbTrig = new StringBuilder();
|
||||
sbTrig.append("Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ");
|
||||
sbTrig.append("ValidCard$ Card.Self | Secondary$ True | TriggerDescription$ ");
|
||||
sbTrig.append("Living Weapon (" + inst.getReminderText() + ")");
|
||||
sbTrig.append("Living Weapon (").append(inst.getReminderText()).append(")");
|
||||
|
||||
final StringBuilder sbGerm = new StringBuilder();
|
||||
sbGerm.append("DB$ Token | TokenAmount$ 1 | TokenScript$ b_0_0_germ |TokenOwner$ You | RememberTokens$ True");
|
||||
@@ -2731,7 +2727,7 @@ public class CardFactoryUtil {
|
||||
" | TriggerDescription$ Melee (" + inst.getReminderText() + ")";
|
||||
|
||||
final String effect = "DB$ Pump | Defined$ TriggeredAttackerLKICopy | NumAtt$ MeleeX | NumDef$ MeleeX";
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic);
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic);
|
||||
|
||||
SpellAbility sa = AbilityFactory.getAbility(effect, card);
|
||||
sa.setSVar("MeleeX", "TriggeredPlayersDefenders$Amount");
|
||||
@@ -2746,7 +2742,7 @@ public class CardFactoryUtil {
|
||||
final String effect = "DB$ PutCounter | CounterType$ P1P1 | CounterNum$ 1"
|
||||
+ " | ValidTgts$ Creature.attacking+powerLTX"
|
||||
+ " | TgtPrompt$ Select target attacking creature with less power";
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic);
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic);
|
||||
|
||||
SpellAbility sa = AbilityFactory.getAbility(effect, card);
|
||||
sa.setSVar("X", "Count$CardPower");
|
||||
@@ -2854,7 +2850,7 @@ public class CardFactoryUtil {
|
||||
final String trigStr = "Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | CombatDamage$ True | Secondary$ True"
|
||||
+ " | TriggerZones$ Battlefield | TriggerDescription$ Poisonous " + n + " (" + inst.getReminderText() + ")";
|
||||
|
||||
final Trigger parsedTrigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic);
|
||||
final Trigger parsedTrigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic);
|
||||
|
||||
final String effect = "DB$ Poison | Defined$ TriggeredTarget | Num$ " + n;
|
||||
parsedTrigger.setOverridingAbility(AbilityFactory.getAbility(effect, card));
|
||||
@@ -2902,7 +2898,7 @@ public class CardFactoryUtil {
|
||||
final String effect = "DB$ Pump | Defined$ TriggeredAttackerLKICopy" +
|
||||
" | NumAtt$ Rampage" + n + " | NumDef$ Rampage" + n;
|
||||
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic);
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic);
|
||||
|
||||
SpellAbility sa = AbilityFactory.getAbility(effect, card);
|
||||
sa.setSVar("Rampage" + n, "SVar$RampageCount/Times." + n);
|
||||
@@ -3070,7 +3066,7 @@ public class CardFactoryUtil {
|
||||
inst.addTrigger(parsedTrigger);
|
||||
} else if (keyword.startsWith("Suspend")) {
|
||||
//upkeep trigger
|
||||
StringBuilder upkeepTrig = new StringBuilder();;
|
||||
StringBuilder upkeepTrig = new StringBuilder();
|
||||
|
||||
upkeepTrig.append("Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Exile ");
|
||||
upkeepTrig.append(" | IsPresent$ Card.Self+suspended | PresentZone$ Exile");
|
||||
@@ -3146,7 +3142,7 @@ public class CardFactoryUtil {
|
||||
}
|
||||
final String costStr = k.length == 3 ? k[2] : cost.toSimpleString();
|
||||
|
||||
sb.append(costStr.substring(0,1).toLowerCase() + costStr.substring(1));
|
||||
sb.append(costStr.substring(0, 1).toLowerCase()).append(costStr.substring(1));
|
||||
sb.append(".");
|
||||
|
||||
String upkeepTrig = "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | " +
|
||||
@@ -3201,7 +3197,7 @@ public class CardFactoryUtil {
|
||||
|
||||
SpellAbility saDelay = AbilityFactory.getAbility(strDelay, card);
|
||||
saDelay.setAdditionalAbility("Execute", (AbilitySub) AbilityFactory.getAbility(strSac, card));
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(strTrig.toString(), card, intrinsic);
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(strTrig, card, intrinsic);
|
||||
trigger.setOverridingAbility(saDelay);
|
||||
inst.addTrigger(trigger);
|
||||
}
|
||||
@@ -3404,7 +3400,7 @@ public class CardFactoryUtil {
|
||||
sb.append("| ValidStackSa$ Spell.Flashback | Description$ Flashback");
|
||||
|
||||
if (keyword.contains(":")) {
|
||||
final String k[] = keyword.split(":");
|
||||
final String[] k = keyword.split(":");
|
||||
final Cost cost = new Cost(k[1], false);
|
||||
sb.append( cost.isOnlyManaCost() ? " " : "—");
|
||||
|
||||
@@ -3896,7 +3892,7 @@ public class CardFactoryUtil {
|
||||
// Add the Epic effect as a subAbility
|
||||
String dbStr = "DB$ Effect | Triggers$ EpicTrigger | SVars$ EpicCopy | StaticAbilities$ EpicCantBeCast | Duration$ Permanent | Epic$ True";
|
||||
|
||||
final AbilitySub newSA = (AbilitySub) AbilityFactory.getAbility(dbStr.toString(), card);
|
||||
final AbilitySub newSA = (AbilitySub) AbilityFactory.getAbility(dbStr, card);
|
||||
|
||||
newSA.setSVar("EpicCantBeCast", "Mode$ CantBeCast | ValidCard$ Card | Caster$ You | EffectZone$ Command | Description$ For the rest of the game, you can't cast spells.");
|
||||
newSA.setSVar("EpicTrigger", "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ EpicCopy | TriggerDescription$ "
|
||||
@@ -3938,8 +3934,8 @@ public class CardFactoryUtil {
|
||||
} else {
|
||||
abilityStr.append(" ");
|
||||
}
|
||||
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " ");
|
||||
abilityStr.append("| SpellDescription$ (" + inst.getReminderText() + ")");
|
||||
abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
|
||||
abilityStr.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
|
||||
// instantiate attach ability
|
||||
final SpellAbility newSA = AbilityFactory.getAbility(abilityStr.toString(), card);
|
||||
newSA.setIntrinsic(intrinsic);
|
||||
@@ -3964,7 +3960,7 @@ public class CardFactoryUtil {
|
||||
// don't use SimpleString there because it does has "and" between cost i dont want that
|
||||
costStr = cost.toString();
|
||||
// but now it has ": " at the end i want to remove
|
||||
sb.append("| CostDesc$ ").append(costStr.substring(0, costStr.length() - 2));
|
||||
sb.append("| CostDesc$ ").append(costStr, 0, costStr.length() - 2);
|
||||
if (!cost.isOnlyManaCost()) {
|
||||
sb.append(".");
|
||||
}
|
||||
@@ -4012,7 +4008,7 @@ public class CardFactoryUtil {
|
||||
abilityStr.append("| PrecostDesc$ Fortify");
|
||||
Cost cost = new Cost(equipCost, true);
|
||||
abilityStr.append(cost.isOnlyManaCost() ? " " : "—");
|
||||
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " ");
|
||||
abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
|
||||
abilityStr.append("| SpellDescription$ (");
|
||||
abilityStr.append(inst.getReminderText()).append(")");
|
||||
|
||||
@@ -4173,8 +4169,8 @@ public class CardFactoryUtil {
|
||||
} else {
|
||||
abilityStr.append(" ");
|
||||
}
|
||||
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " ");
|
||||
abilityStr.append("| SpellDescription$ (" + inst.getReminderText() + ")");
|
||||
abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
|
||||
abilityStr.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
|
||||
|
||||
final SpellAbility sa = AbilityFactory.getAbility(abilityStr.toString(), card);
|
||||
sa.setIntrinsic(intrinsic);
|
||||
@@ -4196,7 +4192,7 @@ public class CardFactoryUtil {
|
||||
// makes new SpellDescription
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(newSA.getCostDescription());
|
||||
sb.append("(" + inst.getReminderText() + ")");
|
||||
sb.append("(").append(inst.getReminderText()).append(")");
|
||||
newSA.setDescription(sb.toString());
|
||||
|
||||
newSA.setBasicSpell(false);
|
||||
@@ -4213,9 +4209,9 @@ public class CardFactoryUtil {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("AB$ PutCounter | CounterType$ P1P1 | ActivationZone$ Hand");
|
||||
sb.append("| ValidTgts$ Creature | TgtPrompt$ Select target creature");
|
||||
sb.append("| Cost$ " + manacost + " Discard<1/CARDNAME>");
|
||||
sb.append("| Cost$ ").append(manacost).append(" Discard<1/CARDNAME>");
|
||||
sb.append("| CounterNum$ ").append(n);
|
||||
sb.append("| CostDesc$ " + ManaCostParser.parse(manacost)); // to hide the Discard from the cost
|
||||
sb.append("| CostDesc$ ").append(ManaCostParser.parse(manacost)); // to hide the Discard from the cost
|
||||
sb.append("| PrecostDesc$ Reinforce ").append(n).append("—");
|
||||
sb.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
|
||||
|
||||
@@ -4425,7 +4421,7 @@ public class CardFactoryUtil {
|
||||
sb.append(manacost);
|
||||
sb.append(" Discard<1/CARDNAME> | ActivationZone$ Hand | PrecostDesc$ Cycling");
|
||||
sb.append(cost.isOnlyManaCost() ? " " : "—");
|
||||
sb.append("| CostDesc$ " + cost.toSimpleString() + " ");
|
||||
sb.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
|
||||
sb.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
|
||||
|
||||
SpellAbility sa = AbilityFactory.getAbility(sb.toString(), card);
|
||||
@@ -4498,7 +4494,7 @@ public class CardFactoryUtil {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Mode$ Continuous | EffectZone$ Exile | Affected$ Card.EncodedWithSource");
|
||||
sb.append(" | AddTrigger$ CipherTrigger");
|
||||
sb.append(" | Description$ Cipher (" + inst.getReminderText() + ")");
|
||||
sb.append(" | Description$ Cipher (").append(inst.getReminderText()).append(")");
|
||||
|
||||
effect = sb.toString();
|
||||
|
||||
@@ -4542,7 +4538,7 @@ public class CardFactoryUtil {
|
||||
final StringBuilder sbValid = new StringBuilder();
|
||||
|
||||
if (!keyword.equals("Hexproof")) {
|
||||
final String k[] = keyword.split(":");
|
||||
final String[] k = keyword.split(":");
|
||||
|
||||
sbDesc.append(" from ").append(k[2]);
|
||||
sbValid.append("| ValidSource$ ").append(k[1]);
|
||||
|
||||
@@ -11,7 +11,7 @@ public final class CardPlayOption {
|
||||
/** Indicates the mana cost must be paid. */
|
||||
YES,
|
||||
/** Indicates the mana cost may not be paid. */
|
||||
NO;
|
||||
NO
|
||||
}
|
||||
|
||||
private final Player player;
|
||||
@@ -82,7 +82,7 @@ public final class CardPlayOption {
|
||||
switch (getPayManaCost()) {
|
||||
case YES:
|
||||
if (altManaCost != null) {
|
||||
sb.append(" (by paying " + getFormattedAltManaCost() + " instead of paying its mana cost");
|
||||
sb.append(" (by paying ").append(getFormattedAltManaCost()).append(" instead of paying its mana cost");
|
||||
if (isWithFlash()) {
|
||||
sb.append(" and as though it has flash");
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public final class CardPredicates {
|
||||
return c.canBeSacrificedBy(sa);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> canBeAttached(final Card aura) {
|
||||
return new Predicate<Card>() {
|
||||
@@ -223,7 +223,7 @@ public final class CardPredicates {
|
||||
return c.canBeAttached(aura);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isColor(final byte color) {
|
||||
return new Predicate<Card>() {
|
||||
|
||||
@@ -27,8 +27,7 @@ import java.util.List;
|
||||
|
||||
public class CardProperty {
|
||||
|
||||
public static boolean cardHasProperty(Card card, String property, Player sourceController, Card source,
|
||||
SpellAbility spellAbility) {
|
||||
public static boolean cardHasProperty(Card card, String property, Player sourceController, Card source, SpellAbility spellAbility) {
|
||||
final Game game = card.getGame();
|
||||
final Combat combat = game.getCombat();
|
||||
// lki can't be null but it does return this
|
||||
@@ -40,7 +39,7 @@ public class CardProperty {
|
||||
String name = TextUtil.fastReplace(property.substring(5), ";", ","); // for some legendary cards
|
||||
if (!card.sharesNameWith(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("notnamed")) {
|
||||
if (card.sharesNameWith(property.substring(8))) {
|
||||
return false;
|
||||
@@ -1115,9 +1114,9 @@ public class CardProperty {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("DrawnThisTurn")) {
|
||||
if (!card.getDrawnThisTurn()) {
|
||||
return false;
|
||||
}
|
||||
if (!card.getDrawnThisTurn()) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("enteredBattlefieldThisTurn")) {
|
||||
if (!(card.getTurnInZone() == game.getPhaseHandler().getTurn())) {
|
||||
return false;
|
||||
@@ -1749,7 +1748,7 @@ public class CardProperty {
|
||||
final ZoneType realZone = ZoneType.smartValueOf(strZone);
|
||||
// lki last zone does fall back to this zone
|
||||
final Zone lkiZone = lki.getLastKnownZone();
|
||||
|
||||
|
||||
if (lkiZone == null || !lkiZone.is(realZone)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1773,4 +1772,4 @@ public class CardProperty {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -56,11 +56,11 @@ public class CardState extends GameObject {
|
||||
private String baseLoyalty = "";
|
||||
private KeywordCollection intrinsicKeywords = new KeywordCollection();
|
||||
|
||||
private final FCollection<SpellAbility> nonManaAbilities = new FCollection<SpellAbility>();
|
||||
private final FCollection<SpellAbility> manaAbilities = new FCollection<SpellAbility>();
|
||||
private FCollection<Trigger> triggers = new FCollection<Trigger>();
|
||||
private FCollection<ReplacementEffect> replacementEffects = new FCollection<ReplacementEffect>();
|
||||
private FCollection<StaticAbility> staticAbilities = new FCollection<StaticAbility>();
|
||||
private final FCollection<SpellAbility> nonManaAbilities = new FCollection<>();
|
||||
private final FCollection<SpellAbility> manaAbilities = new FCollection<>();
|
||||
private FCollection<Trigger> triggers = new FCollection<>();
|
||||
private FCollection<ReplacementEffect> replacementEffects = new FCollection<>();
|
||||
private FCollection<StaticAbility> staticAbilities = new FCollection<>();
|
||||
private String imageKey = "";
|
||||
private Map<String, String> sVars = Maps.newTreeMap();
|
||||
|
||||
@@ -257,24 +257,24 @@ public class CardState extends GameObject {
|
||||
}
|
||||
|
||||
public final FCollectionView<SpellAbility> getSpellAbilities() {
|
||||
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(manaAbilities);
|
||||
FCollection<SpellAbility> newCol = new FCollection<>(manaAbilities);
|
||||
newCol.addAll(nonManaAbilities);
|
||||
card.updateSpellAbilities(newCol, this, null);
|
||||
return newCol;
|
||||
}
|
||||
public final FCollectionView<SpellAbility> getManaAbilities() {
|
||||
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(manaAbilities);
|
||||
FCollection<SpellAbility> newCol = new FCollection<>(manaAbilities);
|
||||
card.updateSpellAbilities(newCol, this, true);
|
||||
return newCol;
|
||||
}
|
||||
public final FCollectionView<SpellAbility> getNonManaAbilities() {
|
||||
FCollection<SpellAbility> newCol = new FCollection<SpellAbility>(nonManaAbilities);
|
||||
FCollection<SpellAbility> newCol = new FCollection<>(nonManaAbilities);
|
||||
card.updateSpellAbilities(newCol, this, false);
|
||||
return newCol;
|
||||
}
|
||||
|
||||
public final FCollectionView<SpellAbility> getIntrinsicSpellAbilities() {
|
||||
return new FCollection<SpellAbility>(Iterables.filter(getSpellAbilities(), SpellAbilityPredicates.isIntrinsic()));
|
||||
return new FCollection<>(Iterables.filter(getSpellAbilities(), SpellAbilityPredicates.isIntrinsic()));
|
||||
}
|
||||
|
||||
public final boolean hasSpellAbility(final SpellAbility sa) {
|
||||
@@ -386,7 +386,7 @@ public class CardState extends GameObject {
|
||||
return staticAbilities.remove(stab);
|
||||
}
|
||||
public final void setStaticAbilities(final Iterable<StaticAbility> staticAbilities0) {
|
||||
staticAbilities = new FCollection<StaticAbility>(staticAbilities0);
|
||||
staticAbilities = new FCollection<>(staticAbilities0);
|
||||
}
|
||||
public final void clearStaticAbilities() {
|
||||
staticAbilities.clear();
|
||||
@@ -471,9 +471,7 @@ public class CardState extends GameObject {
|
||||
view.updateFoilIndex(card.getState(CardStateName.Original));
|
||||
}
|
||||
public final void removeSVar(final String var) {
|
||||
if (sVars.containsKey(var)) {
|
||||
sVars.remove(var);
|
||||
}
|
||||
sVars.remove(var);
|
||||
}
|
||||
|
||||
public final int getFoil() {
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class CardUtil {
|
||||
}
|
||||
|
||||
public static boolean isStackingKeyword(final String keyword) {
|
||||
String kw = new String(keyword);
|
||||
String kw = keyword;
|
||||
if (kw.startsWith("HIDDEN")) {
|
||||
kw = kw.substring(7);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public final class CardUtil {
|
||||
public static String getShortColorsString(final Iterable<String> colors) {
|
||||
StringBuilder colorDesc = new StringBuilder();
|
||||
for (final String col : colors) {
|
||||
colorDesc.append(MagicColor.toShortString(col) + " ");
|
||||
colorDesc.append(MagicColor.toShortString(col)).append(" ");
|
||||
}
|
||||
return colorDesc.toString();
|
||||
}
|
||||
@@ -251,8 +251,8 @@ public final class CardUtil {
|
||||
}
|
||||
|
||||
// lock in the current P/T without bonus from counters
|
||||
newCopy.setBasePower(in.getCurrentPower() + in.getTempPowerBoost() + in.getSemiPermanentPowerBoost());
|
||||
newCopy.setBaseToughness(in.getCurrentToughness() + in.getTempToughnessBoost() + in.getSemiPermanentToughnessBoost());
|
||||
newCopy.setBasePower(in.getCurrentPower() + in.getTempPowerBoost());
|
||||
newCopy.setBaseToughness(in.getCurrentToughness() + in.getTempToughnessBoost());
|
||||
|
||||
newCopy.setCounters(Maps.newEnumMap(in.getCounters()));
|
||||
|
||||
@@ -345,7 +345,7 @@ public final class CardUtil {
|
||||
|
||||
// a nice entry point with minimum parameters
|
||||
public static Set<String> getReflectableManaColors(final SpellAbility sa) {
|
||||
return getReflectableManaColors(sa, sa, Sets.<String>newHashSet(), new CardCollection());
|
||||
return getReflectableManaColors(sa, sa, Sets.newHashSet(), new CardCollection());
|
||||
}
|
||||
|
||||
private static Set<String> getReflectableManaColors(final SpellAbility abMana, final SpellAbility sa,
|
||||
@@ -390,9 +390,7 @@ public final class CardUtil {
|
||||
|
||||
// remove anything cards that is already in parents
|
||||
for (final Card p : parents) {
|
||||
if (cards.contains(p)) {
|
||||
cards.remove(p);
|
||||
}
|
||||
cards.remove(p);
|
||||
}
|
||||
|
||||
if ((cards.size() == 0) && !reflectProperty.equals("Produced")) {
|
||||
@@ -425,7 +423,7 @@ public final class CardUtil {
|
||||
colors.add(MagicColor.Constant.COLORLESS);
|
||||
}
|
||||
} else if (reflectProperty.equals("Produce")) {
|
||||
final FCollection<SpellAbility> abilities = new FCollection<SpellAbility>();
|
||||
final FCollection<SpellAbility> abilities = new FCollection<>();
|
||||
for (final Card c : cards) {
|
||||
abilities.addAll(c.getManaAbilities());
|
||||
}
|
||||
@@ -506,9 +504,7 @@ public final class CardUtil {
|
||||
// Remove cards already targeted
|
||||
final List<Card> targeted = Lists.newArrayList(ability.getTargets().getTargetCards());
|
||||
for (final Card c : targeted) {
|
||||
if (choices.contains(c)) {
|
||||
choices.remove(c);
|
||||
}
|
||||
choices.remove(c);
|
||||
}
|
||||
|
||||
// Remove cards exceeding total CMC
|
||||
|
||||
@@ -18,6 +18,7 @@ import forge.trackable.TrackableCollection;
|
||||
import forge.trackable.TrackableObject;
|
||||
import forge.trackable.TrackableProperty;
|
||||
import forge.trackable.Tracker;
|
||||
import forge.util.Lang;
|
||||
import forge.util.collect.FCollectionView;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -46,7 +47,7 @@ public class CardView extends GameEntityView {
|
||||
if (cards == null) {
|
||||
return null;
|
||||
}
|
||||
TrackableCollection<CardView> collection = new TrackableCollection<CardView>();
|
||||
TrackableCollection<CardView> collection = new TrackableCollection<>();
|
||||
for (Card c : cards) {
|
||||
if (c.getCardForUi() == c) { //only add cards that match their card for UI
|
||||
collection.add(c.getView());
|
||||
@@ -345,17 +346,14 @@ public class CardView extends GameEntityView {
|
||||
return true;
|
||||
}
|
||||
col = get(TrackableProperty.PlayerMayLookTemp);
|
||||
if (col != null && col.contains(pv)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return col != null && col.contains(pv);
|
||||
}
|
||||
void setPlayerMayLook(Player p, boolean mayLook, boolean temp) {
|
||||
TrackableProperty prop = temp ? TrackableProperty.PlayerMayLookTemp : TrackableProperty.PlayerMayLook;
|
||||
TrackableCollection<PlayerView> col = get(prop);
|
||||
if (mayLook) {
|
||||
if (col == null) {
|
||||
col = new TrackableCollection<PlayerView>(p.getView());
|
||||
col = new TrackableCollection<>(p.getView());
|
||||
set(prop, col);
|
||||
}
|
||||
else if (col.add(p.getView())) {
|
||||
@@ -380,7 +378,7 @@ public class CardView extends GameEntityView {
|
||||
return Iterables.any(viewers, new Predicate<PlayerView>() {
|
||||
public final boolean apply(final PlayerView input) {
|
||||
return canBeShownTo(input);
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -462,10 +460,7 @@ public class CardView extends GameEntityView {
|
||||
if (mindSlaveMaster != null && canFaceDownBeShownTo(mindSlaveMaster)) {
|
||||
return true;
|
||||
}
|
||||
if (isInZone(EnumSet.of(ZoneType.Battlefield, ZoneType.Stack, ZoneType.Sideboard)) && getController().equals(viewer)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return isInZone(EnumSet.of(ZoneType.Battlefield, ZoneType.Stack, ZoneType.Sideboard)) && getController().equals(viewer);
|
||||
}
|
||||
|
||||
public FCollectionView<CardView> getEncodedCards() {
|
||||
@@ -565,7 +560,7 @@ public class CardView extends GameEntityView {
|
||||
sb.append(rulesText).append("\r\n\r\n");
|
||||
}
|
||||
if (isCommander()) {
|
||||
sb.append(getOwner()).append("'s " + getCommanderType() + "\r\n");
|
||||
sb.append(getOwner()).append("'s ").append(getCommanderType()).append("\r\n");
|
||||
sb.append(getOwner().getCommanderInfo(this)).append("\r\n");
|
||||
}
|
||||
|
||||
@@ -587,16 +582,6 @@ public class CardView extends GameEntityView {
|
||||
}
|
||||
|
||||
String nonAbilityText = get(TrackableProperty.NonAbilityText);
|
||||
int blockAdditional = state.getBlockAdditional();
|
||||
if (blockAdditional > 1) {
|
||||
final StringBuilder ab = new StringBuilder();
|
||||
ab.append("CARDNAME can block an additional ");
|
||||
ab.append(blockAdditional);
|
||||
ab.append(" creatures each combat.");
|
||||
nonAbilityText = nonAbilityText.replaceFirst("CARDNAME can block an additional creature each combat.", ab.toString());
|
||||
nonAbilityText = nonAbilityText.replaceAll("CARDNAME can block an additional creature each combat.", "");
|
||||
nonAbilityText = nonAbilityText.replaceAll("\r\n\r\n\r\n", "");
|
||||
}
|
||||
if (!nonAbilityText.isEmpty()) {
|
||||
sb.append("\r\n \r\nNon ability features: \r\n");
|
||||
sb.append(nonAbilityText.replaceAll("CARDNAME", getName()));
|
||||
@@ -624,6 +609,22 @@ public class CardView extends GameEntityView {
|
||||
sb.append("\r\n");
|
||||
}
|
||||
|
||||
if (getCanBlockAny()) {
|
||||
sb.append("\r\n\r\n");
|
||||
sb.append("CARDNAME can block any number of creatures.".replaceAll("CARDNAME", getName()));
|
||||
sb.append("\r\n");
|
||||
} else {
|
||||
int i = getBlockAdditional();
|
||||
if (i > 0) {
|
||||
sb.append("\r\n\r\n");
|
||||
sb.append("CARDNAME can block an additional ".replaceAll("CARDNAME", getName()));
|
||||
sb.append(i == 1 ? "creature" : Lang.nounWithNumeral(i, "creature"));
|
||||
sb.append(" each combat.");
|
||||
sb.append("\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String cloner = get(TrackableProperty.Cloner);
|
||||
if (!cloner.isEmpty()) {
|
||||
sb.append("\r\nCloned by: ").append(cloner);
|
||||
@@ -728,6 +729,19 @@ public class CardView extends GameEntityView {
|
||||
set(TrackableProperty.HiddenId, hiddenId);
|
||||
}
|
||||
|
||||
int getBlockAdditional() {
|
||||
return get(TrackableProperty.BlockAdditional);
|
||||
}
|
||||
|
||||
boolean getCanBlockAny() {
|
||||
return get(TrackableProperty.BlockAny);
|
||||
}
|
||||
|
||||
void updateBlockAdditional(Card c) {
|
||||
set(TrackableProperty.BlockAdditional, c.canBlockAdditional());
|
||||
set(TrackableProperty.BlockAny, c.canBlockAny());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
@@ -995,9 +1009,6 @@ public class CardView extends GameEntityView {
|
||||
return get(TrackableProperty.HasTrample);
|
||||
}
|
||||
|
||||
public int getBlockAdditional() {
|
||||
return get(TrackableProperty.BlockAdditional);
|
||||
}
|
||||
public String getAbilityText() {
|
||||
return get(TrackableProperty.AbilityText);
|
||||
}
|
||||
@@ -1011,7 +1022,6 @@ public class CardView extends GameEntityView {
|
||||
set(TrackableProperty.HasInfect, c.hasKeyword(Keyword.INFECT, state));
|
||||
set(TrackableProperty.HasStorm, c.hasKeyword(Keyword.STORM, state));
|
||||
set(TrackableProperty.HasTrample, c.hasKeyword(Keyword.TRAMPLE, state));
|
||||
set(TrackableProperty.BlockAdditional, c.getAmountOfKeyword("CARDNAME can block an additional creature each combat.", state));
|
||||
updateAbilityText(c, state);
|
||||
}
|
||||
|
||||
@@ -1066,8 +1076,8 @@ public class CardView extends GameEntityView {
|
||||
if (oldCards.add(cardToAdd)) {
|
||||
TrackableCollection<CardView> views = get(key);
|
||||
if (views == null) {
|
||||
views = new TrackableCollection<CardView>();
|
||||
views.add(cardToAdd.getView());;
|
||||
views = new TrackableCollection<>();
|
||||
views.add(cardToAdd.getView());
|
||||
set(key, views);
|
||||
}
|
||||
else if (views.add(cardToAdd.getView())) {
|
||||
@@ -1087,7 +1097,7 @@ public class CardView extends GameEntityView {
|
||||
for (Card c : cardsToAdd) {
|
||||
if (c != null && oldCards.add(c)) {
|
||||
if (views == null) {
|
||||
views = new TrackableCollection<CardView>();
|
||||
views = new TrackableCollection<>();
|
||||
views.add(c.getView());
|
||||
set(key, views);
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ public class TokenInfo {
|
||||
if (!CardUtil.isKeywordModifiable(o)) {
|
||||
continue;
|
||||
}
|
||||
String r = new String(o);
|
||||
String r = o;
|
||||
// replace types
|
||||
for (final Map.Entry<String, String> e : typeMap.entrySet()) {
|
||||
final String key = e.getKey();
|
||||
|
||||
@@ -45,7 +45,7 @@ public class AttackConstraints {
|
||||
"If a creature with a magnet counter on it attacks, all creatures with magnet counters on them attack if able.");
|
||||
}
|
||||
|
||||
final MapToAmount<Card> attacksIfOtherAttacks = new LinkedHashMapToAmount<Card>();
|
||||
final MapToAmount<Card> attacksIfOtherAttacks = new LinkedHashMapToAmount<>();
|
||||
for (final Card possibleAttacker : possibleAttackers) {
|
||||
attacksIfOtherAttacks.add(possibleAttacker, possibleAttacker.getAmountOfKeyword("If a creature you control attacks, CARDNAME also attacks if able."));
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class AttackConstraints {
|
||||
for (final Card possibleAttacker : possibleAttackers) {
|
||||
restrictions.put(possibleAttacker, new AttackRestriction(possibleAttacker, possibleDefenders));
|
||||
|
||||
final MapToAmount<Card> causesToAttack = new LinkedHashMapToAmount<Card>();
|
||||
final MapToAmount<Card> causesToAttack = new LinkedHashMapToAmount<>();
|
||||
for (final Entry<Card, Integer> entry : attacksIfOtherAttacks.entrySet()) {
|
||||
if (entry.getKey() != possibleAttacker) {
|
||||
causesToAttack.add(entry.getKey(), entry.getValue().intValue());
|
||||
@@ -94,10 +94,10 @@ public class AttackConstraints {
|
||||
final int globalMax = globalRestrictions.getMax();
|
||||
final int myMax = Ints.min(globalMax == -1 ? Integer.MAX_VALUE : globalMax, possibleAttackers.size());
|
||||
if (myMax == 0) {
|
||||
return Pair.of(Collections.<Card, GameEntity>emptyMap(), Integer.valueOf(0));
|
||||
return Pair.of(Collections.emptyMap(), Integer.valueOf(0));
|
||||
}
|
||||
|
||||
final MapToAmount<Map<Card, GameEntity>> possible = new LinkedHashMapToAmount<Map<Card, GameEntity>>();
|
||||
final MapToAmount<Map<Card, GameEntity>> possible = new LinkedHashMapToAmount<>();
|
||||
final List<Attack> reqs = getSortedFilteredRequirements();
|
||||
final CardCollection myPossibleAttackers = new CardCollection(possibleAttackers);
|
||||
|
||||
@@ -163,8 +163,8 @@ public class AttackConstraints {
|
||||
// Now try all others (plus empty attack) and count their violations
|
||||
final FCollection<Map<Card, GameEntity>> legalAttackers = collectLegalAttackers(reqs, myMax);
|
||||
possible.putAll(Maps.asMap(legalAttackers.asSet(), FN_COUNT_VIOLATIONS));
|
||||
if (countViolations(Collections.<Card, GameEntity>emptyMap()) != -1) {
|
||||
possible.put(Collections.<Card, GameEntity>emptyMap(), countViolations(Collections.<Card, GameEntity>emptyMap()));
|
||||
if (countViolations(Collections.emptyMap()) != -1) {
|
||||
possible.put(Collections.emptyMap(), countViolations(Collections.emptyMap()));
|
||||
}
|
||||
|
||||
// take the case with the fewest violations
|
||||
@@ -172,8 +172,8 @@ public class AttackConstraints {
|
||||
}
|
||||
|
||||
private final FCollection<Map<Card, GameEntity>> collectLegalAttackers(final List<Attack> reqs, final int maximum) {
|
||||
return new FCollection<Map<Card, GameEntity>>
|
||||
(collectLegalAttackers(Collections.<Card, GameEntity>emptyMap(), deepClone(reqs), new CardCollection(), maximum));
|
||||
return new FCollection<>
|
||||
(collectLegalAttackers(Collections.emptyMap(), deepClone(reqs), new CardCollection(), maximum));
|
||||
}
|
||||
|
||||
private final List<Map<Card, GameEntity>> collectLegalAttackers(final Map<Card, GameEntity> attackers, final List<Attack> reqs, final CardCollection reserved, final int maximum) {
|
||||
@@ -182,7 +182,7 @@ public class AttackConstraints {
|
||||
int localMaximum = maximum;
|
||||
final boolean isLimited = globalRestrictions.getMax() != -1;
|
||||
final Map<Card, GameEntity> myAttackers = Maps.newHashMap(attackers);
|
||||
final MapToAmount<GameEntity> toDefender = new LinkedHashMapToAmount<GameEntity>();
|
||||
final MapToAmount<GameEntity> toDefender = new LinkedHashMapToAmount<>();
|
||||
int attackersNeeded = 0;
|
||||
|
||||
outer: while(!reqs.isEmpty()) {
|
||||
|
||||
@@ -29,9 +29,9 @@ public class AttackRequirement {
|
||||
private final MapToAmount<Card> causesToAttack;
|
||||
|
||||
public AttackRequirement(final Card attacker, final MapToAmount<Card> causesToAttack, final FCollectionView<GameEntity> possibleDefenders) {
|
||||
this.defenderSpecific = new LinkedHashMapToAmount<GameEntity>();
|
||||
this.defenderOrPWSpecific = new LinkedHashMapToAmount<GameEntity>();
|
||||
this.defenderSpecificAlternatives = new HashMap<GameEntity, List<GameEntity>>();
|
||||
this.defenderSpecific = new LinkedHashMapToAmount<>();
|
||||
this.defenderOrPWSpecific = new LinkedHashMapToAmount<>();
|
||||
this.defenderSpecificAlternatives = new HashMap<>();
|
||||
|
||||
this.causesToAttack = causesToAttack;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class AttackRequirement {
|
||||
for (Card pw : CardLists.filter(c.getController().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANESWALKERS)) {
|
||||
// Add the attack alternatives that suffice (planeswalkers that can be attacked instead of the player)
|
||||
if (!defenderSpecificAlternatives.containsKey(c.getController())) {
|
||||
defenderSpecificAlternatives.put(c.getController(), Lists.<GameEntity>newArrayList());
|
||||
defenderSpecificAlternatives.put(c.getController(), Lists.newArrayList());
|
||||
}
|
||||
defenderSpecificAlternatives.get(c.getController()).add(pw);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public class AttackRequirement {
|
||||
int violations = 0;
|
||||
|
||||
// first. check to see if "must attack X or Y with at least one creature" requirements are satisfied
|
||||
List<GameEntity> toRemoveFromDefSpecific = Lists.<GameEntity>newArrayList();
|
||||
List<GameEntity> toRemoveFromDefSpecific = Lists.newArrayList();
|
||||
if (!defenderOrPWSpecific.isEmpty()) {
|
||||
for (GameEntity def : defenderOrPWSpecific.keySet()) {
|
||||
if (defenderSpecificAlternatives.containsKey(def)) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class AttackRestriction {
|
||||
this.attacker = attacker;
|
||||
setRestrictions();
|
||||
|
||||
final FCollection<GameEntity> cantAttackDefender = new FCollection<GameEntity>();
|
||||
final FCollection<GameEntity> cantAttackDefender = new FCollection<>();
|
||||
for (final GameEntity defender : possibleDefenders) {
|
||||
if (!CombatUtil.canAttack(attacker, defender)) {
|
||||
cantAttackDefender.add(defender);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AttackingBand {
|
||||
|
||||
public boolean canJoinBand(Card card) {
|
||||
// Trying to join an existing band, attackers should be non-empty and card should exist
|
||||
List<Card> newBand = new ArrayList<Card>(attackers);
|
||||
List<Card> newBand = new ArrayList<>(attackers);
|
||||
if (card != null) {
|
||||
newBand.add(card);
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ public class Combat {
|
||||
private final Player playerWhoAttacks;
|
||||
private final AttackConstraints attackConstraints;
|
||||
// Defenders, as they are attacked by hostile forces
|
||||
private final FCollection<GameEntity> attackableEntries = new FCollection<GameEntity>();
|
||||
private final FCollection<GameEntity> attackableEntries = new FCollection<>();
|
||||
|
||||
// Keyed by attackable defender (player or planeswalker)
|
||||
private final Multimap<GameEntity, AttackingBand> attackedByBands = Multimaps.synchronizedMultimap(ArrayListMultimap.<GameEntity, AttackingBand>create());
|
||||
private final Multimap<AttackingBand, Card> blockedBands = Multimaps.synchronizedMultimap(ArrayListMultimap.<AttackingBand, Card>create());
|
||||
private final Multimap<GameEntity, AttackingBand> attackedByBands = Multimaps.synchronizedMultimap(ArrayListMultimap.create());
|
||||
private final Multimap<AttackingBand, Card> blockedBands = Multimaps.synchronizedMultimap(ArrayListMultimap.create());
|
||||
|
||||
private final Map<Card, Integer> defendingDamageMap = Maps.newHashMap();
|
||||
|
||||
@@ -71,9 +71,7 @@ public class Combat {
|
||||
playerWhoAttacks = attacker;
|
||||
|
||||
// Create keys for all possible attack targets
|
||||
for (final GameEntity defender : CombatUtil.getAllPossibleDefenders(playerWhoAttacks)) {
|
||||
attackableEntries.add(defender);
|
||||
}
|
||||
attackableEntries.addAll(CombatUtil.getAllPossibleDefenders(playerWhoAttacks));
|
||||
|
||||
attackConstraints = new AttackConstraints(this);
|
||||
}
|
||||
@@ -87,7 +85,7 @@ public class Combat {
|
||||
HashMap<AttackingBand, AttackingBand> bandsMap = new HashMap<>();
|
||||
for (Entry<GameEntity, AttackingBand> entry : combat.attackedByBands.entries()) {
|
||||
AttackingBand origBand = entry.getValue();
|
||||
ArrayList<Card> attackers = new ArrayList<Card>();
|
||||
ArrayList<Card> attackers = new ArrayList<>();
|
||||
for (Card c : origBand.getAttackers()) {
|
||||
attackers.add(map.map(c));
|
||||
}
|
||||
@@ -187,7 +185,7 @@ public class Combat {
|
||||
}
|
||||
|
||||
public final FCollection<GameEntity> getDefendersControlledBy(Player who) {
|
||||
FCollection<GameEntity> res = new FCollection<GameEntity>();
|
||||
FCollection<GameEntity> res = new FCollection<>();
|
||||
for (GameEntity ge : attackableEntries) {
|
||||
// if defender is the player himself or his cards
|
||||
if (ge == who || ge instanceof Card && ((Card) ge).getController() == who) {
|
||||
@@ -198,7 +196,7 @@ public class Combat {
|
||||
}
|
||||
|
||||
public final FCollectionView<Player> getDefendingPlayers() {
|
||||
return new FCollection<Player>(Iterables.filter(attackableEntries, Player.class));
|
||||
return new FCollection<>(Iterables.filter(attackableEntries, Player.class));
|
||||
}
|
||||
|
||||
public final CardCollection getDefendingPlaneswalkers() {
|
||||
@@ -353,7 +351,7 @@ public class Combat {
|
||||
|
||||
public final boolean isBlocked(final Card attacker) {
|
||||
AttackingBand band = getBandOfAttacker(attacker);
|
||||
return band == null ? false : Boolean.TRUE.equals(band.isBlocked());
|
||||
return band != null && Boolean.TRUE.equals(band.isBlocked());
|
||||
}
|
||||
|
||||
// Some cards in Alpha may UNBLOCK an attacker, so second parameter is not always-true
|
||||
@@ -414,7 +412,7 @@ public class Combat {
|
||||
}
|
||||
|
||||
public final FCollectionView<AttackingBand> getAttackingBandsBlockedBy(Card blocker) {
|
||||
FCollection<AttackingBand> bands = new FCollection<AttackingBand>();
|
||||
FCollection<AttackingBand> bands = new FCollection<>();
|
||||
for (Entry<AttackingBand, Card> kv : blockedBands.entries()) {
|
||||
if (kv.getValue().equals(blocker)) {
|
||||
bands.add(kv.getKey());
|
||||
@@ -804,7 +802,7 @@ public class Combat {
|
||||
for (final Entry<Card, Integer> entry : defendingDamageMap.entrySet()) {
|
||||
GameEntity defender = getDefenderByAttacker(entry.getKey());
|
||||
if (defender instanceof Player) { // player
|
||||
((Player) defender).addCombatDamage(entry.getValue(), entry.getKey(), dealtDamageTo, preventMap, counterTable);
|
||||
defender.addCombatDamage(entry.getValue(), entry.getKey(), dealtDamageTo, preventMap, counterTable);
|
||||
}
|
||||
else if (defender instanceof Card) { // planeswalker
|
||||
((Card) defender).getController().addCombatDamage(entry.getValue(), entry.getKey(), dealtDamageTo, preventMap, counterTable);
|
||||
@@ -843,7 +841,7 @@ public class Combat {
|
||||
|
||||
public final boolean isUnblocked(final Card att) {
|
||||
AttackingBand band = getBandOfAttacker(att);
|
||||
return band == null ? false : Boolean.FALSE.equals(band.isBlocked());
|
||||
return band != null && Boolean.FALSE.equals(band.isBlocked());
|
||||
}
|
||||
|
||||
public final CardCollection getUnblockedAttackers() {
|
||||
@@ -875,7 +873,7 @@ public class Combat {
|
||||
public boolean isBlocking(Card blocker) {
|
||||
if (blockedBands.containsValue(blocker)) {
|
||||
return true; // is blocking something at the moment
|
||||
};
|
||||
}
|
||||
|
||||
CombatLki lki = lkiCache.get(blocker);
|
||||
return null != lki && !lki.isAttacker; // was blocking something anyway
|
||||
@@ -902,7 +900,7 @@ public class Combat {
|
||||
return; // card was not even in combat
|
||||
}
|
||||
}
|
||||
final FCollectionView<AttackingBand> relatedBands = isAttacker ? new FCollection<AttackingBand>(attackingBand) : attackersBlocked;
|
||||
final FCollectionView<AttackingBand> relatedBands = isAttacker ? new FCollection<>(attackingBand) : attackersBlocked;
|
||||
lkiCache.put(lastKnownInfo, new CombatLki(isAttacker, relatedBands));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class CombatLki {
|
||||
|
||||
public CombatLki(boolean isAttacker, FCollectionView<AttackingBand> relatedBands) {
|
||||
this.isAttacker = isAttacker;
|
||||
this.relatedBands = new FCollection<AttackingBand>(relatedBands);;
|
||||
this.relatedBands = new FCollection<>(relatedBands);
|
||||
}
|
||||
|
||||
public AttackingBand getFirstBand() {
|
||||
|
||||
@@ -59,7 +59,7 @@ import java.util.Map;
|
||||
public class CombatUtil {
|
||||
|
||||
public static FCollectionView<GameEntity> getAllPossibleDefenders(final Player playerWhoAttacks) {
|
||||
final FCollection<GameEntity> defenders = new FCollection<GameEntity>();
|
||||
final FCollection<GameEntity> defenders = new FCollection<>();
|
||||
for (final Player defender : playerWhoAttacks.getOpponents()) {
|
||||
defenders.add(defender);
|
||||
final CardCollection planeswalkers = CardLists.filter(defender.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANESWALKERS);
|
||||
@@ -426,28 +426,17 @@ public class CombatUtil {
|
||||
}
|
||||
|
||||
final List<Card> list = blocker.getController().getCreaturesInPlay();
|
||||
if (list.size() < 2 && blocker.hasKeyword("CARDNAME can't attack or block alone.")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return list.size() >= 2 || !blocker.hasKeyword("CARDNAME can't attack or block alone.");
|
||||
}
|
||||
|
||||
public static boolean canBlockMoreCreatures(final Card blocker, final CardCollectionView blockedBy) {
|
||||
if (blockedBy.isEmpty() || blocker.hasKeyword("CARDNAME can block any number of creatures.")) {
|
||||
if (blockedBy.isEmpty() || blocker.canBlockAny()) {
|
||||
return true;
|
||||
}
|
||||
int canBlockMore = numberOfAdditionalCreaturesCanBlock(blocker);
|
||||
int canBlockMore = blocker.canBlockAdditional();
|
||||
return canBlockMore >= blockedBy.size();
|
||||
}
|
||||
|
||||
public static int numberOfAdditionalCreaturesCanBlock(final Card blocker) {
|
||||
// If Wizards makes a few more of these, we should really just make a generic version
|
||||
return blocker.getAmountOfKeyword("CARDNAME can block an additional creature each combat.") +
|
||||
blocker.getAmountOfKeyword("CARDNAME can block an additional ninety-nine creatures.") * 99 +
|
||||
blocker.getAmountOfKeyword("CARDNAME can block an additional seven creatures each combat.") * 7;
|
||||
}
|
||||
|
||||
// can the attacker be blocked at all?
|
||||
/**
|
||||
* <p>
|
||||
@@ -500,8 +489,7 @@ public class CombatUtil {
|
||||
|
||||
// Landwalk
|
||||
if (isUnblockableFromLandwalk(attacker, defender)) {
|
||||
if (CardLists.getAmountOfKeyword(defender.getCreaturesInPlay(), "CARDNAME can block creatures with landwalk abilities as though they didn't have those abilities.") == 0)
|
||||
return false;
|
||||
return CardLists.getAmountOfKeyword(defender.getCreaturesInPlay(), "CARDNAME can block creatures with landwalk abilities as though they didn't have those abilities.") != 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -518,7 +506,7 @@ public class CombatUtil {
|
||||
IGNORE_LANDWALK_KEYWORDS = new String[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
final String basic = MagicColor.Constant.BASIC_LANDS.get(i);
|
||||
final String landwalk = basic + "walk";;
|
||||
final String landwalk = basic + "walk";
|
||||
LANDWALK_KEYWORDS[i] = landwalk;
|
||||
SNOW_LANDWALK_KEYWORDS[i] = "Snow " + landwalk.toLowerCase();
|
||||
IGNORE_LANDWALK_KEYWORDS[i] = "May be blocked as though it doesn't have " + landwalk + ".";
|
||||
@@ -1053,7 +1041,7 @@ public class CombatUtil {
|
||||
for (KeywordInterface inst : blocker.getKeywords()) {
|
||||
String k = inst.getOriginal();
|
||||
if (k.startsWith("IfReach")) {
|
||||
String n[] = k.split(":");
|
||||
String[] n = k.split(":");
|
||||
if (attacker.getType().hasCreatureType(n[1])) {
|
||||
stillblock = true;
|
||||
break;
|
||||
@@ -1114,9 +1102,7 @@ public class CombatUtil {
|
||||
System.out.println("Warning: it was impossible to deduce the defending player in CombatUtil#canAttackerBeBlockedWithAmount, returning 'true' (safest default).");
|
||||
return true;
|
||||
}
|
||||
if (amount < defender.getCreaturesInPlay().size()) {
|
||||
return false;
|
||||
}
|
||||
return amount >= defender.getCreaturesInPlay().size();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CombatView extends TrackableObject {
|
||||
public Iterable<CardView> getAttackers() {
|
||||
final HashSet<CardView> allAttackers;
|
||||
synchronized (this) {
|
||||
allAttackers = new HashSet<CardView>(getAttackersWithDefenders().keySet());
|
||||
allAttackers = new HashSet<>(getAttackersWithDefenders().keySet());
|
||||
}
|
||||
return allAttackers;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class CombatView extends TrackableObject {
|
||||
public Iterable<GameEntityView> getDefenders() {
|
||||
final HashSet<GameEntityView> allDefenders;
|
||||
synchronized (this) {
|
||||
allDefenders = new HashSet<GameEntityView>(getAttackersWithDefenders().values());
|
||||
allDefenders = new HashSet<>(getAttackersWithDefenders().values());
|
||||
}
|
||||
return allDefenders;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class CombatView extends TrackableObject {
|
||||
synchronized (this) {
|
||||
attackersWithDefenders = Lists.newArrayList(getAttackersWithDefenders().entrySet());
|
||||
}
|
||||
final FCollection<CardView> views = new FCollection<CardView>();
|
||||
final FCollection<CardView> views = new FCollection<>();
|
||||
for (final Entry<CardView, GameEntityView> entry : attackersWithDefenders) {
|
||||
if (defender != null && defender.equals(entry.getValue())) {
|
||||
views.add(entry.getKey());
|
||||
@@ -152,7 +152,7 @@ public class CombatView extends TrackableObject {
|
||||
synchronized (this) {
|
||||
bandsWithDefenders = Lists.newArrayList(getBandsWithDefenders().entrySet());
|
||||
}
|
||||
final List<FCollection<CardView>> views = new ArrayList<FCollection<CardView>>();
|
||||
final List<FCollection<CardView>> views = new ArrayList<>();
|
||||
for (final Entry<FCollection<CardView>, GameEntityView> entry : bandsWithDefenders) {
|
||||
if (defender != null && defender.equals(entry.getValue())) {
|
||||
views.add(entry.getKey());
|
||||
@@ -164,9 +164,9 @@ public class CombatView extends TrackableObject {
|
||||
public void addAttackingBand(final Iterable<CardView> attackingBand, final GameEntityView defender, final Iterable<CardView> blockers, final Iterable<CardView> plannedBlockers) {
|
||||
if (defender == null) { return; }
|
||||
|
||||
final FCollection<CardView> attackingBandCopy = new FCollection<CardView>();
|
||||
final FCollection<CardView> blockersCopy = new FCollection<CardView>();
|
||||
final FCollection<CardView> plannedBlockersCopy = new FCollection<CardView>();
|
||||
final FCollection<CardView> attackingBandCopy = new FCollection<>();
|
||||
final FCollection<CardView> blockersCopy = new FCollection<>();
|
||||
final FCollection<CardView> plannedBlockersCopy = new FCollection<>();
|
||||
|
||||
attackingBandCopy.addAll(attackingBand);
|
||||
if (blockers != null) {
|
||||
|
||||
@@ -45,10 +45,10 @@ public class GlobalAttackRestrictions {
|
||||
private GlobalAttackRestrictionViolations getViolations(final Map<Card, GameEntity> attackers, final CardCollection possibleAttackers, final boolean returnQuickly) {
|
||||
final int nTooMany = max < 0 ? 0 : attackers.size() - max;
|
||||
if (returnQuickly && nTooMany > 0) {
|
||||
return new GlobalAttackRestrictionViolations(nTooMany, MapToAmountUtil.<GameEntity>emptyMap(), MapToAmountUtil.<GameEntity>emptyMap());
|
||||
return new GlobalAttackRestrictionViolations(nTooMany, MapToAmountUtil.emptyMap(), MapToAmountUtil.emptyMap());
|
||||
}
|
||||
|
||||
final MapToAmount<GameEntity> defenderTooMany = new LinkedHashMapToAmount<GameEntity>(defenderMax.size());
|
||||
final MapToAmount<GameEntity> defenderTooMany = new LinkedHashMapToAmount<>(defenderMax.size());
|
||||
outer: for (final GameEntity defender : attackers.values()) {
|
||||
final Integer max = defenderMax.get(defender);
|
||||
if (max == null) {
|
||||
@@ -76,7 +76,7 @@ public class GlobalAttackRestrictions {
|
||||
}
|
||||
}
|
||||
|
||||
final MapToAmount<GameEntity> defenderTooFew = new LinkedHashMapToAmount<GameEntity>(defenderMax.size());
|
||||
final MapToAmount<GameEntity> defenderTooFew = new LinkedHashMapToAmount<>(defenderMax.size());
|
||||
for (final GameEntity mandatoryDef : mustBeAttackedByEachOpp) {
|
||||
// check to ensure that this defender can even legally be attacked in the first place
|
||||
boolean canAttackThisDef = false;
|
||||
@@ -145,7 +145,7 @@ public class GlobalAttackRestrictions {
|
||||
*/
|
||||
public static GlobalAttackRestrictions getGlobalRestrictions(final Player attackingPlayer, final FCollectionView<GameEntity> possibleDefenders) {
|
||||
int max = -1;
|
||||
final MapToAmount<GameEntity> defenderMax = new LinkedHashMapToAmount<GameEntity>(possibleDefenders.size());
|
||||
final MapToAmount<GameEntity> defenderMax = new LinkedHashMapToAmount<>(possibleDefenders.size());
|
||||
final PlayerCollection mustBeAttacked = new PlayerCollection();
|
||||
final Game game = attackingPlayer.getGame();
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class CostAddMana extends CostPart {
|
||||
public boolean payAsDecided(Player ai, PaymentDecision decision, SpellAbility sa) {
|
||||
Card source = sa.getHostCard();
|
||||
|
||||
List<Mana> manaProduced = new ArrayList<Mana>();
|
||||
List<Mana> manaProduced = new ArrayList<>();
|
||||
final String type = this.getType();
|
||||
for (int n = 0; n < decision.c; n++) {
|
||||
if (StringUtils.isNumeric(type)) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import forge.game.keyword.KeywordInterface;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilityActivated;
|
||||
import forge.game.spellability.Spell;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetChoices;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
@@ -40,7 +39,7 @@ public class CostAdjustment {
|
||||
Cost result = cost.copy();
|
||||
|
||||
boolean isStateChangeToFaceDown = false;
|
||||
if (sa.isSpell() && ((Spell) sa).isCastFaceDown()) {
|
||||
if (sa.isSpell() && sa.isCastFaceDown()) {
|
||||
// Turn face down to apply cost modifiers correctly
|
||||
host.turnFaceDownNoUpdate();
|
||||
isStateChangeToFaceDown = true;
|
||||
@@ -159,7 +158,7 @@ public class CostAdjustment {
|
||||
|
||||
boolean isStateChangeToFaceDown = false;
|
||||
if (sa.isSpell()) {
|
||||
if (((Spell) sa).isCastFaceDown()) {
|
||||
if (sa.isCastFaceDown()) {
|
||||
// Turn face down to apply cost modifiers correctly
|
||||
originalCard.turnFaceDownNoUpdate();
|
||||
isStateChangeToFaceDown = true;
|
||||
@@ -490,7 +489,7 @@ public class CostAdjustment {
|
||||
return false;
|
||||
}
|
||||
} else if (type.equals("MorphDown")) {
|
||||
if (!sa.isSpell() || !((Spell) sa).isCastFaceDown()) {
|
||||
if (!sa.isSpell() || !sa.isCastFaceDown()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -546,9 +545,7 @@ public class CostAdjustment {
|
||||
}
|
||||
curSa = curSa.getSubAbility();
|
||||
}
|
||||
if (!targetValid) {
|
||||
return false;
|
||||
}
|
||||
return targetValid;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -112,15 +112,11 @@ public class CostDiscard extends CostPartWithList {
|
||||
final Integer amount = this.convertAmount();
|
||||
|
||||
if (this.payCostFromSource()) {
|
||||
if (!source.canBeDiscardedBy(ability)) {
|
||||
return false;
|
||||
}
|
||||
return source.canBeDiscardedBy(ability);
|
||||
}
|
||||
else {
|
||||
if (type.equals("Hand")) {
|
||||
if (!payer.canDiscardBy(ability)) {
|
||||
return false;
|
||||
}
|
||||
return payer.canDiscardBy(ability);
|
||||
// this will always work
|
||||
}
|
||||
else if (type.equals("LastDrawn")) {
|
||||
@@ -159,7 +155,6 @@ public class CostDiscard extends CostPartWithList {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CostDraw extends CostPart {
|
||||
* @param source
|
||||
*/
|
||||
private List<Player> getPotentialPlayers(final Player payer, final Card source) {
|
||||
List<Player> res = new ArrayList<Player>();
|
||||
List<Player> res = new ArrayList<>();
|
||||
String type = this.getType();
|
||||
for (Player p : payer.getGame().getPlayers()) {
|
||||
if (p.isValid(type, payer, source, null) && p.canDraw()) {
|
||||
|
||||
@@ -93,9 +93,7 @@ public class CostExert extends CostPartWithList {
|
||||
final Integer amount = this.convertAmount();
|
||||
|
||||
|
||||
if (!needsAnnoucement && (amount != null) && (typeList.size() < amount)) {
|
||||
return false;
|
||||
}
|
||||
return needsAnnoucement || (amount == null) || (typeList.size() >= amount);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -146,9 +146,7 @@ public class CostExile extends CostPartWithList {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundPayable) {
|
||||
return false;
|
||||
}
|
||||
return foundPayable;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -94,11 +94,7 @@ public class CostExileFromStack extends CostPart {
|
||||
list = CardLists.getValidCards(list, type.split(";"), payer, source, ability);
|
||||
|
||||
final Integer amount = this.convertAmount();
|
||||
if ((amount != null) && (list.size() < amount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return (amount == null) || (list.size() >= amount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -83,10 +83,7 @@ public class CostGainControl extends CostPartWithList {
|
||||
if (amount == null) {
|
||||
amount = AbilityUtils.calculateAmount(source, this.getAmount(), ability);
|
||||
}
|
||||
if (typeList.size() < amount) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return typeList.size() >= amount;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CostGainLife extends CostPart {
|
||||
|
||||
public List<Player> getPotentialTargets(final Player payer, final Card source)
|
||||
{
|
||||
List<Player> res = new ArrayList<Player>();
|
||||
List<Player> res = new ArrayList<>();
|
||||
for(Player p : payer.getGame().getPlayers())
|
||||
{
|
||||
if(p.isValid(getType(), payer, source, null))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user