Rework of "spend mana as though it were mana of" handling.

This commit is contained in:
LevelX2 2015-10-06 17:28:59 +02:00
parent 2c54cacbc3
commit 625aa29d6e
12 changed files with 184 additions and 152 deletions

View file

@ -1135,7 +1135,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
protected boolean playManaHandling(Ability ability, ManaCost unpaid, Game game) {
// log.info("paying for " + unpaid.getText());
boolean spendAnyMana = game.getContinuousEffects().asThough(ability.getSourceId(), AsThoughEffectType.SPEND_ANY_MANA, ability, ability.getControllerId(), game);
boolean spendAnyMana = game.getContinuousEffects().asThough(ability.getSourceId(), AsThoughEffectType.SPEND_OTHER_MANA, ability, ability.getControllerId(), game);
ManaCost cost;
List<Permanent> producers;
if (unpaid instanceof ManaCosts) {

View file

@ -34,6 +34,7 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.AsThoughManaEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -170,10 +171,10 @@ class EverythingIsColorlessEffect extends ContinuousEffectImpl {
}
}
class ManaCanBeSpentAsAnyColorEffect extends AsThoughEffectImpl {
class ManaCanBeSpentAsAnyColorEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
public ManaCanBeSpentAsAnyColorEffect() {
super(AsThoughEffectType.SPEND_ANY_MANA, Duration.WhileOnBattlefield, Outcome.Benefit);
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "Players may spend mana as though it were mana of any color";
}
@ -184,12 +185,13 @@ class ManaCanBeSpentAsAnyColorEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return true; // not used for mana thought as effects
Player controller = game.getPlayer(source.getControllerId());
return controller != null && controller.getInRange().contains(affectedControllerId);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana) {
return true;
public ManaType getAsThoughtManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
return mana.getFirstAvailable();
}
@Override

View file

@ -34,6 +34,7 @@ import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleEvasionAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.AsThoughManaEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
@ -183,10 +184,10 @@ class DaxosOfMeletisCastFromExileEffect extends AsThoughEffectImpl {
}
}
class DaxosOfMeletisSpendAnyManaEffect extends AsThoughEffectImpl {
class DaxosOfMeletisSpendAnyManaEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
public DaxosOfMeletisSpendAnyManaEffect() {
super(AsThoughEffectType.SPEND_ANY_MANA, Duration.EndOfTurn, Outcome.Benefit);
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.EndOfTurn, Outcome.Benefit);
staticText = "you may spend mana as though it were mana of any color to cast it";
}
@ -206,14 +207,16 @@ class DaxosOfMeletisSpendAnyManaEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return true; // not used for mana thought as effects
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana) {
return source.getControllerId().equals(affectedControllerId)
&& objectId == ((FixedTarget) getTargetPointer()).getTarget()
&& ((FixedTarget) getTargetPointer()).getZoneChangeCounter() + 1 == game.getState().getZoneChangeCounter(objectId)
&& (((FixedTarget) getTargetPointer()).getZoneChangeCounter() + 1 == game.getState().getZoneChangeCounter(objectId))
&& game.getState().getZone(objectId).equals(Zone.STACK);
}
@Override
public ManaType getAsThoughtManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
return mana.getFirstAvailable();
}
}

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.AsThoughManaEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -190,10 +191,10 @@ class PsychicIntrusionCastFromExileEffect extends AsThoughEffectImpl {
}
}
class PsychicIntrusionSpendAnyManaEffect extends AsThoughEffectImpl {
class PsychicIntrusionSpendAnyManaEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
public PsychicIntrusionSpendAnyManaEffect() {
super(AsThoughEffectType.SPEND_ANY_MANA, Duration.Custom, Outcome.Benefit);
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.Custom, Outcome.Benefit);
staticText = "you may spend mana as though it were mana of any color to cast it";
}
@ -213,11 +214,6 @@ class PsychicIntrusionSpendAnyManaEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return true; // not used for mana thought as effects
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana) {
if (objectId.equals(((FixedTarget) getTargetPointer()).getTarget())
&& game.getState().getZoneChangeCounter(objectId) <= ((FixedTarget) getTargetPointer()).getZoneChangeCounter() + 1) {
@ -236,4 +232,9 @@ class PsychicIntrusionSpendAnyManaEffect extends AsThoughEffectImpl {
}
return false;
}
@Override
public ManaType getAsThoughtManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
return mana.getFirstAvailable();
}
}

View file

@ -33,6 +33,7 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.AsThoughManaEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.Card;
@ -146,7 +147,6 @@ class CelestialDawnToWhiteEffect extends ContinuousEffectImpl {
public CelestialDawnToWhiteEffect() {
super(Duration.WhileOnBattlefield, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Benefit);
staticText = "Nonland cards you own that aren't on the battlefield, spells you control, and nonland permanents you control are white";
staticText = "All cards that aren't on the battlefield, spells, and permanents are the chosen color in addition to their other colors";
}
@Override
@ -213,10 +213,10 @@ class CelestialDawnToWhiteEffect extends ContinuousEffectImpl {
}
class CelestialDawnSpendAnyManaEffect extends AsThoughEffectImpl {
class CelestialDawnSpendAnyManaEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
public CelestialDawnSpendAnyManaEffect() {
super(AsThoughEffectType.SPEND_ANY_MANA, Duration.Custom, Outcome.Benefit);
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.Custom, Outcome.Benefit);
staticText = "You may spend white mana as though it were mana of any color";
}
@ -236,22 +236,22 @@ class CelestialDawnSpendAnyManaEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return true; // not used for mana thought as effects
return affectedControllerId.equals(source.getControllerId());
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana) {
if (affectedControllerId.equals(source.getControllerId())) {
return mana.getWhite() > 0;
public ManaType getAsThoughtManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
if (mana.getWhite() > 0) {
return ManaType.WHITE;
}
return false;
return null;
}
}
class CelestialDawnSpendColorlessManaEffect extends AsThoughEffectImpl {
class CelestialDawnSpendColorlessManaEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
public CelestialDawnSpendColorlessManaEffect() {
super(AsThoughEffectType.SPEND_COLORLESS_MANA, Duration.Custom, Outcome.Detriment);
super(AsThoughEffectType.SPEND_ONLY_MANA, Duration.Custom, Outcome.Detriment);
staticText = "You may spend other mana only as though it were colorless mana";
}
@ -271,14 +271,14 @@ class CelestialDawnSpendColorlessManaEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return true; // not used for mana thought as effects
return affectedControllerId.equals(source.getControllerId());
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana) {
if (affectedControllerId.equals(source.getControllerId())) {
return mana.getWhite() == 0;
public ManaType getAsThoughtManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
if (mana.getWhite() == 0 && !ManaType.COLORLESS.equals(manaType)) {
return null;
}
return false;
return manaType;
}
}

View file

@ -30,9 +30,7 @@ package mage.abilities.effects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.constants.AsThoughEffectType;
import mage.constants.ManaType;
import mage.game.Game;
import mage.players.ManaPoolItem;
/**
*
@ -44,8 +42,6 @@ public interface AsThoughEffect extends ContinuousEffect {
boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game);
boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana);
AsThoughEffectType getAsThoughEffectType();
@Override

View file

@ -32,10 +32,8 @@ import mage.abilities.Ability;
import mage.constants.AsThoughEffectType;
import mage.constants.Duration;
import mage.constants.EffectType;
import mage.constants.ManaType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.ManaPoolItem;
/**
*
@ -61,11 +59,6 @@ public abstract class AsThoughEffectImpl extends ContinuousEffectImpl implements
return applies(objectId, source, affectedAbility.getControllerId(), game);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana) {
return false;
}
@Override
public AsThoughEffectType getAsThoughEffectType() {
return type;

View file

@ -0,0 +1,45 @@
/*
* 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.abilities.effects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.constants.ManaType;
import mage.game.Game;
import mage.players.ManaPoolItem;
/**
*
* @author LevelX2
*/
public interface AsThoughManaEffect extends AsThoughEffect {
// return a mana type that can be used to pay a mana cost instead of the normally needed mana type
ManaType getAsThoughtManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game);
}

View file

@ -548,24 +548,35 @@ public class ContinuousEffects implements Serializable {
}
public boolean asThoughMana(UUID objectId, AsThoughEffectType type, Ability affectedAbility, UUID controllerId, Game game, ManaType manaType, ManaPoolItem mana) {
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(type, game);
public ManaType asThoughMana(ManaType manaType, ManaPoolItem mana, UUID objectId, Ability affectedAbility, UUID controllerId, Game game) {
// First check existing only effects
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(AsThoughEffectType.SPEND_ONLY_MANA, game);
for (AsThoughEffect effect : asThoughEffectsList) {
HashSet<Ability> abilities = asThoughEffectsMap.get(type).getAbility(effect.getId());
HashSet<Ability> abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_ONLY_MANA).getAbility(effect.getId());
for (Ability ability : abilities) {
if (affectedAbility == null) {
if (effect.applies(objectId, ability, controllerId, game)) {
return true;
}
} else {
if (effect.applies(objectId, affectedAbility, ability, game)) {
return true;
if ((affectedAbility == null && effect.applies(objectId, ability, controllerId, game))
|| effect.applies(objectId, affectedAbility, ability, game)) {
if (((AsThoughManaEffect) effect).getAsThoughtManaType(manaType, mana, controllerId, ability, game) == null) {
return null;
}
}
}
}
return false;
// then check effects that allow to use other mana types to pay the current mana type to pay
asThoughEffectsList = getApplicableAsThoughEffects(AsThoughEffectType.SPEND_OTHER_MANA, game);
for (AsThoughEffect effect : asThoughEffectsList) {
HashSet<Ability> abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_OTHER_MANA).getAbility(effect.getId());
for (Ability ability : abilities) {
if ((affectedAbility == null && effect.applies(objectId, ability, controllerId, game))
|| effect.applies(objectId, affectedAbility, ability, game)) {
ManaType usableManaType = ((AsThoughManaEffect) effect).getAsThoughtManaType(manaType, mana, controllerId, ability, game);
if (usableManaType != null) {
return usableManaType;
}
}
}
}
return manaType;
}
/**

View file

@ -19,7 +19,7 @@ public enum AsThoughEffectType {
HEXPROOF,
PAY,
LOOK_AT_FACE_DOWN,
SPEND_ANY_MANA,
SPEND_COLORLESS_MANA,
SPEND_OTHER_MANA,
SPEND_ONLY_MANA,
TARGET
}

View file

@ -38,7 +38,6 @@ import mage.ConditionalMana;
import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.constants.AsThoughEffectType;
import mage.constants.Duration;
import mage.constants.ManaType;
import mage.constants.TurnPhase;
@ -65,13 +64,6 @@ public class ManaPool implements Serializable {
private final Set<ManaType> doNotEmptyManaTypes = new HashSet<>();
private enum SpendType {
NORMAL,
ANY,
COLORLESS
}
public ManaPool(UUID playerId) {
this.playerId = playerId;
autoPayment = true;
@ -145,17 +137,15 @@ public class ManaPool implements Serializable {
// no mana added beyond the stock so don't auto pay this
continue;
}
SpendType spendType = getSpendType(ability, game, manaType, mana);
if (!SpendType.COLORLESS.equals(spendType) || ManaType.COLORLESS.equals(manaType)) {
if (mana.get(manaType) > 0 || (spendType.equals(SpendType.ANY) && mana.count() > 0)) {
ManaType usableManaType = game.getContinuousEffects().asThoughMana(manaType, mana, ability.getSourceId(), ability, ability.getControllerId(), game);
if (usableManaType == null) {
continue;
}
if (mana.get(usableManaType) > 0) {
GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag());
event.setData(mana.getOriginalId().toString());
game.fireEvent(event);
if (!SpendType.NORMAL.equals(spendType)) {
mana.removeAny();
} else {
mana.remove(manaType);
}
mana.remove(usableManaType);
if (mana.count() == 0) { // so no items with count 0 stay in list
manaItems.remove(mana);
}
@ -163,21 +153,9 @@ public class ManaPool implements Serializable {
return true;
}
}
}
return false;
}
// check if any mana can be spend to cast the mana cost of an ability
private SpendType getSpendType(Ability ability, Game game, ManaType manaType, ManaPoolItem mana) {
if (game.getContinuousEffects().asThoughMana(ability.getSourceId(), AsThoughEffectType.SPEND_ANY_MANA, ability, ability.getControllerId(), game, manaType, mana)) {
return SpendType.ANY;
}
if (game.getContinuousEffects().asThoughMana(ability.getSourceId(), AsThoughEffectType.SPEND_COLORLESS_MANA, ability, ability.getControllerId(), game, manaType, mana)) {
return SpendType.COLORLESS;
}
return SpendType.NORMAL;
}
public int get(ManaType manaType) {
return getMana().get(manaType);
}

View file

@ -1,30 +1,30 @@
/*
* Copyright 2011 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.
*/
* Copyright 2011 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.players;
import java.io.Serializable;
@ -53,7 +53,8 @@ public class ManaPoolItem implements Serializable {
private Duration duration;
private int stock; // amount the item had at the start of casting something
public ManaPoolItem() {}
public ManaPoolItem() {
}
public ManaPoolItem(int red, int green, int blue, int white, int black, int colorless, UUID sourceId, UUID originalId, boolean flag) {
this.red = red;
@ -191,7 +192,7 @@ public class ManaPoolItem implements Serializable {
}
public int get(ManaType manaType) {
switch(manaType) {
switch (manaType) {
case BLACK:
return black;
case BLUE:
@ -208,29 +209,26 @@ public class ManaPoolItem implements Serializable {
return 0;
}
public void removeAny() {
int oldCount = count();
public ManaType getFirstAvailable() {
if (black > 0) {
black--;
return ManaType.BLACK;
} else if (blue > 0) {
blue--;
return ManaType.BLUE;
} else if (green > 0) {
green--;
return ManaType.GREEN;
} else if (red > 0) {
red--;
return ManaType.RED;
} else if (white > 0) {
white--;
return ManaType.WHITE;
} else if (colorless > 0) {
colorless--;
}
if (stock == oldCount && oldCount > count()) {
stock--;
return ManaType.COLORLESS;
}
return null;
}
public void remove(ManaType manaType) {
int oldCount = count();
switch(manaType) {
switch (manaType) {
case BLACK:
if (black > 0) {
black--;
@ -268,7 +266,7 @@ public class ManaPoolItem implements Serializable {
}
public void clear(ManaType manaType) {
switch(manaType) {
switch (manaType) {
case BLACK:
black = 0;
break;
@ -291,24 +289,29 @@ public class ManaPoolItem implements Serializable {
}
public void add(ManaType manaType, int amount) {
switch(manaType) {
switch (manaType) {
case BLACK:
black += amount;
break;
case BLUE:
blue += amount;;
blue += amount;
;
break;
case GREEN:
green += amount;;
green += amount;
;
break;
case RED:
red += amount;;
red += amount;
;
break;
case WHITE:
white += amount;;
white += amount;
;
break;
case COLORLESS:
colorless += amount;;
colorless += amount;
;
break;
}
}