[LCI] Implement Jadelight Spelunker

This commit is contained in:
Susucre 2023-10-26 12:22:18 +02:00
parent 18c6596cc0
commit 1a205ff193
6 changed files with 94 additions and 29 deletions

View file

@ -1,6 +1,8 @@
package mage.abilities.effects.keyword;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardsImpl;
@ -19,6 +21,8 @@ import java.util.UUID;
*/
public class ExploreSourceEffect extends OneShotEffect {
private final DynamicValue amount;
private static final String REMINDER_TEXT = ". <i>(Reveal the top card of your library. "
+ "Put that card into your hand if it's a land. Otherwise, put a +1/+1 counter on "
+ "this creature, then put the card back or put it into your graveyard.)</i>";
@ -28,13 +32,24 @@ public class ExploreSourceEffect extends OneShotEffect {
}
public ExploreSourceEffect(boolean showAbilityHint, String explorerText) {
this(1, showAbilityHint, explorerText);
}
public ExploreSourceEffect(int amount, boolean showAbilityHint, String explorerText) {
this(StaticValue.get(amount), showAbilityHint, explorerText);
}
public ExploreSourceEffect(DynamicValue amount, boolean showAbilityHint, String explorerText) {
super(Outcome.Benefit);
this.amount = amount;
// triggered ability text gen will replace {this} with "it" where applicable
staticText = "{this} explores" + (showAbilityHint ? REMINDER_TEXT : "");
staticText = explorerText + " explores" + (showAbilityHint ? REMINDER_TEXT : "");
}
protected ExploreSourceEffect(final ExploreSourceEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
@ -44,33 +59,36 @@ public class ExploreSourceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
return explorePermanent(game, source.getSourceId(), source);
return explorePermanent(game, source.getSourceId(), source, this.amount.calculate(game, source, this));
}
public static boolean explorePermanent(Game game, UUID permanentId, Ability source) {
public static boolean explorePermanent(Game game, UUID permanentId, Ability source, int amount) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId);
if (controller == null || permanent == null) {
if (controller == null || permanent == null || amount <= 0) {
return false;
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EXPLORED, permanentId, source, permanent.getControllerId()));
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.revealCards("Explored card", new CardsImpl(card), game);
if (card.isLand(game)) {
controller.moveCards(card, Zone.HAND, source, game);
} else {
addCounter(game, permanent, source);
if (controller.chooseUse(Outcome.Neutral, "Put " + card.getLogName() + " in your graveyard?", source, game)) {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
for (int i = 0; i < amount; ++i) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EXPLORED, permanentId, source, permanent.getControllerId()));
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.revealCards("Explored card", new CardsImpl(card), game);
if (card.isLand(game)) {
controller.moveCards(card, Zone.HAND, source, game);
} else {
game.informPlayers(controller.getLogName() + " leaves " + card.getLogName() + " on top of their library.");
addCounter(game, permanent, source);
if (controller.chooseUse(Outcome.Neutral, "Put " + card.getLogName() + " in your graveyard?", source, game)) {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
} else {
game.informPlayers(controller.getLogName() + " leaves " + card.getLogName() + " on top of their library.");
}
}
} else {
// If no card is revealed, most likely because that player's library is empty,
// the exploring creature receives a +1/+1 counter.
addCounter(game, permanent, source);
}
} else {
// If no card is revealed, most likely because that player's library is empty,
// the exploring creature receives a +1/+1 counter.
addCounter(game, permanent, source);
}
return true;
}

View file

@ -38,7 +38,7 @@ public class ExploreTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
return ExploreSourceEffect.explorePermanent(game, getTargetPointer().getFirst(game, source), source);
return ExploreSourceEffect.explorePermanent(game, getTargetPointer().getFirst(game, source), source, 1);
}
@Override
@ -47,7 +47,7 @@ public class ExploreTargetEffect extends OneShotEffect {
return staticText;
}
return getTargetPointer().describeTargets(mode.getTargets(), "it")
+ " explores" + (withReminderText ? REMINDER_TEXT : "") ;
+ " explores" + (withReminderText ? REMINDER_TEXT : "");
}
}