mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* UI: choose ability to play improves (see 8add25fa12
)
This commit is contained in:
parent
8add25fa12
commit
ce60a9d75b
4 changed files with 26 additions and 8 deletions
|
@ -494,6 +494,14 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// old cancel style (just close dialog)
|
||||||
|
for (Object obj : choices) {
|
||||||
|
AbilityPickerAction action = (AbilityPickerAction) obj;
|
||||||
|
if (action.id == null) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryChoiceOption(int choiceNumber) {
|
private void tryChoiceOption(int choiceNumber) {
|
||||||
|
|
|
@ -18,17 +18,22 @@ public class AbilityPickerView implements Serializable {
|
||||||
private Map<UUID, String> choices = new LinkedHashMap<>();
|
private Map<UUID, String> choices = new LinkedHashMap<>();
|
||||||
private String message = null;
|
private String message = null;
|
||||||
|
|
||||||
public AbilityPickerView(String objectName, List<? extends Ability> abilities) {
|
public AbilityPickerView(String objectName, List<? extends Ability> abilities, String message) {
|
||||||
|
this.message = message;
|
||||||
|
|
||||||
|
int num = 0;
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
|
num++;
|
||||||
|
String rule;
|
||||||
if (objectName == null) {
|
if (objectName == null) {
|
||||||
choices.put(ability.getId(), ability.getRule(true));
|
rule = ability.getRule(true);
|
||||||
} else {
|
} else {
|
||||||
String rule = ability.getRule(objectName);
|
rule = ability.getRule(objectName);
|
||||||
if (rule.isEmpty()) {
|
if (rule.isEmpty()) {
|
||||||
rule = ability.toString();
|
rule = ability.toString();
|
||||||
}
|
}
|
||||||
choices.put(ability.getId(), rule);
|
|
||||||
}
|
}
|
||||||
|
choices.put(ability.getId(), num + ". " + rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1923,10 +1923,15 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = "Choose spell or ability to play";
|
||||||
|
if (object != null) {
|
||||||
|
message = message + "<br>" + object.getLogName();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: add canRespond cycle?
|
// TODO: add canRespond cycle?
|
||||||
prepareForResponse(game);
|
prepareForResponse(game);
|
||||||
if (!isExecutingMacro()) {
|
if (!isExecutingMacro()) {
|
||||||
game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(abilities.values()));
|
game.fireGetChoiceEvent(playerId, message, object, new ArrayList<>(abilities.values()));
|
||||||
}
|
}
|
||||||
waitForResponse(game);
|
waitForResponse(game);
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class GameController implements GameCallback {
|
||||||
if (event.getChoices() != null && !event.getChoices().isEmpty()) {
|
if (event.getChoices() != null && !event.getChoices().isEmpty()) {
|
||||||
objectName = event.getChoices().iterator().next();
|
objectName = event.getChoices().iterator().next();
|
||||||
}
|
}
|
||||||
chooseAbility(event.getPlayerId(), objectName, event.getAbilities());
|
chooseAbility(event.getPlayerId(), objectName, event.getAbilities(), event.getMessage());
|
||||||
break;
|
break;
|
||||||
case CHOOSE_PILE:
|
case CHOOSE_PILE:
|
||||||
choosePile(event.getPlayerId(), event.getMessage(), event.getPile1(), event.getPile2());
|
choosePile(event.getPlayerId(), event.getMessage(), event.getPile1(), event.getPile2());
|
||||||
|
@ -761,8 +761,8 @@ public class GameController implements GameCallback {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void chooseAbility(UUID playerId, final String objectName, final List<? extends Ability> choices) throws MageException {
|
private synchronized void chooseAbility(UUID playerId, final String objectName, final List<? extends Ability> choices, String message) throws MageException {
|
||||||
perform(playerId, playerId1 -> getGameSession(playerId1).chooseAbility(new AbilityPickerView(objectName, choices)));
|
perform(playerId, playerId1 -> getGameSession(playerId1).chooseAbility(new AbilityPickerView(objectName, choices, message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void choosePile(UUID playerId, final String message, final List<? extends Card> pile1, final List<? extends Card> pile2) throws MageException {
|
private synchronized void choosePile(UUID playerId, final String message, final List<? extends Card> pile1, final List<? extends Card> pile2) throws MageException {
|
||||||
|
|
Loading…
Reference in a new issue