Small rework for autochoosing color of mana to add (#11495)

fix #11494
This commit is contained in:
xenohedron 2023-12-01 00:49:42 -05:00 committed by GitHub
parent b4a58a339d
commit 35f4a898f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 7 deletions

View file

@ -106,7 +106,7 @@ class CommanderIdentityManaEffect extends ManaEffect {
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceImpl();
Choice choice = new ChoiceImpl().setManaColorChoice(true);
choice.setMessage("Pick a mana color");
for (UUID commanderId : game.getCommandersIds(controller, CommanderCardType.COMMANDER_OR_OATHBREAKER, false)) {
Card commander = game.getCard(commanderId);

View file

@ -41,6 +41,10 @@ public interface Choice extends Serializable, Copyable<Choice> {
ChoiceHintType getHintType();
boolean isManaColorChoice();
Choice setManaColorChoice(boolean manaColorChoice);
// string choice
void setChoices(Set<String> choices);

View file

@ -47,6 +47,7 @@ public class ChoiceColor extends ChoiceImpl {
this.setMessage(chooseMessage);
this.setSubMessage(chooseSubMessage);
this.manaColorChoice = true;
}
protected ChoiceColor(final ChoiceColor choice) {

View file

@ -34,6 +34,8 @@ public class ChoiceImpl implements Choice {
protected String specialText = "";
protected String specialHint = "";
protected boolean manaColorChoice = false; // set true to allow automatic choosing with Outcome.PutManaInPool
public ChoiceImpl() {
this(false);
}
@ -65,6 +67,7 @@ public class ChoiceImpl implements Choice {
this.specialCanBeEmpty = choice.specialCanBeEmpty;
this.specialText = choice.specialText;
this.specialHint = choice.specialHint;
this.manaColorChoice = choice.manaColorChoice;
}
@Override
@ -328,6 +331,17 @@ public class ChoiceImpl implements Choice {
return this.hintType;
}
@Override
public boolean isManaColorChoice() {
return manaColorChoice;
}
@Override
public ChoiceImpl setManaColorChoice(boolean manaColorChoice) {
this.manaColorChoice = manaColorChoice;
return this;
}
private void protectFromEmptyChoices() {
// if there are no choices then required must be disabled to allow user to close a dialog
// example: database error on too low memory, see Brain Pry and 500 Mb server