Search in sources :

Example 1 with SecondTargetPointer

use of mage.target.targetpointer.SecondTargetPointer in project mage by magefree.

the class DestroyTargetEffect method getText.

@Override
public String getText(Mode mode) {
    if (staticText != null && !staticText.isEmpty()) {
        return staticText;
    }
    StringBuilder sb = new StringBuilder();
    if (mode.getTargets().isEmpty()) {
        // TODO add possibility to specify text with targetPointer usage
        sb.append("destroy that creature");
    } else {
        Target target;
        if (targetPointer instanceof SecondTargetPointer && mode.getTargets().size() > 1) {
            target = mode.getTargets().get(1);
        } else {
            target = mode.getTargets().get(0);
        }
        if (target.getNumberOfTargets() == 1) {
            String targetName = target.getTargetName();
            sb.append("destroy ");
            if (!targetName.startsWith("another")) {
                sb.append("target ");
            }
            sb.append(targetName);
        } else {
            if (target.getMaxNumberOfTargets() == target.getMinNumberOfTargets()) {
                sb.append("destroy ").append(CardUtil.numberToText(target.getNumberOfTargets()));
            } else {
                sb.append("destroy up to ").append(CardUtil.numberToText(target.getMaxNumberOfTargets()));
            }
            sb.append(" target ").append(target.getTargetName());
        }
    }
    if (noRegen) {
        sb.append(". It can't be regenerated");
    }
    return sb.toString();
}
Also used : SecondTargetPointer(mage.target.targetpointer.SecondTargetPointer) Target(mage.target.Target)

Example 2 with SecondTargetPointer

use of mage.target.targetpointer.SecondTargetPointer in project mage by magefree.

the class ExileTargetEffect method getText.

@Override
public String getText(Mode mode) {
    if (staticText != null && !staticText.isEmpty()) {
        return staticText;
    }
    StringBuilder sb = new StringBuilder();
    if (mode.getTargets().isEmpty()) {
        // this will be used if the target is set by target pointer and staticText not set.
        sb.append("exile that permanent");
    } else {
        Target target;
        if (targetPointer instanceof SecondTargetPointer && mode.getTargets().size() > 1) {
            target = mode.getTargets().get(1);
        } else {
            target = mode.getTargets().get(0);
        }
        if (target.getNumberOfTargets() == 1) {
            String targetName = target.getTargetName();
            sb.append("exile ");
            if (!targetName.startsWith("another")) {
                sb.append("target ");
            }
            sb.append(targetName);
        } else if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) {
            sb.append("exile up to ").append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" target ").append(target.getTargetName());
        } else {
            sb.append("exile ").append(CardUtil.numberToText(target.getNumberOfTargets())).append(" target ").append(target.getTargetName());
        }
    }
    return sb.toString();
}
Also used : SecondTargetPointer(mage.target.targetpointer.SecondTargetPointer) Target(mage.target.Target)

Example 3 with SecondTargetPointer

use of mage.target.targetpointer.SecondTargetPointer in project mage by magefree.

the class DrawCardTargetEffect method getText.

@Override
public String getText(Mode mode) {
    if (staticText != null && !staticText.isEmpty()) {
        return staticText;
    }
    StringBuilder sb = new StringBuilder();
    if (!mode.getTargets().isEmpty()) {
        Target target;
        if (targetPointer instanceof SecondTargetPointer && mode.getTargets().size() > 1) {
            target = mode.getTargets().get(1);
        } else {
            target = mode.getTargets().get(0);
        }
        sb.append("target ").append(target.getTargetName());
    } else {
        sb.append("that player");
    }
    if (optional) {
        sb.append(" may draw ");
    } else {
        sb.append(" draws ");
    }
    if (upTo) {
        sb.append("up to ");
    }
    sb.append(CardUtil.numberToText(amount.toString(), "a")).append(" card");
    try {
        if (Integer.parseInt(amount.toString()) > 1) {
            sb.append('s');
        }
    } catch (Exception e) {
        sb.append('s');
    }
    String message = amount.getMessage();
    if (!message.isEmpty()) {
        sb.append(" for each ");
    }
    sb.append(message);
    return sb.toString();
}
Also used : SecondTargetPointer(mage.target.targetpointer.SecondTargetPointer) Target(mage.target.Target)

Example 4 with SecondTargetPointer

use of mage.target.targetpointer.SecondTargetPointer in project mage by magefree.

the class DomineeringWillEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (targetPlayer != null) {
        ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn, targetPlayer.getId());
        effect.setTargetPointer(new SecondTargetPointer());
        effect.setText("Target player gains control of up to three target nonattacking creatures until end of turn");
        game.addEffect(effect, source);
        Effect effect2 = new UntapTargetEffect();
        effect2.setTargetPointer(new SecondTargetPointer());
        effect2.setText("Untap those creatures");
        effect2.apply(game, source);
        RequirementEffect effect3 = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
        effect3.setTargetPointer(new SecondTargetPointer());
        effect3.setText("They block this turn if able");
        game.addEffect(effect3, source);
        return true;
    }
    return false;
}
Also used : SecondTargetPointer(mage.target.targetpointer.SecondTargetPointer) RequirementEffect(mage.abilities.effects.RequirementEffect) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) RequirementEffect(mage.abilities.effects.RequirementEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UntapTargetEffect(mage.abilities.effects.common.UntapTargetEffect) Effect(mage.abilities.effects.Effect) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UntapTargetEffect(mage.abilities.effects.common.UntapTargetEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Aggregations

SecondTargetPointer (mage.target.targetpointer.SecondTargetPointer)4 Target (mage.target.Target)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 RequirementEffect (mage.abilities.effects.RequirementEffect)1 UntapTargetEffect (mage.abilities.effects.common.UntapTargetEffect)1 BlocksIfAbleTargetEffect (mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 Player (mage.players.Player)1 TargetPlayer (mage.target.TargetPlayer)1