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();
}
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();
}
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);
}
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());
}
}
}
}
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);
}
}
}
}
Aggregations