mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Fixed a bug that mana in the mana pool could not be used to pay mana costs that could only be payed with "you may spend mana as thought" effects (fixes #2581).
This commit is contained in:
parent
2c28f64294
commit
2fceafda93
4 changed files with 77 additions and 10 deletions
|
|
@ -131,6 +131,35 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
}
|
||||
}
|
||||
|
||||
public Mana(final ManaType manaType) {
|
||||
Objects.requireNonNull(manaType, "The passed in ManaType can not be null");
|
||||
switch (manaType) {
|
||||
case GREEN:
|
||||
green = 1;
|
||||
break;
|
||||
case RED:
|
||||
red = 1;
|
||||
break;
|
||||
case BLACK:
|
||||
black = 1;
|
||||
break;
|
||||
case BLUE:
|
||||
blue = 1;
|
||||
break;
|
||||
case WHITE:
|
||||
white = 1;
|
||||
break;
|
||||
case COLORLESS:
|
||||
colorless = 1;
|
||||
break;
|
||||
case GENERIC:
|
||||
generic = 1;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown manaType: " + manaType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Mana} object with the passed in {@code num} of Red mana.
|
||||
* {@code num} can not be a negative value. Negative values will be logged
|
||||
|
|
@ -222,13 +251,12 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Mana} object with the passed in {@code num} of Any
|
||||
* mana. {@code num} can not be a negative value. Negative values will be
|
||||
* logged and set to 0.
|
||||
* Creates a {@link Mana} object with the passed in {@code num} of Any mana.
|
||||
* {@code num} can not be a negative value. Negative values will be logged
|
||||
* and set to 0.
|
||||
*
|
||||
* @param num value of Any mana to create.
|
||||
* @return a {@link Mana} object with the passed in {@code num} of Any
|
||||
* mana.
|
||||
* @return a {@link Mana} object with the passed in {@code num} of Any mana.
|
||||
*/
|
||||
public static Mana AnyMana(int num) {
|
||||
return new Mana(0, 0, 0, 0, 0, 0, notNegative(num, "Any"), 0);
|
||||
|
|
|
|||
|
|
@ -118,10 +118,19 @@ public class ManaPool implements Serializable {
|
|||
// if manual payment and the needed mana type was not unlocked, nothing will be paid
|
||||
return false;
|
||||
}
|
||||
ManaType possibleAsThoughtPoolManaType = null;
|
||||
if (autoPayment && autoPaymentRestricted && !wasManaAddedBeyondStock() && manaType != unlockedManaType) {
|
||||
// if automatic restricted payment and there is already mana in the pool
|
||||
// and the needed mana type was not unlocked, nothing will be paid
|
||||
return false;
|
||||
if (unlockedManaType != null) {
|
||||
ManaPoolItem checkItem = new ManaPoolItem();
|
||||
checkItem.add(unlockedManaType, 1);
|
||||
possibleAsThoughtPoolManaType = game.getContinuousEffects().asThoughMana(manaType, checkItem, ability.getSourceId(), ability, ability.getControllerId(), game);
|
||||
}
|
||||
// Check if it's possible to use mana as thought for the unlocked manatype in the mana pool for this ability
|
||||
if (possibleAsThoughtPoolManaType == null || possibleAsThoughtPoolManaType != unlockedManaType) {
|
||||
return false; // if it's not possible return
|
||||
}
|
||||
}
|
||||
|
||||
if (getConditional(manaType, ability, filter, game, costToPay) > 0) {
|
||||
|
|
@ -138,7 +147,7 @@ public class ManaPool implements Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (manaType != unlockedManaType && autoPayment && autoPaymentRestricted && mana.count() == mana.getStock()) {
|
||||
if (possibleAsThoughtPoolManaType == null && manaType != unlockedManaType && autoPayment && autoPaymentRestricted && mana.count() == mana.getStock()) {
|
||||
// no mana added beyond the stock so don't auto pay this
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue