use of mage.game.stack.Spell in project mage by magefree.
the class CopySourceSpellEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = (Spell) getValue("spellCast");
if (spell == null) {
spell = game.getSpellOrLKIStack(source.getSourceId());
}
if (controller == null || spell == null) {
return false;
}
spell.createCopyOnStack(game, source, source.getControllerId(), true, amount);
return true;
}
use of mage.game.stack.Spell in project mage by magefree.
the class CastSourceTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(this.getSourceId())) {
return false;
}
MageObject spellObject = game.getObject(sourceId);
if ((!(spellObject instanceof Spell))) {
return true;
}
Spell spell = (Spell) spellObject;
if (spell.getSpellAbility() != null) {
getEffects().setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
}
getEffects().setValue("spellCast", spell);
return true;
}
use of mage.game.stack.Spell in project mage by magefree.
the class BrowbeatDrawEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
StackObject spell = null;
for (StackObject object : game.getStack()) {
if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) {
spell = object;
}
}
if (spell != null) {
boolean drawCards = true;
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && player.chooseUse(Outcome.Detriment, "Have " + spell.getLogName() + " deal 5 damage to you?", source, game)) {
drawCards = false;
player.damage(5, source.getSourceId(), source, game);
game.informPlayers(player.getLogName() + " has " + spell.getLogName() + " deal 5 to them");
}
}
if (drawCards) {
UUID targetPlayer = getTargetPointer().getFirst(game, source);
if (targetPlayer != null) {
Player player = game.getPlayer(targetPlayer);
if (player != null) {
player.drawCards(3, source, game);
}
}
}
return drawCards;
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class DeniedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell targetSpell = game.getStack().getSpell(source.getFirstTarget());
if (targetSpell == null) {
return true;
}
Player player = game.getPlayer(targetSpell.getControllerId());
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (player != null && cardName != null) {
player.revealCards("Denied!", player.getHand(), game, true);
for (Card card : player.getHand().getCards(game)) {
if (card != null && CardUtil.haveSameNames(card, cardName, game)) {
game.getStack().counter(targetSpell.getId(), source, game);
break;
}
}
return true;
}
return false;
}
use of mage.game.stack.Spell in project mage by magefree.
the class DrainingWhelkEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell targetSpell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
if (targetSpell != null) {
int spellCMC = targetSpell.getManaValue();
super.apply(game, source);
new AddCountersSourceEffect(CounterType.P1P1.createInstance(spellCMC)).apply(game, source);
return true;
}
return false;
}
Aggregations