mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +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();
|
||||
exiledLands.addAll(exiledCards.getCards(filter, source.getSourceId(), controller.getId(), 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);
|
||||
if (controller.chooseTarget(outcome, exiledLands, targetCards, 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.constants.Outcome;
|
||||
*
|
||||
* import mage.constants.Outcome;
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class Mindreaver extends CardImpl {
|
||||
|
@ -78,9 +78,9 @@ public class Mindreaver extends CardImpl {
|
|||
ability.addTarget(new TargetPlayer());
|
||||
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}"));
|
||||
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()));
|
||||
ability.addTarget(new TargetSpell(filter));
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
|
@ -116,12 +116,13 @@ class MindreaverExileEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||
if (opponent != null) {
|
||||
if (opponent != null && sourceObject != null) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card card = opponent.getLibrary().getFromTop(game);
|
||||
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);
|
||||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||
if (exileZone != null) {
|
||||
for(Card card : exileZone.getCards(game)) {
|
||||
for (Card card : exileZone.getCards(game)) {
|
||||
cardNames.add(card.getName());
|
||||
}
|
||||
}
|
||||
// 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.
|
||||
if (input instanceof SplitCard) {
|
||||
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)){
|
||||
SplitCard card = (SplitCard) ((Spell)input).getCard();
|
||||
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)) {
|
||||
SplitCard card = (SplitCard) ((Spell) input).getCard();
|
||||
return cardNames.contains(card.getLeftHalfCard().getName()) || cardNames.contains(card.getRightHalfCard().getName());
|
||||
} else {
|
||||
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}");
|
||||
this.expansionSetCode = "JOU";
|
||||
|
||||
|
||||
// Flash
|
||||
this.addAbility(FlashAbility.getInstance());
|
||||
// Whenever a creature you control dies, each opponent sacrifices a creature.
|
||||
|
|
|
@ -74,7 +74,6 @@ public class ChandraPyromaster extends CardImpl {
|
|||
this.expansionSetCode = "M14";
|
||||
this.subtype.add("Chandra");
|
||||
|
||||
|
||||
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.
|
||||
|
@ -273,36 +272,31 @@ class ChandraPyromasterEffect3 extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (you == null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller == null || sourceObject == null) {
|
||||
return false;
|
||||
}
|
||||
Cards cards = new CardsImpl();
|
||||
int max = Math.min(you.getLibrary().size(), 10);
|
||||
for (int i = 0; i < max; i++) {
|
||||
Card card = you.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToExile(source.getSourceId(), "Chandra Pyromaster", source.getSourceId(), game);
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, 10));
|
||||
controller.moveCardsToExile(cards.getCards(game), source, game, true, source.getSourceId(), sourceObject.getIdName());
|
||||
|
||||
if (cards.getCards(new FilterInstantOrSorceryCard(), game).size() > 0) {
|
||||
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);
|
||||
if (card != null) {
|
||||
if (controller.chooseUse(outcome, "Do you wish to cast copy 1 of " + card.getName(), source, game)) {
|
||||
Card copy1 = card.copy();
|
||||
controller.cast(copy1.getSpellAbility(), game, true);
|
||||
}
|
||||
if (controller.chooseUse(outcome, "Do you wish to cast copy 2 of " + card.getName(), source, game)) {
|
||||
Card copy2 = card.copy();
|
||||
controller.cast(copy2.getSpellAbility(), game, true);
|
||||
}
|
||||
if (controller.chooseUse(outcome, "Do you wish to cast copy 3 of " + card.getName(), source, game)) {
|
||||
Card copy3 = card.copy();
|
||||
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)) {
|
||||
you.cast(copy2.getSpellAbility(), game, true);
|
||||
}
|
||||
if (copy3 != null && you.chooseUse(outcome, "Do you wish to cast copy 3 of " + card.getName(), source, game)) {
|
||||
you.cast(copy3.getSpellAbility(), game, true);
|
||||
controller.cast(copy3.getSpellAbility(), game, 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) {
|
||||
if (!cost.isPaid() && cost instanceof ColoredManaCost) {
|
||||
cost.assignPayment(game, ability, pool);
|
||||
if (pool.count() == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ManaCost cost : this) {
|
||||
if (!cost.isPaid() && cost instanceof HybridManaCost) {
|
||||
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) {
|
||||
if (!cost.isPaid() && cost instanceof MonoHybridManaCost) {
|
||||
cost.assignPayment(game, ability, pool);
|
||||
if (pool.count() == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ManaCost cost : this) {
|
||||
if (!cost.isPaid() && cost instanceof SnowManaCost) {
|
||||
cost.assignPayment(game, ability, pool);
|
||||
if (pool.count() == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ManaCost cost : this) {
|
||||
if (!cost.isPaid() && cost instanceof GenericManaCost) {
|
||||
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
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -46,8 +45,7 @@ import mage.target.TargetPermanent;
|
|||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* All opponents have to sacrifice [amount] permanents
|
||||
* that match the [filter].
|
||||
* All opponents have to sacrifice [amount] permanents that match the [filter].
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
@ -59,6 +57,7 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
|
|||
public SacrificeOpponentsEffect(FilterPermanent filter) {
|
||||
this(1, filter);
|
||||
}
|
||||
|
||||
public SacrificeOpponentsEffect(int amount, FilterPermanent filter) {
|
||||
this(new StaticValue(amount), filter);
|
||||
}
|
||||
|
@ -89,6 +88,7 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
|
||||
if (numTargets > 0) {
|
||||
TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, true);
|
||||
if (target.canChoose(player.getId(), game)) {
|
||||
player.chooseTarget(Outcome.Sacrifice, target, source, game);
|
||||
|
@ -96,6 +96,7 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (UUID permID : perms) {
|
||||
Permanent permanent = game.getPermanent(permID);
|
||||
if (permanent != null) {
|
||||
|
|
Loading…
Reference in a new issue