Commit 08f14d21 authored by Hans Mackowiak's avatar Hans Mackowiak

refactor CardFactoryUtil.xCount into AbilityUtils.xCount

parent b23aee32
......@@ -1125,7 +1125,7 @@ public class ComputerUtil {
creatures2.add(creatures.get(i));
}
}
if (((creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", vengevines.get(0)).size()) > 1)
if (((creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", vengevines.get(0), null).size()) > 1)
&& card.isCreature() && card.getManaCost().getCMC() <= 3) {
return true;
}
......
......@@ -156,7 +156,7 @@ public class ComputerUtilCost {
if (typeList.size() > ai.getMaxHandSize()) {
continue;
}
int num = AbilityUtils.calculateAmount(source, disc.getAmount(), null);
int num = AbilityUtils.calculateAmount(source, disc.getAmount(), sa);
for (int i = 0; i < num; i++) {
Card pref = ComputerUtil.getCardPreference(ai, source, "DiscardCost", typeList);
......
......@@ -768,7 +768,7 @@ public class AttachAi extends SpellAbilityAi {
int powerBuff = 0;
for (StaticAbility stAb : sa.getHostCard().getStaticAbilities()) {
if ("Card.EquippedBy".equals(stAb.getParam("Affected")) && stAb.hasParam("AddPower")) {
powerBuff = AbilityUtils.calculateAmount(sa.getHostCard(), stAb.getParam("AddPower"), null);
powerBuff = AbilityUtils.calculateAmount(sa.getHostCard(), stAb.getParam("AddPower"), stAb);
}
}
if (combat != null && combat.isAttacking(equipped) && ph.is(PhaseType.COMBAT_DECLARE_BLOCKERS, sa.getActivatingPlayer())) {
......
......@@ -434,7 +434,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
}
if (params.containsKey("WerewolfTransformCondition")) {
if (!CardUtil.getLastTurnCast("Card", this.getHostCard()).isEmpty()) {
if (!CardUtil.getLastTurnCast("Card", this.getHostCard(), this).isEmpty()) {
return false;
}
}
......
......@@ -855,7 +855,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), CardPredicates.sharesNameWith(card));
return Iterables.any(CardUtil.getThisTurnCast("Card", source, spellAbility), CardPredicates.sharesNameWith(card));
} else if (restriction.equals("MovedToGrave")) {
for (final SpellAbility sa : source.getCurrentState().getNonManaAbilities()) {
final SpellAbility root = sa.getRootAbility();
......@@ -949,7 +949,7 @@ public class CardProperty {
}
}
} else if (property.startsWith("SecondSpellCastThisTurn")) {
final List<Card> cards = CardUtil.getThisTurnCast("Card", source);
final List<Card> cards = CardUtil.getThisTurnCast("Card", source, spellAbility);
if (cards.size() < 2) {
return false;
}
......@@ -957,7 +957,7 @@ public class CardProperty {
return false;
}
} else if (property.equals("ThisTurnCast")) {
for (final Card c : CardUtil.getThisTurnCast("Card", source)) {
for (final Card c : CardUtil.getThisTurnCast("Card", source, spellAbility)) {
if (card.equals(c)) {
return true;
}
......@@ -1006,7 +1006,7 @@ public class CardProperty {
return false;
}
List<Card> cards = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Hand, "Card", source);
List<Card> cards = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Hand, "Card", source, spellAbility);
if (!cards.contains(card) && !card.getMadnessWithoutCast()) {
return false;
}
......
......@@ -32,6 +32,7 @@ import forge.card.CardStateName;
import forge.card.CardType;
import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.game.CardTraitBase;
import forge.game.Game;
import forge.game.GameEntity;
import forge.game.GameObject;
......@@ -115,7 +116,7 @@ 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) {
public static List<Card> getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src, final CardTraitBase ctb) {
List<Card> res = Lists.newArrayList();
final Game game = src.getGame();
if (to != ZoneType.Stack) {
......@@ -126,8 +127,7 @@ public final class CardUtil {
else {
res.addAll(game.getStackZone().getCardsAddedThisTurn(from));
}
res = CardLists.getValidCardsAsList(res, valid, src.getController(), src, null);
return res;
return CardLists.getValidCardsAsList(res, valid, src.getController(), src, ctb);
}
/**
......@@ -139,7 +139,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) {
public static List<Card> getLastTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src, final CardTraitBase ctb) {
List<Card> res = Lists.newArrayList();
final Game game = src.getGame();
if (to != ZoneType.Stack) {
......@@ -150,16 +150,15 @@ public final class CardUtil {
else {
res.addAll(game.getStackZone().getCardsAddedLastTurn(from));
}
res = CardLists.getValidCardsAsList(res, valid, src.getController(), src, null);
return res;
return CardLists.getValidCardsAsList(res, valid, src.getController(), src, ctb);
}
public static List<Card> getThisTurnCast(final String valid, final Card src) {
return CardLists.getValidCardsAsList(src.getGame().getStack().getSpellsCastThisTurn(), valid, src.getController(), src, null);
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> getLastTurnCast(final String valid, final Card src) {
return CardLists.getValidCardsAsList(src.getGame().getStack().getSpellsCastLastTurn(), valid, src.getController(), src, null);
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);
}
......
......@@ -454,7 +454,7 @@ public class CostAdjustment {
}
List<Card> list;
if (st.hasParam("ValidCard")) {
list = CardUtil.getThisTurnCast(st.getParam("ValidCard"), hostCard);
list = CardUtil.getThisTurnCast(st.getParam("ValidCard"), hostCard, st);
} else {
list = game.getStack().getSpellsCastThisTurn();
}
......
......@@ -132,7 +132,7 @@ public class StaticAbilityCantBeCast {
if (stAb.hasParam("NumLimitEachTurn") && activator != null) {
int limit = Integer.parseInt(stAb.getParam("NumLimitEachTurn"));
String valid = stAb.hasParam("ValidCard") ? stAb.getParam("ValidCard") : "Card";
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, card);
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, card, stAb);
if (CardLists.filterControlledBy(thisTurnCast, activator).size() < limit) {
return false;
}
......
......@@ -178,7 +178,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());
List<Card> thisTurnCast = CardUtil.getThisTurnCast("Card", getHostCard(), this);
thisTurnCast = CardLists.filterControlledByAsList(thisTurnCast, getHostCard().getController());
// checks which card this spell was the castSA
......
......@@ -109,7 +109,7 @@ public class TriggerSpellAbilityCastOrCopy extends Trigger {
if (hasParam("ActivatorThisTurnCast")) {
final String compare = getParam("ActivatorThisTurnCast");
final String valid = hasParam("ValidCard") ? getParam("ValidCard") : "Card";
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, getHostCard());
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, getHostCard(), this);
thisTurnCast = CardLists.filterControlledBy(thisTurnCast, si.getSpellAbility(true).getActivatingPlayer());
int left = thisTurnCast.size();
int right = Integer.parseInt(compare.substring(2));
......
......@@ -5,5 +5,4 @@ A:SP$ DealDamage | Cost$ 3 R | ValidTgts$ Player | TgtPrompt$ Select target play
SVar:X:TargetedPlayer$LifeTotal
SVar:Y:Count$OppsAtLifeTotal.10
SVar:NeedsToPlayVar:Y GE1
SVar:Picture:http://resources.wizards.com/magic/cards/sok/en-us/card88818.jpg
Oracle:If target player has exactly 10 life, Hidetsugu's Second Rite deals 10 damage to that player.
Oracle:If target player has exactly 10 life, Hidetsugu's Second Rite deals 10 damage to that player.
\ No newline at end of file
......@@ -11,5 +11,5 @@ SVar:STPlay:Mode$ Continuous | MayPlay$ True | MayPlayIgnoreColor$ True | Effect
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:Count$ValidHand Card.DefenderCtrl
SVar:Y:Count$InYourHand
SVar:Z:Count$CreaturesAttackedThisTurn_Rogue
SVar:Z:Count$CreaturesAttackedThisTurn Creature.Rogue
Oracle:Reach, haste\nWhenever Robber of the Rich attacks, if defending player has more cards in hand than you, exile the top card of their library. During any turn you attacked with a Rogue, you may cast that card and you may spend mana as though it were mana of any color to cast that spell.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment