* Fixed a problem with triggered mana abilities. Fixed a problem that AI did not always select the needed mana color. Fixed a problem with Reflecting Pool not taking triggered mana abilities into account.

This commit is contained in:
LevelX2 2016-11-03 22:37:54 +01:00
parent f07408f995
commit d2561c1752
74 changed files with 744 additions and 436 deletions

View file

@ -38,7 +38,7 @@ import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.keyword.ChangelingAbility;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.FrameStyle;
import mage.constants.CardType;
import mage.game.Game;
@ -187,8 +187,8 @@ public abstract class MageObjectImpl implements MageObject {
if (getCardType().contains(CardType.LAND)) {
ObjectColor cl = frameColor.copy();
for (Ability ab: getAbilities()) {
if (ab instanceof ManaAbility) {
ManaAbility mana = (ManaAbility)ab;
if (ab instanceof ActivatedManaAbilityImpl) {
ActivatedManaAbilityImpl mana = (ActivatedManaAbilityImpl)ab;
try {
List<Mana> manaAdded = mana.getNetMana(game);
for (Mana m: manaAdded) {

View file

@ -30,6 +30,7 @@ package mage;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import mage.constants.ColoredManaSymbol;
import mage.util.Copyable;
import mage.util.ThreadLocalStringBuilder;
@ -380,6 +381,31 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
return o1 - o2;
}
/**
* Returns a ColoredManaSymbol of a color included If multicolor only one
* symbol is returned
*
* @return null or
*/
public ColoredManaSymbol getColoredManaSymbol() {
if (isBlack()) {
return ColoredManaSymbol.B;
}
if (isRed()) {
return ColoredManaSymbol.R;
}
if (isBlue()) {
return ColoredManaSymbol.U;
}
if (isGreen()) {
return ColoredManaSymbol.G;
}
if (isWhite()) {
return ColoredManaSymbol.W;
}
return null;
}
public static List<ObjectColor> getAllColors() {
List<ObjectColor> colors = new ArrayList<>();
colors.add(ObjectColor.WHITE);
@ -389,4 +415,5 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
colors.add(ObjectColor.GREEN);
return colors;
}
}

View file

@ -24,24 +24,23 @@
* 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;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
import mage.constants.Zone;
import mage.abilities.keyword.ProtectionAbility;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.constants.Zone;
import mage.game.Game;
/**
* Represents a collection of {@link Ability Abilities}. This is the top most
* Represents a collection of {@link Ability Abilities}. This is the top most
* interface for this.
*
*
* @param <T> The ability type this collection will hold.
*
*
* @see mage.abilities.AbilitiesImpl
* @see mage.abilities.DelayedTriggeredAbilities
* @see mage.abilities.SpecialActions
@ -52,10 +51,10 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
/**
* Retrieves a {@link List}&lt;{@link String}&gt; of ability texts for the
* given source.
*
*
* @param source The source to retrieve ability texts.
* @return the {@link List}&lt;{@link String}&gt; of ability texts.
*
*
* @see mage.cards.CardImpl#getRules()
* @see mage.abilities.keyword.LevelAbility#getRule()
*/
@ -63,10 +62,10 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
/**
* Retrieves all activated abilities for the given {@link Zone}.
*
*
* @param zone The {@link Zone} for which abilities should be retrieved.
* @return All abilities for the given {@link Zone}
*
*
* @see mage.cards.CardImpl#getSpellAbility()
*/
Abilities<ActivatedAbility> getActivatedAbilities(Zone zone);
@ -82,47 +81,74 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
Abilities<ActivatedAbility> getPlayableAbilities(Zone zone);
/**
* Retrieves all {@link ManaAbility mana abilities} in the given {@link Zone}.
*
* @param zone The {@link Zone} to search for {@link ManaAbility mana abilities}.
* @return All {@link ManaAbility mana abilities} for the given {@link Zone}.
*
* Retrieves all {@link ActivatedManaAbilityImpl mana abilities} in the
* given {@link Zone}.
*
* @param zone The {@link Zone} to search for
* {@link ActivatedManaAbilityImpl mana abilities}.
* @return All {@link ActivatedManaAbilityImpl mana abilities} for the given
* {@link Zone}.
*
* @see mage.cards.CardImpl#getMana()
* @see mage.players.PlayerImpl#getManaAvailable(mage.game.Game)
* @see mage.players.PlayerImpl#getAvailableManaProducers(mage.game.Game)
*/
Abilities<ManaAbility> getManaAbilities(Zone zone);
Abilities<ActivatedManaAbilityImpl> getActivatedManaAbilities(Zone zone);
/**
* Retrieves all {@link ManaAbility mana abilities} in the given {@link Zone} that can be used.
*
* @param zone The {@link Zone} to search for {@link ManaAbility mana abilities}.
* @return All {@link ManaAbility mana abilities} for the given {@link Zone} that can be used.
*
* Retrieves a list of all mana abilities (activated and triggered
* abilities)
*
* @param zone
* @return
*/
Abilities<Ability> getManaAbilities(Zone zone);
/**
* Retrieves all {@link ActivatedManaAbilityImpl mana abilities} in the
* given {@link Zone} that can be used.
*
* @param zone The {@link Zone} to search for
* {@link ActivatedManaAbilityImpl mana abilities}.
* @return All {@link ActivatedManaAbilityImpl mana abilities} for the given
* {@link Zone} that can be used.
*
* @see mage.cards.CardImpl#getMana()
* @see mage.players.PlayerImpl#getManaAvailable(mage.game.Game)
* @see mage.players.PlayerImpl#getAvailableManaProducers(mage.game.Game)
*/
Abilities<ManaAbility> getAvailableManaAbilities(Zone zone, Game game);
Abilities<ActivatedManaAbilityImpl> getAvailableActivatedManaAbilities(Zone zone, Game game);
/**
* Retrieves all {@link StaticAbility static abilities} in the given {@link Zone}.
*
* Retrieves all {@link StaticAbility static abilities} in the given
* {@link Zone}.
*
* @param zone The {@link Zone} to search for {@link StaticAbility}
* @return All {@link StaticAbility static abilities} in the given {@link Zone}
*
* @see mage.abilities.effects.ContinuousEffects#getLayeredEffects(mage.game.Game)
* @see mage.abilities.effects.ContinuousEffects#getApplicableRequirementEffects(mage.game.permanent.Permanent, mage.game.Game)
* @see mage.abilities.effects.ContinuousEffects#getApplicableRestrictionEffects(mage.game.permanent.Permanent, mage.game.Game)
* @see mage.abilities.effects.ContinuousEffects#getApplicableReplacementEffects(mage.game.events.GameEvent, mage.game.Game)
* @see mage.abilities.effects.ContinuousEffects#asThough(java.util.UUID, mage.constants.AsThoughEffectType, mage.game.Game)
* @see mage.abilities.effects.ContinuousEffects#costModification(mage.abilities.Ability, mage.game.Game)
* @return All {@link StaticAbility static abilities} in the given
* {@link Zone}
*
* @see
* mage.abilities.effects.ContinuousEffects#getLayeredEffects(mage.game.Game)
* @see
* mage.abilities.effects.ContinuousEffects#getApplicableRequirementEffects(mage.game.permanent.Permanent,
* mage.game.Game)
* @see
* mage.abilities.effects.ContinuousEffects#getApplicableRestrictionEffects(mage.game.permanent.Permanent,
* mage.game.Game)
* @see
* mage.abilities.effects.ContinuousEffects#getApplicableReplacementEffects(mage.game.events.GameEvent,
* mage.game.Game)
* @see mage.abilities.effects.ContinuousEffects#asThough(java.util.UUID,
* mage.constants.AsThoughEffectType, mage.game.Game)
* @see
* mage.abilities.effects.ContinuousEffects#costModification(mage.abilities.Ability,
* mage.game.Game)
*/
Abilities<StaticAbility> getStaticAbilities(Zone zone);
/**
* Retrieves all {@link EvasionAbility evasion abilities}.
*
*
* @return The {@link EvasionAbility evasion abilities}.
*/
Abilities<EvasionAbility> getEvasionAbilities();
@ -130,21 +156,27 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
/**
* Retrieves all {@link TriggeredAbility triggered abilities} for the given
* {@link Zone}.
*
* @param zone The {@link Zone} to search for {@link TriggeredAbility triggered abilities}
*
* @param zone The {@link Zone} to search for
* {@link TriggeredAbility triggered abilities}
* @return All found {@link TriggeredAbility triggered abilities}.
*
* @see mage.cards.CardImpl#checkTriggers(mage.constants.Zone, mage.game.events.GameEvent, mage.game.Game)
* @see mage.game.permanent.PermanentImpl#checkTriggers(mage.game.events.GameEvent, mage.game.Game)
* @see mage.game.permanent.PermanentCard#checkPermanentOnlyTriggers(mage.game.events.ZoneChangeEvent, mage.game.Game)
*
* @see mage.cards.CardImpl#checkTriggers(mage.constants.Zone,
* mage.game.events.GameEvent, mage.game.Game)
* @see
* mage.game.permanent.PermanentImpl#checkTriggers(mage.game.events.GameEvent,
* mage.game.Game)
* @see
* mage.game.permanent.PermanentCard#checkPermanentOnlyTriggers(mage.game.events.ZoneChangeEvent,
* mage.game.Game)
*/
Abilities<TriggeredAbility> getTriggeredAbilities(Zone zone);
/**
* Retrieves all {@link ProtectionAbility protection abilities}.
*
*
* @return All found {@link ProtectionAbility protection abilities}.
*
*
* @see mage.game.permanent.PermanentImpl#hasProtectionFrom(mage.MageObject)
* @see mage.players.PlayerImpl#hasProtectionFrom(mage.MageObject)
* @see mage.players.PlayerImpl#canDamage(mage.MageObject)
@ -153,32 +185,34 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
/**
* TODO Method is unused, keep it around?
*
*
* The only implementation seems to want to use this for totally a set of
* abilities by some arbitrary numeral value. Possibly a good method to be
* abilities by some arbitrary numeral value. Possibly a good method to be
* used by the AI's?
*
* @return A numeral value representing the 'strength' or effectiveness of the abilities?
*
* @return A numeral value representing the 'strength' or effectiveness of
* the abilities?
*/
int getOutcomeTotal();
/**
* Sets the controller of this set of abilities.
*
*
* @param controllerId
*
*
* @see mage.cards.CardImpl#setControllerId(java.util.UUID)
* @see mage.cards.CardImpl#setOwnerId(java.util.UUID)
* @see mage.game.permanent.PermanentImpl#changeControllerId(java.util.UUID, mage.game.Game)
* @see mage.game.permanent.PermanentImpl#changeControllerId(java.util.UUID,
* mage.game.Game)
* @see mage.game.permanent.PermanentCard#copyFromCard(mage.cards.Card)
*/
void setControllerId(UUID controllerId);
/**
* Sets the source of this set of abilities.
*
*
* @param sourceId
*
*
* @see mage.cards.CardImpl#assignNewId()
*/
void setSourceId(UUID sourceId);
@ -194,39 +228,40 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
void newOriginalId();
/**
* Searches this set of abilities to see if the ability represented by the abilityId
* is contained within. Can be used to find usages of singleton abilities.
*
* Searches this set of abilities to see if the ability represented by the
* abilityId is contained within. Can be used to find usages of singleton
* abilities.
*
* @param abilityId
* @return
* @return
*/
boolean containsKey(UUID abilityId);
/**
* TODO Method is unused, keep it around?
*
*
* Gets the ability represented by the given abilityId.
*
*
* @param abilityId
* @return
* @return
*/
T get(UUID abilityId);
/**
* TODO The usage of this method seems redundant to that of {@link #containsKey(java.util.UUID)}
* minus the fact that it searches for exact instances instead of id's of
* singleton Abilities.
*
* TODO The usage of this method seems redundant to that of
* {@link #containsKey(java.util.UUID)} minus the fact that it searches for
* exact instances instead of id's of singleton Abilities.
*
* Searches for the exact instance of the passed in ability.
*
*
* @param ability
* @return
* @return
*/
boolean contains(T ability);
/**
* Searches an ability with the same rule text as the passed in ability.
*
*
* @param ability
* @return
*/
@ -235,9 +270,10 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
/**
* Searches this set of abilities for the existence of each of the passed in
* set of abilities.
*
*
* @param abilities
* @return True if the passed in set of abilities is also in this set of abilities.
* @return True if the passed in set of abilities is also in this set of
* abilities.
*/
boolean containsAll(Abilities<T> abilities);
@ -250,10 +286,10 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
boolean containsClass(Class classObject);
/**
* Copies this set of abilities. This copy should be new instances of all
* Copies this set of abilities. This copy should be new instances of all
* the contained abilities.
*
* @return
*
* @return
*/
Abilities<T> copy();

View file

@ -36,7 +36,8 @@ import java.util.UUID;
import mage.abilities.common.ZoneChangeTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.keyword.ProtectionAbility;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.constants.AbilityType;
import mage.constants.Zone;
import mage.game.Game;
import mage.util.ThreadLocalStringBuilder;
@ -48,7 +49,7 @@ import org.apache.log4j.Logger;
* @param <T>
*/
public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Abilities<T> {
private static final Logger logger = Logger.getLogger(AbilitiesImpl.class);
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(200);
@ -143,29 +144,40 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
}
@Override
public Abilities<ManaAbility> getManaAbilities(Zone zone) {
Abilities<ManaAbility> abilities = new AbilitiesImpl<>();
public Abilities<ActivatedManaAbilityImpl> getActivatedManaAbilities(Zone zone) {
Abilities<ActivatedManaAbilityImpl> abilities = new AbilitiesImpl<>();
for (T ability : this) {
if (ability instanceof ManaAbility && ability.getZone().match(zone)) {
abilities.add((ManaAbility) ability);
if (ability instanceof ActivatedManaAbilityImpl && ability.getZone().match(zone)) {
abilities.add((ActivatedManaAbilityImpl) ability);
}
}
return abilities;
}
@Override
public Abilities<ManaAbility> getAvailableManaAbilities(Zone zone, Game game) {
Abilities<ManaAbility> abilities = new AbilitiesImpl<>();
public Abilities<ActivatedManaAbilityImpl> getAvailableActivatedManaAbilities(Zone zone, Game game) {
Abilities<ActivatedManaAbilityImpl> abilities = new AbilitiesImpl<>();
for (T ability : this) {
if (ability instanceof ManaAbility && ability.getZone().match(zone)) {
if ((((ManaAbility) ability).canActivate(ability.getControllerId(), game))) {
abilities.add((ManaAbility) ability);
if (ability instanceof ActivatedManaAbilityImpl && ability.getZone().match(zone)) {
if ((((ActivatedManaAbilityImpl) ability).canActivate(ability.getControllerId(), game))) {
abilities.add((ActivatedManaAbilityImpl) ability);
}
}
}
return abilities;
}
@Override
public Abilities<Ability> getManaAbilities(Zone zone) {
Abilities<Ability> abilities = new AbilitiesImpl<>();
for (T ability : this) {
if (ability.getAbilityType().equals(AbilityType.MANA) && ability.getZone().match(zone)) {
abilities.add(ability);
}
}
return abilities;
}
@Override
public Abilities<EvasionAbility> getEvasionAbilities() {
Abilities<EvasionAbility> abilities = new AbilitiesImpl<>();
@ -340,4 +352,4 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
}
return sb.toString();
}
}
}

View file

@ -52,7 +52,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.BasicManaEffect;
import mage.abilities.effects.common.DynamicManaEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.Card;
import mage.constants.AbilityType;
import mage.constants.AbilityWord;
@ -369,7 +369,7 @@ public abstract class AbilityImpl implements Ability {
}
// this is a hack to prevent mana abilities with mana costs from causing endless loops - pay other costs first
if (this instanceof ManaAbility && !costs.pay(this, game, sourceId, controllerId, noMana, null)) {
if (this instanceof ActivatedManaAbilityImpl && !costs.pay(this, game, sourceId, controllerId, noMana, null)) {
logger.debug("activate mana ability failed - non mana costs");
return false;
}

View file

@ -30,7 +30,7 @@ package mage.abilities.effects.common;
import mage.Mana;
import mage.abilities.Ability;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.choices.ChoiceColor;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -59,7 +59,8 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
return false;
}
Mana types = (Mana) this.getValue("mana");
Choice choice = new ChoiceImpl(true);
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick the type of mana to produce");
if (types.getBlack() > 0) {
choice.getChoices().add("Black");

View file

@ -39,7 +39,7 @@ import mage.abilities.costs.mana.AlternateManaPaymentAbility;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.choices.ChoiceColor;
import mage.constants.AbilityType;
import mage.constants.ManaType;
import mage.constants.Outcome;
@ -263,7 +263,8 @@ class ConvokeEffect extends OneShotEffect {
}
private Choice buildChoice(ObjectColor creatureColor, Mana mana) {
Choice choice = new ChoiceImpl();
Choice choice = new ChoiceColor();
choice.getChoices().clear();
if (creatureColor.isBlack() && mana.getBlack() > 0) {
choice.getChoices().add("Black");
}

View file

@ -3,7 +3,7 @@ package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -67,7 +67,7 @@ class SplitSecondEffect extends ContinuousRuleModifyingEffectImpl {
}
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
Ability ability = game.getAbility(event.getTargetId(), event.getSourceId());
if (ability != null && !(ability instanceof ManaAbility)) {
if (ability != null && !(ability instanceof ActivatedManaAbilityImpl)) {
return true;
}
}

View file

@ -35,7 +35,7 @@ import mage.abilities.effects.common.BasicManaEffect;
import mage.constants.Zone;
import mage.game.Game;
public class ActivateIfConditionManaAbility extends ManaAbility {
public class ActivateIfConditionManaAbility extends ActivatedManaAbilityImpl {
private final Condition condition;

View file

@ -41,7 +41,7 @@ import mage.util.CardUtil;
*
* @author LevelX2
*/
public class ActivateOncePerTurnManaAbility extends ManaAbility {
public class ActivateOncePerTurnManaAbility extends ActivatedManaAbilityImpl {
class ActivationInfo {

View file

@ -0,0 +1,107 @@
/*
* 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.mana;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Mana;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.effects.common.ManaEffect;
import mage.constants.AbilityType;
import mage.constants.Zone;
import mage.game.Game;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public abstract class ActivatedManaAbilityImpl extends ActivatedAbilityImpl implements ManaAbility {
protected List<Mana> netMana = new ArrayList<>();
protected boolean undoPossible;
public ActivatedManaAbilityImpl(Zone zone, ManaEffect effect, Cost cost) {
super(AbilityType.MANA, zone);
this.usesStack = false;
this.undoPossible = true;
if (effect != null) {
this.addEffect(effect);
}
if (cost != null) {
this.addCost(cost);
}
}
public ActivatedManaAbilityImpl(final ActivatedManaAbilityImpl ability) {
super(ability);
this.netMana.addAll(ability.netMana);
this.undoPossible = ability.undoPossible;
}
@Override
public boolean canActivate(UUID playerId, Game game) {
if (!controlsAbility(playerId, game)) {
return false;
}
//20091005 - 605.3a
return costs.canPay(this, sourceId, controllerId, game);
}
/**
* Used to check the possible mana production to determine which spells
* and/or abilities can be used. (player.getPlayable()).
*
* @param game
* @return
*/
@Override
public List<Mana> getNetMana(Game game) {
return netMana;
}
/**
* Used to check if the ability itself defines mana types it can produce.
*
* @return
*/
@Override
public boolean definesMana() {
return netMana.size() > 0;
}
public boolean isUndoPossible() {
return undoPossible;
}
public void setUndoPossible(boolean undoPossible) {
this.undoPossible = undoPossible;
}
}

View file

@ -35,7 +35,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.choices.ChoiceColor;
import mage.constants.ColoredManaSymbol;
import mage.constants.TargetController;
import mage.constants.Zone;
@ -50,7 +50,7 @@ import mage.players.Player;
*
* @author LevelX2
*/
public class AnyColorLandsProduceManaAbility extends ManaAbility {
public class AnyColorLandsProduceManaAbility extends ActivatedManaAbilityImpl {
public AnyColorLandsProduceManaAbility(TargetController targetController) {
super(Zone.BATTLEFIELD, new AnyColorLandsProduceManaEffect(targetController), new TapSourceCost());
@ -91,7 +91,8 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
@Override
public boolean apply(Game game, Ability source) {
Mana types = getManaTypes(game, source);
Choice choice = new ChoiceImpl(true);
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick a mana color");
if (types.getBlack() > 0) {
choice.getChoices().add("Black");
@ -157,8 +158,8 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
Mana types = new Mana();
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
Abilities<ActivatedManaAbilityImpl> mana = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD);
for (ActivatedManaAbilityImpl ability : mana) {
if (!ability.equals(source) && ability.definesMana()) {
for (Mana netMana : ability.getNetMana(game)) {
types.add(netMana);

View file

@ -33,7 +33,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.AddManaOfAnyColorEffect;
import mage.constants.Zone;
public class AnyColorManaAbility extends ManaAbility {
public class AnyColorManaAbility extends ActivatedManaAbilityImpl {
public AnyColorManaAbility() {
this(new TapSourceCost());
}

View file

@ -36,7 +36,7 @@ import mage.abilities.effects.common.ManaEffect;
*
* @author BetaSteward_at_googlemail.com
*/
public abstract class BasicManaAbility extends ManaAbility {
public abstract class BasicManaAbility extends ActivatedManaAbilityImpl {
public BasicManaAbility(ManaEffect effect) {
super(Zone.BATTLEFIELD, effect, new TapSourceCost());

View file

@ -47,7 +47,7 @@ import mage.util.CardUtil;
*
* @author LevelX2
*/
public class CommanderColorIdentityManaAbility extends ManaAbility {
public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl {
private FilterMana commanderMana;

View file

@ -44,7 +44,7 @@ import mage.game.Game;
*
* @author noxx
*/
public class ConditionalAnyColorManaAbility extends ManaAbility {
public class ConditionalAnyColorManaAbility extends ActivatedManaAbilityImpl {
private DynamicValue amount;

View file

@ -16,7 +16,7 @@ import mage.constants.Zone;
*
* @author LevelX2
*/
public class ConditionalColoredManaAbility extends ManaAbility {
public class ConditionalColoredManaAbility extends ActivatedManaAbilityImpl {
public ConditionalColoredManaAbility(Mana mana, ConditionalManaBuilder manaBuilder) {
this(new TapSourceCost(), mana, manaBuilder);

View file

@ -16,7 +16,7 @@ import mage.constants.Zone;
*
* @author LevelX2
*/
public class ConditionalColorlessManaAbility extends ManaAbility {
public class ConditionalColorlessManaAbility extends ActivatedManaAbilityImpl {
public ConditionalColorlessManaAbility(int amount, ConditionalManaBuilder manaBuilder) {
this(new TapSourceCost(), amount, manaBuilder);

View file

@ -41,7 +41,7 @@ import mage.game.Game;
* @author LevelX2
*/
public class ConditionalManaAbility extends ManaAbility {
public class ConditionalManaAbility extends ActivatedManaAbilityImpl {
ConditionalManaEffect conditionalManaEffect;

View file

@ -41,7 +41,7 @@ import mage.game.Game;
*
* @author North
*/
public class DynamicManaAbility extends ManaAbility {
public class DynamicManaAbility extends ActivatedManaAbilityImpl {
private DynamicManaEffect manaEffect;
private String rule;

View file

@ -1,107 +1,33 @@
/*
* 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.
*/
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.mana;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Mana;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.effects.common.ManaEffect;
import mage.constants.AbilityType;
import mage.constants.Zone;
import mage.game.Game;
/**
*
* @author BetaSteward_at_googlemail.com
* @author LevelX2
*/
public abstract class ManaAbility extends ActivatedAbilityImpl {
protected List<Mana> netMana = new ArrayList<>();
protected boolean undoPossible;
public ManaAbility(Zone zone, ManaEffect effect, Cost cost) {
super(AbilityType.MANA, zone);
this.usesStack = false;
this.undoPossible = true;
if (effect != null) {
this.addEffect(effect);
}
if (cost != null) {
this.addCost(cost);
}
}
public ManaAbility(final ManaAbility ability) {
super(ability);
this.netMana.addAll(ability.netMana);
this.undoPossible = ability.undoPossible;
}
@Override
public boolean canActivate(UUID playerId, Game game) {
if (!controlsAbility(playerId, game)) {
return false;
}
//20091005 - 605.3a
return costs.canPay(this, sourceId, controllerId, game);
}
public interface ManaAbility {
/**
* Used to check the possible mana production to determine
* which spells and/or abilities can be used. (player.getPlayable()).
*
* Used to check the possible mana production to determine which spells
* and/or abilities can be used. (player.getPlayable()).
*
* @param game
* @return
* @return
*/
public List<Mana> getNetMana(Game game) {
return netMana;
}
List<Mana> getNetMana(Game game);
/**
* Used to check if the ability itself defines mana types
* it can produce.
* Used to check if the ability itself defines mana types it can produce.
*
* @return
*/
public boolean definesMana() {
return netMana.size() > 0;
}
public boolean isUndoPossible() {
return undoPossible;
}
public void setUndoPossible(boolean undoPossible) {
this.undoPossible = undoPossible;
}
boolean definesMana();
}

View file

@ -54,7 +54,7 @@ public class ManaOptions extends ArrayList<Mana> {
}
}
public void addMana(List<ManaAbility> abilities, Game game) {
public void addMana(List<ActivatedManaAbilityImpl> abilities, Game game) {
if (isEmpty()) {
this.add(new Mana());
}
@ -81,7 +81,7 @@ public class ManaOptions extends ArrayList<Mana> {
//perform a union of all existing options and the new options
List<Mana> copy = copy();
this.clear();
for (ManaAbility ability : abilities) {
for (ActivatedManaAbilityImpl ability : abilities) {
for (Mana netMana : ability.getNetMana(game)) {
SkipAddMana:
for (Mana mana : copy) {
@ -107,14 +107,14 @@ public class ManaOptions extends ArrayList<Mana> {
}
}
public void addManaWithCost(List<ManaAbility> abilities, Game game) {
public void addManaWithCost(List<ActivatedManaAbilityImpl> abilities, Game game) {
if (isEmpty()) {
this.add(new Mana());
}
if (!abilities.isEmpty()) {
if (abilities.size() == 1) {
//if there is only one mana option available add it to all the existing options
ManaAbility ability = abilities.get(0);
ActivatedManaAbilityImpl ability = abilities.get(0);
List<Mana> netManas = abilities.get(0).getNetMana(game);
// no mana costs
if (ability.getManaCosts().isEmpty()) {
@ -151,7 +151,7 @@ public class ManaOptions extends ArrayList<Mana> {
//perform a union of all existing options and the new options
List<Mana> copy = copy();
this.clear();
for (ManaAbility ability : abilities) {
for (ActivatedManaAbilityImpl ability : abilities) {
List<Mana> netManas = ability.getNetMana(game);

View file

@ -41,7 +41,7 @@ import mage.game.Game;
*
* @author BetaSteward_at_googlemail.com
*/
public class SimpleManaAbility extends ManaAbility {
public class SimpleManaAbility extends ActivatedManaAbilityImpl {
public SimpleManaAbility(Zone zone, ManaEffect effect, Cost cost) {
super(zone, effect, cost);

View file

@ -27,17 +27,25 @@
*/
package mage.abilities.mana;
import java.util.ArrayList;
import java.util.List;
import mage.Mana;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DynamicManaEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.constants.AbilityType;
import mage.constants.Zone;
import mage.game.Game;
/**
* see 20110715 - 605.1b
*
* @author BetaSteward_at_googlemail.com
*/
public abstract class TriggeredManaAbility extends TriggeredAbilityImpl {
public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implements ManaAbility {
protected List<Mana> netMana = new ArrayList<>();
public TriggeredManaAbility(Zone zone, ManaEffect effect) {
this(zone, effect, false);
@ -47,9 +55,48 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl {
super(zone, effect, optional);
this.usesStack = false;
this.abilityType = AbilityType.MANA;
}
public TriggeredManaAbility(final TriggeredManaAbility ability) {
super(ability);
this.netMana.addAll(ability.netMana);
}
/**
* Used to check the possible mana production to determine which spells
* and/or abilities can be used. (player.getPlayable()).
*
* @param game
* @return
*/
@Override
public List<Mana> getNetMana(Game game) {
if (!getEffects().isEmpty()) {
Effect effect = getEffects().get(0);
if (effect != null && game != null) {
ArrayList<Mana> newNetMana = new ArrayList<>();
if (effect instanceof DynamicManaEffect) {
// TODO: effects from replacement effects like Mana Reflection are not considered yet
// TODO: effects that need a X payment (e.g. Mage-Ring Network) return always 0
newNetMana.add(((DynamicManaEffect) effect).computeMana(true, game, this));
} else if (effect instanceof Effect) {
newNetMana.add(((ManaEffect) effect).getMana(game, this));
}
return newNetMana;
}
}
return netMana;
}
/**
* Used to check if the ability itself defines mana types it can produce.
*
* @return
*/
@Override
public boolean definesMana() {
return netMana.size() > 0;
}
}

View file

@ -38,7 +38,7 @@ import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability;
import mage.abilities.PlayLandAbility;
import mage.abilities.SpellAbility;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.repository.PluginClassloaderRegistery;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
@ -341,7 +341,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override
public List<Mana> getMana() {
List<Mana> mana = new ArrayList<>();
for (ManaAbility ability : this.abilities.getManaAbilities(Zone.BATTLEFIELD)) {
for (ActivatedManaAbilityImpl ability : this.abilities.getActivatedManaAbilities(Zone.BATTLEFIELD)) {
for (Mana netMana : ability.getNetMana(null)) {
mana.add(netMana);
}

View file

@ -33,7 +33,7 @@ import java.util.UUID;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.CardImpl;
/**
@ -42,7 +42,7 @@ import mage.cards.CardImpl;
*/
public abstract class BasicLand extends CardImpl {
public BasicLand(UUID ownerId, CardSetInfo setInfo, ManaAbility mana) {
public BasicLand(UUID ownerId, CardSetInfo setInfo, ActivatedManaAbilityImpl mana) {
super(ownerId, setInfo, new CardType[]{CardType.LAND}, null);
this.supertype.add("Basic");
this.subtype.add(name);

View file

@ -24,12 +24,10 @@
* 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.choices;
import java.util.ArrayList;
import mage.Mana;
import mage.ObjectColor;
@ -40,6 +38,7 @@ import mage.ObjectColor;
public class ChoiceColor extends ChoiceImpl {
public static final ArrayList<String> colorChoices = new ArrayList<>();
static {
colorChoices.add("Green");
colorChoices.add("Blue");
@ -47,7 +46,7 @@ public class ChoiceColor extends ChoiceImpl {
colorChoices.add("Red");
colorChoices.add("White");
}
public ChoiceColor() {
this(true);
}
@ -93,7 +92,7 @@ public class ChoiceColor extends ChoiceImpl {
}
public Mana getMana(int amount) {
Mana mana = null;
Mana mana;
if (getColor().isBlack()) {
mana = Mana.BlackMana(amount);
} else if (getColor().isBlue()) {
@ -104,6 +103,8 @@ public class ChoiceColor extends ChoiceImpl {
mana = Mana.GreenMana(amount);
} else if (getColor().isWhite()) {
mana = Mana.WhiteMana(amount);
} else {
mana = Mana.ColorlessMana(amount);
}
return mana;
}
@ -119,6 +120,8 @@ public class ChoiceColor extends ChoiceImpl {
mana.increaseGreen();
} else if (getColor().isWhite()) {
mana.increaseWhite();
} else {
mana.increaseColorless();
}
}
}

View file

@ -76,7 +76,7 @@ import mage.abilities.keyword.InfectAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.abilities.keyword.ShroudAbility;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.ManaOptions;
import mage.actions.MageDrawAction;
import mage.cards.Card;
@ -1099,7 +1099,7 @@ public abstract class PlayerImpl implements Player, Serializable {
return true;
}
protected boolean playManaAbility(ManaAbility ability, Game game) {
protected boolean playManaAbility(ActivatedManaAbilityImpl ability, Game game) {
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getId(), ability.getSourceId(), playerId))) {
int bookmark = game.bookmarkState();
if (ability.activate(game, false)) {
@ -1197,7 +1197,7 @@ public abstract class PlayerImpl implements Player, Serializable {
result = specialAction((SpecialAction) ability.copy(), game);
break;
case MANA:
result = playManaAbility((ManaAbility) ability.copy(), game);
result = playManaAbility((ActivatedManaAbilityImpl) ability.copy(), game);
break;
case SPELL:
if (ability instanceof FlashbackAbility) {
@ -1294,7 +1294,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (canUse || ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
if (ability.getZone().match(zone)) {
if (ability instanceof ActivatedAbility) {
if (ability instanceof ManaAbility) {
if (ability instanceof ActivatedManaAbilityImpl) {
if (((ActivatedAbility) ability).canActivate(playerId, game)) {
useable.put(ability.getId(), (ActivatedAbility) ability);
}
@ -1391,10 +1391,10 @@ public abstract class PlayerImpl implements Player, Serializable {
}
}
protected LinkedHashMap<UUID, ManaAbility> getUseableManaAbilities(MageObject object, Zone zone, Game game) {
LinkedHashMap<UUID, ManaAbility> useable = new LinkedHashMap<>();
protected LinkedHashMap<UUID, ActivatedManaAbilityImpl> getUseableManaAbilities(MageObject object, Zone zone, Game game) {
LinkedHashMap<UUID, ActivatedManaAbilityImpl> useable = new LinkedHashMap<>();
boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game);
for (ManaAbility ability : object.getAbilities().getManaAbilities(zone)) {
for (ActivatedManaAbilityImpl ability : object.getAbilities().getActivatedManaAbilities(zone)) {
if (canUse || ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
if (ability.canActivate(playerId, game)) {
useable.put(ability.getId(), ability);
@ -2376,14 +2376,14 @@ public abstract class PlayerImpl implements Player, Serializable {
public ManaOptions getManaAvailable(Game game) {
ManaOptions available = new ManaOptions();
List<Abilities<ManaAbility>> sourceWithoutManaCosts = new ArrayList<>();
List<Abilities<ManaAbility>> sourceWithCosts = new ArrayList<>();
List<Abilities<ActivatedManaAbilityImpl>> sourceWithoutManaCosts = new ArrayList<>();
List<Abilities<ActivatedManaAbilityImpl>> sourceWithCosts = new ArrayList<>();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
Boolean canUse = null;
boolean canAdd = false;
boolean withCost = false;
Abilities<ManaAbility> manaAbilities = permanent.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game);
for (ManaAbility ability : manaAbilities) {
Abilities<ActivatedManaAbilityImpl> manaAbilities = permanent.getAbilities().getAvailableActivatedManaAbilities(Zone.BATTLEFIELD, game);
for (ActivatedManaAbilityImpl ability : manaAbilities) {
if (canUse == null) {
canUse = permanent.canUseActivatedAbilities(game);
}
@ -2404,10 +2404,10 @@ public abstract class PlayerImpl implements Player, Serializable {
}
}
for (Abilities<ManaAbility> manaAbilities : sourceWithoutManaCosts) {
for (Abilities<ActivatedManaAbilityImpl> manaAbilities : sourceWithoutManaCosts) {
available.addMana(manaAbilities, game);
}
for (Abilities<ManaAbility> manaAbilities : sourceWithCosts) {
for (Abilities<ActivatedManaAbilityImpl> manaAbilities : sourceWithCosts) {
available.addManaWithCost(manaAbilities, game);
}
return available;
@ -2419,7 +2419,7 @@ public abstract class PlayerImpl implements Player, Serializable {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
Boolean canUse = null;
boolean canAdd = false;
for (ManaAbility ability : permanent.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) {
for (ActivatedManaAbilityImpl ability : permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) {
if (!ability.getManaCosts().isEmpty()) {
canAdd = false;
break;
@ -2437,7 +2437,7 @@ public abstract class PlayerImpl implements Player, Serializable {
}
for (Card card : getHand().getCards(game)) {
boolean canAdd = false;
for (ManaAbility ability : card.getAbilities(game).getManaAbilities(Zone.HAND)) {
for (ActivatedManaAbilityImpl ability : card.getAbilities(game).getActivatedManaAbilities(Zone.HAND)) {
if (!ability.getManaCosts().isEmpty()) {
canAdd = false;
break;
@ -2458,7 +2458,7 @@ public abstract class PlayerImpl implements Player, Serializable {
List<Permanent> result = new ArrayList<>();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
Boolean canUse = null;
for (ManaAbility ability : permanent.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) {
for (ActivatedManaAbilityImpl ability : permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) {
if (canUse == null) {
canUse = permanent.canUseActivatedAbilities(game);
}
@ -2480,7 +2480,7 @@ public abstract class PlayerImpl implements Player, Serializable {
* @return
*/
protected boolean canPlay(ActivatedAbility ability, ManaOptions available, MageObject sourceObject, Game game) {
if (!(ability instanceof ManaAbility)) {
if (!(ability instanceof ActivatedManaAbilityImpl)) {
ActivatedAbility copy = ability.copy();
copy.setCheckPlayableMode(); // prevents from endless loops for asking player to use effects by checking this mode
if (!copy.canActivate(playerId, game)) {

View file

@ -16,7 +16,7 @@ import mage.abilities.mana.BasicManaAbility;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.RedManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.Card;
@ -56,10 +56,10 @@ public class ManaUtil {
* @return List of mana abilities permanent may produce and are reasonable
* for unpaid mana
*/
public static LinkedHashMap<UUID, ManaAbility> tryToAutoPay(ManaCost unpaid, LinkedHashMap<UUID, ManaAbility> useableAbilities) {
public static LinkedHashMap<UUID, ActivatedManaAbilityImpl> tryToAutoPay(ManaCost unpaid, LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities) {
// first check if we have only basic mana abilities
for (ManaAbility ability : useableAbilities.values()) {
for (ActivatedManaAbilityImpl ability : useableAbilities.values()) {
if (!(ability instanceof BasicManaAbility)) {
// return map as-is without any modification
return useableAbilities;
@ -130,12 +130,12 @@ public class ManaUtil {
return false;
}
private static LinkedHashMap<UUID, ManaAbility> getManaAbilitiesUsingManaSymbols(LinkedHashMap<UUID, ManaAbility> useableAbilities, ManaSymbols symbols, Mana unpaidMana) {
private static LinkedHashMap<UUID, ActivatedManaAbilityImpl> getManaAbilitiesUsingManaSymbols(LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities, ManaSymbols symbols, Mana unpaidMana) {
Set<ManaSymbol> countColored = new HashSet<>();
ManaAbility chosenManaAbility = null;
ManaAbility chosenManaAbilityForHybrid;
for (ManaAbility ability : useableAbilities.values()) {
ActivatedManaAbilityImpl chosenManaAbility = null;
ActivatedManaAbilityImpl chosenManaAbilityForHybrid;
for (ActivatedManaAbilityImpl ability : useableAbilities.values()) {
chosenManaAbility = getManaAbility(symbols, countColored, chosenManaAbility, ability);
chosenManaAbilityForHybrid = checkRedMana(symbols, countColored, ability);
@ -181,7 +181,7 @@ public class ManaUtil {
// we got another chance for auto pay
if (temp.size() == 1) {
for (ManaAbility ability : useableAbilities.values()) {
for (ActivatedManaAbilityImpl ability : useableAbilities.values()) {
chosenManaAbility = getManaAbility(symbols, countColored, chosenManaAbility, ability);
}
return replace(useableAbilities, chosenManaAbility);
@ -195,7 +195,7 @@ public class ManaUtil {
return replace(useableAbilities, chosenManaAbility);
}
private static ManaAbility getManaAbility(ManaSymbols symbols, Set<ManaSymbol> countColored, ManaAbility chosenManaAbility, ManaAbility ability) {
private static ActivatedManaAbilityImpl getManaAbility(ManaSymbols symbols, Set<ManaSymbol> countColored, ActivatedManaAbilityImpl chosenManaAbility, ActivatedManaAbilityImpl ability) {
if (ability instanceof RedManaAbility && symbols.contains(ManaSymbol.R)) {
chosenManaAbility = ability;
countColored.add(ManaSymbol.R);
@ -235,8 +235,8 @@ public class ManaUtil {
return count;
}
private static ManaAbility checkBlackMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ManaAbility ability) {
ManaAbility chosenManaAbilityForHybrid = null;
private static ActivatedManaAbilityImpl checkBlackMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ActivatedManaAbilityImpl ability) {
ActivatedManaAbilityImpl chosenManaAbilityForHybrid = null;
if (ability instanceof BlackManaAbility) {
if (symbols.contains(ManaSymbol.HYBRID_BR)) {
chosenManaAbilityForHybrid = ability;
@ -256,8 +256,8 @@ public class ManaUtil {
return chosenManaAbilityForHybrid;
}
private static ManaAbility checkRedMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ManaAbility ability) {
ManaAbility chosenManaAbilityForHybrid = null;
private static ActivatedManaAbilityImpl checkRedMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ActivatedManaAbilityImpl ability) {
ActivatedManaAbilityImpl chosenManaAbilityForHybrid = null;
if (ability instanceof RedManaAbility) {
if (symbols.contains(ManaSymbol.HYBRID_BR)) {
chosenManaAbilityForHybrid = ability;
@ -276,8 +276,8 @@ public class ManaUtil {
return chosenManaAbilityForHybrid;
}
private static ManaAbility checkBlueMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ManaAbility ability) {
ManaAbility chosenManaAbilityForHybrid = null;
private static ActivatedManaAbilityImpl checkBlueMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ActivatedManaAbilityImpl ability) {
ActivatedManaAbilityImpl chosenManaAbilityForHybrid = null;
if (ability instanceof BlueManaAbility) {
if (symbols.contains(ManaSymbol.HYBRID_UB)) {
chosenManaAbilityForHybrid = ability;
@ -296,8 +296,8 @@ public class ManaUtil {
return chosenManaAbilityForHybrid;
}
private static ManaAbility checkWhiteMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ManaAbility ability) {
ManaAbility chosenManaAbilityForHybrid = null;
private static ActivatedManaAbilityImpl checkWhiteMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ActivatedManaAbilityImpl ability) {
ActivatedManaAbilityImpl chosenManaAbilityForHybrid = null;
if (ability instanceof WhiteManaAbility) {
if (symbols.contains(ManaSymbol.HYBRID_WU)) {
chosenManaAbilityForHybrid = ability;
@ -316,8 +316,8 @@ public class ManaUtil {
return chosenManaAbilityForHybrid;
}
private static ManaAbility checkGreenMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ManaAbility ability) {
ManaAbility chosenManaAbilityForHybrid = null;
private static ActivatedManaAbilityImpl checkGreenMana(ManaSymbols symbols, Set<ManaSymbol> countColored, ActivatedManaAbilityImpl ability) {
ActivatedManaAbilityImpl chosenManaAbilityForHybrid = null;
if (ability instanceof GreenManaAbility) {
if (symbols.contains(ManaSymbol.HYBRID_GW)) {
chosenManaAbilityForHybrid = ability;
@ -344,13 +344,13 @@ public class ManaUtil {
* @param useableAbilities
* @return
*/
private static LinkedHashMap<UUID, ManaAbility> getManaAbilitiesUsingMana(ManaCost unpaid, LinkedHashMap<UUID, ManaAbility> useableAbilities) {
private static LinkedHashMap<UUID, ActivatedManaAbilityImpl> getManaAbilitiesUsingMana(ManaCost unpaid, LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities) {
Mana mana = unpaid.getMana();
int countColorfull = 0;
int countColorless = 0;
ManaAbility chosenManaAbility = null;
for (ManaAbility ability : useableAbilities.values()) {
ActivatedManaAbilityImpl chosenManaAbility = null;
for (ActivatedManaAbilityImpl ability : useableAbilities.values()) {
if (ability instanceof RedManaAbility && mana.contains(Mana.RedMana(1))) {
chosenManaAbility = ability;
countColorfull++;
@ -392,7 +392,7 @@ public class ManaUtil {
return replace(useableAbilities, chosenManaAbility);
}
private static LinkedHashMap<UUID, ManaAbility> replace(LinkedHashMap<UUID, ManaAbility> useableAbilities, ManaAbility chosenManaAbility) {
private static LinkedHashMap<UUID, ActivatedManaAbilityImpl> replace(LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities, ActivatedManaAbilityImpl chosenManaAbility) {
// modify the map with the chosen mana ability
useableAbilities.clear();
useableAbilities.put(chosenManaAbility.getId(), chosenManaAbility);