@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); MageObject mageObject = game.getObject(source.getSourceId()); if (player != null && mageObject != null) { String message = userMessage; if (message == null) { message = getCostText() + " to prevent " + executingEffect.getText(source.getModes().getMode()) + "?"; } message = CardUtil.replaceSourceName(message, mageObject.getLogName()); cost.clearPaid(); if (cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(executingEffect.getOutcome(), message, source, game)) { cost.pay(source, game, source.getSourceId(), player.getId(), false, null); } if (!cost.isPaid()) { executingEffect.setTargetPointer(this.targetPointer); return executingEffect.apply(game, source); } return true; } return false; }
private void checkPaid(UUID uuid, Spell spell) { for (Cost cost : spell.getSpellAbility().getManaCostsToPay()) { if (!cost.isPaid()) { return; } } CardView cardView = stack.get(uuid); cardView.paid = true; }
/** * As we have ability in the stack, we need to update optional costs in original card. This * information will be used later by effects, e.g. to determine whether card was kicked or not. * E.g. Desolation Angel */ private void updateOptionalCosts(int index) { Ability abilityOrig = spellCards.get(index).getAbilities().get(spellAbilities.get(index).getId()); if (abilityOrig != null) { for (Object object : spellAbilities.get(index).getOptionalCosts()) { Cost cost = (Cost) object; for (Cost costOrig : abilityOrig.getOptionalCosts()) { if (cost.getId().equals(costOrig.getId())) { if (cost.isPaid()) { costOrig.setPaid(); } else { costOrig.clearPaid(); } break; } } } } }