This commit is contained in:
tool4EvEr
2021-10-06 10:10:19 +02:00
parent a8115d8a44
commit c65aa86f6b
43 changed files with 80 additions and 90 deletions

View File

@@ -1468,7 +1468,7 @@ public class AiAttackController {
if (artifact != null) { if (artifact != null) {
return artifact; return artifact;
} }
return null;//should never get here return null; //should never get here
} }
private void doLightmineFieldAttackLogic(List<Card> attackersLeft, int numForcedAttackers, boolean playAggro) { private void doLightmineFieldAttackLogic(List<Card> attackersLeft, int numForcedAttackers, boolean playAggro) {

View File

@@ -770,7 +770,7 @@ public class ComputerUtil {
final int considerSacThreshold = getAIPreferenceParameter(host, "CreatureEvalThreshold", source); final int considerSacThreshold = getAIPreferenceParameter(host, "CreatureEvalThreshold", source);
if ("OpponentOnly".equals(source.getParam("AILogic"))) { if ("OpponentOnly".equals(source.getParam("AILogic"))) {
if(!source.getActivatingPlayer().isOpponentOf(ai)) { if (!source.getActivatingPlayer().isOpponentOf(ai)) {
return sacrificed; // sacrifice none return sacrificed; // sacrifice none
} }
} else if ("DesecrationDemon".equals(source.getParam("AILogic"))) { } else if ("DesecrationDemon".equals(source.getParam("AILogic"))) {

View File

@@ -72,7 +72,7 @@ public class ComputerUtilAbility {
if (!player.getCardsIn(ZoneType.Library).isEmpty()) { if (!player.getCardsIn(ZoneType.Library).isEmpty()) {
all.add(player.getCardsIn(ZoneType.Library).get(0)); all.add(player.getCardsIn(ZoneType.Library).get(0));
} }
for(Player p : game.getPlayers()) { for (Player p : game.getPlayers()) {
all.addAll(p.getCardsIn(ZoneType.Exile)); all.addAll(p.getCardsIn(ZoneType.Exile));
all.addAll(p.getCardsIn(ZoneType.Battlefield)); all.addAll(p.getCardsIn(ZoneType.Battlefield));
} }

View File

@@ -436,7 +436,7 @@ public class ComputerUtilCard {
// For ability of Oracle en-Vec, return the first card that are going to attack next turn // For ability of Oracle en-Vec, return the first card that are going to attack next turn
public static Card getBestCreatureToAttackNextTurnAI(final Player aiPlayer, final Iterable<Card> list) { public static Card getBestCreatureToAttackNextTurnAI(final Player aiPlayer, final Iterable<Card> list) {
AiController aic = ((PlayerControllerAi)aiPlayer.getController()).getAi(); AiController aic = ((PlayerControllerAi)aiPlayer.getController()).getAi();
for(final Card card : list) { for (final Card card : list) {
if (aic.getPredictedCombatNextTurn().isAttacking(card)) { if (aic.getPredictedCombatNextTurn().isAttacking(card)) {
return card; return card;
} }
@@ -832,7 +832,7 @@ public class ComputerUtilCard {
} }
} }
// same for Trigger that does make Tokens // same for Trigger that does make Tokens
for(Trigger t:c.getTriggers()){ for (Trigger t :c .getTriggers()) {
SpellAbility sa = t.ensureAbility(); SpellAbility sa = t.ensureAbility();
if (sa != null) { if (sa != null) {
if (sa.getApi() != ApiType.Token || !sa.hasParam("TokenTypes")) { if (sa.getApi() != ApiType.Token || !sa.hasParam("TokenTypes")) {
@@ -851,7 +851,7 @@ public class ComputerUtilCard {
} }
} }
// special rule for Fabricate and Servo // special rule for Fabricate and Servo
if(c.hasStartOfKeyword(Keyword.FABRICATE.toString())){ if (c.hasStartOfKeyword(Keyword.FABRICATE.toString())) {
Integer count = typesInDeck.get("Servo"); Integer count = typesInDeck.get("Servo");
if (count == null) { if (count == null) {
count = 0; count = 0;
@@ -1694,7 +1694,7 @@ public class ComputerUtilCard {
pumped.addHiddenExtrinsicKeywords(timestamp, 0, hiddenKws); pumped.addHiddenExtrinsicKeywords(timestamp, 0, hiddenKws);
} }
Set<CounterType> types = c.getCounters().keySet(); Set<CounterType> types = c.getCounters().keySet();
for(CounterType ct : types) { for (CounterType ct : types) {
pumped.addCounterFireNoEvents(ct, c.getCounters(ct), ai, sa, true, null); pumped.addCounterFireNoEvents(ct, c.getCounters(ct), ai, sa, true, null);
} }
//Copies tap-state and extra keywords (auras, equipment, etc.) //Copies tap-state and extra keywords (auras, equipment, etc.)

View File

@@ -671,7 +671,6 @@ public class ComputerUtilCombat {
int flankingMagnitude = 0; int flankingMagnitude = 0;
if (attacker.hasKeyword(Keyword.FLANKING) && !blocker.hasKeyword(Keyword.FLANKING)) { if (attacker.hasKeyword(Keyword.FLANKING) && !blocker.hasKeyword(Keyword.FLANKING)) {
flankingMagnitude = attacker.getAmountOfKeyword(Keyword.FLANKING); flankingMagnitude = attacker.getAmountOfKeyword(Keyword.FLANKING);
if (flankingMagnitude >= blocker.getNetToughness()) { if (flankingMagnitude >= blocker.getNetToughness()) {

View File

@@ -361,8 +361,7 @@ public class PlayerControllerAi extends PlayerController {
for (Card c: topN) { for (Card c: topN) {
if (ComputerUtil.scryWillMoveCardToBottomOfLibrary(player, c)) { if (ComputerUtil.scryWillMoveCardToBottomOfLibrary(player, c)) {
toBottom.add(c); toBottom.add(c);
} } else {
else {
toTop.add(c); toTop.add(c);
} }
} }
@@ -525,8 +524,7 @@ public class PlayerControllerAi extends PlayerController {
if (copySA instanceof Spell) { if (copySA instanceof Spell) {
Spell spell = (Spell) copySA; Spell spell = (Spell) copySA;
((PlayerControllerAi) player.getController()).getAi().canPlayFromEffectAI(spell, true, true); ((PlayerControllerAi) player.getController()).getAi().canPlayFromEffectAI(spell, true, true);
} } else {
else {
getAi().canPlaySa(copySA); getAi().canPlaySa(copySA);
} }
} }
@@ -884,9 +882,8 @@ public class PlayerControllerAi extends PlayerController {
byte chosenColorMask = MagicColor.fromName(c); byte chosenColorMask = MagicColor.fromName(c);
if ((colors.getColor() & chosenColorMask) != 0) { if ((colors.getColor() & chosenColorMask) != 0) {
return chosenColorMask; return chosenColorMask;
} else {
return Iterables.getFirst(colors, (byte)0);
} }
return Iterables.getFirst(colors, (byte)0);
} }
@Override @Override
@@ -905,10 +902,8 @@ public class PlayerControllerAi extends PlayerController {
if ((colors.getColor() & chosenColorMask) != 0) { if ((colors.getColor() & chosenColorMask) != 0) {
return chosenColorMask; return chosenColorMask;
} }
else {
return Iterables.getFirst(colors, MagicColor.WHITE); return Iterables.getFirst(colors, MagicColor.WHITE);
} }
}
@Override @Override
public ICardFace chooseSingleCardFace(SpellAbility sa, String message, public ICardFace chooseSingleCardFace(SpellAbility sa, String message,
@@ -1370,8 +1365,7 @@ public class PlayerControllerAi extends PlayerController {
} }
@Override @Override
public int chooseNumberForKeywordCost(SpellAbility sa, Cost cost, KeywordInterface keyword, String prompt, public int chooseNumberForKeywordCost(SpellAbility sa, Cost cost, KeywordInterface keyword, String prompt, int max) {
int max) {
// TODO: improve the logic depending on the keyword and the playability of the cost-modified SA (enough targets present etc.) // TODO: improve the logic depending on the keyword and the playability of the cost-modified SA (enough targets present etc.)
int chosenAmount = 0; int chosenAmount = 0;

View File

@@ -178,7 +178,7 @@ public class CharmAi extends SpellAbilityAi {
} else if (ai.canGainLife() && aiLife <= 5) { } else if (ai.canGainLife() && aiLife <= 5) {
// critical Life try to gain more // critical Life try to gain more
chosenList.add(gain); chosenList.add(gain);
} else if(!ai.canGainLife() && aiLife == 14 ) { } else if (!ai.canGainLife() && aiLife == 14 ) {
// ai cant gain life, but try to avoid falling to 13 // ai cant gain life, but try to avoid falling to 13
// but if a opponent does control Tainted Remedy its irrelevant // but if a opponent does control Tainted Remedy its irrelevant
chosenList.add(oppTainted ? lose : gain); chosenList.add(oppTainted ? lose : gain);

View File

@@ -419,15 +419,15 @@ public class CountersPutAi extends SpellAbilityAi {
oa.setActivatingPlayer(ai); oa.setActivatingPlayer(ai);
CardCollection targets = CardLists.getTargetableCards(ai.getOpponents().getCreaturesInPlay(), oa); CardCollection targets = CardLists.getTargetableCards(ai.getOpponents().getCreaturesInPlay(), oa);
if (!targets.isEmpty()){ if (!targets.isEmpty()) {
boolean canSurvive = false; boolean canSurvive = false;
for (Card humanCreature : targets) { for (Card humanCreature : targets) {
if (!FightAi.canKill(humanCreature, source, 0)){ if (!FightAi.canKill(humanCreature, source, 0)) {
canSurvive = true; canSurvive = true;
break; break;
} }
} }
if (!canSurvive){ if (!canSurvive) {
return false; return false;
} }
} }

View File

@@ -165,7 +165,7 @@ public class DamageDealAi extends DamageAiBase {
dmg = 2; dmg = 2;
} else if ("OpponentHasCreatures".equals(logic)) { } else if ("OpponentHasCreatures".equals(logic)) {
for (Player opp : ai.getOpponents()) { for (Player opp : ai.getOpponents()) {
if (!opp.getCreaturesInPlay().isEmpty()){ if (!opp.getCreaturesInPlay().isEmpty()) {
return true; return true;
} }
} }
@@ -287,7 +287,7 @@ public class DamageDealAi extends DamageAiBase {
} }
if ((damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) || if ((damage.equals("X") && sa.getSVar(damage).equals("Count$xPaid")) ||
sourceName.equals("Crater's Claws")){ sourceName.equals("Crater's Claws")) {
// If I can kill my target by paying less mana, do it // If I can kill my target by paying less mana, do it
if (sa.usesTargeting() && !sa.getTargets().isTargetingAnyPlayer() && !sa.isDividedAsYouChoose()) { if (sa.usesTargeting() && !sa.getTargets().isTargetingAnyPlayer() && !sa.isDividedAsYouChoose()) {
int actualPay = dmg; int actualPay = dmg;
@@ -330,7 +330,6 @@ public class DamageDealAi extends DamageAiBase {
*/ */
private Card dealDamageChooseTgtC(final Player ai, final SpellAbility sa, final int d, final boolean noPrevention, private Card dealDamageChooseTgtC(final Player ai, final SpellAbility sa, final int d, final boolean noPrevention,
final Player pl, final boolean mandatory) { final Player pl, final boolean mandatory) {
// wait until stack is empty (prevents duplicate kills) // wait until stack is empty (prevents duplicate kills)
if (!sa.isTrigger() && !ai.getGame().getStack().isEmpty()) { if (!sa.isTrigger() && !ai.getGame().getStack().isEmpty()) {
//TODO:all removal APIs require a check to prevent duplicate kill/bounce/exile/etc. //TODO:all removal APIs require a check to prevent duplicate kill/bounce/exile/etc.
@@ -345,7 +344,7 @@ public class DamageDealAi extends DamageAiBase {
final Player activator = sa.getActivatingPlayer(); final Player activator = sa.getActivatingPlayer();
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
final Game game = source.getGame(); final Game game = source.getGame();
List<Card> hPlay = getTargetableCards(ai, sa, pl, tgt, activator, source, game); List<Card> hPlay = getTargetableCards(mandatory ? pl : ai, sa, pl, tgt, activator, source, game);
// Filter MustTarget requirements // Filter MustTarget requirements
StaticAbilityMustTarget.filterMustTargetCards(ai, hPlay, sa); StaticAbilityMustTarget.filterMustTargetCards(ai, hPlay, sa);
@@ -531,7 +530,7 @@ public class DamageDealAi extends DamageAiBase {
if ("PowerDmg".equals(logic)) { if ("PowerDmg".equals(logic)) {
// check if it is better to target the player instead, the original target is already set in PumpAi.pumpTgtAI() // check if it is better to target the player instead, the original target is already set in PumpAi.pumpTgtAI()
if (tgt.canTgtCreatureAndPlayer() && shouldTgtP(ai, sa, dmg, noPrevention)){ if (tgt.canTgtCreatureAndPlayer() && shouldTgtP(ai, sa, dmg, noPrevention)) {
sa.resetTargets(); sa.resetTargets();
sa.getTargets().add(enemy); sa.getTargets().add(enemy);
} }

View File

@@ -94,7 +94,7 @@ public class DelayedTriggerAi extends SpellAbilityAi {
} }
}); });
if(count == 0) { if (count == 0) {
return false; return false;
} }
return true; return true;

View File

@@ -114,7 +114,7 @@ public class RearrangeTopOfLibraryAi extends SpellAbilityAi {
if (!top.isLand() && cmc - maxCastable >= uncastableCMCThreshold) { if (!top.isLand() && cmc - maxCastable >= uncastableCMCThreshold) {
// Can't cast in the foreseeable future. Shuffle if doing it to ourselves or an ally, otherwise keep it // Can't cast in the foreseeable future. Shuffle if doing it to ourselves or an ally, otherwise keep it
return !p.isOpponentOf(player); return !p.isOpponentOf(player);
} else if (top.isLand() && landsOTB <= minLandsToScryLandsAway){ } else if (top.isLand() && landsOTB <= minLandsToScryLandsAway) {
// We don't want to give the opponent a free land if his land count is low // We don't want to give the opponent a free land if his land count is low
return p.isOpponentOf(player); return p.isOpponentOf(player);
} }

View File

@@ -52,14 +52,14 @@ public class RepeatEachAi extends SpellAbilityAi {
} }
} else if ("OpponentHasCreatures".equals(logic)) { //TODO convert this to NeedsToPlayVar } else if ("OpponentHasCreatures".equals(logic)) { //TODO convert this to NeedsToPlayVar
for (Player opp : aiPlayer.getOpponents()) { for (Player opp : aiPlayer.getOpponents()) {
if (!opp.getCreaturesInPlay().isEmpty()){ if (!opp.getCreaturesInPlay().isEmpty()) {
return true; return true;
} }
} }
return false; return false;
} else if ("OpponentHasMultipleCreatures".equals(logic)) { } else if ("OpponentHasMultipleCreatures".equals(logic)) {
for (Player opp : aiPlayer.getOpponents()) { for (Player opp : aiPlayer.getOpponents()) {
if (opp.getCreaturesInPlay().size() > 1){ if (opp.getCreaturesInPlay().size() > 1) {
return true; return true;
} }
} }

View File

@@ -69,7 +69,7 @@ public class SetStateAi extends SpellAbilityAi {
final String logic = sa.getParamOrDefault("AILogic", ""); final String logic = sa.getParamOrDefault("AILogic", "");
final Game game = source.getGame(); final Game game = source.getGame();
if("Transform".equals(mode)) { if ("Transform".equals(mode)) {
if (!sa.usesTargeting()) { if (!sa.usesTargeting()) {
// no Transform with Defined which is not Self // no Transform with Defined which is not Self
if (!source.canTransform()) { if (!source.canTransform()) {

View File

@@ -35,7 +35,7 @@ public class TapAi extends TapAiBase {
// Don't tap down after blockers // Don't tap down after blockers
return false; return false;
} }
} else if (!SpellAbilityAi.playReusable(ai, sa)){ } else if (!SpellAbilityAi.playReusable(ai, sa)) {
// Generally don't want to tap things with an Instant during Players turn outside of combat // Generally don't want to tap things with an Instant during Players turn outside of combat
return false; return false;
} }

View File

@@ -45,7 +45,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
@Override @Override
public GameLogEntry visit(GameEventGameOutcome ev) { public GameLogEntry visit(GameEventGameOutcome ev) {
for(String outcome : ev.result.getOutcomeStrings()) { for (String outcome : ev.result.getOutcomeStrings()) {
log.add(GameLogEntryType.GAME_OUTCOME, outcome); log.add(GameLogEntryType.GAME_OUTCOME, outcome);
} }
return generateSummary(ev.history); return generateSummary(ev.history);

View File

@@ -2550,7 +2550,7 @@ public class AbilityUtils {
int colorOcurrencices = 0; int colorOcurrencices = 0;
byte colorCode = ManaAtom.fromName(sq[1]); byte colorCode = ManaAtom.fromName(sq[1]);
for (Card c0 : cards) { for (Card c0 : cards) {
for (ManaCostShard sh : c0.getManaCost()){ for (ManaCostShard sh : c0.getManaCost()) {
if (sh.isColor(colorCode)) if (sh.isColor(colorCode))
colorOcurrencices++; colorOcurrencices++;
} }

View File

@@ -192,7 +192,7 @@ public enum ApiType {
private static final Map<String, ApiType> allValues = new HashMap<>(); private static final Map<String, ApiType> allValues = new HashMap<>();
static { static {
for(ApiType t : ApiType.values()) { for (ApiType t : ApiType.values()) {
allValues.put(t.name().toLowerCase(), t); allValues.put(t.name().toLowerCase(), t);
} }
} }

View File

@@ -78,7 +78,7 @@ public class AmassEffect extends TokenEffectBase {
tgtCards = pc.chooseCardsForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblChooseAnArmy"), 1, 1, false, params); tgtCards = pc.chooseCardsForEffect(tgtCards, sa, Localizer.getInstance().getMessage("lblChooseAnArmy"), 1, 1, false, params);
GameEntityCounterTable table = new GameEntityCounterTable(); GameEntityCounterTable table = new GameEntityCounterTable();
for(final Card tgtCard : tgtCards) { for (final Card tgtCard : tgtCards) {
tgtCard.addCounter(CounterEnumType.P1P1, amount, activator, sa, true, table); tgtCard.addCounter(CounterEnumType.P1P1, amount, activator, sa, true, table);
game.updateLastStateForCard(tgtCard); game.updateLastStateForCard(tgtCard);

View File

@@ -96,7 +96,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
SpellAbility changingTgtSA = changingTgtSI.getSpellAbility(true); SpellAbility changingTgtSA = changingTgtSI.getSpellAbility(true);
if (changingTgtSA.usesTargeting()) { if (changingTgtSA.usesTargeting()) {
// random target and DefinedMagnet works on single targets // random target and DefinedMagnet works on single targets
if (sa.hasParam("RandomTarget")){ if (sa.hasParam("RandomTarget")) {
int div = changingTgtSA.getTotalDividedValue(); int div = changingTgtSA.getTotalDividedValue();
changingTgtSA.resetTargets(); changingTgtSA.resetTargets();
List<GameEntity> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true); List<GameEntity> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true);
@@ -116,7 +116,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
changingTgtSI.updateTarget(changingTgtSA.getTargets(), sa.getHostCard()); changingTgtSI.updateTarget(changingTgtSA.getTargets(), sa.getHostCard());
} }
else if (sa.hasParam("DefinedMagnet")){ else if (sa.hasParam("DefinedMagnet")) {
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa, "DefinedMagnet"), null); GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa, "DefinedMagnet"), null);
if (newTarget != null && changingTgtSA.canTarget(newTarget)) { if (newTarget != null && changingTgtSA.canTarget(newTarget)) {
int div = changingTgtSA.getTotalDividedValue(); int div = changingTgtSA.getTotalDividedValue();

View File

@@ -222,7 +222,7 @@ public class CharmEffect extends SpellAbilityEffect {
}); });
for (AbilitySub sub : chosen) { for (AbilitySub sub : chosen) {
// Clone the chosen, just in case the some subAb gets chosen multiple times // Clone the chosen, just in case the same subAb gets chosen multiple times
AbilitySub clone = (AbilitySub)sub.copy(); AbilitySub clone = (AbilitySub)sub.copy();
// update ActivatingPlayer // update ActivatingPlayer
@@ -250,7 +250,6 @@ public class CharmEffect extends SpellAbilityEffect {
// add Clone to Tail of sa // add Clone to Tail of sa
sa.appendSubAbility(clone); sa.appendSubAbility(clone);
} }
} }
} }

View File

@@ -141,7 +141,7 @@ public class ChooseCardNameEffect extends SpellAbilityEffect {
} }
host.setNamedCard(chosen); host.setNamedCard(chosen);
if(!randomChoice) { if (!randomChoice) {
p.getGame().getAction().notifyOfValue(sa, host, Localizer.getInstance().getMessage("lblPlayerPickedChosen", p.getName(), chosen), p); p.getGame().getAction().notifyOfValue(sa, host, Localizer.getInstance().getMessage("lblPlayerPickedChosen", p.getName(), chosen), p);
p.setNamedCard(chosen); p.setNamedCard(chosen);
} }

View File

@@ -28,7 +28,7 @@ public class ControlSpellEffect extends SpellAbilityEffect {
sb.append(newController).append(" gains control of "); sb.append(newController).append(" gains control of ");
for(SpellAbility spell : getTargetSpells(sa)) { for (SpellAbility spell : getTargetSpells(sa)) {
Card c = spell.getHostCard(); Card c = spell.getHostCard();
sb.append(" "); sb.append(" ");
if (c.isFaceDown()) { if (c.isFaceDown()) {

View File

@@ -160,7 +160,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
if (sa.hasParam("MayChooseTarget")) { if (sa.hasParam("MayChooseTarget")) {
copy.setMayChooseNewTargets(true); copy.setMayChooseNewTargets(true);
} }
if (sa.hasParam("RandomTarget")){ if (sa.hasParam("RandomTarget")) {
List<GameEntity> candidates = copy.getTargetRestrictions().getAllCandidates(chosenSA, true); List<GameEntity> candidates = copy.getTargetRestrictions().getAllCandidates(chosenSA, true);
if (sa.hasParam("RandomTargetRestriction")) { if (sa.hasParam("RandomTargetRestriction")) {
candidates.removeIf(new Predicate<GameEntity>() { candidates.removeIf(new Predicate<GameEntity>() {

View File

@@ -37,7 +37,7 @@ public class CountersNoteEffect extends SpellAbilityEffect {
} }
private void noteCounters(Card notee, Card source) { private void noteCounters(Card notee, Card source) {
for(Entry<CounterType, Integer> counter : notee.getCounters().entrySet()) { for (Entry<CounterType, Integer> counter : notee.getCounters().entrySet()) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(NOTE_COUNTERS).append(counter.getKey().getName()); sb.append(NOTE_COUNTERS).append(counter.getKey().getName());
source.setSVar(sb.toString(), counter.getValue().toString()); source.setSVar(sb.toString(), counter.getValue().toString());
@@ -45,7 +45,7 @@ public class CountersNoteEffect extends SpellAbilityEffect {
} }
private void loadCounters(Card notee, Card source, final Player p, final SpellAbility sa, GameEntityCounterTable table) { private void loadCounters(Card notee, Card source, final Player p, final SpellAbility sa, GameEntityCounterTable table) {
for(Entry<String, String> svar : source.getSVars().entrySet()) { for (Entry<String, String> svar : source.getSVars().entrySet()) {
String key = svar.getKey(); String key = svar.getKey();
if (key.startsWith(NOTE_COUNTERS)) { if (key.startsWith(NOTE_COUNTERS)) {
notee.addCounter( notee.addCounter(

View File

@@ -35,7 +35,7 @@ public class DamageAllEffect extends DamageBaseEffect {
if (!definedSources.isEmpty() && definedSources.get(0) != sa.getHostCard()) { if (!definedSources.isEmpty() && definedSources.get(0) != sa.getHostCard()) {
sb.append(definedSources.get(0).toString()).append(" deals"); sb.append(definedSources.get(0).toString()).append(" deals");
} else if ("ParentTarget".equals(definedStr)){ } else if ("ParentTarget".equals(definedStr)) {
sb.append("Target creature deals"); sb.append("Target creature deals");
} else { } else {
sb.append("Deals"); sb.append("Deals");

View File

@@ -96,7 +96,7 @@ public class DebuffEffect extends SpellAbilityEffect {
for (final String kw : kws) { for (final String kw : kws) {
// Check if some of the Keywords are Protection from <color> // Check if some of the Keywords are Protection from <color>
if (!ProtectionFromColor && kw.startsWith("Protection from ")) { if (!ProtectionFromColor && kw.startsWith("Protection from ")) {
for(byte col : MagicColor.WUBRG) { for (byte col : MagicColor.WUBRG) {
final String colString = MagicColor.toLongString(col); final String colString = MagicColor.toLongString(col);
if (kw.endsWith(colString.toLowerCase())) { if (kw.endsWith(colString.toLowerCase())) {
ProtectionFromColor = true; ProtectionFromColor = true;
@@ -110,7 +110,7 @@ public class DebuffEffect extends SpellAbilityEffect {
if (ProtectionFromColor && tgtC.hasKeyword(allColors)) { if (ProtectionFromColor && tgtC.hasKeyword(allColors)) {
final List<String> allColorsProtect = Lists.newArrayList(); final List<String> allColorsProtect = Lists.newArrayList();
for(byte col : MagicColor.WUBRG) { for (byte col : MagicColor.WUBRG) {
allColorsProtect.add("Protection from " + MagicColor.toLongString(col).toLowerCase()); allColorsProtect.add("Protection from " + MagicColor.toLongString(col).toLowerCase());
} }
allColorsProtect.removeAll(kws); allColorsProtect.removeAll(kws);
@@ -123,7 +123,7 @@ public class DebuffEffect extends SpellAbilityEffect {
if (ProtectionFromColor && tgtC.hasKeyword(allColors)) { if (ProtectionFromColor && tgtC.hasKeyword(allColors)) {
final List<String> allColorsProtect = Lists.newArrayList(); final List<String> allColorsProtect = Lists.newArrayList();
for(byte col : MagicColor.WUBRG) { for (byte col : MagicColor.WUBRG) {
final String colString = MagicColor.toLongString(col); final String colString = MagicColor.toLongString(col);
if (!kws.contains("Protection from " + colString)) { if (!kws.contains("Protection from " + colString)) {
allColorsProtect.add( allColorsProtect.add(

View File

@@ -330,7 +330,7 @@ public class EffectEffect extends SpellAbilityEffect {
} }
private void noteCounters(Card notee, Card source) { private void noteCounters(Card notee, Card source) {
for(Map.Entry<CounterType, Integer> counter : notee.getCounters().entrySet()) { for (Map.Entry<CounterType, Integer> counter : notee.getCounters().entrySet()) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("NoteCounters").append(counter.getKey().getName()); sb.append("NoteCounters").append(counter.getKey().getName());
source.setSVar(sb.toString(), counter.getValue().toString()); source.setSVar(sb.toString(), counter.getValue().toString());

View File

@@ -50,7 +50,7 @@ public class PeekAndRevealEffect extends SpellAbilityEffect {
numPeek = Math.min(numPeek, library.size()); numPeek = Math.min(numPeek, library.size());
CardCollection peekCards = new CardCollection(); CardCollection peekCards = new CardCollection();
for(int i = 0; i < numPeek; i++) { for (int i = 0; i < numPeek; i++) {
peekCards.add(library.get(i)); peekCards.add(library.get(i));
} }
@@ -74,7 +74,7 @@ public class PeekAndRevealEffect extends SpellAbilityEffect {
} }
if (imprintRevealed) { if (imprintRevealed) {
Map<Integer, Card> cachedMap = Maps.newHashMap(); Map<Integer, Card> cachedMap = Maps.newHashMap();
for(Card c : revealableCards) { for (Card c : revealableCards) {
source.addImprintedCard(CardUtil.getLKICopy(c, cachedMap)); source.addImprintedCard(CardUtil.getLKICopy(c, cachedMap));
} }
} }

View File

@@ -13,7 +13,7 @@ public class PlaneswalkEffect extends SpellAbilityEffect {
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
Game game = sa.getActivatingPlayer().getGame(); Game game = sa.getActivatingPlayer().getGame();
for(Player p : game.getPlayers()) { for (Player p : game.getPlayers()) {
p.leaveCurrentPlane(); p.leaveCurrentPlane();
} }
if (sa.hasParam("Defined")) { if (sa.hasParam("Defined")) {

View File

@@ -103,7 +103,7 @@ public class PlayEffect extends SpellAbilityEffect {
} else if (sa.hasParam("AnySupportedCard")) { } else if (sa.hasParam("AnySupportedCard")) {
final String valid = sa.getParam("AnySupportedCard"); final String valid = sa.getParam("AnySupportedCard");
List<PaperCard> cards = null; List<PaperCard> cards = null;
if (valid.startsWith("Names:")){ if (valid.startsWith("Names:")) {
cards = new ArrayList<>(); cards = new ArrayList<>();
for (String name : valid.substring(6).split(",")) { for (String name : valid.substring(6).split(",")) {
name = name.replace(";", ","); name = name.replace(";", ",");

View File

@@ -66,7 +66,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
} else if (sa.getParam("Gains").equals("TargetedCardColor")) { } else if (sa.getParam("Gains").equals("TargetedCardColor")) {
for (final Card c : sa.getSATargetingCard().getTargets().getTargetCards()) { for (final Card c : sa.getSATargetingCard().getTargets().getTargetCards()) {
ColorSet cs = CardUtil.getColors(c); ColorSet cs = CardUtil.getColors(c);
for(byte col : MagicColor.WUBRG) { for (byte col : MagicColor.WUBRG) {
if (cs.hasAnyColor(col)) if (cs.hasAnyColor(col))
gains.add(MagicColor.toLongString(col).toLowerCase()); gains.add(MagicColor.toLongString(col).toLowerCase());
} }

View File

@@ -87,7 +87,7 @@ public class TwoPilesEffect extends SpellAbilityEffect {
} }
String title; String title;
if("One".equals(sa.getParamOrDefault("FaceDown", "False"))) { if ("One".equals(sa.getParamOrDefault("FaceDown", "False"))) {
title = Localizer.getInstance().getMessage("lblSelectCardForFaceDownPile"); title = Localizer.getInstance().getMessage("lblSelectCardForFaceDownPile");
} else if (isLeftRightPile) { } else if (isLeftRightPile) {
title = Localizer.getInstance().getMessage("lblSelectCardForLeftPile"); title = Localizer.getInstance().getMessage("lblSelectCardForLeftPile");

View File

@@ -2084,7 +2084,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|| keyword.equals("Foretell") // for the ones without cost || keyword.equals("Foretell") // for the ones without cost
|| keyword.equals("Hideaway") || keyword.equals("Ascend") || keyword.equals("Hideaway") || keyword.equals("Ascend")
|| keyword.equals("Totem armor") || keyword.equals("Battle cry") || keyword.equals("Totem armor") || keyword.equals("Battle cry")
|| keyword.equals("Devoid") || keyword.equals("Riot")){ || keyword.equals("Devoid") || keyword.equals("Riot")) {
sbLong.append(keyword).append(" (").append(inst.getReminderText()).append(")"); sbLong.append(keyword).append(" (").append(inst.getReminderText()).append(")");
} else if (keyword.startsWith("Partner:")) { } else if (keyword.startsWith("Partner:")) {
final String[] k = keyword.split(":"); final String[] k = keyword.split(":");
@@ -3580,10 +3580,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
return changed; return changed;
} }
public boolean clearChangedCardKeywords() {
return clearChangedCardKeywords(false);
}
public boolean clearChangedCardColors() { public boolean clearChangedCardColors() {
boolean changed = false; boolean changed = false;
@@ -3981,7 +3977,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
this.tempBoost = 0; this.tempBoost = 0;
this.bonusFromCounters = 0; this.bonusFromCounters = 0;
} }
public StatBreakdown(int currentValue, int tempBoost, int bonusFromCounters){ public StatBreakdown(int currentValue, int tempBoost, int bonusFromCounters) {
this.currentValue = currentValue; this.currentValue = currentValue;
this.tempBoost = tempBoost; this.tempBoost = tempBoost;
this.bonusFromCounters = bonusFromCounters; this.bonusFromCounters = bonusFromCounters;
@@ -4268,6 +4264,9 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
return change; return change;
} }
public boolean clearChangedCardKeywords() {
return clearChangedCardKeywords(false);
}
public final boolean clearChangedCardKeywords(final boolean updateView) { public final boolean clearChangedCardKeywords(final boolean updateView) {
if (changedCardKeywords.isEmpty()) { if (changedCardKeywords.isEmpty()) {
return false; return false;

View File

@@ -270,7 +270,7 @@ public class CardFactory {
original.addNonManaAbilities(card.getCurrentState().getNonManaAbilities()); original.addNonManaAbilities(card.getCurrentState().getNonManaAbilities());
original.addIntrinsicKeywords(card.getCurrentState().getIntrinsicKeywords()); // Copy 'Fuse' to original side original.addIntrinsicKeywords(card.getCurrentState().getIntrinsicKeywords()); // Copy 'Fuse' to original side
original.getSVars().putAll(card.getCurrentState().getSVars()); // Unfortunately need to copy these to (Effect looks for sVars on execute) original.getSVars().putAll(card.getCurrentState().getSVars()); // Unfortunately need to copy these to (Effect looks for sVars on execute)
} else if (state != CardStateName.Original){ } else if (state != CardStateName.Original) {
CardFactoryUtil.setupKeywordedAbilities(card); CardFactoryUtil.setupKeywordedAbilities(card);
} }
if (state == CardStateName.Adventure) { if (state == CardStateName.Adventure) {

View File

@@ -538,7 +538,7 @@ public class CardFactoryUtil {
landkw.add(k); landkw.add(k);
} else if (k.startsWith("Protection")) { } else if (k.startsWith("Protection")) {
protectionkw.add(k); protectionkw.add(k);
for(byte col : MagicColor.WUBRG) { for (byte col : MagicColor.WUBRG) {
final String colString = "Protection from " + MagicColor.toLongString(col).toLowerCase(); final String colString = "Protection from " + MagicColor.toLongString(col).toLowerCase();
if (k.contains(colString)) { if (k.contains(colString)) {
protectionColorkw.add(colString); protectionColorkw.add(colString);
@@ -896,7 +896,7 @@ public class CardFactoryUtil {
cascadeTrigger.setOverridingAbility(dig); cascadeTrigger.setOverridingAbility(dig);
inst.addTrigger(cascadeTrigger); inst.addTrigger(cascadeTrigger);
} else if (keyword.startsWith("Champion")){ } else if (keyword.startsWith("Champion")) {
final String[] k = keyword.split(":"); final String[] k = keyword.split(":");
final String[] valid = k[1].split(","); final String[] valid = k[1].split(",");
String desc = Lang.joinHomogenous(Lists.newArrayList(valid), null, "or"); String desc = Lang.joinHomogenous(Lists.newArrayList(valid), null, "or");
@@ -1688,7 +1688,7 @@ public class CardFactoryUtil {
int idx = 0; int idx = 0;
int skipId = 0; int skipId = 0;
for(String ab : abs) { for (String ab : abs) {
idx += 1; idx += 1;
if (idx <= skipId) { if (idx <= skipId) {
continue; continue;
@@ -1898,7 +1898,7 @@ public class CardFactoryUtil {
final List<String> abs = Arrays.asList(keyword.substring("Dungeon:".length()).split(",")); final List<String> abs = Arrays.asList(keyword.substring("Dungeon:".length()).split(","));
final Map<String, SpellAbility> saMap = new LinkedHashMap<>(); final Map<String, SpellAbility> saMap = new LinkedHashMap<>();
for(String ab : abs) { for (String ab : abs) {
saMap.put(ab, AbilityFactory.getAbility(card, ab)); saMap.put(ab, AbilityFactory.getAbility(card, ab));
} }
for (SpellAbility sa : saMap.values()) { for (SpellAbility sa : saMap.values()) {
@@ -2956,7 +2956,7 @@ public class CardFactoryUtil {
inst.addSpellAbility(abilityMorphDown(card)); inst.addSpellAbility(abilityMorphDown(card));
inst.addSpellAbility(abilityMorphUp(card, k[1], false)); inst.addSpellAbility(abilityMorphUp(card, k[1], false));
} else if (keyword.startsWith("Megamorph")){ } else if (keyword.startsWith("Megamorph")) {
final String[] k = keyword.split(":"); final String[] k = keyword.split(":");
inst.addSpellAbility(abilityMorphDown(card)); inst.addSpellAbility(abilityMorphDown(card));

View File

@@ -354,7 +354,7 @@ public final class CardUtil {
if ((combinedColor & color) == 0) { if ((combinedColor & color) == 0) {
continue; continue;
} }
for(final Card c : game.getColoredCardsInPlay(MagicColor.toLongString(color))) { for (final Card c : game.getColoredCardsInPlay(MagicColor.toLongString(color))) {
if (!res.contains(c) && !tgts.contains(c) && c.isValid(valid, source.getController(), source, targetSA)) { if (!res.contains(c) && !tgts.contains(c) && c.isValid(valid, source.getController(), source, targetSA)) {
res.add(c); res.add(c);
} }

View File

@@ -49,7 +49,7 @@ public class AttackingBand {
String[] validString = { "Legendary.Creature", "Creature.namedWolves of the Hunt", "Dinosaur" }; String[] validString = { "Legendary.Creature", "Creature.namedWolves of the Hunt", "Dinosaur" };
Card source = band.get(0); Card source = band.get(0);
for(int i = 0; i < bandsWithString.length; i++) { for (int i = 0; i < bandsWithString.length; i++) {
String keyword = bandsWithString[i]; String keyword = bandsWithString[i];
String valid = validString[i]; String valid = validString[i];

View File

@@ -807,7 +807,7 @@ public class Combat {
if (defender instanceof Player && defender.hasKeyword("You assign combat damage of each creature attacking you.")) { if (defender instanceof Player && defender.hasKeyword("You assign combat damage of each creature attacking you.")) {
assigningPlayer = (Player)defender; assigningPlayer = (Player)defender;
} }
else if (AttackingBand.isValidBand(orderedBlockers, true)){ else if (AttackingBand.isValidBand(orderedBlockers, true)) {
assigningPlayer = orderedBlockers.get(0).getController(); assigningPlayer = orderedBlockers.get(0).getController();
} }

View File

@@ -175,7 +175,7 @@ public class CostPutCounter extends CostPartWithList {
* @see forge.card.cost.CostPartWithList#executePayment(forge.card.spellability.SpellAbility, forge.Card) * @see forge.card.cost.CostPartWithList#executePayment(forge.card.spellability.SpellAbility, forge.Card)
*/ */
@Override @Override
protected Card doPayment(SpellAbility ability, Card targetCard){ protected Card doPayment(SpellAbility ability, Card targetCard) {
final Integer i = this.convertAmount(); final Integer i = this.convertAmount();
targetCard.addCounter(this.getCounter(), i, ability.getActivatingPlayer(), null, ability.getRootAbility().isTrigger(), counterTable); targetCard.addCounter(this.getCounter(), i, ability.getActivatingPlayer(), null, ability.getRootAbility().isTrigger(), counterTable);
return targetCard; return targetCard;

View File

@@ -394,7 +394,7 @@ public class PhaseHandler implements java.io.Serializable {
final CardZoneTable table = new CardZoneTable(); final CardZoneTable table = new CardZoneTable();
final CardCollection discarded = new CardCollection(); final CardCollection discarded = new CardCollection();
boolean firstDiscarded = playerTurn.getNumDiscardedThisTurn() == 0; boolean firstDiscarded = playerTurn.getNumDiscardedThisTurn() == 0;
for (Card c : playerTurn.getController().chooseCardsToDiscardToMaximumHandSize(numDiscard)){ for (Card c : playerTurn.getController().chooseCardsToDiscardToMaximumHandSize(numDiscard)) {
if (playerTurn.discard(c, null, table) != null) { if (playerTurn.discard(c, null, table) != null) {
discarded.add(c); discarded.add(c);
} }
@@ -590,7 +590,7 @@ public class PhaseHandler implements java.io.Serializable {
"You may exert CARDNAME as it attacks."); "You may exert CARDNAME as it attacks.");
if (!possibleExerters.isEmpty()) { if (!possibleExerters.isEmpty()) {
for(Card exerter : whoDeclares.getController().exertAttackers(possibleExerters)) { for (Card exerter : whoDeclares.getController().exertAttackers(possibleExerters)) {
exerter.exert(); exerter.exert();
} }
} }
@@ -1087,7 +1087,7 @@ public class PhaseHandler implements java.io.Serializable {
sw.reset(); sw.reset();
} }
} }
else if (DEBUG_PHASES){ else if (DEBUG_PHASES) {
System.out.print(" >> (no priority given to " + getPriorityPlayer() + ")\n"); System.out.print(" >> (no priority given to " + getPriorityPlayer() + ")\n");
} }

View File

@@ -483,7 +483,7 @@ public class PlayerView extends GameEntityView {
if (cards == null) if (cards == null)
return 0; return 0;
for(CardView c : cards) { for (CardView c : cards) {
types.addAll((Collection<? extends CardType.CoreType>) c.getCurrentState().getType().getCoreTypes()); types.addAll((Collection<? extends CardType.CoreType>) c.getCurrentState().getType().getCoreTypes());
} }

View File

@@ -2190,7 +2190,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
@Override @Override
public int compareTo(SpellAbility ab) { public int compareTo(SpellAbility ab) {
if (this.isManaAbility() && ab.isManaAbility()){ if (this.isManaAbility() && ab.isManaAbility()) {
return this.calculateScoreForManaAbility() - ab.calculateScoreForManaAbility(); return this.calculateScoreForManaAbility() - ab.calculateScoreForManaAbility();
} }
return 0; return 0;

View File

@@ -318,7 +318,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
SpellAbility compare = sa; SpellAbility compare = sa;
SpellAbilityStackInstance sub = this; SpellAbilityStackInstance sub = this;
if (!compare.equals(sub.ability)){ if (!compare.equals(sub.ability)) {
return false; return false;
} }