Code cleanup

This commit is contained in:
drdev
2013-12-08 22:14:19 +00:00
parent 49aa0cc459
commit 29ef7a7d3b

View File

@@ -28,57 +28,65 @@ public final class InputProliferate extends InputSelectManyBase<GameEntity> {
protected String getMessage() {
StringBuilder sb = new StringBuilder("Choose permanents and/or players with counters on them to add one more counter of that type.");
sb.append("\n\nYou've selected so far:\n");
if( selected.isEmpty())
if (selected.isEmpty()) {
sb.append("(none)");
else
for(GameEntity ge : selected ) {
if( ge instanceof Player )
}
else {
for (GameEntity ge : selected) {
if (ge instanceof Player) {
sb.append("* A poison counter to player ").append(ge).append("\n");
else
}
else {
sb.append("* ").append(ge).append(" -> ").append(chosenCounters.get(ge)).append("counter\n");
}
}
}
return sb.toString();
}
@Override
protected void onCardSelected(final Card card, final MouseEvent triggerEvent) {
if( !selectEntity(card) )
if (!selectEntity(card)) {
return;
if( selected.contains(card) ) {
}
if (selected.contains(card)) {
final List<CounterType> choices = new ArrayList<CounterType>();
for (final CounterType ct : CounterType.values()) {
if (card.getCounters(ct) > 0) {
choices.add(ct);
}
}
CounterType toAdd = choices.size() == 1 ? choices.get(0) : GuiChoose.one("Select counter type", choices);
chosenCounters.put(card, toAdd);
}
refresh();
}
@Override
public void selectPlayer(final Player player) {
if( !selectEntity(player) )
if (!selectEntity(player)) {
return;
}
refresh();
}
@Override
protected boolean isValidChoice(GameEntity choice) {
if (choice instanceof Player)
if (choice instanceof Player) {
return ((Player) choice).getPoisonCounters() > 0 && !choice.hasKeyword("You can't get poison counters");
if (choice instanceof Card)
}
if (choice instanceof Card) {
return ((Card) choice).hasCounters();
}
return false;
}
public CounterType getCounterFor(GameEntity ge) {
return chosenCounters.get(ge);
}