CharmEffect: now allows zero choices

This commit is contained in:
Hans Mackowiak
2019-01-05 12:01:30 +00:00
parent f0a561b1ee
commit 55da7435f8
3 changed files with 24 additions and 5 deletions

View File

@@ -67,6 +67,8 @@ public class CharmEffect extends SpellAbilityEffect {
if (num == min) { if (num == min) {
sb.append(Lang.getNumeral(num)); sb.append(Lang.getNumeral(num));
} else if (min == 0) {
sb.append("up to ").append(Lang.getNumeral(num));
} else { } else {
sb.append(Lang.getNumeral(min)).append(" or ").append(list.size() == 2 ? "both" : "more"); sb.append(Lang.getNumeral(min)).append(" or ").append(list.size() == 2 ? "both" : "more");
} }
@@ -101,6 +103,8 @@ public class CharmEffect extends SpellAbilityEffect {
if (num == min) { if (num == min) {
sb.append(Lang.getNumeral(num)); sb.append(Lang.getNumeral(num));
} else if (min == 0) {
sb.append("up to ").append(Lang.getNumeral(num));
} else { } else {
sb.append(Lang.getNumeral(min)).append(" or ").append(list.size() == 2 ? "both" : "more"); sb.append(Lang.getNumeral(min)).append(" or ").append(list.size() == 2 ? "both" : "more");
} }
@@ -158,7 +162,7 @@ public class CharmEffect extends SpellAbilityEffect {
final int num = sa.hasParam("CharmNumOnResolve") ? final int num = sa.hasParam("CharmNumOnResolve") ?
AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("CharmNumOnResolve"), sa) AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("CharmNumOnResolve"), sa)
: Integer.parseInt(sa.hasParam("CharmNum") ? sa.getParam("CharmNum") : "1"); : Integer.parseInt(sa.getParamOrDefault("CharmNum", "1"));
final int min = sa.hasParam("MinCharmNum") ? Integer.parseInt(sa.getParam("MinCharmNum")) : num; final int min = sa.hasParam("MinCharmNum") ? Integer.parseInt(sa.getParam("MinCharmNum")) : num;
Card source = sa.getHostCard(); Card source = sa.getHostCard();

View File

@@ -206,15 +206,20 @@ public abstract class Trigger extends TriggerReplacementBase {
} else { } else {
saDesc = sa.getDescription(); saDesc = sa.getDescription();
} }
// string might have leading whitespace
saDesc = saDesc.trim();
if (!saDesc.isEmpty()) { if (!saDesc.isEmpty()) {
// string might have leading whitespace // in case sa starts with CARDNAME, dont lowercase it
saDesc = saDesc.trim(); if (!saDesc.startsWith(sa.getHostCard().getName())) {
saDesc = saDesc.substring(0, 1).toLowerCase() + saDesc.substring(1); saDesc = saDesc.substring(0, 1).toLowerCase() + saDesc.substring(1);
}
if (saDesc.contains("ORIGINALHOST") && sa.getOriginalHost() != null) { if (saDesc.contains("ORIGINALHOST") && sa.getOriginalHost() != null) {
saDesc = TextUtil.fastReplace(saDesc, "ORIGINALHOST", sa.getOriginalHost().getName()); saDesc = TextUtil.fastReplace(saDesc, "ORIGINALHOST", sa.getOriginalHost().getName());
} }
result = TextUtil.fastReplace(result, "ABILITY", saDesc); } else {
saDesc = "<take no action>"; // printed in case nothing is chosen for the ability (e.g. Charm with Up to X)
} }
result = TextUtil.fastReplace(result, "ABILITY", saDesc);
} }
return result; return result;

View File

@@ -0,0 +1,10 @@
Name:Ravager Wurm
ManaCost:3 R G G
Types:Creature Wurm
PT:4/5
K:Riot
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigCharm | TriggerDescription$ When CARDNAME enters the battlefield, ABILITY
SVar:TrigCharm:DB$ Charm | MinCharmNum$ 0 | CharmNum$ 1 | Choices$ DBFight,DBDestroy
SVar:DBFight:DB$ Fight | Defined$ TriggeredCardLKICopy | ValidTgts$ Creature.YouDontCtrl | TgtPrompt$ Choose target creature you don't control | SpellDescription$ CARDNAME fights target creature you don't control.
SVar:DBDestroy:DB$ Destroy | ValidTgts$ Land.hasNonManaActivatedAbility | TgtPrompt$ Select target land with an activated ability that isn't a mana ability | SpellDescription$ Destroy target land with an activated ability that iasn't a mana ability.
Oracle:Riot (This creature enters the battlefield with your choice of a +1/+1 counter or haste.)\nWhen Ravager Wurm enters the battlefield, choose up to one -\n- Ravager Wurm fights target creature you don't control.\n- Destroy target land with an activated ability that isn't a mana ability.