@Override public boolean chooseUse(Outcome outcome, String message, String secondMessage, String trueText, String falseText, Ability source, Game game) { MessageToClient messageToClient = new MessageToClient(message, secondMessage); Map<String, Serializable> options = new HashMap<>(2); if (trueText != null) { if (messageToClient.getSecondMessage() == null) { messageToClient.setSecondMessage(getRelatedObjectName(source, game));
private Map<String, Serializable> addMessageToOptions(MessageToClient message, Map<String, Serializable> options) { if (message.getSecondMessage() != null) { if (options == null) { options = new HashMap<>(); } options.put("secondMessage", message.getSecondMessage()); } if (message.getHintText() != null) { if (options == null) { options = new HashMap<>(); } options.put("hintText", message.getHintText()); } return options; }
@Override public void fireSelectTargetEvent(UUID playerId, MessageToClient message, Set<UUID> targets, boolean required, Map<String, Serializable> options) { if (simulation) { return; } playerQueryEventSource.target(playerId, message.getMessage(), targets, required, addMessageToOptions(message, options)); }
@Override public boolean chooseMulligan(Game game) { updateGameStatePriority("chooseMulligan", game); int nextHandSize = game.mulliganDownTo(playerId); do { String message = "Mulligan " + (getHand().size() > nextHandSize ? "down to " : "for free, draw ") + nextHandSize + (nextHandSize == 1 ? " card?" : " cards?"); Map<String, Serializable> options = new HashMap<>(); options.put("UI.left.btn.text", "Mulligan"); options.put("UI.right.btn.text", "Keep"); prepareForResponse(game); if (!isExecutingMacro()) { game.fireAskPlayerEvent(playerId, new MessageToClient(message), null, options); } waitForResponse(game); } while (response.getBoolean() == null && !abort); if (!abort) { return response.getBoolean(); } return false; }
game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage()), cards, required, options);
game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), cards, required, options);
@Override public void fireSelectTargetEvent(UUID playerId, MessageToClient message, Cards cards, boolean required, Map<String, Serializable> options) { if (simulation) { return; } playerQueryEventSource.target(playerId, message.getMessage(), cards, required, addMessageToOptions(message, options)); }
if (!isExecutingMacro()) { game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), possibleTargets, required, getOptions(target, null));
@Override public void fireAskPlayerEvent(UUID playerId, MessageToClient message, Ability source, Map<String, Serializable> options) { if (simulation) { return; } playerQueryEventSource.ask(playerId, message.getMessage(), source, addMessageToOptions(message, options)); }
protected void selectCombatGroup(UUID defenderId, UUID blockerId, Game game) { updateGameStatePriority("selectCombatGroup", game); TargetAttackingCreature target = new TargetAttackingCreature(); prepareForResponse(game); if (!isExecutingMacro()) { game.fireSelectTargetEvent(playerId, new MessageToClient("Select attacker to block", getRelatedObjectName(blockerId, game)), target.possibleTargets(null, playerId, game), false, getOptions(target, null)); } waitForResponse(game); if (response.getBoolean() != null) { // do nothing } else if (response.getUUID() != null) { CombatGroup group = game.getCombat().findGroup(response.getUUID()); if (group != null) { // check if already blocked, if not add if (!group.getBlockers().contains(blockerId)) { declareBlocker(defenderId, blockerId, response.getUUID(), game); } else { // else remove from block game.getCombat().removeBlockerGromGroup(blockerId, group, game); } } } }
game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(sourceId, game)), targetIds, required, getOptions(target, options));
@Override public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) { updateGameStatePriority("chooseTargetAmount", game); while (!abort) { prepareForResponse(game); if (!isExecutingMacro()) { game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(), getRelatedObjectName(source, game)), target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game), target.isRequired(source), getOptions(target, null)); } waitForResponse(game); if (response.getUUID() != null) { if (target.canTarget(response.getUUID(), source, game)) { UUID targetId = response.getUUID(); int amountSelected = getAmount(1, target.getAmountRemaining(), "Select amount", game); target.addTarget(targetId, amountSelected, source, game); return true; } } else if (!target.isRequired(source)) { return false; } } return false; }