@Override public void addCost(Cost cost) { if (cost != null) { if (cost instanceof ManaCost) { this.addManaCost((ManaCost) cost); } else { this.costs.add(cost); } } }
@Override public boolean canChooseTarget(Game game) { if (this instanceof SpellAbility) { if (SpellAbilityType.SPLIT_FUSED.equals(((SpellAbility) this).getSpellAbilityType())) { Card card = game.getCard(getSourceId()); if (card != null) { return canChooseTargetAbility(((SplitCard) card).getLeftHalfCard().getSpellAbility(), game, getControllerId()) && canChooseTargetAbility(((SplitCard) card).getRightHalfCard().getSpellAbility(), game, getControllerId()); } return false; } } return canChooseTargetAbility(this, game, getControllerId()); }
@Override public boolean resolve(Game game) { boolean result = true; //20100716 - 117.12 if (checkIfClause(game)) { if (this instanceof TriggeredAbility) { for (UUID modeId : this.getModes().getSelectedModes()) { this.getModes().setActiveMode(modeId); result = resolveMode(game); } } else { result = resolveMode(game); } } return result; }
@Override public String getRule(String source) { return formatRule(getRule(), source); }
@Override public boolean activate(Game game, boolean noMana) { Player controller = game.getPlayer(this.getControllerId()); if (controller == null) { return false; if (!getModes().choose(game, this)) { return false; MageObject sourceObject = getSourceObject(game); if (getSourceObjectZoneChangeCounter() == 0) { setSourceObjectZoneChangeCounter(game.getState().getZoneChangeCounter(getSourceId())); if (!this.getManaCostsToPay().getVariableCosts().isEmpty()) { int xValue = this.getManaCostsToPay().getX(); this.getManaCostsToPay().clear(); VariableManaCost xCosts = new VariableManaCost(); xCosts.setAmount(xValue); this.getManaCostsToPay().add(xCosts); } else { this.getManaCostsToPay().clear(); if (!activateAlternateOrAdditionalCosts(sourceObject, noMana, controller, game)) { if (getAbilityType() == AbilityType.SPELL && ((SpellAbility) this).getSpellAbilityType() == SpellAbilityType.FACE_DOWN_CREATURE) { return false; if (getAbilityType() == AbilityType.SPELL && (getManaCostsToPay().isEmpty() && getCosts().isEmpty()) && !noMana) { return false;
@Override public String getGameLogMessage(Game game) { if (game.isSimulation()) { return ""; } MageObject object = game.getObject(this.sourceId); if (object == null) { // e.g. sacrificed token logger.warn("Could get no object: " + this.toString()); } return new StringBuilder(" activates: ") .append(object != null ? this.formatRule(getModes().getText(), object.getLogName()) : getModes().getText()) .append(" from ") .append(getMessageText(game)).toString(); }
private boolean resolveMode(Game game) { boolean result = true; for (Effect effect : getEffects()) { if (effect instanceof OneShotEffect) { boolean effectResult = effect.apply(game, this); result &= effectResult; if (logger.isDebugEnabled()) { if (this.getAbilityType() != AbilityType.MANA) { if (!effectResult) { if (this.getSourceId() != null) { MageObject mageObject = game.getObject(this.getSourceId()); if (mageObject != null) { logger.debug("AbilityImpl.resolve: object: " + mageObject.getName()); logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode()));
@Override public void newId() { if (!(this instanceof MageSingleton)) { this.id = UUID.randomUUID(); } getEffects().newId(); }
@Override public boolean activate(Game game, boolean noMana) { if (hasMoreActivationsThisTurn(game)) { if (super.activate(game, noMana)) { ActivationInfo activationInfo = getActivationInfo(game); if (activationInfo == null) { activationInfo = new ActivationInfo(game.getTurnNum(), 1); } else if (activationInfo.turnNum != game.getTurnNum()) { activationInfo.turnNum = game.getTurnNum(); activationInfo.activationCounter = 1; } else { activationInfo.activationCounter++; } setActivationInfo(activationInfo, game); return true; } } return false; }
if (this.getAbilityType() == AbilityType.SPELL
@Override public void newOriginalId() { this.id = UUID.randomUUID(); this.originalId = id; getEffects().newId(); }
@Override public void addEffect(Effect effect) { if (effect != null) { getEffects().add(effect); } }
@Override public Effects getEffects(Game game, EffectType effectType) { Effects typedEffects = new Effects(); for (Effect effect : getEffects()) { if (effect.getEffectType() == effectType) { typedEffects.add(effect); } } return typedEffects; }