Fix Frankenstein's Monster (#6143)

This commit is contained in:
tool4ever
2024-09-14 19:47:40 +02:00
committed by GitHub
parent d303bb122c
commit 21c34b552d
5 changed files with 32 additions and 19 deletions

View File

@@ -91,13 +91,12 @@ public class CountersPutEffect extends SpellAbilityEffect {
// skip the StringBuilder if no targets are chosen ("up to" scenario)
if (sa.usesTargeting()) {
final List<Card> targetCards = getTargetCards(sa);
if (targetCards.size() == 0) {
if (targetCards.isEmpty()) {
return stringBuilder.toString();
}
}
final String key = forEach ? "ForEachNum" : "CounterNum";
final int amount = AbilityUtils.calculateAmount(card, sa.getParamOrDefault(key, "1"), sa);
final int amount = AbilityUtils.calculateAmount(card, sa.getParamOrDefault("CounterNum", "1"), sa);
if (sa.hasParam("Bolster")) {
stringBuilder.append("bolsters ").append(amount).append(".");
@@ -308,7 +307,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
for (int i = 0; i < num; i++) {
CounterType ct = chooseTypeFromList(sa, options, obj, pc);
typesToAdd.add(ct);
options = options.replace(ct.getName(),"");
options = options.replace(ct.getName(), "");
}
for (CounterType ct : typesToAdd) {
if (obj instanceof Player) {
@@ -338,7 +337,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
CardCollectionView counterCards =
CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield),
type.split("_")[1], activator, card, sa);
List <CounterType> counterTypes = Lists.newArrayList();
List<CounterType> counterTypes = Lists.newArrayList();
for (Card c : counterCards) {
for (final Map.Entry<CounterType, Integer> map : c.getCounters().entrySet()) {
if (!counterTypes.contains(map.getKey())) {
@@ -357,7 +356,23 @@ public class CountersPutEffect extends SpellAbilityEffect {
typesToAdd.add(CounterType.getType(type));
}
}
int remaining = counterAmount;
for (CounterType ct : typesToAdd) {
if (sa.hasParam("SplitAmount")) {
if (typesToAdd.size() - typesToAdd.indexOf(ct) > 1) {
Map<String, Object> params = Maps.newHashMap();
params.put("Target", obj);
params.put("CounterType", counterType);
counterAmount = pc.chooseNumber(sa, ct.toString() + ": " +
Localizer.getInstance().getMessage("lblHowManyCounters"), 0, remaining, params);
if (counterAmount == 0) {
continue;
}
remaining -= counterAmount;
} else {
counterAmount = remaining;
}
}
if (obj instanceof Player) {
((Player) obj).addCounter(ct, counterAmount, placer, table);
}
@@ -483,11 +498,9 @@ public class CountersPutEffect extends SpellAbilityEffect {
}
// Adapt need extra logic
if (sa.hasParam("Adapt")) {
if (!(gameCard.getCounters(CounterEnumType.P1P1) == 0
|| StaticAbilityAdapt.anyWithAdapt(sa, gameCard))) {
continue;
}
if (sa.hasParam("Adapt") &&
!(gameCard.getCounters(CounterEnumType.P1P1) == 0 || StaticAbilityAdapt.anyWithAdapt(sa, gameCard))) {
continue;
}
if (sa.isKeyword(Keyword.TRIBUTE)) {

View File

@@ -48,7 +48,7 @@ public class ReplaceEffect extends SpellAbilityEffect {
for (Player key : AbilityUtils.getDefinedPlayers(card, sa.getParam("VarKey"), sa)) {
m.put(key, m.getOrDefault(key, 0) + AbilityUtils.calculateAmount(card, varValue, sa));
}
} else {
} else if (varName != null) {
params.put(varName, AbilityUtils.calculateAmount(card, varValue, sa));
}

View File

@@ -62,6 +62,10 @@ public class StaticAbilityPanharmonicon {
continue;
}
// it can't trigger more times than the limit allows
if (t.hasParam("GameActivationLimit") &&
t.getActivationsThisGame() + n + 1 >= Integer.parseInt(t.getParam("GameActivationLimit"))) {
break;
}
if (t.hasParam("ActivationLimit") &&
t.getActivationsThisTurn() + n + 1 >= Integer.parseInt(t.getParam("ActivationLimit"))) {
break;