use of mage.game.permanent.Permanent in project mage by magefree.
the class FigureOfDestinyWarriorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null || !permanent.hasSubtype(SubType.WARRIOR, game)) {
return false;
}
game.addEffect(new AddCardSubTypeSourceEffect(Duration.Custom, SubType.KITHKIN, SubType.SPIRIT, SubType.WARRIOR, SubType.AVATAR), source);
game.addEffect(new SetPowerToughnessSourceEffect(8, 8, Duration.Custom, SubLayer.SetPT_7b), source);
game.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.Custom), source);
game.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.Custom), source);
return true;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class FeySteedTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player targetter = game.getPlayer(event.getPlayerId());
if (targetter == null || !targetter.hasOpponent(this.controllerId, game)) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null || !permanent.isControlledBy(this.getControllerId()) || (!permanent.isCreature(game) && !permanent.isPlaneswalker(game))) {
return false;
}
return true;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class FiendlashEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanentOrLKIBattlefield((UUID) game.getState().getValue("Fiendlash" + source.getSourceId()));
if (creature == null) {
return false;
}
int damage = creature.getPower().getValue();
if (damage < 1) {
return false;
}
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
if (permanent.isPlaneswalker()) {
permanent.damage(damage, creature.getId(), source, game);
return true;
}
}
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
player.damage(damage, creature.getId(), source, game);
return true;
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class FiendlashEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent equipment = game.getPermanent(this.getSourceId());
if (equipment == null) {
return false;
}
UUID attachedCreature = equipment.getAttachedTo();
if (attachedCreature == null) {
return false;
}
game.getState().setValue("Fiendlash" + equipment.getId(), attachedCreature);
DamagedPermanentBatchEvent dEvent = (DamagedPermanentBatchEvent) event;
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
UUID targetID = damagedEvent.getTargetId();
if (targetID == null) {
continue;
}
if (targetID == attachedCreature) {
return true;
}
}
return false;
}
use of mage.game.permanent.Permanent in project mage by magefree.
the class FriendlyFireEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
Player controllerOfTargetCreature = game.getPlayer(targetCreature.getControllerId());
if (controllerOfTargetCreature != null) {
if (!controllerOfTargetCreature.getHand().isEmpty()) {
Card card = controllerOfTargetCreature.getHand().getRandom(game);
if (card != null) {
Cards cards = new CardsImpl(card);
controllerOfTargetCreature.revealCards(sourceObject.getName(), cards, game);
int damage = card.getManaValue();
targetCreature.damage(damage, source.getSourceId(), source, game, false, true);
controllerOfTargetCreature.damage(damage, source.getSourceId(), source, game);
return true;
}
}
}
}
}
return false;
}
Aggregations