use of mage.game.stack.StackObject in project mage by magefree.
the class ShannaSisaysLegacyEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Card targetCard = game.getCard(event.getTargetId());
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (targetCard != null && stackObject != null && targetCard.getId().equals(source.getSourceId())) {
if (stackObject instanceof Ability) {
if (!stackObject.isControlledBy(source.getControllerId())) {
return true;
}
}
}
return false;
}
use of mage.game.stack.StackObject in project mage by magefree.
the class MoveAuraEffect method apply.
@Override
public boolean apply(ObjectSourcePlayer<MageItem> input, Game game) {
StackObject source = game.getStack().getStackObject(input.getSourceId());
if (source != null) {
if (source.getStackAbility().getTargets().isEmpty() || source.getStackAbility().getTargets().get(0).getTargets().isEmpty()) {
return true;
}
Permanent firstTarget = game.getPermanent(source.getStackAbility().getTargets().get(0).getTargets().get(0));
Permanent inputPermanent = game.getPermanent(input.getObject().getId());
if (firstTarget != null && inputPermanent != null) {
return firstTarget.isControlledBy(inputPermanent.getControllerId());
}
}
return true;
}
use of mage.game.stack.StackObject in project mage by magefree.
the class GreatestPowerCountCreatureYouControl method apply.
@Override
public boolean apply(Game game, Ability source) {
StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source));
if (spell != null) {
Player player = game.getPlayer(spell.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && controller != null && sourceObject != null) {
int maxPower = new GreatestPowerCountCreatureYouControl().calculate(game, source, this);
Cost cost = ManaUtil.createManaCost(maxPower, true);
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "? (otherwise " + spell.getName() + " will be countered)", source, game) && cost.pay(source, game, source, player.getId(), false)) {
return true;
}
game.informPlayers(sourceObject.getName() + ": cost wasn't payed - countering " + spell.getName());
return game.getStack().counter(source.getFirstTarget(), source, game);
}
}
return false;
}
use of mage.game.stack.StackObject in project mage by magefree.
the class SpelljackEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID targetId = targetPointer.getFirst(game, source);
StackObject stackObject = game.getStack().getStackObject(targetId);
if (stackObject != null && game.getStack().counter(targetId, source, game, Zone.EXILED, false, ZoneDetail.NONE)) {
Card card = ((Spell) stackObject).getCard();
if (card != null) {
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.Custom, true);
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
use of mage.game.stack.StackObject in project mage by magefree.
the class ToshiroUmezawaReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
UUID eventObject = event.getTargetId();
StackObject stackObject = game.getStack().getStackObject(eventObject);
Player controller = game.getPlayer(source.getControllerId());
if (stackObject != null && controller != null) {
if (stackObject instanceof Spell) {
game.rememberLKI(stackObject.getId(), Zone.STACK, stackObject);
}
if (stackObject instanceof Card && eventObject.equals(cardId)) {
return controller.moveCards((Card) stackObject, Zone.EXILED, source, game);
}
}
return false;
}
Aggregations