use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class ChainStasisEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
Effect effect = new MayTapOrUntapTargetEffect();
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
effect.apply(game, source);
Player player = game.getPlayer(permanent.getControllerId());
if (player == null) {
return false;
}
Cost cost = new ManaCostsImpl("{2}{U}");
if (cost.pay(source, game, source, controller.getId(), false)) {
if (player.chooseUse(outcome, "Copy the spell?", source, game)) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
spell.createCopyOnStack(game, source, player.getId(), true);
}
}
}
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class ChainLightningEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID targetId = source.getFirstTarget();
Player affectedPlayer = null;
Player player = game.getPlayer(targetId);
if (player != null) {
player.damage(3, source.getSourceId(), source, game);
affectedPlayer = player;
} else {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.damage(3, source.getSourceId(), source, game, false, true);
affectedPlayer = game.getPlayer(permanent.getControllerId());
}
}
if (affectedPlayer != null) {
if (affectedPlayer.chooseUse(Outcome.Copy, "Pay {R}{R} to copy the spell?", source, game)) {
Cost cost = new ManaCostsImpl("{R}{R}");
if (cost.pay(source, game, source, affectedPlayer.getId(), false, null)) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
spell.createCopyOnStack(game, source, affectedPlayer.getId(), true);
}
}
}
return true;
}
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class DimirDoppelgangerCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DimirDoppelgangerEffect(), new ManaCostsImpl("{1}{U}{B}"));
ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
blueprint.getAbilities().add(ability);
return true;
}
Aggregations