@Override public boolean activate(Game game, boolean noMana) { return ability.activate(game, noMana); }
protected void addAbilityNode(SimulationNode parent, Ability ability, Game game) { Game sim = game.copy(); sim.getStack().push(new StackAbility(ability, playerId)); ability.activate(sim, false); if (ability.activate(sim, false) && ability.isUsesStack()) { game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId())); } sim.applyEffects(); SimulationNode newNode = new SimulationNode(parent, sim, playerId); logger.debug(indent(newNode.getDepth()) + "simulating -- node #:" + SimulationNode.getCount() + " triggered ability option"); for (Target target: ability.getTargets()) { for (UUID targetId: target.getTargets()) { newNode.getTargets().add(targetId); } } parent.children.add(newNode); }
protected void addAbilityNode(SimulationNode2 parent, Ability ability, int depth, Game game) { Game sim = game.copy(); sim.getStack().push(new StackAbility(ability, playerId)); if (ability.activate(sim, false) && ability.isUsesStack()) { game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId())); } sim.applyEffects(); SimulationNode2 newNode = new SimulationNode2(parent, sim, depth, playerId); logger.debug("simulating -- node #:" + SimulationNode2.getCount() + " triggered ability option"); for (Target target : ability.getTargets()) { for (UUID targetId : target.getTargets()) { newNode.getTargets().add(targetId); } } parent.children.add(newNode); }
@Override public boolean triggerAbility(TriggeredAbility source, Game game) { Ability ability = source.copy(); List<Ability> options = getPlayableOptions(ability, game); if (options.isEmpty()) { if (logger.isDebugEnabled()) logger.debug("simulating -- triggered ability:" + ability); game.getStack().push(new StackAbility(ability, playerId)); if (ability.activate(game, false) && ability.isUsesStack()) { game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId())); } game.applyEffects(); game.getPlayers().resetPassed(); } else { SimulationNode parent = (SimulationNode) game.getCustomData(); if (parent.getDepth() == maxDepth) return true; logger.debug(indent(parent.getDepth()) + "simulating -- triggered ability - adding children:" + options.size()); for (Ability option: options) { addAbilityNode(parent, option, game); } } return true; }
@Override public boolean triggerAbility(TriggeredAbility source, Game game) { Ability ability = source.copy(); List<Ability> options = getPlayableOptions(ability, game); if (options.isEmpty()) { logger.debug("simulating -- triggered ability:" + ability); game.getStack().push(new StackAbility(ability, playerId)); if (ability.activate(game, false) && ability.isUsesStack()) { game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId())); } game.applyEffects(); game.getPlayers().resetPassed(); } else { SimulationNode2 parent = (SimulationNode2) game.getCustomData(); int depth = parent.getDepth() - 1; if (depth == 0) { return true; } logger.debug("simulating -- triggered ability - adding children:" + options.size()); for (Ability option : options) { addAbilityNode(parent, option, depth, game); } } return true; }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { if (optional) { Player controller = game.getPlayer(source.getControllerId()); MageObject object = game.getObject(source.getSourceId()); if (controller == null || object == null) { return false; } if (!controller.chooseUse(outcome, "Use effect of " + object.getIdName() + "?", source, game)) { return false; } } for (Effect effect : baseEffects) { if (source.activate(game, false)) { if (effect instanceof ContinuousEffect) { game.addEffect((ContinuousEffect) effect, source); } else { effect.apply(game, source); } } } return false; }
manaAbiltiy.setSourceObjectZoneChangeCounter(getState().getZoneChangeCounter(ability.getSourceId())); manaAbiltiy.activate(this, false); manaAbiltiy.resolve(this); } else {