mirror of
https://github.com/correl/mage.git
synced 2025-04-11 09:11:12 -09:00
[AFR] Implemented Treasure Chest
This commit is contained in:
parent
841aac30a8
commit
4b8a419d28
3 changed files with 109 additions and 0 deletions
Mage.Sets/src/mage
Mage/src/main/java/mage/util
104
Mage.Sets/src/mage/cards/t/TreasureChest.java
Normal file
104
Mage.Sets/src/mage/cards/t/TreasureChest.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.*;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.token.TreasureToken;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class TreasureChest extends CardImpl {
|
||||
|
||||
public TreasureChest(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
|
||||
|
||||
// {4}, Sacrifice Treasure Chest: Roll a d20.
|
||||
RollDieWithResultTableEffect effect = new RollDieWithResultTableEffect();
|
||||
Ability ability = new SimpleActivatedAbility(effect, new GenericManaCost(4));
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
|
||||
// 1 | Trapped! — You lose 3 life.
|
||||
effect.addTableEntry(1, 1, new LoseLifeSourceControllerEffect(3)
|
||||
.setText(CardUtil.italicizeWithEmDash("Trapped!") + "You lose 3 life"));
|
||||
|
||||
// 2-9 | Create five Treasure tokens.
|
||||
effect.addTableEntry(2, 9, new CreateTokenEffect(new TreasureToken(), 5));
|
||||
|
||||
// 10-19 | You gain 3 life and draw three cards.
|
||||
effect.addTableEntry(
|
||||
10, 19, new GainLifeEffect(3),
|
||||
new DrawCardSourceControllerEffect(3).concatBy("and")
|
||||
);
|
||||
|
||||
// 20 | Search your library for a card. If it's an artifact card you may put it onto the battlefield. Otherwise, put that card into your hand. Then shuffle.
|
||||
effect.addTableEntry(20, 20, new TreasureChestEffect());
|
||||
}
|
||||
|
||||
private TreasureChest(final TreasureChest card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreasureChest copy() {
|
||||
return new TreasureChest(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TreasureChestEffect extends OneShotEffect {
|
||||
|
||||
TreasureChestEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "search your library for a card. If it's an artifact card you may " +
|
||||
"put it onto the battlefield. Otherwise, put that card into your hand. Then shuffle";
|
||||
}
|
||||
|
||||
private TreasureChestEffect(final TreasureChestEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreasureChestEffect copy() {
|
||||
return new TreasureChestEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
player.searchLibrary(target, source, game);
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card == null) {
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
if (CardType.ARTIFACT.getPredicate().apply(card, game) && player.chooseUse(
|
||||
Outcome.PlayForFree, "Put it onto the battlefield or your hand?",
|
||||
null, "Battlefield", "Hand", source, game
|
||||
)) {
|
||||
player.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
} else {
|
||||
player.moveCards(card, Zone.HAND, source, game);
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -120,6 +120,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Tasha's Hideous Laughter", 78, Rarity.RARE, mage.cards.t.TashasHideousLaughter.class));
|
||||
cards.add(new SetCardInfo("The Deck of Many Things", 241, Rarity.MYTHIC, mage.cards.t.TheDeckOfManyThings.class));
|
||||
cards.add(new SetCardInfo("Tiamat", 235, Rarity.MYTHIC, mage.cards.t.Tiamat.class));
|
||||
cards.add(new SetCardInfo("Treasure Chest", 252, Rarity.RARE, mage.cards.t.TreasureChest.class));
|
||||
cards.add(new SetCardInfo("Trelasarra Moon Dancer", 236, Rarity.UNCOMMON, mage.cards.t.TrelasarraMoonDancer.class));
|
||||
cards.add(new SetCardInfo("Varis, Silverymoon Ranger", 209, Rarity.RARE, mage.cards.v.VarisSilverymoonRanger.class));
|
||||
cards.add(new SetCardInfo("Veteran Dungeoneer", 40, Rarity.COMMON, mage.cards.v.VeteranDungeoneer.class));
|
||||
|
|
|
@ -923,6 +923,10 @@ public final class CardUtil {
|
|||
return vowels.contains(text.substring(0, 1)) ? "an " + text : "a " + text;
|
||||
}
|
||||
|
||||
public static String italicizeWithEmDash(String text) {
|
||||
return "<i>" + text + "</i> — ";
|
||||
}
|
||||
|
||||
public static Set<UUID> getAllSelectedTargets(Ability ability, Game game) {
|
||||
return ability.getModes().getSelectedModes()
|
||||
.stream()
|
||||
|
|
Loading…
Add table
Reference in a new issue