[CMR] Implemented Wheel of Misfortune

This commit is contained in:
Evan Kranzler 2020-11-07 15:55:23 -05:00
parent 5c865eaa9d
commit b73d3d5ccd
2 changed files with 94 additions and 0 deletions

View file

@ -0,0 +1,93 @@
package mage.cards.w;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class WheelOfMisfortune extends CardImpl {
public WheelOfMisfortune(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}");
// Each player secretly chooses a number 0 or greater, then all players reveal those numbers simultaneously and determine the highest and lowest numbers revealed this way. Wheel of Misfortune deals damage equal to the highest number to each player who chose that number. Each player who didn't choose the lowest number discards their hand, then draws seven cards.
this.getSpellAbility().addEffect(new WheelOfMisfortuneEffect());
}
private WheelOfMisfortune(final WheelOfMisfortune card) {
super(card);
}
@Override
public WheelOfMisfortune copy() {
return new WheelOfMisfortune(this);
}
}
class WheelOfMisfortuneEffect extends OneShotEffect {
WheelOfMisfortuneEffect() {
super(Outcome.Benefit);
staticText = "Each player secretly chooses a number 0 or greater, " +
"then all players reveal those numbers simultaneously " +
"and determine the highest and lowest numbers revealed this way. " +
"{this} deals damage equal to the highest number to each player who chose that number. " +
"Each player who didn't choose the lowest number discards their hand, then draws seven cards.";
}
private WheelOfMisfortuneEffect(final WheelOfMisfortuneEffect effect) {
super(effect);
}
@Override
public WheelOfMisfortuneEffect copy() {
return new WheelOfMisfortuneEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Map<UUID, Integer> playerMap = new HashMap<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
playerMap.put(playerId, player.getAmount(0, 1000, "Choose a number", game));
}
for (Map.Entry<UUID, Integer> entry : playerMap.entrySet()) {
Player player = game.getPlayer(entry.getKey());
if (player == null) {
continue;
}
game.informPlayers(player.getName() + " chose " + playerMap);
}
int maxValue = playerMap.values().stream().mapToInt(x -> x).max().orElse(0);
game.informPlayers("The highest number chosen was " + maxValue);
int minValue = playerMap.values().stream().mapToInt(x -> x).min().orElse(0);
game.informPlayers("The lowest number chosen was " + maxValue);
for (Map.Entry<UUID, Integer> entry : playerMap.entrySet()) {
Player player = game.getPlayer(entry.getKey());
if (player == null) {
continue;
}
if (entry.getValue() >= maxValue) {
player.damage(maxValue, source.getSourceId(), game);
} else if (entry.getValue() > minValue) {
player.discard(player.getHand(), source, game);
player.drawCards(7, source.getSourceId(), game);
}
}
return true;
}
}

View file

@ -514,6 +514,7 @@ public final class CommanderLegends extends ExpansionSet {
cards.add(new SetCardInfo("Warden of Evos Isle", 106, Rarity.UNCOMMON, mage.cards.w.WardenOfEvosIsle.class));
cards.add(new SetCardInfo("Wear // Tear", 456, Rarity.UNCOMMON, mage.cards.w.WearTear.class));
cards.add(new SetCardInfo("Welding Sparks", 210, Rarity.COMMON, mage.cards.w.WeldingSparks.class));
cards.add(new SetCardInfo("Wheel of Misfortune", 211, Rarity.RARE, mage.cards.w.WheelOfMisfortune.class));
cards.add(new SetCardInfo("Whelming Wave", 409, Rarity.RARE, mage.cards.w.WhelmingWave.class));
cards.add(new SetCardInfo("White Sun's Zenith", 391, Rarity.RARE, mage.cards.w.WhiteSunsZenith.class));
cards.add(new SetCardInfo("Wickerbough Elder", 440, Rarity.COMMON, mage.cards.w.WickerboughElder.class));