Merge branch 'counters' into 'master'

CountersPutEffect allow to handle multiple Defined

See merge request core-developers/forge!6345
This commit is contained in:
Michael Kamensky
2022-03-05 15:04:19 +00:00
3 changed files with 27 additions and 15 deletions

View File

@@ -69,19 +69,26 @@ public class CountersPutEffect extends SpellAbilityEffect {
stringBuilder.append("up to ");
}
String type = spellAbility.getParam("CounterType");
if (amount == 1) {
stringBuilder.append(Lang.startsWithVowel(type) ? "an " : "a ");
} else {
stringBuilder.append(Lang.getNumeral(amount)).append(" ");
}
stringBuilder.append(CounterType.getType(type).getName().toLowerCase()).append(" counter");
stringBuilder.append(amount != 1 ? "s" : "").append(divAsChoose || spellAbility.hasParam("DividedRandomly")
final String typeName = CounterType.getType(spellAbility.getParam("CounterType")).getName().toLowerCase();
stringBuilder.append(Lang.nounWithNumeralExceptOne(amount,
typeName + " counter"));
stringBuilder.append(divAsChoose || spellAbility.hasParam("DividedRandomly")
? " among " : " on ");
// special handling for multiple Defined
if (spellAbility.hasParam("Defined") && spellAbility.getParam("Defined").contains(" & ")) {
String[] def = spellAbility.getParam("Defined").split(" & ");
for (int i = 0; i < def.length; i++) {
stringBuilder.append(AbilityUtils.getDefinedEntities(card, def[i],
spellAbility).toString().replaceAll("[\\[\\]]",""));
if (i + 1 < def.length) {
stringBuilder.append(" and ");
stringBuilder.append(Lang.nounWithNumeralExceptOne(amount,
typeName + " counter")).append(" on ");
}
}
// if use targeting we show all targets and corresponding counters
if(spellAbility.usesTargeting()) {
} else if (spellAbility.usesTargeting()) {
final List<Card> targetCards = SpellAbilityEffect.getTargetCards(spellAbility);
for(int i = 0; i < targetCards.size(); i++) {
Card targetCard = targetCards.get(i);
@@ -182,7 +189,13 @@ public class CountersPutEffect extends SpellAbilityEffect {
sa.hasParam("ChoiceOptional"), params));
}
} else {
tgtObjects.addAll(getDefinedEntitiesOrTargeted(sa, "Defined"));
if (sa.hasParam("Defined") && sa.getParam("Defined").contains(" & ")) {
for (String def : sa.getParam("Defined").split(" & ")) {
tgtObjects.addAll(AbilityUtils.getDefinedEntities(card, def, sa));
}
} else {
tgtObjects.addAll(getDefinedEntitiesOrTargeted(sa, "Defined"));
}
}
if (sa.hasParam("Optional") && !pc.confirmAction

View File

@@ -3,7 +3,7 @@ ManaCost:3 G W
Types:Creature Human Knight Ranger
PT:2/4
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Creature.Other+YouCtrl | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever another creature enters the battlefield under your control, put a +1/+1 counter on that creature and a +1/+1 counter on CARDNAME.
SVar:TrigPutCounter:DB$ PutCounter | Defined$ TriggeredCardLKICopy | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ DBPutCounter
SVar:DBPutCounter:DB$ PutCounter | Defined$ Self.StrictlySelf | CounterType$ P1P1 | CounterNum$ 1
SVar:TrigPutCounter:DB$ PutCounter | Defined$ TriggeredCardLKICopy & Self | CounterType$ P1P1
SVar:BuffedBy:Creature
DeckHas:Ability$Counters
Oracle:Whenever another creature enters the battlefield under your control, put a +1/+1 counter on that creature and a +1/+1 counter on Juniper Order Ranger.

View File

@@ -2,6 +2,5 @@ Name:Serrated Biskelion
ManaCost:3
Types:Artifact Creature Construct
PT:2/2
A:AB$ PutCounter | Cost$ T | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ M1M1 | CounterNum$ 1 | SubAbility$ DBPutCounter | IsCurse$ True | SpellDescription$ Put a -1/-1 counter on target creature and a -1/-1 counter on CARDNAME.
SVar:DBPutCounter:DB$ PutCounter | CounterType$ M1M1 | CounterNum$ 1
A:AB$ PutCounter | Cost$ T | Defined$ Self & Targeted | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ M1M1 | IsCurse$ True | SpellDescription$ Put a -1/-1 counter on target creature and a -1/-1 counter on CARDNAME.
Oracle:{T}: Put a -1/-1 counter on Serrated Biskelion and a -1/-1 counter on target creature.