mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Monocolor hybrid mana - Fixed that the payment did not always try to pay the colored cost if possible.
This commit is contained in:
parent
8880e263f9
commit
b2ff7ac380
7 changed files with 143 additions and 52 deletions
|
@ -106,7 +106,9 @@ class OblivionSowerEffect extends OneShotEffect {
|
||||||
Cards exiledLands = new CardsImpl();
|
Cards exiledLands = new CardsImpl();
|
||||||
exiledLands.addAll(exiledCards.getCards(filter, source.getSourceId(), controller.getId(), game));
|
exiledLands.addAll(exiledCards.getCards(filter, source.getSourceId(), controller.getId(), game));
|
||||||
if (!exiledLands.isEmpty() && controller.chooseUse(outcome, "Put lands into play?", source, game)) {
|
if (!exiledLands.isEmpty() && controller.chooseUse(outcome, "Put lands into play?", source, game)) {
|
||||||
FilterCard filterToPlay = new FilterCard("Lands owned by " + targetPlayer.getName() + " to put into play under your control");
|
FilterCard filterToPlay = new FilterCard("land"
|
||||||
|
+ (exiledLands.size() > 1 ? "s" : "") + " from exile owned by "
|
||||||
|
+ targetPlayer.getName() + " to put into play under your control");
|
||||||
TargetCard targetCards = new TargetCard(0, exiledLands.size(), Zone.EXILED, filterToPlay);
|
TargetCard targetCards = new TargetCard(0, exiledLands.size(), Zone.EXILED, filterToPlay);
|
||||||
if (controller.chooseTarget(outcome, exiledLands, targetCards, source, game)) {
|
if (controller.chooseTarget(outcome, exiledLands, targetCards, source, game)) {
|
||||||
controller.moveCards(new CardsImpl(targetCards.getTargets()), null, Zone.BATTLEFIELD, source, game);
|
controller.moveCards(new CardsImpl(targetCards.getTargets()), null, Zone.BATTLEFIELD, source, game);
|
||||||
|
|
|
@ -58,8 +58,8 @@ import mage.target.TargetSpell;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
import mage.constants.Outcome;
|
* import mage.constants.Outcome;
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class Mindreaver extends CardImpl {
|
public class Mindreaver extends CardImpl {
|
||||||
|
@ -78,9 +78,9 @@ public class Mindreaver extends CardImpl {
|
||||||
ability.addTarget(new TargetPlayer());
|
ability.addTarget(new TargetPlayer());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// {U}{U}, Sacrifice Mindreaver: Counter target spell with the same name as a card exiled with mindreaver.
|
// {U}{U}, Sacrifice Mindreaver: Counter target spell with the same name as a card exiled with Mindreaver.
|
||||||
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterTargetEffect(), new ManaCostsImpl("{U}{U}"));
|
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterTargetEffect(), new ManaCostsImpl("{U}{U}"));
|
||||||
FilterSpell filter = new FilterSpell("spell with the same name as a card exiled with mindreaver");
|
FilterSpell filter = new FilterSpell("spell with the same name as a card exiled with {this}");
|
||||||
filter.add(new MindreaverNamePredicate(this.getId()));
|
filter.add(new MindreaverNamePredicate(this.getId()));
|
||||||
ability.addTarget(new TargetSpell(filter));
|
ability.addTarget(new TargetSpell(filter));
|
||||||
ability.addCost(new SacrificeSourceCost());
|
ability.addCost(new SacrificeSourceCost());
|
||||||
|
@ -116,12 +116,13 @@ class MindreaverExileEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||||
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||||
if (opponent != null) {
|
if (opponent != null && sourceObject != null) {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
Card card = opponent.getLibrary().getFromTop(game);
|
Card card = opponent.getLibrary().getFromTop(game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
card.moveToExile(exileId, "Mindreaver", source.getSourceId(), game);
|
card.moveToExile(exileId, sourceObject.getIdName(), source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,16 +144,16 @@ class MindreaverNamePredicate implements Predicate<MageObject> {
|
||||||
UUID exileId = CardUtil.getCardExileZoneId(game, sourceId);
|
UUID exileId = CardUtil.getCardExileZoneId(game, sourceId);
|
||||||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||||
if (exileZone != null) {
|
if (exileZone != null) {
|
||||||
for(Card card : exileZone.getCards(game)) {
|
for (Card card : exileZone.getCards(game)) {
|
||||||
cardNames.add(card.getName());
|
cardNames.add(card.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If a player names a card, the player may name either half of a split card, but not both.
|
// If a player names a card, the player may name either half of a split card, but not both.
|
||||||
// A split card has the chosen name if one of its two names matches the chosen name.
|
// A split card has the chosen name if one of its two names matches the chosen name.
|
||||||
if (input instanceof SplitCard) {
|
if (input instanceof SplitCard) {
|
||||||
return cardNames.contains(((SplitCard)input).getLeftHalfCard().getName()) || cardNames.contains(((SplitCard)input).getRightHalfCard().getName());
|
return cardNames.contains(((SplitCard) input).getLeftHalfCard().getName()) || cardNames.contains(((SplitCard) input).getRightHalfCard().getName());
|
||||||
} else if (input instanceof Spell && ((Spell)input).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)){
|
} else if (input instanceof Spell && ((Spell) input).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
|
||||||
SplitCard card = (SplitCard) ((Spell)input).getCard();
|
SplitCard card = (SplitCard) ((Spell) input).getCard();
|
||||||
return cardNames.contains(card.getLeftHalfCard().getName()) || cardNames.contains(card.getRightHalfCard().getName());
|
return cardNames.contains(card.getLeftHalfCard().getName()) || cardNames.contains(card.getRightHalfCard().getName());
|
||||||
} else {
|
} else {
|
||||||
return cardNames.contains(input.getName());
|
return cardNames.contains(input.getName());
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class DictateOfErebos extends CardImpl {
|
||||||
super(ownerId, 65, "Dictate of Erebos", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{B}{B}");
|
super(ownerId, 65, "Dictate of Erebos", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{B}{B}");
|
||||||
this.expansionSetCode = "JOU";
|
this.expansionSetCode = "JOU";
|
||||||
|
|
||||||
|
|
||||||
// Flash
|
// Flash
|
||||||
this.addAbility(FlashAbility.getInstance());
|
this.addAbility(FlashAbility.getInstance());
|
||||||
// Whenever a creature you control dies, each opponent sacrifices a creature.
|
// Whenever a creature you control dies, each opponent sacrifices a creature.
|
||||||
|
|
|
@ -74,7 +74,6 @@ public class ChandraPyromaster extends CardImpl {
|
||||||
this.expansionSetCode = "M14";
|
this.expansionSetCode = "M14";
|
||||||
this.subtype.add("Chandra");
|
this.subtype.add("Chandra");
|
||||||
|
|
||||||
|
|
||||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(4)), false));
|
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(4)), false));
|
||||||
|
|
||||||
// +1: Chandra, Pyromaster deals 1 damage to target player and 1 damage to up to one target creature that player controls. That creature can't block this turn.
|
// +1: Chandra, Pyromaster deals 1 damage to target player and 1 damage to up to one target creature that player controls. That creature can't block this turn.
|
||||||
|
@ -273,36 +272,31 @@ class ChandraPyromasterEffect3 extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player you = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (you == null) {
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
|
if (controller == null || sourceObject == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
int max = Math.min(you.getLibrary().size(), 10);
|
cards.addAll(controller.getLibrary().getTopCards(game, 10));
|
||||||
for (int i = 0; i < max; i++) {
|
controller.moveCardsToExile(cards.getCards(game), source, game, true, source.getSourceId(), sourceObject.getIdName());
|
||||||
Card card = you.getLibrary().removeFromTop(game);
|
|
||||||
if (card != null) {
|
|
||||||
card.moveToExile(source.getSourceId(), "Chandra Pyromaster", source.getSourceId(), game);
|
|
||||||
cards.add(card);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cards.getCards(new FilterInstantOrSorceryCard(), game).size() > 0) {
|
if (cards.getCards(new FilterInstantOrSorceryCard(), game).size() > 0) {
|
||||||
TargetCard target = new TargetCard(Zone.EXILED, new FilterInstantOrSorceryCard());
|
TargetCard target = new TargetCard(Zone.EXILED, new FilterInstantOrSorceryCard());
|
||||||
if (you.chooseTarget(Outcome.PlayForFree, cards, target, source, game)) {
|
if (controller.chooseTarget(Outcome.PlayForFree, cards, target, source, game)) {
|
||||||
Card card = cards.get(target.getFirstTarget(), game);
|
Card card = cards.get(target.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
Card copy1 = card.copy();
|
if (controller.chooseUse(outcome, "Do you wish to cast copy 1 of " + card.getName(), source, game)) {
|
||||||
Card copy2 = card.copy();
|
Card copy1 = card.copy();
|
||||||
Card copy3 = card.copy();
|
controller.cast(copy1.getSpellAbility(), game, true);
|
||||||
if (copy1 != null && you.chooseUse(outcome, "Do you wish to cast copy 1 of " + card.getName(), source, game)) {
|
|
||||||
you.cast(copy1.getSpellAbility(), game, true);
|
|
||||||
}
|
}
|
||||||
if (copy2 != null && you.chooseUse(outcome, "Do you wish to cast copy 2 of " + card.getName(), source, game)) {
|
if (controller.chooseUse(outcome, "Do you wish to cast copy 2 of " + card.getName(), source, game)) {
|
||||||
you.cast(copy2.getSpellAbility(), game, true);
|
Card copy2 = card.copy();
|
||||||
|
controller.cast(copy2.getSpellAbility(), game, true);
|
||||||
}
|
}
|
||||||
if (copy3 != null && you.chooseUse(outcome, "Do you wish to cast copy 3 of " + card.getName(), source, game)) {
|
if (controller.chooseUse(outcome, "Do you wish to cast copy 3 of " + card.getName(), source, game)) {
|
||||||
you.cast(copy3.getSpellAbility(), game, true);
|
Card copy3 = card.copy();
|
||||||
|
controller.cast(copy3.getSpellAbility(), game, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* 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 org.mage.test.cards.mana;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class HybridManaTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCastReaperKingMonoHybrid() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||||
|
|
||||||
|
// Other Scarecrow creatures you control get +1/+1.
|
||||||
|
// Whenever another Scarecrow enters the battlefield under your control, destroy target permanent.
|
||||||
|
addCard(Zone.HAND, playerA, "Reaper King", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Reaper King");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Reaper King", 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -228,30 +228,62 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
for (ManaCost cost : this) {
|
for (ManaCost cost : this) {
|
||||||
if (!cost.isPaid() && cost instanceof ColoredManaCost) {
|
if (!cost.isPaid() && cost instanceof ColoredManaCost) {
|
||||||
cost.assignPayment(game, ability, pool);
|
cost.assignPayment(game, ability, pool);
|
||||||
|
if (pool.count() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ManaCost cost : this) {
|
for (ManaCost cost : this) {
|
||||||
if (!cost.isPaid() && cost instanceof HybridManaCost) {
|
if (!cost.isPaid() && cost instanceof HybridManaCost) {
|
||||||
cost.assignPayment(game, ability, pool);
|
cost.assignPayment(game, ability, pool);
|
||||||
|
if (pool.count() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mono Hybrid mana costs
|
||||||
|
// First try only to pay colored mana with the pool
|
||||||
|
for (ManaCost cost : this) {
|
||||||
|
if (!cost.isPaid() && cost instanceof MonoHybridManaCost) {
|
||||||
|
if (((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.W)) && pool.getWhite() > 0)
|
||||||
|
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.B)) && pool.getBlack() > 0)
|
||||||
|
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.R)) && pool.getRed() > 0)
|
||||||
|
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.G)) && pool.getGreen() > 0)
|
||||||
|
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.U)) && pool.getBlue() > 0)) {
|
||||||
|
cost.assignPayment(game, ability, pool);
|
||||||
|
if (pool.count() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if colored didn't fit pay colorless with the mana
|
||||||
for (ManaCost cost : this) {
|
for (ManaCost cost : this) {
|
||||||
if (!cost.isPaid() && cost instanceof MonoHybridManaCost) {
|
if (!cost.isPaid() && cost instanceof MonoHybridManaCost) {
|
||||||
cost.assignPayment(game, ability, pool);
|
cost.assignPayment(game, ability, pool);
|
||||||
|
if (pool.count() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ManaCost cost : this) {
|
for (ManaCost cost : this) {
|
||||||
if (!cost.isPaid() && cost instanceof SnowManaCost) {
|
if (!cost.isPaid() && cost instanceof SnowManaCost) {
|
||||||
cost.assignPayment(game, ability, pool);
|
cost.assignPayment(game, ability, pool);
|
||||||
|
if (pool.count() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ManaCost cost : this) {
|
for (ManaCost cost : this) {
|
||||||
if (!cost.isPaid() && cost instanceof GenericManaCost) {
|
if (!cost.isPaid() && cost instanceof GenericManaCost) {
|
||||||
cost.assignPayment(game, ability, pool);
|
cost.assignPayment(game, ability, pool);
|
||||||
|
if (pool.count() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -46,8 +45,7 @@ import mage.target.TargetPermanent;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All opponents have to sacrifice [amount] permanents
|
* All opponents have to sacrifice [amount] permanents that match the [filter].
|
||||||
* that match the [filter].
|
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
@ -59,6 +57,7 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
|
||||||
public SacrificeOpponentsEffect(FilterPermanent filter) {
|
public SacrificeOpponentsEffect(FilterPermanent filter) {
|
||||||
this(1, filter);
|
this(1, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SacrificeOpponentsEffect(int amount, FilterPermanent filter) {
|
public SacrificeOpponentsEffect(int amount, FilterPermanent filter) {
|
||||||
this(new StaticValue(amount), filter);
|
this(new StaticValue(amount), filter);
|
||||||
}
|
}
|
||||||
|
@ -89,10 +88,12 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
|
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
|
||||||
TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, true);
|
if (numTargets > 0) {
|
||||||
if (target.canChoose(player.getId(), game)) {
|
TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, true);
|
||||||
player.chooseTarget(Outcome.Sacrifice, target, source, game);
|
if (target.canChoose(player.getId(), game)) {
|
||||||
perms.addAll(target.getTargets());
|
player.chooseTarget(Outcome.Sacrifice, target, source, game);
|
||||||
|
perms.addAll(target.getTargets());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue