fix #11353 (InvestigateTargetEffect)

add some test cases
This commit is contained in:
xenohedron 2023-10-28 15:17:21 -04:00
parent 9733786e5d
commit ad66b91642
9 changed files with 167 additions and 59 deletions

View file

@ -1,7 +1,6 @@
package mage.abilities.effects.keyword;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
@ -29,6 +28,7 @@ public class InvestigateEffect extends OneShotEffect {
public InvestigateEffect(DynamicValue amount) {
super(Outcome.Benefit);
this.amount = amount;
this.staticText = makeText();
}
protected InvestigateEffect(final InvestigateEffect effect) {
@ -54,11 +54,7 @@ public class InvestigateEffect extends OneShotEffect {
return new InvestigateEffect(this);
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
private String makeText() {
String message;
if (amount instanceof StaticValue) {
int value = ((StaticValue) amount).getValue();
@ -75,7 +71,7 @@ public class InvestigateEffect extends OneShotEffect {
} else {
message = " X times, where X is the " + amount.getMessage() + ". <i>(To investigate, c";
}
return "investigate" + message + "reate a colorless Clue artifact token " +
"with \"{2}, Sacrifice this artifact: Draw a card.\")</i>";
return "investigate" + message + "reate a Clue token. " +
"It's an artifact with \"{2}, Sacrifice this artifact: Draw a card.\")</i>";
}
}

View file

@ -0,0 +1,68 @@
package mage.abilities.effects.keyword;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.token.ClueArtifactToken;
import mage.players.Player;
/**
* @author LevelX2
*/
public class InvestigateTargetEffect extends OneShotEffect {
private final DynamicValue amount;
public InvestigateTargetEffect() {
this(1);
}
public InvestigateTargetEffect(int amount) {
this(StaticValue.get(amount));
}
public InvestigateTargetEffect(DynamicValue amount) {
super(Outcome.Benefit);
this.amount = amount;
}
protected InvestigateTargetEffect(final InvestigateTargetEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer == null) {
return false;
}
int value = this.amount.calculate(game, source, this);
if (value < 1) {
return false;
}
new ClueArtifactToken().putOntoBattlefield(value, game, source, targetPlayer.getId());
for (int i = 0; i < value; i++) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.INVESTIGATED, source.getSourceId(), source, targetPlayer.getId()));
}
return true;
}
@Override
public InvestigateTargetEffect copy() {
return new InvestigateTargetEffect(this);
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return getTargetPointer().describeTargets(mode.getTargets(), "that player") + " investigates";
}
}

View file

@ -84,7 +84,7 @@ public class GameEvent implements Serializable {
playerId controller of the card
*/
MADNESS_CARD_EXILED,
INVESTIGATED,
INVESTIGATED, // playerId is the player who investigated
KICKED,
/* CONVOKED
targetId id of the creature that was taped to convoke the sourceId