mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
SpellRestrictions: restrict non special mana abilities when special is used
This commit is contained in:
@@ -446,10 +446,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
public boolean isAbility() { return true; }
|
||||
public boolean isActivatedAbility() { return false; }
|
||||
|
||||
|
||||
public boolean isPayingSpecial() {
|
||||
for (SpellAbility sa : getPayingManaAbilities()) {
|
||||
if (sa.isImprovise() || sa.isConvoke() || sa.isDelve()) {
|
||||
if (sa.isSpecialPayment()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -461,6 +460,10 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
public boolean isImprovise() { return false; }
|
||||
public boolean isDelve() { return false; }
|
||||
|
||||
public boolean isSpecialPayment() {
|
||||
return isConvoke() || isImprovise() || isDelve();
|
||||
}
|
||||
|
||||
public final CardCollectionView getDelved() {
|
||||
return CardCollection.getView(delvedCards);
|
||||
}
|
||||
|
||||
@@ -474,6 +474,15 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!sa.isSpecialPayment()) {
|
||||
IndividualCostPaymentInstance i = game.costPaymentStack.peek();
|
||||
if (i != null) {
|
||||
SpellAbility saPay = i.getPayment().getAbility();
|
||||
if (saPay.isPayingSpecial()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getsVarToCheck() != null) {
|
||||
@@ -508,7 +517,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean canPlay(final Card c, final SpellAbility sa) {
|
||||
if (c.isPhasedOut() || c.isUsedToPay()) {
|
||||
if (c.isPhasedOut()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,40 +172,6 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<SpellAbility> getUsefulManaAbilities(Card card) {
|
||||
List<SpellAbility> abilities = new ArrayList<>();
|
||||
|
||||
if (card.getController() != player) {
|
||||
return abilities;
|
||||
}
|
||||
|
||||
byte colorCanUse = 0;
|
||||
for (final byte color : ManaAtom.MANATYPES) {
|
||||
if (manaCost.isAnyPartPayableWith(color, player.getManaPool())) {
|
||||
colorCanUse |= color;
|
||||
}
|
||||
}
|
||||
if (manaCost.isAnyPartPayableWith((byte) ManaAtom.GENERIC, player.getManaPool())) {
|
||||
colorCanUse |= ManaAtom.GENERIC;
|
||||
}
|
||||
if (colorCanUse == 0) { // no mana cost or something
|
||||
return abilities;
|
||||
}
|
||||
|
||||
final String typeRes = manaCost.getSourceRestriction();
|
||||
if (StringUtils.isNotBlank(typeRes) && !card.getType().hasStringType(typeRes)) {
|
||||
return abilities;
|
||||
}
|
||||
|
||||
for (SpellAbility ma : getAllManaAbilities(card)) {
|
||||
ma.setActivatingPlayer(player);
|
||||
if (ma.isManaAbilityFor(saPaidFor, colorCanUse))
|
||||
abilities.add(ma);
|
||||
}
|
||||
return abilities;
|
||||
}
|
||||
|
||||
public void useManaFromPool(byte colorCode) {
|
||||
// find the matching mana in pool.
|
||||
if (player.getManaPool().tryPayCostWithColor(colorCode, saPaidFor, manaCost)) {
|
||||
@@ -352,7 +318,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
@Override
|
||||
public void run() {
|
||||
if (HumanPlay.playSpellAbility(getController(), chosen.getActivatingPlayer(), chosen)) {
|
||||
if (chosen.isConvoke() || chosen.isImprovise() || chosen.isDelve()) {
|
||||
if (chosen.isSpecialPayment()) {
|
||||
saPaidFor.getPayingManaAbilities().add(chosen);
|
||||
// bypass the mana from Ability part
|
||||
} else if (chosen.getManaPart().meetsManaRestrictions(saPaidFor)) {
|
||||
|
||||
Reference in New Issue
Block a user