Search in sources :

Example 36 with Target

use of mage.target.Target in project mage by magefree.

the class PutOnLibraryTargetEffect method getText.

@Override
public String getText(Mode mode) {
    if (this.staticText != null && !this.staticText.isEmpty()) {
        return staticText;
    }
    StringBuilder sb = new StringBuilder();
    Target target = mode.getTargets().get(0);
    sb.append("put ");
    if (target.getMaxNumberOfTargets() == 0 || target.getMaxNumberOfTargets() == Integer.MAX_VALUE) {
        sb.append("any number of ");
    } else if (target.getMaxNumberOfTargets() != 1 || target.getNumberOfTargets() != 1) {
        if (target.getMaxNumberOfTargets() > target.getNumberOfTargets()) {
            sb.append("up to ");
        }
        sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(' ');
    }
    sb.append("target ").append(mode.getTargets().get(0).getTargetName()).append(" on ");
    sb.append(onTop ? "top" : "the bottom").append(" of ").append(mode.getTargets().get(0) instanceof TargetCardInYourGraveyard ? "your" : "its owner's").append(" library");
    return sb.toString();
}
Also used : Target(mage.target.Target) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 37 with Target

use of mage.target.Target in project mage by magefree.

the class RegenerateTargetEffect method getText.

@Override
public String getText(Mode mode) {
    if (staticText != null && !staticText.isEmpty()) {
        return staticText;
    }
    StringBuilder sb = new StringBuilder();
    sb.append("Regenerate ");
    Target target = mode.getTargets().get(0);
    if (target != null) {
        if (!target.getTargetName().toLowerCase(Locale.ENGLISH).startsWith("another")) {
            sb.append("target ");
        }
        sb.append(target.getTargetName());
    }
    return sb.toString();
}
Also used : Target(mage.target.Target)

Example 38 with Target

use of mage.target.Target in project mage by magefree.

the class PopulateEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Target target = new TargetPermanent(filter);
    target.setNotTarget(true);
    if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
        return true;
    }
    player.choose(Outcome.Copy, target, source.getSourceId(), game);
    Permanent tokenToCopy = game.getPermanent(target.getFirstTarget());
    if (tokenToCopy == null) {
        return true;
    }
    game.informPlayers("Token selected for populate: " + tokenToCopy.getLogName());
    Effect effect = new CreateTokenCopyTargetEffect(null, null, false, 1, tappedAndAttacking, tappedAndAttacking);
    effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) TargetPermanent(mage.target.TargetPermanent)

Example 39 with Target

use of mage.target.Target in project mage by magefree.

the class PreventDamageToTargetMultiAmountEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    Target target = source.getTargets().get(0);
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (target instanceof TargetAmount && sourceObject != null) {
        TargetAmount multiTarget = (TargetAmount) target;
        for (UUID targetId : multiTarget.getTargets()) {
            Player player = null;
            Permanent permanent = game.getPermanent(targetId);
            if (permanent == null) {
                player = game.getPlayer(targetId);
            }
            targetAmountMap.put(targetId, multiTarget.getTargetAmount(targetId));
            if (!game.isSimulation()) {
                StringBuilder sb = new StringBuilder(sourceObject.getName()).append(": Prevent the next ");
                sb.append(multiTarget.getTargetAmount(targetId)).append(" damage to ");
                if (player != null) {
                    sb.append(player.getLogName());
                } else if (permanent != null) {
                    sb.append(permanent.getName());
                }
                game.informPlayers(sb.toString());
            }
        }
    }
}
Also used : Target(mage.target.Target) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) UUID(java.util.UUID) TargetAmount(mage.target.TargetAmount)

Example 40 with Target

use of mage.target.Target in project mage by magefree.

the class ImproviseEffect method addSpecialAction.

@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
    Player controller = game.getPlayer(source.getControllerId());
    int canPayCount = untappedCount.calculate(game, source, null);
    if (controller != null && canPayCount > 0) {
        if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) {
            SpecialAction specialAction = new ImproviseSpecialAction(unpaid, this);
            specialAction.setControllerId(source.getControllerId());
            specialAction.setSourceId(source.getSourceId());
            // create filter for possible artifacts to tap
            Target target = new TargetControlledPermanent(1, unpaid.getMana().getGeneric(), filterUntapped, true);
            target.setTargetName("artifact to tap as Improvise's pay");
            specialAction.addTarget(target);
            if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
                game.getState().getSpecialActions().add(specialAction);
            }
        }
    }
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) SpecialAction(mage.abilities.SpecialAction) Target(mage.target.Target) ValueHint(mage.abilities.hint.ValueHint)

Aggregations

Target (mage.target.Target)385 Player (mage.players.Player)291 Permanent (mage.game.permanent.Permanent)223 UUID (java.util.UUID)155 Card (mage.cards.Card)86 TargetPermanent (mage.target.TargetPermanent)80 FilterCard (mage.filter.FilterCard)62 FilterPermanent (mage.filter.FilterPermanent)56 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)54 FixedTarget (mage.target.targetpointer.FixedTarget)49 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)45 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)45 MageObject (mage.MageObject)43 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)42 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)38 TargetOpponent (mage.target.common.TargetOpponent)35 CardsImpl (mage.cards.CardsImpl)32 ArrayList (java.util.ArrayList)31 ContinuousEffect (mage.abilities.effects.ContinuousEffect)31 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)30