mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
CountersPutEffect : streamline most CounterType choosing into chooseTypeFromList (supporting UniqueType and RandomType)
This commit is contained in:
@@ -348,17 +348,8 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sa.hasParam("CounterTypePerDefined")) {
|
if (sa.hasParam("CounterTypePerDefined") || sa.hasParam("UniqueType")) {
|
||||||
List<CounterType> choices = Lists.newArrayList();
|
counterType = chooseTypeFromList(sa, sa.getParam("CounterType"), obj, pc);
|
||||||
for (String s : sa.getParam("CounterType").split(",")) {
|
|
||||||
choices.add(CounterType.getType(s));
|
|
||||||
}
|
|
||||||
Map<String, Object> params = Maps.newHashMap();
|
|
||||||
params.put("Target", obj);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(Localizer.getInstance().getMessage("lblSelectCounterTypeAddTo") + " ");
|
|
||||||
sb.append(obj);
|
|
||||||
counterType = pc.chooseCounterType(choices, sa, sb.toString(), params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj instanceof Card) {
|
if (obj instanceof Card) {
|
||||||
@@ -527,14 +518,8 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
|||||||
&& !sa.hasParam("UniqueType") && !sa.hasParam("CounterTypePerDefined")
|
&& !sa.hasParam("UniqueType") && !sa.hasParam("CounterTypePerDefined")
|
||||||
&& !sa.hasParam("CounterTypes") && !sa.hasParam("ChooseDifferent")) {
|
&& !sa.hasParam("CounterTypes") && !sa.hasParam("ChooseDifferent")) {
|
||||||
try {
|
try {
|
||||||
List<CounterType> choices = Lists.newArrayList();
|
counterType = chooseTypeFromList(sa, sa.getParam("CounterType"), null,
|
||||||
for (String s : sa.getParam("CounterType").split(",")) {
|
placer.getController());
|
||||||
choices.add(CounterType.getType(s));
|
|
||||||
}
|
|
||||||
Map<String, Object> params = Maps.newHashMap();
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(Localizer.getInstance().getMessage("lblSelectCounterTypeAddTo"));
|
|
||||||
counterType = placer.getController().chooseCounterType(choices, sa, sb.toString(), params);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Counter type doesn't match, nor does an SVar exist with the type name.");
|
System.out.println("Counter type doesn't match, nor does an SVar exist with the type name.");
|
||||||
return;
|
return;
|
||||||
@@ -595,6 +580,27 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected CounterType chooseTypeFromList(SpellAbility sa, String list, GameEntity obj, PlayerController pc) {
|
||||||
|
List<CounterType> choices = Lists.newArrayList();
|
||||||
|
for (String s : list.split(",")) {
|
||||||
|
if (!s.equals("") && (!sa.hasParam("UniqueType") || obj.getCounters(CounterType.getType(s)) == 0)) {
|
||||||
|
choices.add(CounterType.getType(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sa.hasParam("RandomType")) {
|
||||||
|
return Aggregates.random(choices);
|
||||||
|
}
|
||||||
|
Map<String, Object> params = Maps.newHashMap();
|
||||||
|
params.put("Target", obj);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (obj != null) {
|
||||||
|
sb.append(Localizer.getInstance().getMessage("lblSelectCounterTypeAddTo")).append(" ").append(obj);
|
||||||
|
} else {
|
||||||
|
sb.append(Localizer.getInstance().getMessage("lblSelectCounterType"));
|
||||||
|
}
|
||||||
|
return pc.chooseCounterType(choices, sa, sb.toString(), params);
|
||||||
|
}
|
||||||
|
|
||||||
protected String logOutput(Map<Object, Integer> randomMap, Card card) {
|
protected String logOutput(Map<Object, Integer> randomMap, Card card) {
|
||||||
StringBuilder randomLog = new StringBuilder();
|
StringBuilder randomLog = new StringBuilder();
|
||||||
randomLog.append(card.getName()).append(" randomly distributed ");
|
randomLog.append(card.getName()).append(" randomly distributed ");
|
||||||
|
|||||||
Reference in New Issue
Block a user