[NCC] Implement Master of Ceremonies (#9186)

This commit is contained in:
Alex Vasile 2022-07-04 22:22:57 -04:00 committed by GitHub
parent 25e3c62eee
commit 7dd6b03a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 150 additions and 0 deletions

View file

@ -0,0 +1,149 @@
package mage.cards.m;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.choices.VoteHandler;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.game.Game;
import mage.game.permanent.token.CitizenGreenWhiteToken;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.TreasureToken;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import java.util.*;
/**
* @author Alex-Vasile
*/
public class MasterOfCeremonies extends CardImpl {
public MasterOfCeremonies(UUID ownderId, CardSetInfo setInfo) {
super(ownderId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}");
this.subtype.add(SubType.RHINO);
this.subtype.add(SubType.DRUID);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// At the beginning of your upkeep, each opponent chooses money, friends, or secrets.
// For each player who chose money, you and that player each create a Treasure token.
// For each player who chose friends, you and that player each create a 1/1 green and white Citizen creature token.
// For each player who chose secrets, you and that player each draw a card.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
new MasterOfCeremoniesChoiceEffect(),
TargetController.YOU,
false)
);
}
private MasterOfCeremonies(final MasterOfCeremonies card) {
super(card);
}
@Override
public MasterOfCeremonies copy() {
return new MasterOfCeremonies(this);
}
}
class MasterOfCeremoniesChoiceEffect extends OneShotEffect {
MasterOfCeremoniesChoiceEffect() {
super(Outcome.Benefit);
this.staticText = "each opponent chooses money, friends, or secrets. " +
"For each player who chose money, you and that player each create a Treasure token. " +
"For each player who chose friends, you and that player each create a 1/1 green and white Citizen creature token. " +
"For each player who chose secrets, you and that player each draw a card.";
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
HashSet<UUID> moneyChoosers = new HashSet<>();
HashSet<UUID> friendChoosers = new HashSet<>();
HashSet<UUID> secretsChoosers = new HashSet<>();
// Get opponents choices
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent == null) {
continue;
}
Choice choice = new ChoiceImpl(true);
choice.getChoices().add("Money");
choice.getChoices().add("Friends");
choice.getChoices().add("Secrets");
if (opponent.choose(Outcome.Neutral, choice, game)) {
game.informPlayers(opponent.getLogName() + " chooses " + choice.getChoice());
switch (choice.getChoice()) {
case "Money":
moneyChoosers.add(opponentId);
break;
case "Friends":
friendChoosers.add(opponentId);
break;
case "Secrets":
secretsChoosers.add(opponentId);
break;
}
}
}
// Money - You and that player each create a Treasure token.
for (UUID opponentId : moneyChoosers) {
Token treasureController = new TreasureToken();
treasureController.putOntoBattlefield(1, game, source, controller.getId());
Token treasureOpponent = new TreasureToken();
treasureOpponent.putOntoBattlefield(1, game, source, opponentId);
}
// Friends - You and that player each create a 1/1 green and white Citizen creature token.
for (UUID opponentId : friendChoosers) {
Token citizenOwner = new CitizenGreenWhiteToken();
citizenOwner.putOntoBattlefield(1, game, source, opponentId);
Token citizenOpponent = new CitizenGreenWhiteToken();
citizenOpponent.putOntoBattlefield(1, game, source, opponentId);
}
// Secrets - You and that player each draw a card.
for (UUID opponentId : secretsChoosers) {
Effect drawEffectController = new DrawCardTargetEffect(1);
drawEffectController.setTargetPointer(new FixedTarget(controller.getId()));
drawEffectController.apply(game, source);
Effect drawEffectOpponent = new DrawCardTargetEffect(1);
drawEffectOpponent.setTargetPointer(new FixedTarget(opponentId));
drawEffectOpponent.apply(game, source);
}
return true;
}
private MasterOfCeremoniesChoiceEffect(final MasterOfCeremoniesChoiceEffect effect) {
super(effect);
}
@Override
public MasterOfCeremoniesChoiceEffect copy() {
return new MasterOfCeremoniesChoiceEffect(this);
}
}

View file

@ -197,6 +197,7 @@ public final class NewCapennaCommander extends ExpansionSet {
cards.add(new SetCardInfo("Martial Coup", 206, Rarity.RARE, mage.cards.m.MartialCoup.class));
cards.add(new SetCardInfo("Mask of Riddles", 347, Rarity.UNCOMMON, mage.cards.m.MaskOfRiddles.class));
cards.add(new SetCardInfo("Mask of the Schemer", 28, Rarity.RARE, mage.cards.m.MaskOfTheSchemer.class));
cards.add(new SetCardInfo("Master of Ceremonies", 18, Rarity.RARE, mage.cards.m.MasterOfCeremonies.class));
cards.add(new SetCardInfo("Mezzio Mugger", 49, Rarity.RARE, mage.cards.m.MezzioMugger.class));
cards.add(new SetCardInfo("Midnight Clock", 226, Rarity.RARE, mage.cards.m.MidnightClock.class));
cards.add(new SetCardInfo("Migration Path", 301, Rarity.UNCOMMON, mage.cards.m.MigrationPath.class));