Jegantha, the Wellspring

This commit is contained in:
rory
2020-05-10 11:34:07 -07:00
parent 538430009b
commit 4eb21594b4
6 changed files with 89 additions and 2 deletions

View File

@@ -741,7 +741,7 @@ public class ComputerUtilMana {
continue; continue;
} }
if (thisMana.getManaAbility() != null && !thisMana.getManaAbility().meetsManaRestrictions(saBeingPaidFor)) { if (thisMana.getManaAbility() != null && !thisMana.getManaAbility().meetsSpellAndShardRestrictions(saBeingPaidFor, shard, thisMana.getColor())) {
continue; continue;
} }

View File

@@ -289,13 +289,20 @@ public enum ManaCostShard {
return BinaryUtil.bitCount(this.shard & COLORS_SUPERPOSITION) == 2; return BinaryUtil.bitCount(this.shard & COLORS_SUPERPOSITION) == 2;
} }
public boolean isGeneric() {
return isOfKind(ManaAtom.GENERIC)|| isOfKind(ManaAtom.IS_X) || this.isSnow() || this.isOr2Generic();
}
public boolean isOr2Generic() { public boolean isOr2Generic() {
return isOfKind(ManaAtom.OR_2_GENERIC); return isOfKind(ManaAtom.OR_2_GENERIC);
} }
public boolean isColor(byte colorCode) {
return (colorCode & this.shard) > 0;
}
public boolean canBePaidWithManaOfColor(byte colorCode) { public boolean canBePaidWithManaOfColor(byte colorCode) {
return this.isOr2Generic() || ((COLORS_SUPERPOSITION | ManaAtom.COLORLESS) & this.shard) == 0 || return this.isOr2Generic() || ((COLORS_SUPERPOSITION | ManaAtom.COLORLESS) & this.shard) == 0 ||
(colorCode & this.shard) > 0; this.isColor(colorCode);
} }
public boolean isOfKind(int atom) { public boolean isOfKind(int atom) {

View File

@@ -543,6 +543,9 @@ public class ManaCostBeingPaid {
if (shard.isSnow() && !mana.isSnow()) { if (shard.isSnow() && !mana.isSnow()) {
return false; return false;
} }
if (mana.isRestricted() && !mana.getManaAbility().meetsManaShardRestrictions(shard, mana.getColor())) {
return false;
}
byte color = mana.getColor(); byte color = mana.getColor();
return pool.canPayForShardWithColor(shard, color); return pool.canPayForShardWithColor(shard, color);

View File

@@ -25,6 +25,7 @@ import forge.ImageKeys;
import forge.LobbyPlayer; import forge.LobbyPlayer;
import forge.card.CardType; import forge.card.CardType;
import forge.card.MagicColor; import forge.card.MagicColor;
import forge.card.mana.ManaCostShard;
import forge.game.*; import forge.game.*;
import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityFactory;
import forge.game.ability.AbilityKey; import forge.game.ability.AbilityKey;
@@ -2870,6 +2871,18 @@ public class Player extends GameEntity implements Comparable<Player> {
cardTypes.retainAll((Collection<?>) c.getPaperCard().getRules().getType().getCoreTypes()); cardTypes.retainAll((Collection<?>) c.getPaperCard().getRules().getType().getCoreTypes());
} }
boolean uniqueManaSymbols = true;
for (final Card c : getCardsIn(ZoneType.Library)) {
Set<ManaCostShard> manaSymbols = new HashSet<>();
for (final ManaCostShard manaSymbol : c.getManaCost()) {
if (manaSymbols.contains(manaSymbol)) {
uniqueManaSymbols = false;
} else {
manaSymbols.add(manaSymbol);
}
}
}
int deckSize = getCardsIn(ZoneType.Library).size(); int deckSize = getCardsIn(ZoneType.Library).size();
int minSize = game.getMatch().getRules().getGameType().getDeckFormat().getMainRange().getMinimum(); int minSize = game.getMatch().getRules().getGameType().getDeckFormat().getMainRange().getMinimum();
@@ -2886,6 +2899,10 @@ public class Player extends GameEntity implements Comparable<Player> {
if (uniqueNames) { if (uniqueNames) {
legalCompanions.add(c); legalCompanions.add(c);
} }
} else if (specialRules.equals("UniqueManaSymbols")) {
if (uniqueManaSymbols) {
legalCompanions.add(c);
}
} else if (specialRules.equals("DeckSizePlus20")) { } else if (specialRules.equals("DeckSizePlus20")) {
// +20 deck size to min deck size // +20 deck size to min deck size
if (deckSize >= minSize + 20) { if (deckSize >= minSize + 20) {

View File

@@ -23,6 +23,7 @@ import com.google.common.collect.Maps;
import forge.card.ColorSet; import forge.card.ColorSet;
import forge.card.MagicColor; import forge.card.MagicColor;
import forge.card.mana.ManaAtom; import forge.card.mana.ManaAtom;
import forge.card.mana.ManaCostShard;
import forge.game.Game; import forge.game.Game;
import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityFactory;
import forge.game.ability.AbilityKey; import forge.game.ability.AbilityKey;
@@ -382,11 +383,63 @@ public class AbilityManaPart implements java.io.Serializable {
} }
} }
if (restriction.equals("CantPayGenericCosts")) {
return true;
}
} }
return false; return false;
} }
/**
* <p>
* meetsManaShardRestrictions.
* </p>
*
* @param shard
* a {@link forge.card.mana.ManaCostShard} object.
* @param color
* the color of mana being paid
* @return a boolean.
*/
public boolean meetsManaShardRestrictions(final ManaCostShard shard, final byte color) {
if (this.manaRestrictions.isEmpty()) {
return true;
}
for (String restriction : this.manaRestrictions.split(",")) {
if (restriction.equals("CantPayGenericCosts")) {
if (shard.isGeneric()) {
if (shard.isOr2Generic() && shard.isColor(color)) {
continue;
} else {
return false;
}
} else {
continue;
}
}
}
return true;
}
/**
* <p>
* meetsSpellAndShardRestrictions.
* </p>
*
* @param sa
* a {@link forge.game.spellability.SpellAbility} object.
* @param shard
* a {@link forge.card.mana.ManaCostShard} object.
* @param color
* the color of mana being paid
* @return a boolean.
*/
public boolean meetsSpellAndShardRestrictions(final SpellAbility sa, final ManaCostShard shard, final byte color) {
return this.meetsManaRestrictions(sa) && this.meetsManaShardRestrictions(shard, color);
}
/** /**
* <p> * <p>
* mana. * mana.

View File

@@ -0,0 +1,7 @@
Name:Jegantha, the Wellspring
ManaCost:4 R/G
Types:Legendary Creature Elemental Elk
PT:5/5
K:Companion:Special:UniqueManaSymbols:No card in your starting deck has more than one of the same mana symbol in its mana cost.
A:AB$ Mana | Cost$ T | Produced$ W U B R G | RestrictValid$ CantPayGenericCosts | SpellDescription$ Add {W}{U}{B}{R}{G}. This mana can't be spent to pay generic mana costs.
Oracle:Companion — No card in your starting deck has more than one of the same mana symbol in its mana cost. (If this card is your chosen companion, you may cast it once from outside the game.)\n{T}: Add {W}{U}{B}{R}{G}. This mana can't be spent to pay generic mana costs.