use of mage.abilities.effects.common.continuous.LoseAbilityTargetEffect in project mage by magefree.
the class WalkingSpongeEffect 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) {
ChoiceImpl chooseAbility = new ChoiceImpl();
chooseAbility.setMessage("Choose an ability to remove (default is flying)");
Set<String> choice = new LinkedHashSet<>();
choice.add("Flying");
choice.add("First strike");
choice.add("Trample");
chooseAbility.setChoices(choice);
// since the player can't pick "no ability", let's default to the first option
Ability ability = FlyingAbility.getInstance();
if (controller.choose(Outcome.UnboostCreature, chooseAbility, game)) {
String chosenAbility = chooseAbility.getChoice();
if (chosenAbility.equals("First strike")) {
ability = FirstStrikeAbility.getInstance();
} else if (chosenAbility.equals("Trample")) {
ability = TrampleAbility.getInstance();
}
} else {
return false;
}
game.informPlayers(controller.getLogName() + " has chosen " + ability.getRule());
ContinuousEffect effect = new LoseAbilityTargetEffect(ability, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.LoseAbilityTargetEffect in project mage by magefree.
the class UrborgEffect 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) {
return false;
}
Ability ability;
if (player.chooseUse(Outcome.UnboostCreature, "Which ability should be lost?", null, "First Strike", "Swampwalk", source, game)) {
ability = FirstStrikeAbility.getInstance();
} else {
ability = new SwampwalkAbility();
}
ContinuousEffect effect = new LoseAbilityTargetEffect(ability, Duration.EndOfTurn);
// effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
return true;
}
use of mage.abilities.effects.common.continuous.LoseAbilityTargetEffect in project mage by magefree.
the class BurnFromWithinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
int amount = source.getManaCostsToPay().getX();
if (creature != null) {
game.addEffect(new DiesReplacementEffect(new MageObjectReference(creature, game), Duration.EndOfTurn), source);
int damageDealt = creature.damage(amount, source.getSourceId(), source, game, false, true);
if (damageDealt > 0) {
ContinuousEffect effect = new LoseAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(effect, source);
}
return true;
}
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
targetPlayer.damage(amount, source.getSourceId(), source, game);
return true;
}
}
return false;
}
Aggregations