mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
* Fixed some mana handling problems of conditionalMana (GemstoneCavern) and possible exception of ChromeMox.Fixed some tests.
This commit is contained in:
parent
0051f70b8a
commit
df341bd0d6
9 changed files with 85 additions and 56 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -127,8 +126,9 @@ class ChromeMoxManaEffect extends ManaEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
checkToFirePossibleEvents(getMana(game, source), game, source);
|
||||
controller.getManaPool().addMana(getMana(game, source), game, source);
|
||||
Mana mana = getMana(game, source);
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
controller.getManaPool().addMana(mana, game, source);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.g;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -121,6 +120,7 @@ class GemstoneCavernsEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean result = false;
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
|
|
@ -133,13 +133,12 @@ class GemstoneCavernsEffect extends OneShotEffect {
|
|||
if (permanent != null) {
|
||||
Cost cost = new ExileFromHandCost(new TargetCardInHand());
|
||||
if (cost.canPay(source, source.getSourceId(), source.getControllerId(), game)) {
|
||||
cost.pay(source, game, source.getSourceId(), source.getControllerId(), true, null);
|
||||
result = cost.pay(source, game, source.getSourceId(), source.getControllerId(), true, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,10 +135,11 @@ public class ConstellationTest extends CardTestPlayerBase {
|
|||
@Test
|
||||
public void test_DaxosGotBoostWithLoseFlyAndGotItAgain() {
|
||||
// 112.10c If two or more effects add and remove the same ability, in general the most recent one prevails.
|
||||
addCard(Zone.HAND, playerA, daxosCard, 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
|
||||
addCard(Zone.HAND, playerA, "Gravity Sphere", 1); // All creatures lose flying.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
||||
addCard(Zone.HAND, playerA, daxosCard, 1); // {3}{B}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
|
||||
// All creatures lose flying.
|
||||
addCard(Zone.HAND, playerA, "Gravity Sphere", 1); // World Enchantment {2}{R}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
|
||||
|
||||
// got fly on enter, lose on gravity, got fly on gravity enter
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, daxosCard);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package org.mage.test.cards.mana;
|
||||
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
import static org.mage.test.utils.ManaOptionsTestUtils.manaOptionsContain;
|
||||
import static org.mage.test.utils.ManaOptionsTestUtils.assertDuplicatedManaOptions;
|
||||
import static org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -47,7 +49,14 @@ public class NagaVitalistTest extends CardTestPlayerBase {
|
|||
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
Assert.assertTrue("playerA must cast {Any}{Any}", manaOptionsContain(playerA.getManaAvailable(currentGame), "{Any}{Any}"));
|
||||
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
|
||||
assertDuplicatedManaOptions(manaOptions);
|
||||
Assert.assertEquals("mana variations don't fit", 5, manaOptions.size());
|
||||
assertManaOptions("{B}{B}", manaOptions);
|
||||
assertManaOptions("{W}{W}", manaOptions);
|
||||
assertManaOptions("{U}{U}", manaOptions);
|
||||
assertManaOptions("{R}{R}", manaOptions);
|
||||
assertManaOptions("{G}{G}", manaOptions);
|
||||
}
|
||||
|
||||
public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(int giftCastTurn, int nagaManaTapTurn, String nagaManaTapColor) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import mage.constants.ManaType;
|
|||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
|
@ -41,7 +40,6 @@ public class VorinclexVoiceOfHungerTest extends CardTestPlayerBase {
|
|||
* Vorinclex, Voice of Hunger is not mana doubling River of Tears.
|
||||
*/
|
||||
@Test
|
||||
// @Ignore // TODO: need to fix Vorinclex, Voice of Hunger -- it's double fireup mana tap event
|
||||
public void testVorinclexVoiceofHungerRiverOfTearsManaMultiplier() {
|
||||
// Mana pools don't empty as steps and phases end.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Upwelling", 1);
|
||||
|
|
@ -64,7 +62,6 @@ public class VorinclexVoiceOfHungerTest extends CardTestPlayerBase {
|
|||
/**
|
||||
* Vorinclex glitches with Gemstone Cavern
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGemstoneCavern() {
|
||||
// Trample
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package mage.abilities.decorator;
|
||||
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
|
|
@ -47,10 +48,10 @@ public class ConditionalManaEffect extends ManaEffect {
|
|||
return false;
|
||||
}
|
||||
Mana mana = getMana(game, source);
|
||||
controller.getManaPool().addMana(mana, game, source);
|
||||
if (produceMana(true, game, source).getAny() > 0) {
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
}
|
||||
controller.getManaPool().addMana(mana, game, source);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +65,16 @@ public class ConditionalManaEffect extends ManaEffect {
|
|||
return produceMana(false, game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
if (condition.apply(game, source)) {
|
||||
return effect.getNetMana(game, source);
|
||||
} else if (otherwiseEffect != null) {
|
||||
return otherwiseEffect.getNetMana(game, source);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(boolean netMana, Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
package mage.abilities.effects.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.choices.ChoiceColor;
|
||||
|
|
@ -13,25 +14,28 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class AddManaOfAnyColorEffect extends BasicManaEffect {
|
||||
|
||||
protected int amount;
|
||||
protected final int amount;
|
||||
protected final ArrayList<Mana> netMana = new ArrayList<>();
|
||||
|
||||
public AddManaOfAnyColorEffect() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public AddManaOfAnyColorEffect(final int amount) {
|
||||
public AddManaOfAnyColorEffect(int amount) {
|
||||
super(new Mana(0, 0, 0, 0, 0, 0, amount, 0));
|
||||
this.amount = amount;
|
||||
this.staticText = new StringBuilder("add ")
|
||||
.append(CardUtil.numberToText(amount))
|
||||
.append(" mana of any ")
|
||||
.append(amount > 1 ? "one " : "")
|
||||
.append("color").toString();
|
||||
netMana.add(Mana.GreenMana(amount));
|
||||
netMana.add(Mana.BlueMana(amount));
|
||||
netMana.add(Mana.BlackMana(amount));
|
||||
netMana.add(Mana.WhiteMana(amount));
|
||||
netMana.add(Mana.RedMana(amount));
|
||||
this.staticText = "add " + CardUtil.numberToText(amount) + " mana of any " + (amount > 1 ? "one " : "") + "color";
|
||||
}
|
||||
|
||||
public AddManaOfAnyColorEffect(final AddManaOfAnyColorEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
this.netMana.addAll(effect.netMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -41,23 +45,33 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
checkToFirePossibleEvents(getMana(game, source), game, source);
|
||||
controller.getManaPool().addMana(getMana(game, source), game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(boolean netMana, Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
String mes = String.format("Select color of %d mana to add it", this.amount);
|
||||
ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source.getSourceId()));
|
||||
if (controller.choose(outcome, choice, game)) {
|
||||
if (choice.getColor() == null) {
|
||||
return false;
|
||||
if (choice.getColor() != null) {
|
||||
return choice.getMana(amount);
|
||||
}
|
||||
Mana createdMana = choice.getMana(amount);
|
||||
if (createdMana != null) {
|
||||
checkToFirePossibleEvents(createdMana, game, source);
|
||||
controller.getManaPool().addMana(createdMana, game, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -14,7 +12,6 @@ import mage.game.Game;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class ConditionalManaAbility extends ActivatedManaAbilityImpl {
|
||||
|
||||
ConditionalManaEffect conditionalManaEffect;
|
||||
|
|
@ -37,7 +34,7 @@ public class ConditionalManaAbility extends ActivatedManaAbilityImpl {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
List<Mana> newNetMana = new ArrayList<>();
|
||||
newNetMana.add(conditionalManaEffect.getMana(game, this));
|
||||
newNetMana.addAll(conditionalManaEffect.getNetMana(game, this));
|
||||
return newNetMana;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.players;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -366,25 +365,27 @@ public class ManaPool implements Serializable {
|
|||
}
|
||||
|
||||
public void addMana(Mana manaToAdd, Game game, Ability source, boolean emptyOnTurnsEnd) {
|
||||
Mana mana = manaToAdd.copy();
|
||||
if (!game.replaceEvent(new ManaEvent(EventType.ADD_MANA, source.getId(), source.getSourceId(), playerId, mana))) {
|
||||
if (mana instanceof ConditionalMana) {
|
||||
ManaPoolItem item = new ManaPoolItem((ConditionalMana) mana, source.getSourceObject(game),
|
||||
((ConditionalMana) mana).getManaProducerOriginalId() != null ? ((ConditionalMana) mana).getManaProducerOriginalId() : source.getOriginalId());
|
||||
if (emptyOnTurnsEnd) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
if (manaToAdd != null) {
|
||||
Mana mana = manaToAdd.copy();
|
||||
if (!game.replaceEvent(new ManaEvent(EventType.ADD_MANA, source.getId(), source.getSourceId(), playerId, mana))) {
|
||||
if (mana instanceof ConditionalMana) {
|
||||
ManaPoolItem item = new ManaPoolItem((ConditionalMana) mana, source.getSourceObject(game),
|
||||
((ConditionalMana) mana).getManaProducerOriginalId() != null ? ((ConditionalMana) mana).getManaProducerOriginalId() : source.getOriginalId());
|
||||
if (emptyOnTurnsEnd) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
}
|
||||
this.manaItems.add(item);
|
||||
} else {
|
||||
ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getGeneric() + mana.getColorless(), source.getSourceObject(game), source.getOriginalId(), mana.getFlag());
|
||||
if (emptyOnTurnsEnd) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
}
|
||||
this.manaItems.add(item);
|
||||
}
|
||||
this.manaItems.add(item);
|
||||
} else {
|
||||
ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getGeneric() + mana.getColorless(), source.getSourceObject(game), source.getOriginalId(), mana.getFlag());
|
||||
if (emptyOnTurnsEnd) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
}
|
||||
this.manaItems.add(item);
|
||||
ManaEvent manaEvent = new ManaEvent(EventType.MANA_ADDED, source.getId(), source.getSourceId(), playerId, mana);
|
||||
manaEvent.setData(mana.toString());
|
||||
game.fireEvent(manaEvent);
|
||||
}
|
||||
ManaEvent manaEvent = new ManaEvent(EventType.MANA_ADDED, source.getId(), source.getSourceId(), playerId, mana);
|
||||
manaEvent.setData(mana.toString());
|
||||
game.fireEvent(manaEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue