mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Clean up (#2907)
This commit is contained in:
@@ -450,6 +450,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
|
||||
}
|
||||
|
||||
if (params.containsKey("CheckSVar")) {
|
||||
// TODO this provides only the card controller instead of the stack one
|
||||
final int sVar = AbilityUtils.calculateAmount(getHostCard(), params.get("CheckSVar"), this);
|
||||
final String comparator = getParamOrDefault("SVarCompare", "GE1");
|
||||
final String svarOperator = comparator.substring(0, 2);
|
||||
@@ -463,7 +464,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
|
||||
final String comparator2 = getParamOrDefault("SecondSVarCompare", "GE1");
|
||||
final String svarOperator2 = comparator2.substring(0, 2);
|
||||
final String svarOperand2 = comparator2.substring(2);
|
||||
final int operandValue2 = AbilityUtils.calculateAmount(this.hostCard, svarOperand2, this);
|
||||
final int operandValue2 = AbilityUtils.calculateAmount(getHostCard(), svarOperand2, this);
|
||||
if (!Expressions.compare(sVar2, svarOperator2, operandValue2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ public class AbilityUtils {
|
||||
origin = null;
|
||||
validFilter = workingCopy[2];
|
||||
}
|
||||
for (final Card cl : CardUtil.getThisTurnEntered(destination, origin, validFilter, hostCard, sa)) {
|
||||
for (final Card cl : CardUtil.getThisTurnEntered(destination, origin, validFilter, hostCard, sa, player)) {
|
||||
Card gameState = game.getCardState(cl, null);
|
||||
// cards that use this should only care about if it is still in that zone
|
||||
// TODO if all LKI needs to be returned, need to change CardCollection return from this function
|
||||
@@ -1846,11 +1846,6 @@ public class AbilityUtils {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
// Count$TriggeredManaSpent
|
||||
if (sq[0].equals("TriggeredManaSpent")) {
|
||||
final SpellAbility root = (SpellAbility) sa.getRootAbility().getTriggeringObject(AbilityKey.SpellAbility);
|
||||
return root == null ? 0 : root.getTotalManaSpent();
|
||||
}
|
||||
|
||||
// Count$ManaColorsPaid
|
||||
if (sq[0].equals("ManaColorsPaid")) {
|
||||
@@ -2624,7 +2619,7 @@ public class AbilityUtils {
|
||||
//game info
|
||||
// Count$Morbid.<True>.<False>
|
||||
if (sq[0].startsWith("Morbid")) {
|
||||
final List<Card> res = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Battlefield, "Creature", c, ctb);
|
||||
final List<Card> res = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Battlefield, "Creature", c, ctb, player);
|
||||
return doXMath(calculateAmount(c, sq[res.size() > 0 ? 1 : 2], ctb), expr, c, ctb);
|
||||
}
|
||||
|
||||
@@ -2736,9 +2731,9 @@ public class AbilityUtils {
|
||||
|
||||
List<Card> res = Lists.newArrayList();
|
||||
if (workingCopy[0].contains("This")) {
|
||||
res = CardUtil.getThisTurnCast(validFilter, c, ctb);
|
||||
res = CardUtil.getThisTurnCast(validFilter, c, ctb, player);
|
||||
} else {
|
||||
res = CardUtil.getLastTurnCast(validFilter, c, ctb);
|
||||
res = CardUtil.getLastTurnCast(validFilter, c, ctb, player);
|
||||
}
|
||||
|
||||
return doXMath(res.size(), expr, c, ctb);
|
||||
@@ -2753,7 +2748,7 @@ public class AbilityUtils {
|
||||
ZoneType origin = hasFrom ? ZoneType.smartValueOf(workingCopy[3]) : null;
|
||||
String validFilter = workingCopy[hasFrom ? 4 : 2];
|
||||
|
||||
final List<Card> res = CardUtil.getThisTurnEntered(destination, origin, validFilter, c, ctb);
|
||||
final List<Card> res = CardUtil.getThisTurnEntered(destination, origin, validFilter, c, ctb, player);
|
||||
return doXMath(res.size(), expr, c, ctb);
|
||||
}
|
||||
|
||||
@@ -2766,7 +2761,7 @@ public class AbilityUtils {
|
||||
ZoneType origin = hasFrom ? ZoneType.smartValueOf(workingCopy[3]) : null;
|
||||
String validFilter = workingCopy[hasFrom ? 4 : 2];
|
||||
|
||||
final List<Card> res = CardUtil.getLastTurnEntered(destination, origin, validFilter, c, ctb);
|
||||
final List<Card> res = CardUtil.getLastTurnEntered(destination, origin, validFilter, c, ctb, player);
|
||||
return doXMath(res.size(), expr, c, ctb);
|
||||
}
|
||||
|
||||
|
||||
@@ -1238,7 +1238,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
CardLists.shuffle(chosenCards);
|
||||
}
|
||||
// do not shuffle the library once we have placed a fetched card on top.
|
||||
if (origin.contains(ZoneType.Library) && (destination == ZoneType.Library) && shuffleMandatory) {
|
||||
if (origin.contains(ZoneType.Library) && destination == ZoneType.Library && shuffleMandatory) {
|
||||
player.shuffle(sa);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ public class DamageDealEffect extends DamageBaseEffect {
|
||||
} else { // only for Comet, Stellar Pup
|
||||
final String prompt = sa.hasParam("ChoicePrompt") ? sa.getParam("ChoicePrompt") :
|
||||
Localizer.getInstance().getMessage("lblChooseEntityDmg");
|
||||
tgts.addAll(sa.getActivatingPlayer().getController().chooseEntitiesForEffect(choices, n, n, null, sa,
|
||||
tgts.addAll(activator.getController().chooseEntitiesForEffect(choices, n, n, null, sa,
|
||||
prompt, null, null));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -127,7 +127,7 @@ public class RepeatEachEffect extends SpellAbilityEffect {
|
||||
if (def.startsWith("ThisTurnCast")) {
|
||||
final String[] workingCopy = def.split("_");
|
||||
final String validFilter = workingCopy[1];
|
||||
res = CardUtil.getThisTurnCast(validFilter, source, sa);
|
||||
res = CardUtil.getThisTurnCast(validFilter, source, sa, player);
|
||||
} else if (def.startsWith("Defined ")) {
|
||||
res = AbilityUtils.getDefinedCards(source, def.substring(8), sa);
|
||||
} else {
|
||||
|
||||
@@ -25,19 +25,17 @@ public class TapEffect extends SpellAbilityEffect {
|
||||
card.clearRemembered();
|
||||
}
|
||||
|
||||
CardCollection toTap = new CardCollection();
|
||||
Iterable<Card> toTap;
|
||||
|
||||
if (sa.hasParam("CardChoices")) { // choosing outside Defined/Targeted
|
||||
final Player activator = sa.getActivatingPlayer();
|
||||
CardCollection choices = new CardCollection();
|
||||
choices.addAll(CardLists.getValidCards(card.getGame().getCardsIn(ZoneType.Battlefield),
|
||||
sa.getParam("CardChoices"), activator, card, sa));
|
||||
CardCollection choices = CardLists.getValidCards(card.getGame().getCardsIn(ZoneType.Battlefield), sa.getParam("CardChoices"), activator, card, sa);
|
||||
int n = sa.hasParam("ChoiceAmount") ?
|
||||
AbilityUtils.calculateAmount(card, sa.getParam("ChoiceAmount"), sa) : 1;
|
||||
int min = (sa.hasParam("AnyNumber")) ? 0 : n;
|
||||
int min = sa.hasParam("AnyNumber") ? 0 : n;
|
||||
final String prompt = sa.hasParam("ChoicePrompt") ? sa.getParam("ChoicePrompt") :
|
||||
Localizer.getInstance().getMessage("lblChoosePermanentstoTap");
|
||||
toTap.addAll(activator.getController().chooseEntitiesForEffect(choices, min, n, null, sa, prompt, null, null));
|
||||
toTap = activator.getController().chooseEntitiesForEffect(choices, min, n, null, sa, prompt, null, null);
|
||||
} else {
|
||||
toTap = getTargetCards(sa);
|
||||
}
|
||||
|
||||
@@ -870,7 +870,7 @@ public class CardProperty {
|
||||
} else if (restriction.equals(ZoneType.Battlefield.toString())) {
|
||||
return Iterables.any(game.getCardsIn(ZoneType.Battlefield), CardPredicates.sharesNameWith(card));
|
||||
} else if (restriction.equals("ThisTurnCast")) {
|
||||
return Iterables.any(CardUtil.getThisTurnCast("Card", source, spellAbility), CardPredicates.sharesNameWith(card));
|
||||
return Iterables.any(CardUtil.getThisTurnCast("Card", source, spellAbility, sourceController), CardPredicates.sharesNameWith(card));
|
||||
} else if (restriction.equals("MovedToGrave")) {
|
||||
if (!(spellAbility instanceof SpellAbility)) {
|
||||
final SpellAbility root = ((SpellAbility) spellAbility).getRootAbility();
|
||||
@@ -962,7 +962,7 @@ public class CardProperty {
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("SecondSpellCastThisTurn")) {
|
||||
final List<Card> cards = CardUtil.getThisTurnCast("Card", source, spellAbility);
|
||||
final List<Card> cards = CardUtil.getThisTurnCast("Card", source, spellAbility, sourceController);
|
||||
if (cards.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
@@ -970,7 +970,7 @@ public class CardProperty {
|
||||
return false;
|
||||
}
|
||||
} else if (property.equals("ThisTurnCast")) {
|
||||
for (final Card c : CardUtil.getThisTurnCast("Card", source, spellAbility)) {
|
||||
for (final Card c : CardUtil.getThisTurnCast("Card", source, spellAbility, sourceController)) {
|
||||
if (card.equals(c)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -101,9 +101,6 @@ public final class CardUtil {
|
||||
* @param src a Card object
|
||||
* @return a CardCollection that matches the given criteria
|
||||
*/
|
||||
public static List<Card> getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src, final CardTraitBase ctb) {
|
||||
return getThisTurnEntered(to, from, valid, src, ctb, src.getController());
|
||||
}
|
||||
public static List<Card> getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src, final CardTraitBase ctb, final Player controller) {
|
||||
List<Card> res = Lists.newArrayList();
|
||||
final Game game = src.getGame();
|
||||
@@ -126,7 +123,7 @@ public final class CardUtil {
|
||||
* @param src a Card object
|
||||
* @return a CardCollection that matches the given criteria
|
||||
*/
|
||||
public static List<Card> getLastTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src, final CardTraitBase ctb) {
|
||||
public static List<Card> getLastTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src, final CardTraitBase ctb, final Player controller) {
|
||||
List<Card> res = Lists.newArrayList();
|
||||
final Game game = src.getGame();
|
||||
if (to != ZoneType.Stack) {
|
||||
@@ -136,15 +133,15 @@ public final class CardUtil {
|
||||
} else {
|
||||
res.addAll(game.getStackZone().getCardsAddedLastTurn(from));
|
||||
}
|
||||
return CardLists.getValidCardsAsList(res, valid, src.getController(), src, ctb);
|
||||
return CardLists.getValidCardsAsList(res, valid, controller, src, ctb);
|
||||
}
|
||||
|
||||
public static List<Card> getThisTurnCast(final String valid, final Card src, final CardTraitBase ctb) {
|
||||
return CardLists.getValidCardsAsList(src.getGame().getStack().getSpellsCastThisTurn(), valid, src.getController(), src, ctb);
|
||||
public static List<Card> getThisTurnCast(final String valid, final Card src, final CardTraitBase ctb, final Player controller) {
|
||||
return CardLists.getValidCardsAsList(src.getGame().getStack().getSpellsCastThisTurn(), valid, controller, src, ctb);
|
||||
}
|
||||
|
||||
public static List<Card> getLastTurnCast(final String valid, final Card src, final CardTraitBase ctb) {
|
||||
return CardLists.getValidCardsAsList(src.getGame().getStack().getSpellsCastLastTurn(), valid, src.getController(), src, ctb);
|
||||
public static List<Card> getLastTurnCast(final String valid, final Card src, final CardTraitBase ctb, final Player controller) {
|
||||
return CardLists.getValidCardsAsList(src.getGame().getStack().getSpellsCastLastTurn(), valid, controller, src, ctb);
|
||||
}
|
||||
|
||||
public static List<Card> getLKICopyList(final Iterable<Card> in, Map<Integer, Card> cachedMap) {
|
||||
|
||||
@@ -468,7 +468,7 @@ public class CostAdjustment {
|
||||
}
|
||||
List<Card> list;
|
||||
if (st.hasParam("ValidCard")) {
|
||||
list = CardUtil.getThisTurnCast(st.getParam("ValidCard"), hostCard, st);
|
||||
list = CardUtil.getThisTurnCast(st.getParam("ValidCard"), hostCard, st, controller);
|
||||
} else {
|
||||
list = game.getStack().getSpellsCastThisTurn();
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class StaticAbilityCantBeCast {
|
||||
if (stAb.hasParam("NumLimitEachTurn") && activator != null) {
|
||||
int limit = Integer.parseInt(stAb.getParam("NumLimitEachTurn"));
|
||||
String valid = stAb.getParamOrDefault("ValidCard", "Card");
|
||||
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, card, stAb);
|
||||
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, card, stAb, activator);
|
||||
if (CardLists.filterControlledByAsList(thisTurnCast, activator).size() < limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Expressions;
|
||||
@@ -190,7 +189,7 @@ public class TriggerChangesZone extends Trigger {
|
||||
/* this trigger only activates for the nth spell you cast this turn */
|
||||
if (hasParam("ConditionYouCastThisTurn")) {
|
||||
final String compare = getParam("ConditionYouCastThisTurn");
|
||||
List<Card> thisTurnCast = CardUtil.getThisTurnCast("Card", getHostCard(), this);
|
||||
List<Card> thisTurnCast = getHostCard().getGame().getStack().getSpellsCastThisTurn();
|
||||
thisTurnCast = CardLists.filterControlledByAsList(thisTurnCast, getHostCard().getController());
|
||||
|
||||
// checks which card this spell was the castSA
|
||||
|
||||
@@ -102,7 +102,7 @@ public class TriggerSpellAbilityCastOrCopy extends Trigger {
|
||||
if (hasParam("ActivatorThisTurnCast")) {
|
||||
final String compare = getParam("ActivatorThisTurnCast");
|
||||
final String valid = getParamOrDefault("ValidCard", "Card");
|
||||
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, getHostCard(), this);
|
||||
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, getHostCard(), this, getHostCard().getController());
|
||||
thisTurnCast = CardLists.filterControlledByAsList(thisTurnCast, activator);
|
||||
int left = thisTurnCast.size();
|
||||
int right = Integer.parseInt(compare.substring(2));
|
||||
|
||||
Reference in New Issue
Block a user