mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
TargetChoices extend ForwardingList
This commit is contained in:
@@ -835,7 +835,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
c = source.getCounters(cost.counter);
|
||||
} else if (sVar.equals("Targeted$CardManaCost")) {
|
||||
c = 0;
|
||||
if (ability.getTargets().getNumTargeted() > 0) {
|
||||
if (ability.getTargets().size() > 0) {
|
||||
for (Card tgt : ability.getTargets().getTargetCards()) {
|
||||
if (tgt.getManaCost() != null) {
|
||||
c += tgt.getManaCost().getCMC();
|
||||
|
||||
@@ -1573,7 +1573,7 @@ public class ComputerUtil {
|
||||
return threatened;
|
||||
}
|
||||
} else {
|
||||
objects = topStack.getTargets().getTargets();
|
||||
objects = topStack.getTargets();
|
||||
final List<GameObject> canBeTargeted = new ArrayList<>();
|
||||
for (Object o : objects) {
|
||||
if (o instanceof Card) {
|
||||
|
||||
@@ -484,7 +484,7 @@ public class ComputerUtilMana {
|
||||
SpellAbility saPayment = saList.isEmpty() ? null : chooseManaAbility(cost, sa, ai, toPay, saList, checkPlayable || !test);
|
||||
|
||||
if (saPayment != null && ComputerUtilCost.isSacrificeSelfCost(saPayment.getPayCosts())) {
|
||||
if (sa.getTargets() != null && sa.getTargets().isTargeting(saPayment.getHostCard())) {
|
||||
if (sa.getTargets() != null && sa.getTargets().contains(saPayment.getHostCard())) {
|
||||
saExcludeList.add(saPayment); // not a good idea to sac a card that you're targeting with the SA you're paying for
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -819,7 +819,7 @@ public abstract class GameState {
|
||||
}
|
||||
|
||||
if (sa.hasParam("RememberTargets")) {
|
||||
for (final GameObject o : sa.getTargets().getTargets()) {
|
||||
for (final GameObject o : sa.getTargets()) {
|
||||
sa.getHostCard().addRemembered(o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class SpecialCardAi {
|
||||
sa.getTargets().add(worstCreat);
|
||||
}
|
||||
|
||||
return sa.getTargets().getNumTargeted() > 0;
|
||||
return sa.getTargets().size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1302,7 +1302,7 @@ public class SpecialCardAi {
|
||||
sa.getTargets().add(worstOwnCreat);
|
||||
}
|
||||
|
||||
return sa.getTargets().getNumTargeted() > 0;
|
||||
return sa.getTargets().size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -972,7 +972,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
targets = AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
} else {
|
||||
AttachAi.attachPreference(sa, tgt, mandatory);
|
||||
targets = sa.getTargets().getTargets();
|
||||
targets = sa.getTargets();
|
||||
}
|
||||
|
||||
if (!mandatory && card.isEquipment() && !targets.isEmpty()) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class BecomesBlockedAi extends SpellAbilityAi {
|
||||
list = CardLists.getTargetableCards(list, sa);
|
||||
list = CardLists.getNotKeyword(list, Keyword.TRAMPLE);
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
Card choice = null;
|
||||
|
||||
if (list.isEmpty()) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ChangeTargetsAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() != 0) {
|
||||
if (sa.getTargets().size() != 0) {
|
||||
// something was already chosen before (e.g. in response to a trigger - Mizzium Meddler), so just proceed
|
||||
return true;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class ChangeTargetsAi extends SpellAbilityAi {
|
||||
ManaCost normalizedMana = manaCost.getNormalizedMana();
|
||||
boolean canPay = ComputerUtilMana.canPayManaCost(new ManaCostBeingPaid(normalizedMana), sa, aiPlayer);
|
||||
if (potentialDmg != -1 && potentialDmg <= payDamage && !canPay
|
||||
&& topSa.getTargets().getTargets().contains(aiPlayer)) {
|
||||
&& topSa.getTargets().contains(aiPlayer)) {
|
||||
// do not pay Phyrexian mana if the spell is a damaging one but it deals less damage or the same damage as we'll pay life
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1125,7 +1125,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
// AI Targeting
|
||||
Card choice = null;
|
||||
|
||||
@@ -1190,7 +1190,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
if (choice == null) { // can't find anything left
|
||||
if (sa.getTargets().getNumTargeted() == 0 || sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (sa.getTargets().size() == 0 || sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -1204,7 +1204,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
boolean aiTgtsOK = false;
|
||||
if (sa.hasParam("AIMinTgts")) {
|
||||
int minTgts = Integer.parseInt(sa.getParam("AIMinTgts"));
|
||||
if (sa.getTargets().getNumTargeted() >= minTgts) {
|
||||
if (sa.getTargets().size() >= minTgts) {
|
||||
aiTgtsOK = true;
|
||||
}
|
||||
}
|
||||
@@ -1382,7 +1382,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
// AI Targeting
|
||||
Card choice = null;
|
||||
|
||||
@@ -1424,7 +1424,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
if (choice == null) { // can't find anything left
|
||||
if (sa.getTargets().getNumTargeted() == 0 || sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (sa.getTargets().size() == 0 || sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
if (!topStack.usesTargeting() && topStack.hasParam("ValidPlayers") && !topStack.hasParam("Defined")) {
|
||||
objects = AbilityUtils.getDefinedPlayers(threatSource, topStack.getParam("ValidPlayers"), topStack);
|
||||
}
|
||||
|
||||
|
||||
if (!objects.contains(ai) || topStack.hasParam("NoPrevention")) {
|
||||
return false;
|
||||
}
|
||||
@@ -123,9 +123,9 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCard(final Player aiChoser, SpellAbility sa, Iterable<Card> options, boolean isOptional, Player targetedPlayer, Map<String, Object> params) {
|
||||
if ("NeedsPrevention".equals(sa.getParam("AILogic"))) {
|
||||
@@ -139,11 +139,11 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
final Combat combat = game.getCombat();
|
||||
|
||||
|
||||
List<Card> permanentSources = CardLists.filter(options, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (c == null || c.getZone() == null || c.getZone().getZoneType() != ZoneType.Battlefield
|
||||
if (c == null || c.getZone() == null || c.getZone().getZoneType() != ZoneType.Battlefield
|
||||
|| combat == null || !combat.isAttacking(c, ai) || !combat.isUnblocked(c)) {
|
||||
return false;
|
||||
}
|
||||
@@ -186,12 +186,12 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
return ComputerUtilCard.getBestAI(options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Card chooseCardOnStack(SpellAbility sa, Player ai, Game game) {
|
||||
for (SpellAbilityStackInstance si : game.getStack()) {
|
||||
final Card source = si.getSourceCard();
|
||||
final SpellAbility abilityOnStack = si.getSpellAbility(true);
|
||||
|
||||
|
||||
if (sa.hasParam("Choices") && !abilityOnStack.getHostCard().isValid(sa.getParam("Choices"), ai, sa.getHostCard(), sa)) {
|
||||
continue;
|
||||
}
|
||||
@@ -202,9 +202,9 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
|
||||
List<? extends GameObject> objects = getTargets(abilityOnStack);
|
||||
|
||||
if (!abilityOnStack.usesTargeting() && !abilityOnStack.hasParam("Defined") && abilityOnStack.hasParam("ValidPlayers"))
|
||||
if (!abilityOnStack.usesTargeting() && !abilityOnStack.hasParam("Defined") && abilityOnStack.hasParam("ValidPlayers"))
|
||||
objects = AbilityUtils.getDefinedPlayers(source, abilityOnStack.getParam("ValidPlayers"), abilityOnStack);
|
||||
|
||||
|
||||
if (!objects.contains(ai) || abilityOnStack.hasParam("NoPrevention")) {
|
||||
continue;
|
||||
}
|
||||
@@ -215,11 +215,11 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
return source;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<GameObject> getTargets(final SpellAbility sa) {
|
||||
return sa.usesTargeting() && (!sa.hasParam("Defined"))
|
||||
? Lists.newArrayList(sa.getTargets().getTargets())
|
||||
? Lists.newArrayList(sa.getTargets())
|
||||
: AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam("Defined"), sa);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ClashAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
return sa.getTargets().getNumTargeted() > 0;
|
||||
return sa.getTargets().size() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -197,11 +197,11 @@ public class ControlGainAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card t = null;
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if ((sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().size() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -132,7 +132,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
// target loop
|
||||
while (sa.canAddMoreTarget()) {
|
||||
if (list.isEmpty()) {
|
||||
if (!sa.isTargetNumberValid() || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if (!sa.isTargetNumberValid() || (sa.getTargets().size() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -159,7 +159,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if (!sa.isTargetNumberValid() || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if (!sa.isTargetNumberValid() || (sa.getTargets().size() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -173,7 +173,7 @@ public class CountersMultiplyAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// targeting does failed
|
||||
if (!sa.isTargetNumberValid() || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (!sa.isTargetNumberValid() || sa.getTargets().size() == 0) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (sa.usesTargeting() && abTgt.getMinTargets(source, sa) < 2) {
|
||||
if (ComputerUtilCard.canPumpAgainstRemoval(ai, sa)) {
|
||||
Card c = sa.getTargets().getFirstTargetedCard();
|
||||
if (sa.getTargets().getNumTargeted() > 1) {
|
||||
if (sa.getTargets().size() > 1) {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
@@ -456,7 +456,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
&& sa.hasParam("Planeswalker")
|
||||
&& sa.getPayCosts().hasOnlySpecificCostType(CostPutCounter.class)
|
||||
&& sa.isTargetNumberValid()
|
||||
&& sa.getTargets().getNumTargeted() == 0
|
||||
&& sa.getTargets().size() == 0
|
||||
&& ai.getGame().getPhaseHandler().is(PhaseType.MAIN2, ai)) {
|
||||
return true;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
abTgt.addDividedAllocation(c, i);
|
||||
left -= i;
|
||||
}
|
||||
if (left < i || sa.getTargets().getNumTargeted() == abTgt.getMaxTargets(source, sa)) {
|
||||
if (left < i || sa.getTargets().size() == abTgt.getMaxTargets(source, sa)) {
|
||||
abTgt.addDividedAllocation(sa.getTargets().getFirstTargetedCard(), left + i);
|
||||
left = 0;
|
||||
break;
|
||||
@@ -492,7 +492,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
// target loop
|
||||
while (sa.canAddMoreTarget()) {
|
||||
if (list.isEmpty()) {
|
||||
if (!sa.isTargetNumberValid() || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if (!sa.isTargetNumberValid() || (sa.getTargets().size() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -530,7 +530,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if (!sa.isTargetNumberValid() || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (!sa.isTargetNumberValid() || sa.getTargets().size() == 0) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -637,7 +637,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if (!sa.isTargetNumberValid()
|
||||
|| sa.getTargets().getNumTargeted() == 0) {
|
||||
|| sa.getTargets().size() == 0) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -661,7 +661,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if ((!sa.isTargetNumberValid())
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
|| (sa.getTargets().size() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -819,7 +819,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (choice != null && divided) {
|
||||
final TargetRestrictions abTgt = sa.getTargetRestrictions();
|
||||
int alloc = Math.max(amount / totalTargets, 1);
|
||||
if (sa.getTargets().getNumTargeted() == Math.min(totalTargets, abTgt.getMaxTargets(sa.getHostCard(), sa)) - 1) {
|
||||
if (sa.getTargets().size() == Math.min(totalTargets, abTgt.getMaxTargets(sa.getHostCard(), sa)) - 1) {
|
||||
abTgt.addDividedAllocation(choice, left);
|
||||
} else {
|
||||
abTgt.addDividedAllocation(choice, alloc);
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
if (!sa.canTarget(enemy)) {
|
||||
return false;
|
||||
}
|
||||
if (sa.getTargets() != null && sa.getTargets().getTargets().contains(enemy)) {
|
||||
if (sa.getTargets() != null && sa.getTargets().contains(enemy)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to chain damage/debuff effects
|
||||
@@ -497,7 +497,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
hPlay = CardLists.filterControlledBy(hPlay, pl);
|
||||
}
|
||||
|
||||
final List<GameObject> objects = Lists.newArrayList(sa.getTargets().getTargets());
|
||||
final List<GameObject> objects = Lists.newArrayList(sa.getTargets());
|
||||
if (sa.hasParam("TargetUnique")) {
|
||||
objects.addAll(sa.getUniqueTargets());
|
||||
}
|
||||
@@ -525,8 +525,8 @@ public class DamageDealAi extends DamageAiBase {
|
||||
private boolean damageTargetAI(final Player ai, final SpellAbility saMe, final int dmg, final boolean immediately) {
|
||||
final TargetRestrictions tgt = saMe.getTargetRestrictions();
|
||||
if ("Atarka's Command".equals(ComputerUtilAbility.getAbilitySourceName(saMe))) {
|
||||
// playReusable in damageChooseNontargeted wrongly assumes that CharmEffect options are re-usable
|
||||
return this.shouldTgtP(ai, saMe, dmg, false);
|
||||
// playReusable in damageChooseNontargeted wrongly assumes that CharmEffect options are re-usable
|
||||
return this.shouldTgtP(ai, saMe, dmg, false);
|
||||
}
|
||||
if (tgt == null) {
|
||||
return this.damageChooseNontargeted(ai, saMe, dmg);
|
||||
@@ -655,13 +655,13 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
|
||||
int totalTargetedSoFar = -1;
|
||||
while (tcs.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
if (totalTargetedSoFar == tcs.getNumTargeted()) {
|
||||
while (tcs.size() < tgt.getMaxTargets(source, sa)) {
|
||||
if (totalTargetedSoFar == tcs.size()) {
|
||||
// Avoid looping endlessly when choosing targets for cards with variable target number and type
|
||||
// like Jaya's Immolating Inferno
|
||||
break;
|
||||
}
|
||||
totalTargetedSoFar = tcs.getNumTargeted();
|
||||
totalTargetedSoFar = tcs.size();
|
||||
if (oppTargetsChoice && sa.getActivatingPlayer().equals(ai) && !sa.isTrigger()) {
|
||||
// canPlayAI (sa activated by ai)
|
||||
Player targetingPlayer = AbilityUtils.getDefinedPlayers(source, sa.getParam("TargetingPlayer"), sa).get(0);
|
||||
@@ -699,7 +699,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
continue;
|
||||
}
|
||||
if ("RoundedDown".equals(sa.getParam("DivideEvenly"))) {
|
||||
dmg = dmg * sa.getTargets().getNumTargeted() / (sa.getTargets().getNumTargeted() +1);
|
||||
dmg = dmg * sa.getTargets().size() / (sa.getTargets().size() +1);
|
||||
}
|
||||
|
||||
// look for creature targets; currently also catches planeswalkers that can be killed immediately
|
||||
@@ -735,7 +735,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
boolean freePing = immediately || abCost == null
|
||||
|| sa.getTargets().getNumTargeted() > 0;
|
||||
|| sa.getTargets().size() > 0;
|
||||
|
||||
if (!source.isSpell()) {
|
||||
if (phase.is(PhaseType.END_OF_TURN) && sa.isAbility() && abCost.isReusuableResource()) {
|
||||
@@ -782,21 +782,21 @@ public class DamageDealAi extends DamageAiBase {
|
||||
continue;
|
||||
}
|
||||
} else if ("OppAtTenLife".equals(logic)) {
|
||||
for (final Player p : ai.getOpponents()) {
|
||||
if (sa.canTarget(p) && p.getLife() == 10 && tcs.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
tcs.add(p);
|
||||
}
|
||||
}
|
||||
for (final Player p : ai.getOpponents()) {
|
||||
if (sa.canTarget(p) && p.getLife() == 10 && tcs.size() < tgt.getMaxTargets(source, sa)) {
|
||||
tcs.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: Improve Damage, we shouldn't just target the player just
|
||||
// because we can
|
||||
if (sa.canTarget(enemy) && tcs.getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
if (sa.canTarget(enemy) && tcs.size() < tgt.getMaxTargets(source, sa)) {
|
||||
if (((phase.is(PhaseType.END_OF_TURN) && phase.getNextTurn().equals(ai))
|
||||
|| (SpellAbilityAi.isSorcerySpeed(sa) && phase.is(PhaseType.MAIN2))
|
||||
|| ("PingAfterAttack".equals(logic) && phase.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && phase.isPlayerTurn(ai))
|
||||
|| immediately || shouldTgtP(ai, sa, dmg, noPrevention)) &&
|
||||
(!avoidTargetP(ai, sa))) {
|
||||
tcs.add(enemy);
|
||||
tcs.add(enemy);
|
||||
if (divided) {
|
||||
tgt.addDividedAllocation(enemy, dmg);
|
||||
break;
|
||||
@@ -805,7 +805,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
}
|
||||
}
|
||||
// fell through all the choices, no targets left?
|
||||
if (tcs.getNumTargeted() < tgt.getMinTargets(source, sa) || tcs.getNumTargeted() == 0) {
|
||||
if (tcs.size() < tgt.getMinTargets(source, sa) || tcs.size() == 0) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -896,7 +896,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final boolean divided = sa.hasParam("DividedAsYouChoose");
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (tgt.canTgtPlaneswalker()) {
|
||||
final Card c = this.dealDamageChooseTgtPW(ai, sa, dmg, noPrevention, ai, true);
|
||||
if (c != null) {
|
||||
|
||||
@@ -139,15 +139,15 @@ public class DamagePreventAi extends SpellAbilityAi {
|
||||
ComputerUtilCard.sortByEvaluateCreature(combatants);
|
||||
|
||||
for (final Card c : combatants) {
|
||||
if (ComputerUtilCombat.combatantWouldBeDestroyed(ai, c, combat) && tcs.getNumTargeted() < tgt.getMaxTargets(hostCard, sa)) {
|
||||
if (ComputerUtilCombat.combatantWouldBeDestroyed(ai, c, combat) && tcs.size() < tgt.getMaxTargets(hostCard, sa)) {
|
||||
tcs.add(c);
|
||||
chance = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tgt != null && sa.hasParam("DividedAsYouChoose") && sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
|
||||
tgt.addDividedAllocation(sa.getTargets().getTargets().get(0), AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa));
|
||||
if (tgt != null && sa.hasParam("DividedAsYouChoose") && sa.getTargets() != null && !sa.getTargets().isEmpty()) {
|
||||
tgt.addDividedAllocation(sa.getTargets().get(0), AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa));
|
||||
}
|
||||
|
||||
return chance;
|
||||
|
||||
@@ -138,12 +138,12 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
return mandatory && debuffMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card t = null;
|
||||
// boolean goodt = false;
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if ((sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().size() == 0)) {
|
||||
if (mandatory) {
|
||||
return debuffMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
final CardCollection forced = CardLists.filterControlledBy(list, ai);
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
if (pref.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (forced.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -207,10 +207,10 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// target loop
|
||||
while (sa.getTargets().getNumTargeted() < maxTargets) {
|
||||
while (sa.getTargets().size() < maxTargets) {
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if ((sa.getTargets().size() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().size() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -253,8 +253,8 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||
if ((sa.getTargets().size() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||
|| (sa.getTargets().size() == 0)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -344,10 +344,10 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
if (preferred.isEmpty()) {
|
||||
if (sa.getTargets().getNumTargeted() == 0
|
||||
|| sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (sa.getTargets().size() == 0
|
||||
|| sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
@@ -371,7 +371,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (list.isEmpty()) {
|
||||
break;
|
||||
} else {
|
||||
@@ -392,7 +392,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa);
|
||||
return sa.getTargets().size() >= tgt.getMinTargets(sa.getHostCard(), sa);
|
||||
} else {
|
||||
return mandatory;
|
||||
}
|
||||
|
||||
@@ -226,12 +226,12 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
return mandatory && protectMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
Card t = null;
|
||||
// boolean goodt = false;
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if ((sa.getTargets().size() < tgt.getMinTargets(source, sa)) || sa.getTargets().size() == 0) {
|
||||
if (mandatory) {
|
||||
return protectMandatoryTarget(ai, sa, mandatory);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
final List<Card> forced = CardLists.filterControlledBy(list, ai);
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
if (pref.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
if (pref2.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -319,7 +319,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMinTargets(source, sa)) {
|
||||
if (forced.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -336,7 +336,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -573,12 +573,12 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
Card t = null;
|
||||
// boolean goodt = false;
|
||||
|
||||
if (list.isEmpty()) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(source, sa) || sa.getTargets().size() == 0) {
|
||||
if (mandatory || ComputerUtil.activateForCost(sa, ai)) {
|
||||
return pumpMandatoryTarget(ai, sa);
|
||||
}
|
||||
@@ -634,7 +634,7 @@ public class PumpAi extends PumpAiBase {
|
||||
forced = CardLists.filterControlledBy(list, ai.getOpponents());
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
if (pref.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -651,7 +651,7 @@ public class PumpAi extends PumpAiBase {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMinTargets(source, sa)) {
|
||||
if (forced.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -668,7 +668,7 @@ public class PumpAi extends PumpAiBase {
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa)) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(source, sa)) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ public class SetStateAi extends SpellAbilityAi {
|
||||
for (final Card c : list) {
|
||||
if (shouldTransformCard(c, ai, ph) || "Always".equals(logic)) {
|
||||
sa.getTargets().add(c);
|
||||
if (sa.getTargets().getNumTargeted() == tgt.getMaxTargets(source, sa)) {
|
||||
if (sa.getTargets().size() == tgt.getMaxTargets(source, sa)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(source, sa);
|
||||
return sa.getTargets().size() >= tgt.getMinTargets(source, sa);
|
||||
}
|
||||
} else if ("TurnFace".equals(mode)) {
|
||||
if (!sa.usesTargeting()) {
|
||||
@@ -115,13 +115,13 @@ public class SetStateAi extends SpellAbilityAi {
|
||||
for (final Card c : list) {
|
||||
if (shouldTurnFace(c, ai, ph) || "Always".equals(logic)) {
|
||||
sa.getTargets().add(c);
|
||||
if (sa.getTargets().getNumTargeted() == tgt.getMaxTargets(source, sa)) {
|
||||
if (sa.getTargets().size() == tgt.getMaxTargets(source, sa)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sa.getTargets().getNumTargeted() >= tgt.getMinTargets(source, sa);
|
||||
return sa.getTargets().size() >= tgt.getMinTargets(source, sa);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -51,11 +51,11 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
Card choice = null;
|
||||
|
||||
if (tapList.size() == 0) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(source, sa) || sa.getTargets().size() == 0) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().size() == 0) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -166,11 +166,11 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
boolean goodTargets = false;
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
Card choice = null;
|
||||
|
||||
if (tapList.isEmpty()) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(source, sa) || sa.getTargets().size() == 0) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().size() == 0) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Nothing was ever targeted, so we need to bail.
|
||||
return sa.getTargets().getNumTargeted() != 0;
|
||||
return sa.getTargets().size() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +277,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (sa.getTargets().size() >= tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sa.getTargets().getNumTargeted() >= tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (sa.getTargets().size() >= tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
untapList.removeAll(toExclude);
|
||||
|
||||
sa.resetTargets();
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
|
||||
Card choice = null;
|
||||
|
||||
if (untapList.isEmpty()) {
|
||||
@@ -183,7 +183,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
if (sa.getSubAbility() != null && sa.getSubAbility().getApi() == ApiType.Animate && !list.isEmpty()
|
||||
&& ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
choice = ComputerUtilCard.getWorstPermanentAI(list, false, false, false, false);
|
||||
} else if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
} else if (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().size() == 0) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -204,7 +204,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().size() == 0) {
|
||||
sa.resetTargets();
|
||||
return false;
|
||||
} else {
|
||||
@@ -271,11 +271,11 @@ public class UntapAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(source, sa)) {
|
||||
while (sa.getTargets().size() < tgt.getMaxTargets(source, sa)) {
|
||||
Card choice = null;
|
||||
|
||||
if (tapList.isEmpty()) {
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(source, sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(source, sa) || sa.getTargets().size() == 0) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
@@ -293,7 +293,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (choice == null) { // can't find anything left
|
||||
if (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().getNumTargeted() == 0) {
|
||||
if (sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa) || sa.getTargets().size() == 0) {
|
||||
if (!mandatory) {
|
||||
sa.resetTargets();
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class GameCopier {
|
||||
if (newSa != null) {
|
||||
newSa.setActivatingPlayer(map.map(origSa.getActivatingPlayer()));
|
||||
if (origSa.usesTargeting()) {
|
||||
for (GameObject o : origSa.getTargets().getTargets()) {
|
||||
for (GameObject o : origSa.getTargets()) {
|
||||
newSa.getTargets().add(map.map(o));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class GameSimulator {
|
||||
final boolean divided = origSaOrSubSa.hasParam("DividedAsYouChoose");
|
||||
final TargetRestrictions origTgtRes = origSaOrSubSa.getTargetRestrictions();
|
||||
final TargetRestrictions tgtRes = saOrSubSa.getTargetRestrictions();
|
||||
for (final GameObject o : origSaOrSubSa.getTargets().getTargets()) {
|
||||
for (final GameObject o : origSaOrSubSa.getTargets()) {
|
||||
final GameObject target = copier.find(o);
|
||||
saOrSubSa.getTargets().add(target);
|
||||
if (divided) {
|
||||
@@ -189,7 +189,7 @@ public class GameSimulator {
|
||||
if (debugPrint && !sa.getAllTargetChoices().isEmpty()) {
|
||||
debugPrint("Targets: ");
|
||||
for (TargetChoices target : sa.getAllTargetChoices()) {
|
||||
System.out.print(target.getTargetedString());
|
||||
System.out.print(target);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public class PossibleTargetSelector {
|
||||
private void selectTargetsByIndexImpl(int index) {
|
||||
targetingSa.resetTargets();
|
||||
|
||||
while (targetingSa.getTargets().getNumTargeted() < maxTargets && index < validTargets.size()) {
|
||||
while (targetingSa.getTargets().size() < maxTargets && index < validTargets.size()) {
|
||||
targetingSa.getTargets().add(validTargets.get(index++));
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class PossibleTargetSelector {
|
||||
final int amountPerCard = amount / targetCount;
|
||||
int amountLeftOver = amount - (amountPerCard * targetCount);
|
||||
final TargetRestrictions tgtRes = targetingSa.getTargetRestrictions();
|
||||
for (GameObject target : targetingSa.getTargets().getTargets()) {
|
||||
for (GameObject target : targetingSa.getTargets()) {
|
||||
tgtRes.addDividedAllocation(target, amountPerCard + amountLeftOver);
|
||||
amountLeftOver = 0;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class PossibleTargetSelector {
|
||||
}
|
||||
|
||||
public Targets getLastSelectedTargets() {
|
||||
return new Targets(targetingSaIndex, validTargets.size(), targetIndex - 1, targetingSa.getTargets().getTargetedString());
|
||||
return new Targets(targetingSaIndex, validTargets.size(), targetIndex - 1, targetingSa.getTargets().toString());
|
||||
}
|
||||
|
||||
public boolean selectTargetsByIndex(int targetIndex) {
|
||||
|
||||
@@ -177,10 +177,10 @@ public class SimulationController {
|
||||
saOrSubSa = saOrSubSa.getSubAbility();
|
||||
}
|
||||
|
||||
if (saOrSubSa == null || saOrSubSa.getTargets() == null || saOrSubSa.getTargets().getTargets().size() != 1) {
|
||||
if (saOrSubSa == null || saOrSubSa.getTargets() == null || saOrSubSa.getTargets().size() != 1) {
|
||||
return null;
|
||||
}
|
||||
GameObject target = saOrSubSa.getTargets().getTargets().get(0);
|
||||
GameObject target = saOrSubSa.getTargets().get(0);
|
||||
GameObject originalTarget = target;
|
||||
if (!(target instanceof Card)) { return null; }
|
||||
Card hostCard = sa.getHostCard();
|
||||
|
||||
@@ -284,7 +284,7 @@ public class SpellAbilityPicker {
|
||||
SpellAbility saOrSubSa = sa;
|
||||
do {
|
||||
if (saOrSubSa.usesTargeting()) {
|
||||
saString.append(" (targets: ").append(saOrSubSa.getTargets().getTargetedString()).append(")");
|
||||
saString.append(" (targets: ").append(saOrSubSa.getTargets()).append(")");
|
||||
}
|
||||
saOrSubSa = saOrSubSa.getSubAbility();
|
||||
} while (saOrSubSa != null);
|
||||
|
||||
@@ -110,7 +110,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
targets.add(event.si.getTargetChoices());
|
||||
for (TargetChoices ch : targets) {
|
||||
if (null != ch) {
|
||||
sb.append(ch.getTargetedString());
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
messageForLog = localizer.getMessage("lblLogPlayerActionObjectWitchTarget", player, action, object, sb.toString());
|
||||
|
||||
@@ -611,7 +611,7 @@ public class AbilityUtils {
|
||||
SpellAbility loopSA = sa.getRootAbility();
|
||||
while (loopSA != null) {
|
||||
if (loopSA.getTargetRestrictions() != null) {
|
||||
Iterables.addAll(objects, loopSA.getTargets().getTargets());
|
||||
Iterables.addAll(objects, loopSA.getTargets());
|
||||
}
|
||||
loopSA = loopSA.getSubAbility();
|
||||
}
|
||||
@@ -1288,7 +1288,7 @@ public class AbilityUtils {
|
||||
// information so it's not lost if the calling code is interested in targets of the triggered SA.
|
||||
if (triggeringType.equals("SpellAbility")) {
|
||||
final CardCollectionView tgtList = (CardCollectionView)root.getTriggeringObject(AbilityKey.SpellAbilityTargetingCards);
|
||||
if (s.getTargets() != null && s.getTargets().getNumTargeted() == 0) {
|
||||
if (s.getTargets() != null && s.getTargets().size() == 0) {
|
||||
if (tgtList != null && tgtList.size() > 0) {
|
||||
TargetChoices tc = new TargetChoices();
|
||||
for (Card c : tgtList) {
|
||||
@@ -1510,7 +1510,7 @@ public class AbilityUtils {
|
||||
if (sa.hasParam("ForgetOtherTargets")) {
|
||||
host.clearRemembered();
|
||||
}
|
||||
for (final GameObject o : sa.getTargets().getTargets()) {
|
||||
for (final GameObject o : sa.getTargets()) {
|
||||
host.addRemembered(o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ public abstract class SpellAbilityEffect {
|
||||
String desc = TextUtil.fastReplace(desc1, "NICKNAME", currentName.split(",")[0]);
|
||||
sb.append(desc);
|
||||
}
|
||||
if (sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
|
||||
sb.append(" (Targeting: ").append(sa.getTargets().getTargets()).append(")");
|
||||
if (sa.getTargets() != null && !sa.getTargets().isEmpty()) {
|
||||
sb.append(" (Targeting: ").append(sa.getTargets()).append(")");
|
||||
}
|
||||
} else if (!"None".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output
|
||||
makeSpellDescription(sa, sb, stackDesc);
|
||||
@@ -233,7 +233,7 @@ public abstract class SpellAbilityEffect {
|
||||
|
||||
private static List<GameObject> getTargetables(final boolean definedFirst, final String definedParam, final SpellAbility sa) {
|
||||
final boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
return useTargets ? Lists.newArrayList(sa.getTargets().getTargets())
|
||||
return useTargets ? Lists.newArrayList(sa.getTargets())
|
||||
: AbilityUtils.getDefinedObjects(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
||||
while(changingTgtSI != null) {
|
||||
SpellAbility changedSa = changingTgtSI.getSpellAbility(true);
|
||||
if (changedSa.usesTargeting()) {
|
||||
for(GameObject it : changedSa.getTargets().getTargets())
|
||||
for(GameObject it : changedSa.getTargets())
|
||||
allTargets.add(ImmutablePair.of(changingTgtSI, it));
|
||||
}
|
||||
changingTgtSI = changingTgtSI.getSubInstance();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ChooseGenericEffect extends SpellAbilityEffect {
|
||||
}
|
||||
abilities.removeAll(saToRemove);
|
||||
|
||||
if (sa.usesTargeting() && sa.getTargets().isTargeting(p) && !p.canBeTargetedBy(sa)) {
|
||||
if (sa.usesTargeting() && sa.getTargets().contains(p) && !p.canBeTargetedBy(sa)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
// Find subability or rootability that has targets
|
||||
SpellAbility targetedSA = chosenSA;
|
||||
while (targetedSA != null) {
|
||||
if (targetedSA.usesTargeting() && targetedSA.getTargets().getNumTargeted() != 0) {
|
||||
if (targetedSA.usesTargeting() && targetedSA.getTargets().size() != 0) {
|
||||
break;
|
||||
}
|
||||
targetedSA = targetedSA.getSubAbility();
|
||||
|
||||
@@ -124,7 +124,7 @@ public class CostAdjustment {
|
||||
--count;
|
||||
} else if ("Strive".equals(amount)) {
|
||||
for (TargetChoices tc : sa.getAllTargetChoices()) {
|
||||
count += tc.getNumTargeted();
|
||||
count += tc.size();
|
||||
}
|
||||
--count;
|
||||
} else {
|
||||
@@ -531,7 +531,7 @@ public class CostAdjustment {
|
||||
curSa = curSa.getSubAbility();
|
||||
continue;
|
||||
}
|
||||
for (GameObject target : curSa.getTargets().getTargets()) {
|
||||
for (GameObject target : curSa.getTargets()) {
|
||||
if (target.isValid(st.getParam("ValidTarget").split(","), hostCard.getController(), hostCard, curSa)) {
|
||||
targetValid = true;
|
||||
break outer;
|
||||
|
||||
@@ -1413,11 +1413,11 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
return false;
|
||||
}
|
||||
|
||||
return getTargets().getNumTargeted() < getTargetRestrictions().getMaxTargets(hostCard, this);
|
||||
return getTargets().size() < getTargetRestrictions().getMaxTargets(hostCard, this);
|
||||
}
|
||||
|
||||
public boolean isZeroTargets() {
|
||||
return getTargetRestrictions().getMinTargets(hostCard, this) == 0 && getTargets().getNumTargeted() == 0;
|
||||
return getTargetRestrictions().getMinTargets(hostCard, this) == 0 && getTargets().size() == 0;
|
||||
}
|
||||
|
||||
public boolean isTargetNumberValid() {
|
||||
@@ -1427,7 +1427,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
|
||||
int minTargets = getTargetRestrictions().getMinTargets(hostCard, this);
|
||||
int maxTargets = getTargetRestrictions().getMaxTargets(hostCard, this);
|
||||
int numTargets = getTargets().getNumTargeted();
|
||||
int numTargets = getTargets().size();
|
||||
|
||||
if (maxTargets == 0 && getPayCosts().hasSpecificCostType(CostRemoveCounter.class)
|
||||
&& hasSVar(getParam("TargetMax"))
|
||||
@@ -1580,7 +1580,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
SpellAbility child = getParent();
|
||||
while (child != null) {
|
||||
if (child.getTargetRestrictions() != null) {
|
||||
Iterables.addAll(targets, child.getTargets().getTargets());
|
||||
Iterables.addAll(targets, child.getTargets());
|
||||
}
|
||||
child = child.getParent();
|
||||
}
|
||||
@@ -1617,7 +1617,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
|
||||
boolean result = false;
|
||||
|
||||
for (final GameObject o : matchTgt.getTargets()) {
|
||||
for (final GameObject o : matchTgt) {
|
||||
if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard(), this)) {
|
||||
result = true;
|
||||
break;
|
||||
@@ -1633,7 +1633,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
if (matchTgt == null) {
|
||||
continue;
|
||||
}
|
||||
for (final GameObject o : matchTgt.getTargets()) {
|
||||
for (final GameObject o : matchTgt) {
|
||||
if (o.isValid(splitTargetRestrictions.split(","), getActivatingPlayer(), getHostCard(), this)) {
|
||||
result = true;
|
||||
break;
|
||||
@@ -1652,7 +1652,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
if (tgt.isSingleTarget()) {
|
||||
Set<GameObject> targets = new HashSet<>();
|
||||
for (TargetChoices tc : topSA.getAllTargetChoices()) {
|
||||
targets.addAll(tc.getTargets());
|
||||
targets.addAll(tc);
|
||||
if (targets.size() > 1) {
|
||||
// As soon as we get more than one, bail out
|
||||
return false;
|
||||
@@ -1668,7 +1668,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
}
|
||||
|
||||
public boolean isTargeting(GameObject o) {
|
||||
if (getTargets().isTargeting(o)) {
|
||||
if (getTargets().contains(o)) {
|
||||
return true;
|
||||
}
|
||||
SpellAbility p = getParent();
|
||||
|
||||
@@ -398,7 +398,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
||||
|
||||
boolean result = false;
|
||||
|
||||
for (final GameObject o : matchTgt.getFirstTargetedSpell().getTargets().getTargets()) {
|
||||
for (final GameObject o : matchTgt.getFirstTargetedSpell().getTargets()) {
|
||||
if (o.isValid(this.getTargetValidTargeting().split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa)) {
|
||||
result = true;
|
||||
break;
|
||||
@@ -419,7 +419,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
||||
|
||||
Set<GameObject> targets = new HashSet<>();
|
||||
for (TargetChoices tc : sa.getAllTargetChoices()) {
|
||||
targets.addAll(tc.getTargets());
|
||||
targets.addAll(tc);
|
||||
if (targets.size() > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
// try to deduce which target has been replaced
|
||||
// (this may be imprecise, updateTarget should specify old target if possible)
|
||||
for (Object obj : map.keySet()) {
|
||||
if (!target.getTargets().contains(obj)) {
|
||||
if (!target.contains(obj)) {
|
||||
toRemove = obj;
|
||||
break;
|
||||
}
|
||||
@@ -314,7 +314,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
} else {
|
||||
// try to deduce which target was added
|
||||
// (this may be imprecise, updateTarget should specify new target if possible)
|
||||
for (Object newTgts : target.getTargets()) {
|
||||
for (Object newTgts : target) {
|
||||
if (!map.containsKey(newTgts)) {
|
||||
toAdd = newTgts;
|
||||
break;
|
||||
@@ -333,7 +333,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.SourceSA, ability);
|
||||
Set<Object> distinctObjects = new HashSet<>();
|
||||
for (final Object tgt : target.getTargets()) {
|
||||
for (final Object tgt : target) {
|
||||
if (distinctObjects.contains(tgt)) {
|
||||
continue;
|
||||
}
|
||||
@@ -346,7 +346,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
||||
runParams.put(AbilityKey.Target, tgt);
|
||||
getSourceCard().getGame().getTriggerHandler().runTrigger(TriggerType.BecomesTarget, runParams, false);
|
||||
}
|
||||
runParams.put(AbilityKey.Targets, target.getTargets());
|
||||
runParams.put(AbilityKey.Targets, target);
|
||||
getSourceCard().getGame().getTriggerHandler().runTrigger(TriggerType.BecomesTargetOnce, runParams, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.game.spellability;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ForwardingList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@@ -29,7 +30,6 @@ import forge.game.card.CardCollectionView;
|
||||
import forge.game.player.Player;
|
||||
import forge.util.collect.FCollection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -40,14 +40,10 @@ import java.util.List;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TargetChoices implements Cloneable {
|
||||
public class TargetChoices extends ForwardingList<GameObject> implements Cloneable {
|
||||
|
||||
private final FCollection<GameObject> targets = new FCollection<GameObject>();
|
||||
|
||||
public final int getNumTargeted() {
|
||||
return targets.size();
|
||||
}
|
||||
|
||||
public final int getTotalTargetedCMC() {
|
||||
int totalCMC = 0;
|
||||
for (Card c : Iterables.filter(targets, Card.class)) {
|
||||
@@ -58,16 +54,11 @@ public class TargetChoices implements Cloneable {
|
||||
|
||||
public final boolean add(final GameObject o) {
|
||||
if (o instanceof Player || o instanceof Card || o instanceof SpellAbility) {
|
||||
return targets.add(o);
|
||||
super.add(o);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean remove(final GameObject target) {
|
||||
// remove returns true if element was found in given list
|
||||
return targets.remove(target);
|
||||
}
|
||||
|
||||
public final CardCollectionView getTargetCards() {
|
||||
return new CardCollection(Iterables.filter(targets, Card.class));
|
||||
}
|
||||
@@ -84,41 +75,6 @@ public class TargetChoices implements Cloneable {
|
||||
return Lists.newArrayList(Iterables.filter(targets, GameEntity.class));
|
||||
}
|
||||
|
||||
public final List<GameObject> getTargets() {
|
||||
return this.targets;
|
||||
}
|
||||
|
||||
|
||||
public final String getTargetedString() {
|
||||
final List<GameObject> tgts = getTargets();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (final Object o : tgts) {
|
||||
if (!first) {
|
||||
sb.append(" ");
|
||||
}
|
||||
first = false;
|
||||
if (o instanceof Player) {
|
||||
final Player p = (Player) o;
|
||||
sb.append(p.getName());
|
||||
}
|
||||
if (o instanceof Card) {
|
||||
final Card c = (Card) o;
|
||||
sb.append(c);
|
||||
}
|
||||
if (o instanceof SpellAbility) {
|
||||
final SpellAbility sa = (SpellAbility) o;
|
||||
sb.append(sa);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.getTargetedString();
|
||||
}
|
||||
|
||||
public final boolean isTargetingAnyCard() {
|
||||
return Iterables.any(targets, Predicates.instanceOf(Card.class));
|
||||
}
|
||||
@@ -131,10 +87,6 @@ public class TargetChoices implements Cloneable {
|
||||
return Iterables.any(targets, Predicates.instanceOf(SpellAbility.class));
|
||||
}
|
||||
|
||||
public final boolean isTargeting(GameObject e) {
|
||||
return targets.contains(e);
|
||||
}
|
||||
|
||||
public final Card getFirstTargetedCard() {
|
||||
return Iterables.getFirst(Iterables.filter(targets, Card.class), null);
|
||||
}
|
||||
@@ -147,28 +99,14 @@ public class TargetChoices implements Cloneable {
|
||||
return Iterables.getFirst(getTargetSpells(), null);
|
||||
}
|
||||
|
||||
public final boolean isEmpty() {
|
||||
return targets.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetChoices clone() {
|
||||
TargetChoices tc = new TargetChoices();
|
||||
tc.targets.addAll(targets);
|
||||
return tc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof TargetChoices) {
|
||||
TargetChoices compare = (TargetChoices)obj;
|
||||
|
||||
if (getNumTargeted() != compare.getNumTargeted()) {
|
||||
return false;
|
||||
}
|
||||
return getTargets().equals(compare.getTargets());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
protected List<GameObject> delegate() {
|
||||
return targets;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class TargetRestrictions {
|
||||
*/
|
||||
public final boolean isMaxTargetsChosen(final Card c, final SpellAbility sa) {
|
||||
TargetChoices choice = sa.getTargets();
|
||||
return this.getMaxTargets(c, sa) == choice.getNumTargeted();
|
||||
return this.getMaxTargets(c, sa) == choice.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,7 +298,7 @@ public class TargetRestrictions {
|
||||
return true;
|
||||
}
|
||||
TargetChoices choice = sa.getTargets();
|
||||
return this.getMinTargets(c, sa) <= choice.getNumTargeted();
|
||||
return this.getMinTargets(c, sa) <= choice.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,7 +490,7 @@ public class TargetRestrictions {
|
||||
if (isTargeted && !sa.canTarget(c)) {
|
||||
continue;
|
||||
}
|
||||
if (sa.getTargets().isTargeting(c)) {
|
||||
if (sa.getTargets().contains(c)) {
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
@@ -559,21 +559,12 @@ public class TargetRestrictions {
|
||||
}
|
||||
|
||||
final Card srcCard = sa.getHostCard(); // should there be OrginalHost at any moment?
|
||||
if (this.tgtZone.contains(ZoneType.Stack)) {
|
||||
for (final Card c : game.getStackZone().getCards()) {
|
||||
if (c.isValid(this.validTgts, srcCard.getController(), srcCard, sa)
|
||||
&& (!isTargeted || sa.canTarget(c))
|
||||
&& !sa.getTargets().isTargeting(c)) {
|
||||
candidates.add(c);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Card c : game.getCardsIn(this.tgtZone)) {
|
||||
if (c.isValid(this.validTgts, srcCard.getController(), srcCard, sa)
|
||||
&& (!isTargeted || sa.canTarget(c))
|
||||
&& !sa.getTargets().isTargeting(c)) {
|
||||
candidates.add(c);
|
||||
}
|
||||
|
||||
for (final Card c : game.getCardsIn(this.tgtZone)) {
|
||||
if (c.isValid(this.validTgts, srcCard.getController(), srcCard, sa)
|
||||
&& (!isTargeted || sa.canTarget(c))
|
||||
&& !sa.getTargets().contains(c)) {
|
||||
candidates.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ public class TriggerSpellAbilityCast extends Trigger {
|
||||
final CardCollection candidates = new CardCollection();
|
||||
SpellAbility targetedSA = spellAbility;
|
||||
while (targetedSA != null) {
|
||||
if (targetedSA.usesTargeting() && targetedSA.getTargets().getNumTargeted() != 0) {
|
||||
if (targetedSA.usesTargeting() && targetedSA.getTargets().size() != 0) {
|
||||
break;
|
||||
}
|
||||
targetedSA = targetedSA.getSubAbility();
|
||||
@@ -233,7 +233,7 @@ public class TriggerSpellAbilityCast extends Trigger {
|
||||
if (hasParam("IsSingleTarget")) {
|
||||
Set<GameObject> targets = Sets.newHashSet();
|
||||
for (TargetChoices tc : spellAbility.getAllTargetChoices()) {
|
||||
targets.addAll(tc.getTargets());
|
||||
targets.addAll(tc);
|
||||
if (targets.size() > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ public class WrappedAbility extends Ability {
|
||||
final StringBuilder sb = new StringBuilder(regtrig.replaceAbilityText(regtrig.toString(true), this));
|
||||
if (usesTargeting()) {
|
||||
sb.append(" (Targeting ");
|
||||
for (final GameObject o : this.getTargets().getTargets()) {
|
||||
for (final GameObject o : this.getTargets()) {
|
||||
sb.append(o.toString());
|
||||
sb.append(", ");
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
Set<Object> distinctObjects = Sets.newHashSet();
|
||||
for (final TargetChoices tc : chosenTargets) {
|
||||
if (tc != null && tc.getTargetCards() != null) {
|
||||
for (final Object tgt : tc.getTargets()) {
|
||||
for (final Object tgt : tc) {
|
||||
// Track distinct objects so Becomes targets don't trigger for things like:
|
||||
// Seeds of Strength
|
||||
if (distinctObjects.contains(tgt)) {
|
||||
@@ -369,7 +369,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
runParams.put(AbilityKey.Target, tgt);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.BecomesTarget, runParams, false);
|
||||
}
|
||||
runParams.put(AbilityKey.Targets, tc.getTargets());
|
||||
runParams.put(AbilityKey.Targets, tc);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.BecomesTargetOnce, runParams, false);
|
||||
}
|
||||
}
|
||||
@@ -580,7 +580,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
// With multi-targets, as long as one target is still legal,
|
||||
// we'll try to go through as much as possible
|
||||
final TargetChoices choices = sa.getTargets();
|
||||
for (final GameObject o : sa.getTargets().getTargets()) {
|
||||
for (final GameObject o : sa.getTargets()) {
|
||||
boolean invalidTarget = false;
|
||||
if (rememberTgt) {
|
||||
source.addRemembered(o);
|
||||
|
||||
@@ -1379,7 +1379,7 @@ public final class CMatchUI
|
||||
if (sa.getTargetRestrictions() != null) {
|
||||
sb.append(" targeting ");
|
||||
TargetChoices targets = si.getTargetChoices();
|
||||
sb.append(targets.getTargetedString());
|
||||
sb.append(targets);
|
||||
}
|
||||
sb.append(".");
|
||||
String message1 = sb.toString();
|
||||
|
||||
@@ -98,7 +98,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
||||
}
|
||||
|
||||
final int maxTargets = tgt.getMaxTargets(sa.getHostCard(), sa);
|
||||
final int targeted = sa.getTargets().getNumTargeted();
|
||||
final int targeted = sa.getTargets().size();
|
||||
if(maxTargets > 1) {
|
||||
sb.append(TextUtil.concatNoSpace("\n(", String.valueOf(maxTargets - targeted), " more can be targeted)"));
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
||||
"(Targeting ERROR)", "");
|
||||
showMessage(message, sa.getView());
|
||||
|
||||
if (tgt.isDividedAsYouChoose() && tgt.getMinTargets(sa.getHostCard(), sa) == 0 && sa.getTargets().getNumTargeted() == 0) {
|
||||
if (tgt.isDividedAsYouChoose() && tgt.getMinTargets(sa.getHostCard(), sa) == 0 && sa.getTargets().size() == 0) {
|
||||
// extra logic for Divided with min targets = 0, should only work if num targets are 0 too
|
||||
getController().getGui().updateButtons(getOwner(), true, true, false);
|
||||
} else if (!tgt.isMinTargetsChosen(sa.getHostCard(), sa) || tgt.isDividedAsYouChoose()) {
|
||||
@@ -243,7 +243,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
||||
final int stillToDivide = tgt.getStillToDivide();
|
||||
int allocatedPortion = 0;
|
||||
// allow allocation only if the max targets isn't reached and there are more candidates
|
||||
if ((sa.getTargets().getNumTargeted() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa))
|
||||
if ((sa.getTargets().size() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa))
|
||||
&& (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
|
||||
final ImmutableList.Builder<Integer> choices = ImmutableList.builder();
|
||||
for (int i = 1; i <= stillToDivide; i++) {
|
||||
@@ -304,7 +304,7 @@ public final class InputSelectTargets extends InputSyncronizedBase {
|
||||
final int stillToDivide = tgt.getStillToDivide();
|
||||
int allocatedPortion = 0;
|
||||
// allow allocation only if the max targets isn't reached and there are more candidates
|
||||
if ((sa.getTargets().getNumTargeted() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa)) && (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
|
||||
if ((sa.getTargets().size() + 1 < tgt.getMaxTargets(sa.getHostCard(), sa)) && (tgt.getNumCandidates(sa, true) - 1 > 0) && stillToDivide > 1) {
|
||||
final ImmutableList.Builder<Integer> choices = ImmutableList.builder();
|
||||
for (int i = 1; i <= stillToDivide; i++) {
|
||||
choices.add(Integer.valueOf(i));
|
||||
|
||||
@@ -314,7 +314,7 @@ public class HumanPlaySpellAbility {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(ability.getHostCard().getName());
|
||||
if (ability.getTargetRestrictions() != null) {
|
||||
final Iterable<GameObject> targets = ability.getTargets().getTargets();
|
||||
final Iterable<GameObject> targets = ability.getTargets();
|
||||
if (!Iterables.isEmpty(targets)) {
|
||||
sb.append(" - Targeting ");
|
||||
for (final GameObject o : targets) {
|
||||
|
||||
@@ -1033,7 +1033,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
final TargetChoices oldTarget = sa.getTargets();
|
||||
final TargetSelection select = new TargetSelection(this, sa);
|
||||
sa.resetTargets();
|
||||
if (select.chooseTargets(oldTarget.getNumTargeted())) {
|
||||
if (select.chooseTargets(oldTarget.size())) {
|
||||
return sa.getTargets();
|
||||
} else {
|
||||
// Return old target, since we had to reset them above
|
||||
|
||||
@@ -81,7 +81,7 @@ public class TargetSelection {
|
||||
final int minTargets = numTargets != null ? numTargets.intValue() : tgt.getMinTargets(ability.getHostCard(), ability);
|
||||
final int maxTargets = numTargets != null ? numTargets.intValue() : tgt.getMaxTargets(ability.getHostCard(), ability);
|
||||
//final int maxTotalCMC = tgt.getMaxTotalCMC(ability.getHostCard(), ability);
|
||||
final int numTargeted = ability.getTargets().getNumTargeted();
|
||||
final int numTargeted = ability.getTargets().size();
|
||||
final boolean isSingleZone = ability.getTargetRestrictions().isSingleZone();
|
||||
|
||||
final boolean hasEnoughTargets = minTargets == 0 || numTargeted >= minTargets;
|
||||
|
||||
Reference in New Issue
Block a user