use of mage.game.permanent.Permanent in project mage by magefree.
the class GlintHawkEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseUse(outcome, "Return an artifact you control to its owner's hand?", source, game)) {
controller.chooseTarget(Outcome.ReturnToHand, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
controller.moveCards(permanent, Zone.HAND, source, game);
return true;
}
}
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
return permanent != null && permanent.sacrifice(source, game);
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class GlissaSunseekerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (controller == null || permanent == null) {
return false;
}
ManaPool pool = controller.getManaPool();
int blackMana = pool.getBlack();
int whiteMana = pool.getWhite();
int blueMana = pool.getBlue();
int greenMana = pool.getGreen();
int redMana = pool.getRed();
int colorlessMana = pool.getColorless();
int manaPoolTotal = blackMana + whiteMana + blueMana + greenMana + redMana + colorlessMana;
if (permanent.getManaValue() == manaPoolTotal) {
return permanent.destroy(source, game, false);
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class GoblinBombEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
if (controller.flipCoin(source, game, true)) {
game.informPlayers("Goblin Bomb: Won flip. Put a fuse counter on Goblin Bomb.");
new AddCountersSourceEffect(CounterType.FUSE.createInstance(1)).apply(game, source);
return true;
} else {
game.informPlayers("Goblin Bomb: Lost flip. Remove a fuse counter from Goblin Bomb.");
new RemoveCounterSourceEffect(CounterType.FUSE.createInstance(1)).apply(game, source);
return true;
}
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class GloomlanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
Player targetController = game.getPlayer(targetCreature.getControllerId());
targetCreature.destroy(source, game, false);
Permanent destroyedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (destroyedCreature.getColor(game).isGreen() || destroyedCreature.getColor(game).isWhite()) {
if (targetController != null) {
targetController.discard(1, false, false, source, game);
return true;
}
}
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class HatefulEidolonTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int auraCount = 0;
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent()) {
return false;
}
Permanent deadCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (deadCreature.getAttachments().isEmpty()) {
return false;
}
for (UUID auraId : deadCreature.getAttachments()) {
Permanent attachment = game.getPermanentOrLKIBattlefield(auraId);
if (attachment.getControllerId().equals(controllerId) && attachment.isEnchantment(game)) {
// Shadowspear or any other equipment does not count
auraCount += 1;
}
}
if (auraCount == 0) {
// just equipment not aura's
return false;
}
Player controller = game.getPlayer(controllerId);
if (controller != null && controller.canRespond()) {
this.getEffects().clear();
DrawCardTargetEffect drawCard = new DrawCardTargetEffect(auraCount);
drawCard.setTargetPointer(new FixedTarget(controllerId));
this.addEffect(drawCard);
return true;
}
return false;
}
Aggregations