use of mage.game.permanent.Permanent in project mage by magefree.
the class KaervekTheMercilessEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
if (spell != null) {
int cost = spell.getManaValue();
Player target = game.getPlayer(source.getFirstTarget());
if (target != null) {
target.damage(cost, source.getSourceId(), source, game);
return true;
}
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature != null) {
targetCreature.damage(cost, source.getSourceId(), source, game, false, true);
return true;
}
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class JumboImpRemoveCountersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) {
int amount = controller.rollDice(outcome, source, game, 6);
// the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game, appliedEffects);
return super.apply(game, source);
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class JumpTrooperTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
Permanent creature = game.getPermanent(event.getTargetId());
if (creature != null && filter.match(creature, getSourceId(), getControllerId(), game)) {
this.getTargets().clear();
TargetStackObject target = new TargetStackObject();
target.add(event.getSourceId(), game);
this.addTarget(target);
return true;
}
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class KusariGamaDamageEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent sourcePermanet = game.getPermanent(event.getSourceId());
Permanent targetPermanet = game.getPermanent(event.getTargetId());
if (sourcePermanet != null && targetPermanet != null && sourcePermanet.getAttachments().contains(this.getSourceId()) && filter.match(targetPermanet, game)) {
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
this.getEffects().get(0).setValue("damagedCreatureId", targetPermanet.getId());
return true;
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class KrothussLordOfTheDeepEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
int count = permanent.hasSubtype(SubType.KRAKEN, game) || permanent.hasSubtype(SubType.LEVIATHAN, game) || permanent.hasSubtype(SubType.OCTOPUS, game) || permanent.hasSubtype(SubType.SERPENT, game) ? 2 : 1;
return new CreateTokenCopyTargetEffect(null, null, false, count, true, true).apply(game, source);
}
Aggregations