CountersPutEffect almost there

This commit is contained in:
Northmoc
2020-11-17 22:23:54 -05:00
parent 5dc9faa45c
commit 24a2a569f7

View File

@@ -139,6 +139,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
boolean eachExistingCounter = sa.hasParam("EachExistingCounter"); boolean eachExistingCounter = sa.hasParam("EachExistingCounter");
List<GameObject> tgtObjects = Lists.newArrayList(); List<GameObject> tgtObjects = Lists.newArrayList();
int divrem = 0;
if (sa.hasParam("Bolster")) { if (sa.hasParam("Bolster")) {
CardCollection creatsYouCtrl = CardLists.filter(activator.getCardsIn(ZoneType.Battlefield), Presets.CREATURES); CardCollection creatsYouCtrl = CardLists.filter(activator.getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
CardCollection leastToughness = new CardCollection(Aggregates.listWithMin(creatsYouCtrl, CardPredicates.Accessors.fnGetDefense)); CardCollection leastToughness = new CardCollection(Aggregates.listWithMin(creatsYouCtrl, CardPredicates.Accessors.fnGetDefense));
@@ -163,7 +164,10 @@ public class CountersPutEffect extends SpellAbilityEffect {
CardCollection choices = new CardCollection(game.getCardsIn(choiceZone)); CardCollection choices = new CardCollection(game.getCardsIn(choiceZone));
int n = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParamOrDefault("ChoiceAmount", "1"), sa); int n = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParamOrDefault("ChoiceAmount",
"1"), sa);
int m = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParamOrDefault("MinChoiceAmount",
sa.getParamOrDefault("ChoiceAmount", "1")), sa);
choices = CardLists.getValidCards(choices, sa.getParam("Choices"), activator, card, sa); choices = CardLists.getValidCards(choices, sa.getParam("Choices"), activator, card, sa);
@@ -178,11 +182,12 @@ public class CountersPutEffect extends SpellAbilityEffect {
Map<String, Object> params = Maps.newHashMap(); Map<String, Object> params = Maps.newHashMap();
params.put("CounterType", counterType); params.put("CounterType", counterType);
Iterables.addAll(tgtObjects, chooser.getController().chooseCardsForEffect(choices, sa, title, n, n, sa.hasParam("ChoiceOptional"), params)); Iterables.addAll(tgtObjects, chooser.getController().chooseCardsForEffect(choices, sa, title, m, n, sa.hasParam("ChoiceOptional"), params));
} else { } else {
tgtObjects.addAll(getDefinedOrTargeted(sa, "Defined")); tgtObjects.addAll(getDefinedOrTargeted(sa, "Defined"));
} }
int counterRemaining = counterAmount;
for (final GameObject obj : tgtObjects) { for (final GameObject obj : tgtObjects) {
// check if the object is still in game or if it was moved // check if the object is still in game or if it was moved
Card gameCard = null; Card gameCard = null;
@@ -259,6 +264,20 @@ public class CountersPutEffect extends SpellAbilityEffect {
params.put("CounterType", counterType); params.put("CounterType", counterType);
counterAmount = pc.chooseNumber(sa, Localizer.getInstance().getMessage("lblHowManyCounters"), 0, counterAmount, params); counterAmount = pc.chooseNumber(sa, Localizer.getInstance().getMessage("lblHowManyCounters"), 0, counterAmount, params);
} }
if (sa.hasParam("DividedAsYouChoose")) {
Map<String, Object> params = Maps.newHashMap();
params.put("Target", obj);
params.put("CounterType", counterType);
if (!(divrem++ == tgtObjects.size() -1)) {
counterAmount = pc.chooseNumber(sa, Localizer.getInstance().getMessage
("lblHowManyCountersThis", CardTranslation.getTranslatedName(gameCard.getName())),
1, counterRemaining, params);
} else if (divrem++ == tgtObjects.size() -1) {
counterAmount = pc.chooseNumber(sa, Localizer.getInstance().getMessage
("lblHowManyCountersThis", CardTranslation.getTranslatedName(gameCard.getName())),
counterRemaining, counterRemaining, params);
}
}
// Adapt need extra logic // Adapt need extra logic
if (sa.hasParam("Adapt")) { if (sa.hasParam("Adapt")) {
@@ -355,6 +374,10 @@ public class CountersPutEffect extends SpellAbilityEffect {
card.addRemembered(gameCard); card.addRemembered(gameCard);
} }
game.updateLastStateForCard(gameCard); game.updateLastStateForCard(gameCard);
if (sa.hasParam("DividedAsYouChoose") && !sa.usesTargeting()) {
counterRemaining = counterRemaining - counterAmount;
divrem++;
}
} }
} else if (obj instanceof Player) { } else if (obj instanceof Player) {
// Add Counters to players! // Add Counters to players!