use of mage.game.stack.Spell in project mage by magefree.
the class PsychicRebuttalPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
if (spell != null) {
game.getStack().counter(spell.getId(), source, game);
if (SpellMasteryCondition.instance.apply(game, source) && controller.chooseUse(Outcome.PlayForFree, "Copy " + spell.getName() + " (you may choose new targets for the copy)?", source, game)) {
spell.createCopyOnStack(game, source, source.getControllerId(), true);
}
return true;
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class RemKarolusStalwartSlayerReplacementEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
UUID targetId = event.getTargetId();
if (targetId.equals(source.getSourceId())) {
return false;
}
UUID controllerId = source.getControllerId();
if (!targetId.equals(controllerId)) {
Permanent permanent = game.getPermanent(targetId);
if (permanent == null || !permanent.isControlledBy(controllerId)) {
return false;
}
}
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (stackObject == null) {
stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
}
if (stackObject instanceof Spell) {
return super.applies(event, source, game);
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class SenTripletsPlayFromOpponentsHandEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Card card = game.getCard(objectId);
Zone zone;
if (card instanceof Spell) {
zone = ((Spell) card).getFromZone();
} else if (card != null) {
zone = game.getState().getZone(card.getMainCard().getId());
} else {
return false;
}
return card.isOwnedBy(getTargetPointer().getFirst(game, source)) && zone == Zone.HAND && source.isControlledBy(affectedControllerId);
}
use of mage.game.stack.Spell in project mage by magefree.
the class SiftThroughSandsWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (condition) {
// no need to check - condition has already occured
return;
}
if (event.getType() == GameEvent.EventType.SPELL_CAST && controllerId.equals(event.getPlayerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell.getCard().getName().equals("Peer Through Depths")) {
castPeerThroughDepths = true;
} else if (spell.getCard().getName().equals("Reach Through Mists")) {
castReachThroughMists = true;
}
condition = castPeerThroughDepths && castReachThroughMists;
}
}
use of mage.game.stack.Spell in project mage by magefree.
the class SplitDecisionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
if (spell == null) {
return false;
}
// Outcome.Benefit - AI will use counter all the time (Denial choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Denial (counter " + spell.getIdName() + ")", "Duplication (copy " + spell.getIdName() + ")", Outcome.Benefit);
vote.doVotes(source, game);
int denialCount = vote.getVoteCount(true);
int duplicationCount = vote.getVoteCount(false);
if (denialCount > duplicationCount) {
return game.getStack().counter(spell.getId(), source, game);
} else {
return new CopyTargetSpellEffect().apply(game, source);
}
}
Aggregations