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