mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Fixed AddCountersTargetEffect text for cards with target pointers (#5523)
This commit is contained in:
parent
727165dd3a
commit
0b648343bc
3 changed files with 46 additions and 10 deletions
|
@ -28,7 +28,7 @@ public final class EssenceCapture extends CardImpl {
|
|||
// Put a +1/+1 counter on up to one target creature you control.
|
||||
this.getSpellAbility().addEffect(new AddCountersTargetEffect(
|
||||
CounterType.P1P1.createInstance()
|
||||
).setTargetPointer(new SecondTargetPointer()).setText("Put a +1/+1 counter on up to one target creature you control"));
|
||||
).setTargetPointer(new SecondTargetPointer()));
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(0, 1));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
|
@ -19,8 +16,10 @@ import mage.players.Player;
|
|||
import mage.target.Target;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class AddCountersTargetEffect extends OneShotEffect {
|
||||
|
@ -121,8 +120,8 @@ public class AddCountersTargetEffect extends OneShotEffect {
|
|||
}
|
||||
sb.append(" on ");
|
||||
|
||||
if (!mode.getTargets().isEmpty()) {
|
||||
Target target = mode.getTargets().get(0);
|
||||
Target target = mode.getTargets().getEffectTarget(this.targetPointer);
|
||||
if (target != null) {
|
||||
if (target.getNumberOfTargets() == 0) {
|
||||
sb.append("up to ");
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
|
||||
package mage.target;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FirstTargetPointer;
|
||||
import mage.target.targetpointer.SecondTargetPointer;
|
||||
import mage.target.targetpointer.TargetPointer;
|
||||
import mage.target.targetpointer.ThirdTargetPointer;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -12,11 +16,12 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Targets extends ArrayList<Target> {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Targets.class);
|
||||
|
||||
public Targets() {
|
||||
}
|
||||
|
||||
|
@ -101,7 +106,7 @@ public class Targets extends ArrayList<Target> {
|
|||
* Checks if there are enough targets that can be chosen. Should only be
|
||||
* used for Ability targets since this checks for protection, shroud etc.
|
||||
*
|
||||
* @param sourceId - the target event source
|
||||
* @param sourceId - the target event source
|
||||
* @param sourceControllerId - controller of the target event source
|
||||
* @param game
|
||||
* @return - true if enough valid targets exist
|
||||
|
@ -130,6 +135,38 @@ public class Targets extends ArrayList<Target> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Target getEffectTarget(TargetPointer targetPointer) {
|
||||
boolean proccessed = false;
|
||||
|
||||
if (targetPointer instanceof FirstTargetPointer) {
|
||||
proccessed = true;
|
||||
if (this.size() > 0) {
|
||||
return this.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (targetPointer instanceof SecondTargetPointer) {
|
||||
proccessed = true;
|
||||
if (this.size() > 1) {
|
||||
return this.get(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (targetPointer instanceof ThirdTargetPointer) {
|
||||
proccessed = true;
|
||||
if (this.size() > 2) {
|
||||
return this.get(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!proccessed) {
|
||||
logger.error("Unknown target pointer " + (targetPointer != null ? targetPointer : "null"), new Throwable());
|
||||
// TODO: add other target types?
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Targets copy() {
|
||||
return new Targets(this);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue