mirror of
https://github.com/correl/mage.git
synced 2024-11-14 11:09:31 +00:00
[LTC] Implement Cirdan, the Shipwright
This commit is contained in:
parent
6852d9a6fc
commit
3404a34b2d
4 changed files with 157 additions and 4 deletions
138
Mage.Sets/src/mage/cards/c/CirdanTheShipwright.java
Normal file
138
Mage.Sets/src/mage/cards/c/CirdanTheShipwright.java
Normal file
|
@ -0,0 +1,138 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.choices.VoteHandler;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class CirdanTheShipwright extends CardImpl {
|
||||
|
||||
public CirdanTheShipwright(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{U}");
|
||||
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.ELF);
|
||||
this.subtype.add(SubType.NOBLE);
|
||||
this.power = new MageInt(3);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
// Vigilance
|
||||
this.addAbility(VigilanceAbility.getInstance());
|
||||
|
||||
// Secret council -- Whenever Cirdan the Shipwright enters the battlefield or attacks, each player secretly votes for a player, then those votes are revealed. Each player draws a card for each vote they received. Each player who received no votes may put a permanent card from their hand onto the battlefield.
|
||||
this.addAbility(new EntersBattlefieldOrAttacksSourceTriggeredAbility(new CirdanTheShipwrightEffect()).setAbilityWord(AbilityWord.SECRET_COUNCIL));
|
||||
}
|
||||
|
||||
private CirdanTheShipwright(final CirdanTheShipwright card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CirdanTheShipwright copy() {
|
||||
return new CirdanTheShipwright(this);
|
||||
}
|
||||
}
|
||||
|
||||
class CirdanTheShipwrightEffect extends OneShotEffect {
|
||||
|
||||
CirdanTheShipwrightEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "each player secretly votes for a player, then those votes are revealed. " +
|
||||
"Each player draws a card for each vote they received. " +
|
||||
"Each player who received no votes may put a permanent card from their hand onto the battlefield";
|
||||
}
|
||||
|
||||
private CirdanTheShipwrightEffect(final CirdanTheShipwrightEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CirdanTheShipwrightEffect copy() {
|
||||
return new CirdanTheShipwrightEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
CirdanTheShipwrightVote vote = new CirdanTheShipwrightVote();
|
||||
vote.doVotes(source, game);
|
||||
Map<UUID, Integer> playerMap = vote.getVotesPerPlayer(game);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
int amount = playerMap.getOrDefault(playerId, 0);
|
||||
if (player != null && amount > 0) {
|
||||
player.drawCards(amount, source, game);
|
||||
}
|
||||
}
|
||||
Map<Player, Card> voteless = new HashMap<>();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !playerMap.containsKey(playerId)) {
|
||||
TargetCard target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_PERMANENT);
|
||||
target.withChooseHint("to put onto the battlefield");
|
||||
player.choose(outcome, player.getHand(), target, source, game);
|
||||
voteless.put(player, game.getCard(target.getFirstTarget()));
|
||||
}
|
||||
}
|
||||
for (Map.Entry<Player, Card> entry : voteless.entrySet()) {
|
||||
if (entry.getValue() != null) {
|
||||
entry.getKey().moveCards(entry.getValue(), Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class CirdanTheShipwrightVote extends VoteHandler<Player> {
|
||||
|
||||
@Override
|
||||
protected Set<Player> getPossibleVotes(Ability source, Game game) {
|
||||
return game
|
||||
.getState()
|
||||
.getPlayersInRange(source.getControllerId(), game)
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Player playerChoose(String voteInfo, Player player, Player decidingPlayer, Ability source, Game game) {
|
||||
TargetPlayer target = new TargetPlayer();
|
||||
target.setNotTarget(true);
|
||||
target.withChooseHint("to vote for");
|
||||
decidingPlayer.choose(Outcome.Benefit, target, source, game);
|
||||
return game.getPlayer(target.getFirstTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String voteName(Player vote) {
|
||||
return vote.getName();
|
||||
}
|
||||
|
||||
Map<UUID, Integer> getVotesPerPlayer(Game game) {
|
||||
return playerMap
|
||||
.values()
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toMap(MageItem::getId, x -> 1, Integer::sum));
|
||||
}
|
||||
}
|
|
@ -48,6 +48,7 @@ public final class TalesOfMiddleEarthCommander extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Cavern of Souls", 362, Rarity.MYTHIC, mage.cards.c.CavernOfSouls.class));
|
||||
cards.add(new SetCardInfo("Choked Estuary", 299, Rarity.RARE, mage.cards.c.ChokedEstuary.class));
|
||||
cards.add(new SetCardInfo("Chromatic Lantern", 275, Rarity.RARE, mage.cards.c.ChromaticLantern.class));
|
||||
cards.add(new SetCardInfo("Cirdan the Shipwright", 50, Rarity.RARE, mage.cards.c.CirdanTheShipwright.class));
|
||||
cards.add(new SetCardInfo("Clifftop Retreat", 300, Rarity.RARE, mage.cards.c.ClifftopRetreat.class));
|
||||
cards.add(new SetCardInfo("Cloudstone Curio", 349, Rarity.MYTHIC, mage.cards.c.CloudstoneCurio.class));
|
||||
cards.add(new SetCardInfo("Colossal Whale", 186, Rarity.RARE, mage.cards.c.ColossalWhale.class));
|
||||
|
|
|
@ -18,6 +18,7 @@ public abstract class VoteHandler<T> {
|
|||
|
||||
protected final Map<UUID, List<T>> playerMap = new HashMap<>();
|
||||
protected VoteHandlerAI<T> aiVoteHint = null;
|
||||
private boolean secret = false;
|
||||
|
||||
public void doVotes(Ability source, Game game) {
|
||||
doVotes(source, game, null);
|
||||
|
@ -28,6 +29,7 @@ public abstract class VoteHandler<T> {
|
|||
this.playerMap.clear();
|
||||
int stepCurrent = 0;
|
||||
int stepTotal = game.getState().getPlayersInRange(source.getControllerId(), game).size();
|
||||
List<String> messages = new ArrayList<>();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
stepCurrent++;
|
||||
VoteEvent event = new VoteEvent(playerId, source);
|
||||
|
@ -70,18 +72,25 @@ public abstract class VoteHandler<T> {
|
|||
if (!Objects.equals(player, decidingPlayer)) {
|
||||
message += " (chosen by " + decidingPlayer.getName() + ')';
|
||||
}
|
||||
game.informPlayers(message);
|
||||
if (secret) {
|
||||
messages.add(message);
|
||||
} else {
|
||||
game.informPlayers(message);
|
||||
}
|
||||
this.playerMap.computeIfAbsent(playerId, x -> new ArrayList<>()).add(vote);
|
||||
}
|
||||
}
|
||||
|
||||
// show final results to players
|
||||
|
||||
if (secret) {
|
||||
for (String message : messages) {
|
||||
game.informPlayers(message);
|
||||
}
|
||||
}
|
||||
Map<T, Integer> totalVotes = new LinkedHashMap<>();
|
||||
// fill by possible choices
|
||||
this.getPossibleVotes(source, game).forEach(vote -> {
|
||||
totalVotes.putIfAbsent(vote, 0);
|
||||
});
|
||||
this.getPossibleVotes(source, game).forEach(vote -> totalVotes.putIfAbsent(vote, 0));
|
||||
// fill by real choices
|
||||
playerMap.entrySet()
|
||||
.stream()
|
||||
|
@ -180,4 +189,8 @@ public abstract class VoteHandler<T> {
|
|||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public void setSecret(boolean secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ public enum AbilityWord {
|
|||
RAID("Raid"),
|
||||
RALLY("Rally"),
|
||||
REVOLT("Revolt"),
|
||||
SECRET_COUNCIL("Secret council"),
|
||||
SPELL_MASTERY("Spell mastery"),
|
||||
STRIVE("Strive"),
|
||||
SWEEP("Sweep"),
|
||||
|
|
Loading…
Reference in a new issue