mirror of
https://github.com/correl/mage.git
synced 2025-04-12 01:01:04 -09:00
Added Stronghold Gambit.
This commit is contained in:
parent
37db757c4b
commit
fb7d05e82a
2 changed files with 169 additions and 22 deletions
Mage.Sets/src/mage/sets
138
Mage.Sets/src/mage/sets/nemesis/StrongholdGambit.java
Normal file
138
Mage.Sets/src/mage/sets/nemesis/StrongholdGambit.java
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.nemesis;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class StrongholdGambit extends CardImpl {
|
||||
|
||||
public StrongholdGambit(UUID ownerId) {
|
||||
super(ownerId, 100, "Stronghold Gambit", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{1}{R}");
|
||||
this.expansionSetCode = "NMS";
|
||||
|
||||
// Each player chooses a card in his or her hand. Then each player reveals his or her chosen card. The owner of each creature card revealed this way with the lowest converted mana cost puts it onto the battlefield.
|
||||
getSpellAbility().addEffect(new StrongholdGambitEffect());
|
||||
}
|
||||
|
||||
public StrongholdGambit(final StrongholdGambit card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StrongholdGambit copy() {
|
||||
return new StrongholdGambit(this);
|
||||
}
|
||||
}
|
||||
|
||||
class StrongholdGambitEffect extends OneShotEffect {
|
||||
|
||||
public StrongholdGambitEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.staticText = "Each player chooses a card in his or her hand. Then each player reveals his or her chosen card. The owner of each creature card revealed this way with the lowest converted mana cost puts it onto the battlefield";
|
||||
}
|
||||
|
||||
public StrongholdGambitEffect(final StrongholdGambitEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StrongholdGambitEffect copy() {
|
||||
return new StrongholdGambitEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
Map<UUID, UUID> choosenCard = new LinkedHashMap<>();
|
||||
for (UUID playerId : game.getState().getPlayerList(controller.getId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.getHand().size() > 0) {
|
||||
TargetCardInHand target = new TargetCardInHand();
|
||||
if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
|
||||
choosenCard.put(playerId, target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
int lowestCMC = Integer.MAX_VALUE;
|
||||
for (UUID playerId : game.getState().getPlayerList(controller.getId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && choosenCard.containsKey(playerId)) {
|
||||
Card card = game.getCard(choosenCard.get(playerId));
|
||||
if (card != null) {
|
||||
Cards cardsToReveal = new CardsImpl(card);
|
||||
player.revealCards(sourceObject.getIdName() + " (" + player.getName() + ")", cardsToReveal, game);
|
||||
if (card.getCardType().contains(CardType.CREATURE)
|
||||
&& lowestCMC > card.getManaCost().convertedManaCost()) {
|
||||
lowestCMC = card.getManaCost().convertedManaCost();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lowestCMC < Integer.MAX_VALUE) {
|
||||
Cards creaturesToBattlefield = new CardsImpl();
|
||||
for (UUID playerId : game.getState().getPlayerList(controller.getId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && choosenCard.containsKey(playerId)) {
|
||||
Card card = game.getCard(choosenCard.get(playerId));
|
||||
if (card != null) {
|
||||
if (card.getCardType().contains(CardType.CREATURE)
|
||||
&& lowestCMC == card.getManaCost().convertedManaCost()) {
|
||||
creaturesToBattlefield.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
controller.moveCards(creaturesToBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -27,21 +27,23 @@
|
|||
*/
|
||||
package mage.sets.shadowmoor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.other.OwnerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
||||
|
@ -55,7 +57,6 @@ public class Worldpurge extends CardImpl {
|
|||
super(ownerId, 156, "Worldpurge", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{W/U}{W/U}{W/U}{W/U}");
|
||||
this.expansionSetCode = "SHM";
|
||||
|
||||
|
||||
// Return all permanents to their owners' hands. Each player chooses up to seven cards in his or her hand, then shuffles the rest into his or her library. Empty all mana pools.
|
||||
this.getSpellAbility().addEffect(new WorldpurgeEffect());
|
||||
|
||||
|
@ -89,29 +90,37 @@ class WorldpurgeEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), source.getControllerId(), source.getSourceId(), game)) {
|
||||
permanent.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
}
|
||||
game.informPlayers("Worldpurge: All permanents returned to owners' hands");
|
||||
for (Player player : game.getPlayers().values()) {
|
||||
if (player != null) {
|
||||
Cards hand = player.getHand();
|
||||
FilterCard filter = new FilterCard("card to keep in hand");
|
||||
filter.add(new OwnerIdPredicate(player.getId()));
|
||||
int numberInHand = Math.min(7, hand.size());
|
||||
TargetCardInHand target = new TargetCardInHand(0, numberInHand, filter);
|
||||
if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
|
||||
for (Card card : hand.getCards(game)) {
|
||||
if (!target.getTargets().contains(card.getId())) {
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
Set<Card> allPermanents = new HashSet<>();
|
||||
allPermanents.addAll(game.getBattlefield().getActivePermanents(new FilterPermanent(), source.getControllerId(), source.getSourceId(), game));
|
||||
controller.moveCards(allPermanents, Zone.HAND, source, game, false, false, true, null);
|
||||
game.informPlayers(sourceObject.getLogName() + " - All permanents returned to owners' hands");
|
||||
|
||||
for (UUID playerId : game.getState().getPlayerList(controller.getId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
Cards hand = player.getHand();
|
||||
int numberInHand = Math.min(7, hand.size());
|
||||
TargetCardInHand target = new TargetCardInHand(0, numberInHand, new FilterCard("cards to keep in hand"));
|
||||
Cards cardsToLibrary = new CardsImpl();
|
||||
if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
|
||||
for (Card card : hand.getCards(game)) {
|
||||
if (!target.getTargets().contains(card.getId())) {
|
||||
cardsToLibrary.add(card);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
player.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false);
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
game.emptyManaPools();
|
||||
game.informPlayers(sourceObject.getLogName() + " - All mana pools have been emptied");
|
||||
return true;
|
||||
}
|
||||
game.emptyManaPools();
|
||||
game.informPlayers("Worldpurge: All mana pools have been emptied");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue