mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Implemented Magus of the Balance
This commit is contained in:
parent
fa9e500329
commit
4779b86da8
3 changed files with 205 additions and 3 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.b;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -26,7 +25,7 @@ import java.util.UUID;
|
|||
public final class Balance extends CardImpl {
|
||||
|
||||
public Balance(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{W}");
|
||||
|
||||
// Each player chooses a number of lands he or she controls equal to the number of lands controlled by the player who controls the fewest, then sacrifices the rest. Players discard cards and sacrifice creatures the same way.
|
||||
this.getSpellAbility().addEffect(new BalanceEffect());
|
||||
|
@ -46,7 +45,10 @@ class BalanceEffect extends OneShotEffect {
|
|||
|
||||
BalanceEffect() {
|
||||
super(Outcome.Sacrifice);
|
||||
staticText = "Each player chooses a number of lands he or she controls equal to the number of lands controlled by the player who controls the fewest, then sacrifices the rest. Players sacrifice creatures and discard cards the same way";
|
||||
staticText = "each player chooses a number of lands they control "
|
||||
+ "equal to the number of lands controlled by the player "
|
||||
+ "who controls the fewest, then sacrifices the rest. "
|
||||
+ "Players discard cards and sacrifice creatures the same way";
|
||||
}
|
||||
|
||||
BalanceEffect(final BalanceEffect effect) {
|
||||
|
|
199
Mage.Sets/src/mage/cards/m/MagusOfTheBalance.java
Normal file
199
Mage.Sets/src/mage/cards/m/MagusOfTheBalance.java
Normal file
|
@ -0,0 +1,199 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.SubType;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class MagusOfTheBalance extends CardImpl {
|
||||
|
||||
public MagusOfTheBalance(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
|
||||
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.WIZARD);
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
|
||||
// {4}{W}, {T}, Sacrifice Magus of the Balance: Each player chooses a number of lands they control equal to the number of lands controlled by the player who controls the fewest, then sacrifices the rest. Players discard cards and sacrifice creatures the same way.
|
||||
Ability ability = new SimpleActivatedAbility(
|
||||
new MagusOfTheBalanceEffect(),
|
||||
new ManaCostsImpl("{4}{W}")
|
||||
);
|
||||
ability.addCost(new TapSourceCost());
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public MagusOfTheBalance(final MagusOfTheBalance card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagusOfTheBalance copy() {
|
||||
return new MagusOfTheBalance(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MagusOfTheBalanceEffect extends OneShotEffect {
|
||||
|
||||
MagusOfTheBalanceEffect() {
|
||||
super(Outcome.Sacrifice);
|
||||
staticText = "each player chooses a number of lands they control "
|
||||
+ "equal to the number of lands controlled by the player "
|
||||
+ "who controls the fewest, then sacrifices the rest. "
|
||||
+ "Players discard cards and sacrifice creatures the same way";
|
||||
}
|
||||
|
||||
MagusOfTheBalanceEffect(final MagusOfTheBalanceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagusOfTheBalanceEffect copy() {
|
||||
return new MagusOfTheBalanceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
//Lands
|
||||
int minLand = Integer.MAX_VALUE;
|
||||
Cards landsToSacrifice = new CardsImpl();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
int count = game.getBattlefield().countAll(new FilterControlledLandPermanent(), player.getId(), game);
|
||||
if (count < minLand) {
|
||||
minLand = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(minLand, minLand, new FilterControlledLandPermanent("lands to keep"), true);
|
||||
if (target.choose(Outcome.Sacrifice, player.getId(), source.getSourceId(), game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), player.getId(), source.getSourceId(), game)) {
|
||||
if (permanent != null && !target.getTargets().contains(permanent.getId())) {
|
||||
landsToSacrifice.add(permanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID cardId : landsToSacrifice) {
|
||||
Permanent permanent = game.getPermanent(cardId);
|
||||
if (permanent != null) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
|
||||
//Creatures
|
||||
int minCreature = Integer.MAX_VALUE;
|
||||
Cards creaturesToSacrifice = new CardsImpl();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
int count = game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), player.getId(), game);
|
||||
if (count < minCreature) {
|
||||
minCreature = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(minCreature, minCreature, new FilterControlledCreaturePermanent("creatures to keep"), true);
|
||||
if (target.choose(Outcome.Sacrifice, player.getId(), source.getSourceId(), game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), player.getId(), source.getSourceId(), game)) {
|
||||
if (permanent != null && !target.getTargets().contains(permanent.getId())) {
|
||||
creaturesToSacrifice.add(permanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID cardId : creaturesToSacrifice) {
|
||||
Permanent permanent = game.getPermanent(cardId);
|
||||
if (permanent != null) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
|
||||
//Cards in hand
|
||||
int minCard = Integer.MAX_VALUE;
|
||||
Map<UUID, Cards> cardsToDiscard = new HashMap<>(2);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
int count = player.getHand().size();
|
||||
if (count < minCard) {
|
||||
minCard = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard("cards to keep"));
|
||||
if (target.choose(Outcome.Discard, player.getId(), source.getSourceId(), game)) {
|
||||
for (Card card : player.getHand().getCards(game)) {
|
||||
if (card != null && !target.getTargets().contains(card.getId())) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
cardsToDiscard.put(playerId, cards);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && cardsToDiscard.get(playerId) != null) {
|
||||
for (UUID cardId : cardsToDiscard.get(playerId)) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
player.discard(card, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -54,6 +54,7 @@ public final class Commander2018 extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Loyal Drake", 10, Rarity.UNCOMMON, mage.cards.l.LoyalDrake.class));
|
||||
cards.add(new SetCardInfo("Loyal Guardian", 31, Rarity.UNCOMMON, mage.cards.l.LoyalGuardian.class));
|
||||
cards.add(new SetCardInfo("Loyal Subordinate", 16, Rarity.UNCOMMON, mage.cards.l.LoyalSubordinate.class));
|
||||
cards.add(new SetCardInfo("Magus of the Balance", 5, Rarity.RARE, mage.cards.m.MagusOfTheBalance.class));
|
||||
cards.add(new SetCardInfo("Nesting Dragon", 24, Rarity.RARE, mage.cards.n.NestingDragon.class));
|
||||
cards.add(new SetCardInfo("Night Incarnate", 17, Rarity.RARE, mage.cards.n.NightIncarnate.class));
|
||||
cards.add(new SetCardInfo("Nylea's Colossus", 33, Rarity.RARE, mage.cards.n.NyleasColossus.class));
|
||||
|
|
Loading…
Reference in a new issue