use of mage.players.Player in project mage by magefree.
the class DeflectingPalmEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
PreventionEffectData preventionData = preventDamageAction(event, source, game);
this.used = true;
// only one use
this.discard();
if (preventionData.getPreventedDamage() > 0) {
MageObject damageDealingObject = game.getObject(target.getFirstTarget());
UUID objectControllerId = null;
if (damageDealingObject instanceof Permanent) {
objectControllerId = ((Permanent) damageDealingObject).getControllerId();
} else if (damageDealingObject instanceof Ability) {
objectControllerId = ((Ability) damageDealingObject).getControllerId();
} else if (damageDealingObject instanceof Spell) {
objectControllerId = ((Spell) damageDealingObject).getControllerId();
}
if (objectControllerId != null) {
Player objectController = game.getPlayer(objectControllerId);
if (objectController != null) {
objectController.damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game);
}
}
}
return true;
}
use of mage.players.Player in project mage by magefree.
the class DelifsConePreventEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (player != null || permanent != null) {
player.gainLife(permanent.getPower().getValue(), game, source);
return true;
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class DeliriumEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(source.getFirstTarget());
if (creature != null) {
int amount = creature.getPower().getValue();
Player controller = game.getPlayer(creature.getControllerId());
if (controller != null) {
controller.damage(amount, creature.getId(), source, game);
return true;
}
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class DemilichPlayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(targetPointer.getFirst(game, source));
if (controller == null || card == null) {
return false;
}
controller.moveCards(card, Zone.EXILED, source, game);
if (controller.chooseUse(outcome, "Cast copy of " + card.getName() + '?', source, game)) {
Card copiedCard = game.copyCard(card, source, controller.getId());
game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(copiedCard, game, false), game, false, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), null);
}
return true;
}
use of mage.players.Player in project mage by magefree.
the class DemilichPlayEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (source.getSourceId().equals(objectId) && source.isControlledBy(affectedControllerId) && game.getState().getZone(objectId) == Zone.GRAVEYARD) {
Player controller = game.getPlayer(affectedControllerId);
if (controller != null) {
Costs<Cost> costs = new CostsImpl<>();
costs.add(new ExileFromGraveCost(new TargetCardInYourGraveyard(4, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY_FROM_YOUR_GRAVEYARD)));
controller.setCastSourceIdWithAlternateMana(objectId, new ManaCostsImpl<>("{U}{U}{U}{U}"), costs);
return true;
}
}
return false;
}
Aggregations