use of mage.game.permanent.Permanent in project mage by magefree.
the class GlyphOfLifeGainLifeEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getFirstTarget())) {
DamagedEvent damageEvent = (DamagedEvent) event;
Permanent attackingCreature = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
if (attackingCreature != null && attackingCreature.isCreature(game) && attackingCreature.isAttacking()) {
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
return true;
}
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class GoblinArchaeologistEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
if (!player.flipCoin(source, game, true)) {
permanent.sacrifice(source, game);
} else {
Permanent targetArtifact = game.getPermanent(source.getFirstTarget());
targetArtifact.destroy(source, game, true);
permanent.untap(game);
}
return true;
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class GoblinAssassinTriggeredEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<UUID> perms = new ArrayList<>();
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && !player.flipCoin(source, game, false)) {
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
perms.addAll(target.getTargets());
}
}
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
return true;
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class GlimmerpointStagEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
int zcc = permanent.getZoneChangeCounter(game);
controller.moveCards(permanent, Zone.EXILED, source, game);
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setTargetPointer(new FixedTarget(permanent.getId(), zcc + 1));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class GloomwidowsFeastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature != null) {
targetCreature.destroy(source, game, false);
Permanent destroyedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (destroyedCreature.getColor(game).isBlue() || destroyedCreature.getColor(game).isBlack()) {
SpiderToken token = new SpiderToken();
token.putOntoBattlefield(1, game, source, source.getControllerId());
return true;
}
}
return false;
}
Aggregations