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