mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 17:58:01 +00:00
Card: chosenColors use Table for LinkedAbilities
This commit is contained in:
@@ -414,7 +414,6 @@ public class ComputerUtilMana {
|
|||||||
// then apply this one
|
// then apply this one
|
||||||
if (!replaceType.isEmpty()) {
|
if (!replaceType.isEmpty()) {
|
||||||
for (SpellAbility saMana : replaceAmount) {
|
for (SpellAbility saMana : replaceAmount) {
|
||||||
Card card = saMana.getHostCard();
|
|
||||||
if (saMana.hasParam("ReplaceType")) {
|
if (saMana.hasParam("ReplaceType")) {
|
||||||
// replace color and colorless
|
// replace color and colorless
|
||||||
String color = saMana.getParam("ReplaceType");
|
String color = saMana.getParam("ReplaceType");
|
||||||
@@ -436,8 +435,8 @@ public class ComputerUtilMana {
|
|||||||
// replace color
|
// replace color
|
||||||
String color = saMana.getParam("ReplaceColor");
|
String color = saMana.getParam("ReplaceColor");
|
||||||
if ("Chosen".equals(color)) {
|
if ("Chosen".equals(color)) {
|
||||||
if (card.hasChosenColor()) {
|
if (saMana.hasChosenColor()) {
|
||||||
color = MagicColor.toShortString(card.getChosenColor());
|
color = MagicColor.toShortString(saMana.getChosenColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (saMana.hasParam("ReplaceOnly")) {
|
if (saMana.hasParam("ReplaceOnly")) {
|
||||||
@@ -489,7 +488,7 @@ public class ComputerUtilMana {
|
|||||||
int pAmount = AbilityUtils.calculateAmount(trSA.getHostCard(), trSA.getParamOrDefault("Amount", "1"), trSA);
|
int pAmount = AbilityUtils.calculateAmount(trSA.getHostCard(), trSA.getParamOrDefault("Amount", "1"), trSA);
|
||||||
String produced = trSA.getParam("Produced");
|
String produced = trSA.getParam("Produced");
|
||||||
if (produced.equals("Chosen")) {
|
if (produced.equals("Chosen")) {
|
||||||
produced = MagicColor.toShortString(trSA.getHostCard().getChosenColor());
|
produced = MagicColor.toShortString(trSA.getHostCard().getChosenColor(trSA));
|
||||||
}
|
}
|
||||||
manaProduced += " " + StringUtils.repeat(produced, pAmount);
|
manaProduced += " " + StringUtils.repeat(produced, pAmount);
|
||||||
} else if (ApiType.ManaReflected.equals(trSA.getApi())) {
|
} else if (ApiType.ManaReflected.equals(trSA.getApi())) {
|
||||||
|
|||||||
@@ -341,8 +341,9 @@ public abstract class GameState {
|
|||||||
newText.append("|Damage:").append(c.getDamage());
|
newText.append("|Damage:").append(c.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c.getChosenColor().isEmpty()) {
|
SpellAbility first = c.getFirstSpellAbility();
|
||||||
newText.append("|ChosenColor:").append(TextUtil.join(c.getChosenColors(), ","));
|
if (first != null) {
|
||||||
|
newText.append("|ChosenColor:").append(TextUtil.join(first.getChosenColors(), ","));
|
||||||
}
|
}
|
||||||
if (!c.getChosenType().isEmpty()) {
|
if (!c.getChosenType().isEmpty()) {
|
||||||
newText.append("|ChosenType:").append(c.getChosenType());
|
newText.append("|ChosenType:").append(c.getChosenType());
|
||||||
@@ -734,7 +735,7 @@ public abstract class GameState {
|
|||||||
if (persistent) {
|
if (persistent) {
|
||||||
produced.put("PersistentMana", "True");
|
produced.put("PersistentMana", "True");
|
||||||
}
|
}
|
||||||
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
final AbilityManaPart abMana = new AbilityManaPart(dummy, null, produced);
|
||||||
game.getAction().invoke(new Runnable() {
|
game.getAction().invoke(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -1088,7 +1089,7 @@ public abstract class GameState {
|
|||||||
Card c = entry.getKey();
|
Card c = entry.getKey();
|
||||||
List<String> colors = entry.getValue();
|
List<String> colors = entry.getValue();
|
||||||
|
|
||||||
c.setChosenColors(colors);
|
c.setChosenColors(colors, c.getFirstSpellAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chosen type
|
// Chosen type
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ public class AnimateAi extends SpellAbilityAi {
|
|||||||
if (sa.hasParam("Colors")) {
|
if (sa.hasParam("Colors")) {
|
||||||
final String colors = sa.getParam("Colors");
|
final String colors = sa.getParam("Colors");
|
||||||
if (colors.equals("ChosenColor")) {
|
if (colors.equals("ChosenColor")) {
|
||||||
tmpDesc = CardUtil.getShortColorsString(source.getChosenColors());
|
tmpDesc = CardUtil.getShortColorsString(sa.getChosenColors());
|
||||||
} else {
|
} else {
|
||||||
tmpDesc = CardUtil.getShortColorsString(Lists.newArrayList(Arrays.asList(colors.split(","))));
|
tmpDesc = CardUtil.getShortColorsString(Lists.newArrayList(Arrays.asList(colors.split(","))));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.google.common.collect.Iterables;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
|
||||||
import forge.ai.ComputerUtilAbility;
|
import forge.ai.ComputerUtilAbility;
|
||||||
import forge.ai.ComputerUtilCard;
|
import forge.ai.ComputerUtilCard;
|
||||||
import forge.ai.ComputerUtilCost;
|
import forge.ai.ComputerUtilCost;
|
||||||
@@ -31,6 +32,7 @@ import forge.game.phase.PhaseType;
|
|||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.AbilitySub;
|
import forge.game.spellability.AbilitySub;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
import forge.game.staticability.StaticAbilityCantBeCast;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
import forge.util.collect.FCollection;
|
import forge.util.collect.FCollection;
|
||||||
@@ -228,11 +230,10 @@ public class ChooseGenericEffectAi extends SpellAbilityAi {
|
|||||||
return allow;
|
return allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if Iona does prevent from casting, allow it to draw
|
SpellAbility firstSpell = imprinted.getFirstSpellAbility();
|
||||||
for (final Card io : player.getCardsIn(ZoneType.Battlefield, "Iona, Shield of Emeria")) {
|
// check if something would prevent it from casting
|
||||||
if (CardUtil.getColors(imprinted).hasAnyColor(MagicColor.fromName(io.getChosenColor()))) {
|
if (firstSpell == null || StaticAbilityCantBeCast.cantBeCastAbility(firstSpell, imprinted, owner)) {
|
||||||
return allow;
|
return allow;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmg == 0) {
|
if (dmg == 0) {
|
||||||
|
|||||||
@@ -55,15 +55,15 @@ public class GameCopier {
|
|||||||
public GameCopier(Game origGame) {
|
public GameCopier(Game origGame) {
|
||||||
this.origGame = origGame;
|
this.origGame = origGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game getOriginalGame() {
|
public Game getOriginalGame() {
|
||||||
return origGame;
|
return origGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game getCopiedGame() {
|
public Game getCopiedGame() {
|
||||||
return gameObjectMap.getGame();
|
return gameObjectMap.getGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game makeCopy() {
|
public Game makeCopy() {
|
||||||
return makeCopy(null);
|
return makeCopy(null);
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ public class GameCopier {
|
|||||||
for (Player p : newGame.getPlayers()) {
|
for (Player p : newGame.getPlayers()) {
|
||||||
((PlayerZoneBattlefield) p.getZone(ZoneType.Battlefield)).setTriggers(false);
|
((PlayerZoneBattlefield) p.getZone(ZoneType.Battlefield)).setTriggers(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyGameState(newGame);
|
copyGameState(newGame);
|
||||||
|
|
||||||
for (Player p : newGame.getPlayers()) {
|
for (Player p : newGame.getPlayers()) {
|
||||||
@@ -124,7 +124,6 @@ public class GameCopier {
|
|||||||
System.err.println(c + " Remembered: " + o + "/" + o.getClass());
|
System.err.println(c + " Remembered: " + o + "/" + o.getClass());
|
||||||
c.addRemembered(o);
|
c.addRemembered(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (SpellAbility sa : c.getSpellAbilities()) {
|
for (SpellAbility sa : c.getSpellAbilities()) {
|
||||||
@@ -153,7 +152,7 @@ public class GameCopier {
|
|||||||
if (advanceToPhase != null) {
|
if (advanceToPhase != null) {
|
||||||
newGame.getPhaseHandler().devAdvanceToPhase(advanceToPhase);
|
newGame.getPhaseHandler().devAdvanceToPhase(advanceToPhase);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newGame;
|
return newGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +179,7 @@ public class GameCopier {
|
|||||||
}
|
}
|
||||||
newGame.getStack().add(newSa);
|
newGame.getStack().add(newSa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RegisteredPlayer clonePlayer(RegisteredPlayer p) {
|
private RegisteredPlayer clonePlayer(RegisteredPlayer p) {
|
||||||
@@ -227,7 +226,7 @@ public class GameCopier {
|
|||||||
// TODO: Verify that the above relationships are preserved bi-directionally or not.
|
// TODO: Verify that the above relationships are preserved bi-directionally or not.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final boolean USE_FROM_PAPER_CARD = true;
|
private static final boolean USE_FROM_PAPER_CARD = true;
|
||||||
private Card createCardCopy(Game newGame, Player newOwner, Card c) {
|
private Card createCardCopy(Game newGame, Player newOwner, Card c) {
|
||||||
if (c.isToken() && !c.isEmblem()) {
|
if (c.isToken() && !c.isEmblem()) {
|
||||||
@@ -277,7 +276,7 @@ public class GameCopier {
|
|||||||
// TODO: Controllers' list with timestamps should be copied.
|
// TODO: Controllers' list with timestamps should be copied.
|
||||||
zoneOwner = playerMap.get(c.getController());
|
zoneOwner = playerMap.get(c.getController());
|
||||||
newCard.setController(zoneOwner, 0);
|
newCard.setController(zoneOwner, 0);
|
||||||
|
|
||||||
int setPower = c.getSetPower();
|
int setPower = c.getSetPower();
|
||||||
int setToughness = c.getSetToughness();
|
int setToughness = c.getSetToughness();
|
||||||
if (setPower != Integer.MAX_VALUE || setToughness != Integer.MAX_VALUE) {
|
if (setPower != Integer.MAX_VALUE || setToughness != Integer.MAX_VALUE) {
|
||||||
@@ -286,7 +285,7 @@ public class GameCopier {
|
|||||||
}
|
}
|
||||||
newCard.setPTBoost(c.getPTBoostTable());
|
newCard.setPTBoost(c.getPTBoostTable());
|
||||||
newCard.setDamage(c.getDamage());
|
newCard.setDamage(c.getDamage());
|
||||||
|
|
||||||
newCard.setChangedCardTypes(c.getChangedCardTypesMap());
|
newCard.setChangedCardTypes(c.getChangedCardTypesMap());
|
||||||
newCard.setChangedCardKeywords(c.getChangedCardKeywords());
|
newCard.setChangedCardKeywords(c.getChangedCardKeywords());
|
||||||
newCard.setChangedCardNames(c.getChangedCardNames());
|
newCard.setChangedCardNames(c.getChangedCardNames());
|
||||||
@@ -341,9 +340,13 @@ public class GameCopier {
|
|||||||
if (!c.getChosenType2().isEmpty()) {
|
if (!c.getChosenType2().isEmpty()) {
|
||||||
newCard.setChosenType2(c.getChosenType2());
|
newCard.setChosenType2(c.getChosenType2());
|
||||||
}
|
}
|
||||||
if (c.getChosenColors() != null) {
|
|
||||||
newCard.setChosenColors(Lists.newArrayList(c.getChosenColors()));
|
SpellAbility first = c.getFirstSpellAbility();
|
||||||
|
|
||||||
|
if (first != null && first.hasChosenColor()) {
|
||||||
|
newCard.setChosenColors(Lists.newArrayList(first.getChosenColors()), newCard.getFirstSpellAbility());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c.getNamedCard().isEmpty()) {
|
if (!c.getNamedCard().isEmpty()) {
|
||||||
newCard.setNamedCard(c.getNamedCard());
|
newCard.setNamedCard(c.getNamedCard());
|
||||||
}
|
}
|
||||||
@@ -359,7 +362,7 @@ public class GameCopier {
|
|||||||
zoneOwner.getZone(zone).add(newCard);
|
zoneOwner.getZone(zone).add(newCard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SpellAbility findSAInCard(SpellAbility sa, Card c) {
|
private static SpellAbility findSAInCard(SpellAbility sa, Card c) {
|
||||||
String saDesc = sa.getDescription();
|
String saDesc = sa.getDescription();
|
||||||
for (SpellAbility cardSa : c.getAllSpellAbilities()) {
|
for (SpellAbility cardSa : c.getAllSpellAbilities()) {
|
||||||
@@ -387,7 +390,7 @@ public class GameCopier {
|
|||||||
return find(o);
|
return find(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject find(GameObject o) {
|
public GameObject find(GameObject o) {
|
||||||
GameObject result = cardMap.get(o);
|
GameObject result = cardMap.get(o);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
|
|||||||
@@ -637,4 +637,20 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView,
|
|||||||
// dont use setHostCard to not trigger the not copied parts yet
|
// dont use setHostCard to not trigger the not copied parts yet
|
||||||
copy.hostCard = host;
|
copy.hostCard = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getChosenColor() {
|
||||||
|
return getHostCard().getChosenColor(this);
|
||||||
|
}
|
||||||
|
public final Iterable<String> getChosenColors() {
|
||||||
|
return getHostCard().getChosenColors(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean hasChosenColor() {
|
||||||
|
return getHostCard().hasChosenColor(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean hasChosenColor(String s) {
|
||||||
|
return getHostCard().hasChosenColor(s, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,13 +54,13 @@ public class ForgeScript {
|
|||||||
} else if (property.startsWith("ChosenColor")) {
|
} else if (property.startsWith("ChosenColor")) {
|
||||||
if (property.endsWith("Source") && isColorlessSource)
|
if (property.endsWith("Source") && isColorlessSource)
|
||||||
return false;
|
return false;
|
||||||
return source.hasChosenColor() && colors.hasAnyColor(MagicColor.fromName(source.getChosenColor()));
|
return spellAbility.hasChosenColor() && colors.hasAnyColor(MagicColor.fromName(spellAbility.getChosenColor()));
|
||||||
|
|
||||||
} else if (property.startsWith("AnyChosenColor")) {
|
} else if (property.startsWith("AnyChosenColor")) {
|
||||||
if (property.endsWith("Source") && isColorlessSource)
|
if (property.endsWith("Source") && isColorlessSource)
|
||||||
return false;
|
return false;
|
||||||
return source.hasChosenColor()
|
return spellAbility.hasChosenColor()
|
||||||
&& colors.hasAnyColor(ColorSet.fromNames(source.getChosenColors()).getColor());
|
&& colors.hasAnyColor(ColorSet.fromNames(spellAbility.getChosenColors()).getColor());
|
||||||
|
|
||||||
} else if (property.startsWith("non")) {
|
} else if (property.startsWith("non")) {
|
||||||
// ... Other Card types
|
// ... Other Card types
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class AbilityApiBased extends AbilityActivated {
|
|||||||
effect = api.getSpellEffect();
|
effect = api.getSpellEffect();
|
||||||
|
|
||||||
if (api.equals(ApiType.Mana) || api.equals(ApiType.ManaReflected)) {
|
if (api.equals(ApiType.Mana) || api.equals(ApiType.ManaReflected)) {
|
||||||
this.setManaPart(new AbilityManaPart(sourceCard, mapParams));
|
this.setManaPart(new AbilityManaPart(sourceCard, this, mapParams));
|
||||||
this.setUndoable(true); // will try at least
|
this.setUndoable(true); // will try at least
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1736,7 +1736,7 @@ public class AbilityUtils {
|
|||||||
if (sq[0].contains("HasNumChosenColors")) {
|
if (sq[0].contains("HasNumChosenColors")) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (Card card : AbilityUtils.getDefinedCards(sa.getHostCard(), sq[1], sa)) {
|
for (Card card : AbilityUtils.getDefinedCards(sa.getHostCard(), sq[1], sa)) {
|
||||||
sum += CardUtil.getColors(card).getSharedColors(ColorSet.fromNames(c.getChosenColors())).countColors();
|
sum += CardUtil.getColors(card).getSharedColors(ColorSet.fromNames(sa.getChosenColors())).countColors();
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@@ -1849,6 +1849,29 @@ public class AbilityUtils {
|
|||||||
if (l[0].startsWith("ExiledWith")) {
|
if (l[0].startsWith("ExiledWith")) {
|
||||||
return CardFactoryUtil.doXMath(c.getExiledWith(ctb).size(), expr, c);
|
return CardFactoryUtil.doXMath(c.getExiledWith(ctb).size(), expr, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count$DevotionDual.<color name>.<color name>
|
||||||
|
// Count$Devotion.<color name>
|
||||||
|
if (sq[0].contains("Devotion")) {
|
||||||
|
int colorOcurrencices = 0;
|
||||||
|
String colorName = sq[1];
|
||||||
|
if (colorName.contains("Chosen")) {
|
||||||
|
colorName = MagicColor.toShortString(ctb.getChosenColor());
|
||||||
|
}
|
||||||
|
byte colorCode = ManaAtom.fromName(colorName);
|
||||||
|
if (sq[0].equals("DevotionDual")) {
|
||||||
|
colorCode |= ManaAtom.fromName(sq[2]);
|
||||||
|
}
|
||||||
|
for (Card c0 : player.getCardsIn(ZoneType.Battlefield)) {
|
||||||
|
for (ManaCostShard sh : c0.getManaCost()) {
|
||||||
|
if ((sh.getColorMask() & colorCode) != 0) {
|
||||||
|
colorOcurrencices++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
colorOcurrencices += c0.getAmountOfKeyword("Your devotion to each color and each combination of colors is increased by one.");
|
||||||
|
}
|
||||||
|
return CardFactoryUtil.doXMath(colorOcurrencices, expr, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CardFactoryUtil.xCount(c, s2);
|
return CardFactoryUtil.xCount(c, s2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class SpellApiBased extends Spell {
|
|||||||
this.setIntrinsic(true);
|
this.setIntrinsic(true);
|
||||||
|
|
||||||
if (api.equals(ApiType.Mana) || api.equals(ApiType.ManaReflected)) {
|
if (api.equals(ApiType.Mana) || api.equals(ApiType.ManaReflected)) {
|
||||||
this.setManaPart(new AbilityManaPart(sourceCard, mapParams));
|
this.setManaPart(new AbilityManaPart(sourceCard, this, mapParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api.equals(ApiType.ChangeZone) || api.equals(ApiType.ChangeZoneAll)) {
|
if (api.equals(ApiType.ChangeZone) || api.equals(ApiType.ChangeZoneAll)) {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
|||||||
if (sa.hasParam("Colors")) {
|
if (sa.hasParam("Colors")) {
|
||||||
final String colors = sa.getParam("Colors");
|
final String colors = sa.getParam("Colors");
|
||||||
if (colors.equals("ChosenColor")) {
|
if (colors.equals("ChosenColor")) {
|
||||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColors());
|
tmpDesc = CardUtil.getShortColorsString(sa.getChosenColors());
|
||||||
} else {
|
} else {
|
||||||
tmpDesc = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(","))));
|
tmpDesc = CardUtil.getShortColorsString(new ArrayList<>(Arrays.asList(colors.split(","))));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
|||||||
final String colors = sa.getParam("Colors");
|
final String colors = sa.getParam("Colors");
|
||||||
if (colors.equals("ChosenColor")) {
|
if (colors.equals("ChosenColor")) {
|
||||||
|
|
||||||
tmpDesc = CardUtil.getShortColorsString(source.getChosenColors());
|
tmpDesc = CardUtil.getShortColorsString(sa.getChosenColors());
|
||||||
} else {
|
} else {
|
||||||
tmpDesc = CardUtil.getShortColorsString(Arrays.asList(colors.split(",")));
|
tmpDesc = CardUtil.getShortColorsString(Arrays.asList(colors.split(",")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ public class ChooseColorEffect extends SpellAbilityEffect {
|
|||||||
if (chosenColors.isEmpty()) {
|
if (chosenColors.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
card.setChosenColors(chosenColors);
|
card.setChosenColors(chosenColors, sa);
|
||||||
p.getGame().getAction().notifyOfValue(sa, card, Localizer.getInstance().getMessage("lblPlayerPickedChosen", p.getName(), Lang.joinHomogenous(chosenColors)), p);
|
p.getGame().getAction().nofityOfValue(sa, card, Localizer.getInstance().getMessage("lblPlayerPickedChosen", p.getName(), Lang.joinHomogenous(chosenColors)), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class CleanUpEffect extends SpellAbilityEffect {
|
|||||||
source.setChosenType2("");
|
source.setChosenType2("");
|
||||||
}
|
}
|
||||||
if (sa.hasParam("ClearChosenColor")) {
|
if (sa.hasParam("ClearChosenColor")) {
|
||||||
source.setChosenColors(null);
|
source.setChosenColors(null, sa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,8 +232,8 @@ public class EffectEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set Chosen Color(s)
|
// Set Chosen Color(s)
|
||||||
if (hostCard.hasChosenColor()) {
|
if (sa.hasChosenColor()) {
|
||||||
eff.setChosenColors(Lists.newArrayList(hostCard.getChosenColors()));
|
eff.setChosenColors(Lists.newArrayList(sa.getChosenColors()), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Chosen Cards
|
// Set Chosen Cards
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
|||||||
game.getAction().notifyOfValue(sa, choser, Lang.joinHomogenous(gains), choser);
|
game.getAction().notifyOfValue(sa, choser, Lang.joinHomogenous(gains), choser);
|
||||||
} else {
|
} else {
|
||||||
if (sa.getParam("Gains").equals("ChosenColor")) {
|
if (sa.getParam("Gains").equals("ChosenColor")) {
|
||||||
for (final String color : host.getChosenColors()) {
|
for (final String color : sa.getChosenColors()) {
|
||||||
gains.add(color.toLowerCase());
|
gains.add(color.toLowerCase());
|
||||||
}
|
}
|
||||||
} else if (sa.getParam("Gains").equals("TargetedCardColor")) {
|
} else if (sa.getParam("Gains").equals("TargetedCardColor")) {
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ public class ProtectEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve(SpellAbility sa) {
|
public void resolve(SpellAbility sa) {
|
||||||
final Card host = sa.getHostCard();
|
|
||||||
final Game game = sa.getActivatingPlayer().getGame();
|
final Game game = sa.getActivatingPlayer().getGame();
|
||||||
|
|
||||||
final boolean isChoice = sa.getParam("Gains").contains("Choice");
|
final boolean isChoice = sa.getParam("Gains").contains("Choice");
|
||||||
@@ -117,7 +116,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
|||||||
game.getAction().notifyOfValue(sa, choser, Lang.joinHomogenous(gains), choser);
|
game.getAction().notifyOfValue(sa, choser, Lang.joinHomogenous(gains), choser);
|
||||||
} else {
|
} else {
|
||||||
if (sa.getParam("Gains").equals("ChosenColor")) {
|
if (sa.getParam("Gains").equals("ChosenColor")) {
|
||||||
for (final String color : host.getChosenColors()) {
|
for (final String color : sa.getChosenColors()) {
|
||||||
gains.add(color.toLowerCase());
|
gains.add(color.toLowerCase());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ public class ReplaceManaEffect extends SpellAbilityEffect {
|
|||||||
// replace color
|
// replace color
|
||||||
String color = sa.getParam("ReplaceColor");
|
String color = sa.getParam("ReplaceColor");
|
||||||
if ("Chosen".equals(color)) {
|
if ("Chosen".equals(color)) {
|
||||||
if (card.hasChosenColor()) {
|
if (sa.hasChosenColor()) {
|
||||||
color = MagicColor.toShortString(card.getChosenColor());
|
color = MagicColor.toShortString(sa.getChosenColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sa.hasParam("ReplaceOnly")) {
|
if (sa.hasParam("ReplaceOnly")) {
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ public class SubgameEffect extends SpellAbilityEffect {
|
|||||||
List<String> chosenColors;
|
List<String> chosenColors;
|
||||||
SpellAbility cmdColorsa = new SpellAbility.EmptySa(ApiType.ChooseColor, cmd, player);
|
SpellAbility cmdColorsa = new SpellAbility.EmptySa(ApiType.ChooseColor, cmd, player);
|
||||||
chosenColors = player.getController().chooseColors(prompt,cmdColorsa, 1, 1, colorChoices);
|
chosenColors = player.getController().chooseColors(prompt,cmdColorsa, 1, 1, colorChoices);
|
||||||
cmd.setChosenColors(chosenColors);
|
cmd.setChosenColors(chosenColors, cmdColorsa);
|
||||||
subgame.getAction().notifyOfValue(cmdColorsa, cmd, Localizer.getInstance().getMessage("lblPlayerPickedChosen", player.getName(), Lang.joinHomogenous(chosenColors)), player);
|
subgame.getAction().nofityOfValue(cmdColorsa, cmd, Localizer.getInstance().getMessage("lblPlayerPickedChosen", player.getName(), Lang.joinHomogenous(chosenColors)), player);
|
||||||
}
|
}
|
||||||
cmd.setCommander(true);
|
cmd.setCommander(true);
|
||||||
com.add(cmd);
|
com.add(cmd);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class TokenEffect extends TokenEffectBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sa.hasParam("TokenColors")) {
|
if (sa.hasParam("TokenColors")) {
|
||||||
if (sa.getParam("TokenColors").contains("ChosenColor") && !host.hasChosenColor()) {
|
if (sa.getParam("TokenColors").contains("ChosenColor") && !sa.hasChosenColor()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
private String originalText = "", text = "";
|
private String originalText = "", text = "";
|
||||||
private String chosenType = "";
|
private String chosenType = "";
|
||||||
private String chosenType2 = "";
|
private String chosenType2 = "";
|
||||||
private List<String> chosenColors;
|
private LinkedAbilityTable<String> chosenColorsTable = new LinkedAbilityTable<String>();
|
||||||
private String chosenName = "";
|
private String chosenName = "";
|
||||||
private String chosenName2 = "";
|
private String chosenName2 = "";
|
||||||
private Integer chosenNumber;
|
private Integer chosenNumber;
|
||||||
@@ -1710,28 +1710,25 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
return chosenType2 != null && !chosenType2.isEmpty();
|
return chosenType2 != null && !chosenType2.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getChosenColor() {
|
public String getChosenColor(CardTraitBase ctb) {
|
||||||
if (hasChosenColor()) {
|
return Iterables.getFirst(chosenColorsTable.get(ctb), null);
|
||||||
return chosenColors.get(0);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
public final Iterable<String> getChosenColors() {
|
public final Iterable<String> getChosenColors(CardTraitBase ctb) {
|
||||||
if (chosenColors == null) {
|
return chosenColorsTable.get(ctb);
|
||||||
return Lists.newArrayList();
|
|
||||||
}
|
|
||||||
return chosenColors;
|
|
||||||
}
|
}
|
||||||
public final void setChosenColors(final List<String> s) {
|
|
||||||
chosenColors = s;
|
public final boolean hasChosenColor(CardTraitBase ctb) {
|
||||||
|
return !chosenColorsTable.get(ctb).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean hasChosenColor(String s, CardTraitBase ctb) {
|
||||||
|
return chosenColorsTable.contains(s, ctb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChosenColors(final Iterable<String> colors, CardTraitBase ctb) {
|
||||||
|
chosenColorsTable.set(colors, ctb);
|
||||||
view.updateChosenColors(this);
|
view.updateChosenColors(this);
|
||||||
}
|
}
|
||||||
public boolean hasChosenColor() {
|
|
||||||
return chosenColors != null && !chosenColors.isEmpty();
|
|
||||||
}
|
|
||||||
public boolean hasChosenColor(String s) {
|
|
||||||
return chosenColors != null && chosenColors.contains(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Card getChosenCard() {
|
public final Card getChosenCard() {
|
||||||
return getChosenCards().getFirst();
|
return getChosenCards().getFirst();
|
||||||
@@ -6999,11 +6996,11 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
return exiledWithTable;
|
return exiledWithTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExiledWithTable(Table<Card, Optional<StaticAbility>, CardCollection> map) {
|
public void setExiledWithTable(Table<Card, Optional<StaticAbility>, FCollection<Card>> map) {
|
||||||
exiledWithTable = new ExileWithTable(map);
|
exiledWithTable = new ExileWithTable(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardCollectionView getExiledWith(CardTraitBase ctb) {
|
public FCollection<Card> getExiledWith(CardTraitBase ctb) {
|
||||||
return exiledWithTable.get(ctb);
|
return exiledWithTable.get(ctb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ public class CardFactory {
|
|||||||
* </p>
|
* </p>
|
||||||
* */
|
* */
|
||||||
private final static Card copySpellHost(final SpellAbility sourceSA, final SpellAbility targetSA, Player controller) {
|
private final static Card copySpellHost(final SpellAbility sourceSA, final SpellAbility targetSA, Player controller) {
|
||||||
final Card source = sourceSA.getHostCard();
|
|
||||||
final Card original = targetSA.getHostCard();
|
final Card original = targetSA.getHostCard();
|
||||||
final Card c = copyCard(original, true);
|
final Card c = copyCard(original, true);
|
||||||
|
|
||||||
@@ -138,7 +137,7 @@ public class CardFactory {
|
|||||||
String tmp = "";
|
String tmp = "";
|
||||||
final String newColor = sourceSA.getParam("CopyIsColor");
|
final String newColor = sourceSA.getParam("CopyIsColor");
|
||||||
if (newColor.equals("ChosenColor")) {
|
if (newColor.equals("ChosenColor")) {
|
||||||
tmp = CardUtil.getShortColorsString(source.getChosenColors());
|
tmp = CardUtil.getShortColorsString(sourceSA.getChosenColors());
|
||||||
} else {
|
} else {
|
||||||
tmp = CardUtil.getShortColorsString(Lists.newArrayList(newColor.split(",")));
|
tmp = CardUtil.getShortColorsString(Lists.newArrayList(newColor.split(",")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1052,28 +1052,6 @@ public class CardFactoryUtil {
|
|||||||
}
|
}
|
||||||
return doXMath(colorOcurrencices, m, c);
|
return doXMath(colorOcurrencices, m, c);
|
||||||
}
|
}
|
||||||
// Count$DevotionDual.<color name>.<color name>
|
|
||||||
// Count$Devotion.<color name>
|
|
||||||
if (sq[0].contains("Devotion")) {
|
|
||||||
int colorOcurrencices = 0;
|
|
||||||
String colorName = sq[1];
|
|
||||||
if (colorName.contains("Chosen")) {
|
|
||||||
colorName = MagicColor.toShortString(c.getChosenColor());
|
|
||||||
}
|
|
||||||
byte colorCode = ManaAtom.fromName(colorName);
|
|
||||||
if (sq[0].equals("DevotionDual")) {
|
|
||||||
colorCode |= ManaAtom.fromName(sq[2]);
|
|
||||||
}
|
|
||||||
for (Card c0 : cc.getCardsIn(ZoneType.Battlefield)) {
|
|
||||||
for (ManaCostShard sh : c0.getManaCost()) {
|
|
||||||
if ((sh.getColorMask() & colorCode) != 0) {
|
|
||||||
colorOcurrencices++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
colorOcurrencices += c0.getAmountOfKeyword("Your devotion to each color and each combination of colors is increased by one.");
|
|
||||||
}
|
|
||||||
return doXMath(colorOcurrencices, m, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sq[0].contains("ColorsCtrl")) {
|
if (sq[0].contains("ColorsCtrl")) {
|
||||||
final String restriction = l[0].substring(11);
|
final String restriction = l[0].substring(11);
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ public class CardView extends GameEntityView {
|
|||||||
return get(TrackableProperty.ChosenColors);
|
return get(TrackableProperty.ChosenColors);
|
||||||
}
|
}
|
||||||
void updateChosenColors(Card c) {
|
void updateChosenColors(Card c) {
|
||||||
set(TrackableProperty.ChosenColors, c.getChosenColors());
|
//set(TrackableProperty.ChosenColors, c.getChosenColors());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FCollectionView<CardView> getMergedCardsCollection() {
|
public FCollectionView<CardView> getMergedCardsCollection() {
|
||||||
|
|||||||
@@ -1,76 +1,18 @@
|
|||||||
package forge.game.card;
|
package forge.game.card;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ForwardingTable;
|
|
||||||
import com.google.common.collect.HashBasedTable;
|
|
||||||
import com.google.common.collect.Table;
|
import com.google.common.collect.Table;
|
||||||
|
|
||||||
import forge.game.CardTraitBase;
|
|
||||||
import forge.game.staticability.StaticAbility;
|
import forge.game.staticability.StaticAbility;
|
||||||
|
import forge.util.collect.FCollection;
|
||||||
|
|
||||||
public class ExileWithTable extends ForwardingTable<Card, Optional<StaticAbility>, CardCollection> {
|
public class ExileWithTable extends LinkedAbilityTable<Card> {
|
||||||
private Table<Card, Optional<StaticAbility>, CardCollection> dataTable = HashBasedTable.create();
|
|
||||||
|
|
||||||
public ExileWithTable(Table<Card, Optional<StaticAbility>, CardCollection> map) {
|
public ExileWithTable(Table<Card, Optional<StaticAbility>, FCollection<Card>> map) {
|
||||||
this.putAll(map);
|
this.putAll(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ExileWithTable() {
|
public ExileWithTable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Table<Card, Optional<StaticAbility>, CardCollection> delegate() {
|
|
||||||
return dataTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CardCollection putInternal(Card object, Card host, StaticAbility stAb) {
|
|
||||||
host = ObjectUtils.defaultIfNull(host.getEffectSource(), host);
|
|
||||||
Optional<StaticAbility> st = Optional.fromNullable(stAb);
|
|
||||||
CardCollection old;
|
|
||||||
if (contains(host, st)) {
|
|
||||||
old = get(host, st);
|
|
||||||
old.add(object);
|
|
||||||
} else {
|
|
||||||
old = new CardCollection(object);
|
|
||||||
delegate().put(host, st, old);
|
|
||||||
}
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CardCollection put(Card object, Card host) {
|
|
||||||
return putInternal(object, host, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CardCollection put(Card object, CardTraitBase ctb) {
|
|
||||||
return putInternal(object, ctb.getOriginalOrHost(), ctb.getGrantorStatic());
|
|
||||||
}
|
|
||||||
|
|
||||||
public CardCollectionView get(CardTraitBase ctb) {
|
|
||||||
Card host = ctb.getOriginalOrHost();
|
|
||||||
host = ObjectUtils.defaultIfNull(host.getEffectSource(), host);
|
|
||||||
Optional<StaticAbility> st = Optional.fromNullable(ctb.getGrantorStatic());
|
|
||||||
if (contains(host, st)) {
|
|
||||||
return get(host, st);
|
|
||||||
} else {
|
|
||||||
return CardCollection.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean contains(Card object, CardTraitBase ctb) {
|
|
||||||
return get(ctb).contains(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean remove(Card value) {
|
|
||||||
boolean changed = false;
|
|
||||||
for (CardCollection col : delegate().values()) {
|
|
||||||
if (col.remove(value)) {
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package forge.game.card;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.collect.ForwardingTable;
|
||||||
|
import com.google.common.collect.HashBasedTable;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Table;
|
||||||
|
|
||||||
|
import forge.game.CardTraitBase;
|
||||||
|
import forge.game.staticability.StaticAbility;
|
||||||
|
import forge.util.collect.FCollection;
|
||||||
|
|
||||||
|
public class LinkedAbilityTable<T> extends ForwardingTable<Card, Optional<StaticAbility>, FCollection<T>> {
|
||||||
|
private Table<Card, Optional<StaticAbility>, FCollection<T>> dataTable = HashBasedTable.create();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Table<Card, Optional<StaticAbility>, FCollection<T>> delegate() {
|
||||||
|
return dataTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FCollection<T> getSupplier() {
|
||||||
|
return new FCollection<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FCollection<T> putInternal(T object, Card host, StaticAbility stAb) {
|
||||||
|
host = ObjectUtils.defaultIfNull(host.getEffectSource(), host);
|
||||||
|
Optional<StaticAbility> st = Optional.fromNullable(stAb);
|
||||||
|
FCollection<T> old;
|
||||||
|
if (contains(host, st)) {
|
||||||
|
old = get(host, st);
|
||||||
|
} else {
|
||||||
|
old = getSupplier();
|
||||||
|
delegate().put(host, st, old);
|
||||||
|
}
|
||||||
|
old.add(object);
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FCollection<T> put(T object, Card host) {
|
||||||
|
return putInternal(object, host, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FCollection<T> put(T object, CardTraitBase ctb) {
|
||||||
|
return putInternal(object, ctb.getOriginalOrHost(), ctb.getGrantorStatic());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setInternal(Iterable<T> list, Card host, StaticAbility stAb) {
|
||||||
|
host = ObjectUtils.defaultIfNull(host.getEffectSource(), host);
|
||||||
|
Optional<StaticAbility> st = Optional.fromNullable(stAb);
|
||||||
|
if (list == null || Iterables.isEmpty(list)) {
|
||||||
|
delegate().remove(host, st);
|
||||||
|
} else {
|
||||||
|
FCollection<T> old = getSupplier();
|
||||||
|
old.addAll(list);
|
||||||
|
delegate().put(host, st, old);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(Iterable<T> list, CardTraitBase ctb) {
|
||||||
|
setInternal(list, ctb.getOriginalOrHost(), ctb.getGrantorStatic());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FCollection<T> get(CardTraitBase ctb) {
|
||||||
|
Card host = ctb.getOriginalOrHost();
|
||||||
|
host = ObjectUtils.defaultIfNull(host.getEffectSource(), host);
|
||||||
|
Optional<StaticAbility> st = Optional.fromNullable(ctb.getGrantorStatic());
|
||||||
|
if (contains(host, st)) {
|
||||||
|
return get(host, st);
|
||||||
|
} else {
|
||||||
|
return FCollection.<T>getEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(T object, CardTraitBase ctb) {
|
||||||
|
return get(ctb).contains(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean remove(T value) {
|
||||||
|
boolean changed = false;
|
||||||
|
for (FCollection<T> col : delegate().values()) {
|
||||||
|
if (col.remove(value)) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -365,7 +365,7 @@ public class TokenInfo {
|
|||||||
|
|
||||||
if (sa.hasParam("TokenColors")) {
|
if (sa.hasParam("TokenColors")) {
|
||||||
String colors = sa.getParam("TokenColors");
|
String colors = sa.getParam("TokenColors");
|
||||||
colors = colors.replace("ChosenColor", sa.getHostCard().getChosenColor());
|
colors = colors.replace("ChosenColor", sa.getHostCard().getChosenColor(sa));
|
||||||
result.setColor(MagicColor.toShortString(colors));
|
result.setColor(MagicColor.toShortString(colors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3039,8 +3039,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
List<String> chosenColors;
|
List<String> chosenColors;
|
||||||
SpellAbility cmdColorsa = new SpellAbility.EmptySa(ApiType.ChooseColor, cmd, p);
|
SpellAbility cmdColorsa = new SpellAbility.EmptySa(ApiType.ChooseColor, cmd, p);
|
||||||
chosenColors = p.getController().chooseColors(prompt,cmdColorsa, 1, 1, colorChoices);
|
chosenColors = p.getController().chooseColors(prompt,cmdColorsa, 1, 1, colorChoices);
|
||||||
cmd.setChosenColors(chosenColors);
|
cmd.setChosenColors(chosenColors, cmdColorsa);
|
||||||
p.getGame().getAction().notifyOfValue(cmdColorsa, cmd, Localizer.getInstance().getMessage("lblPlayerPickedChosen", p.getName(), Lang.joinHomogenous(chosenColors)), p);
|
p.getGame().getAction().nofityOfValue(cmdColorsa, cmd, Localizer.getInstance().getMessage("lblPlayerPickedChosen", p.getName(), Lang.joinHomogenous(chosenColors)), p);
|
||||||
}
|
}
|
||||||
cmd.setCommander(true);
|
cmd.setCommander(true);
|
||||||
com.add(cmd);
|
com.add(cmd);
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
private transient List<Mana> lastManaProduced = Lists.newArrayList();
|
private transient List<Mana> lastManaProduced = Lists.newArrayList();
|
||||||
|
|
||||||
private transient Card sourceCard;
|
private transient Card sourceCard;
|
||||||
|
private transient SpellAbility spellAbility;
|
||||||
|
|
||||||
|
|
||||||
// Spells paid with this mana spell can't be countered.
|
// Spells paid with this mana spell can't be countered.
|
||||||
@@ -84,8 +85,9 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
* @param sourceCard
|
* @param sourceCard
|
||||||
* a {@link forge.game.card.Card} object.
|
* a {@link forge.game.card.Card} object.
|
||||||
*/
|
*/
|
||||||
public AbilityManaPart(final Card sourceCard, final Map<String, String> params) {
|
public AbilityManaPart(final Card sourceCard, final SpellAbility sa, final Map<String, String> params) {
|
||||||
this.sourceCard = sourceCard;
|
this.sourceCard = sourceCard;
|
||||||
|
this.spellAbility = sa;
|
||||||
|
|
||||||
origProduced = params.containsKey("Produced") ? params.get("Produced") : "1";
|
origProduced = params.containsKey("Produced") ? params.get("Produced") : "1";
|
||||||
this.manaRestrictions = params.containsKey("RestrictValid") ? params.get("RestrictValid") : "";
|
this.manaRestrictions = params.containsKey("RestrictValid") ? params.get("RestrictValid") : "";
|
||||||
@@ -413,9 +415,11 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public final String mana() {
|
public final String mana() {
|
||||||
if (this.getOrigProduced().contains("Chosen")) {
|
if (getOrigProduced().contains("Chosen")) {
|
||||||
if (this.getSourceCard() != null && this.getSourceCard().hasChosenColor()) {
|
if (spellAbility == null) {
|
||||||
return MagicColor.toShortString(this.getSourceCard().getChosenColor());
|
return "";
|
||||||
|
} else {
|
||||||
|
return MagicColor.toShortString(spellAbility.getChosenColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.getOrigProduced();
|
return this.getOrigProduced();
|
||||||
@@ -499,15 +503,15 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean canProduce(final String s, final SpellAbility sa) {
|
public final boolean canProduce(final String s) {
|
||||||
// Any mana never means Colorless?
|
// Any mana never means Colorless?
|
||||||
if (isAnyMana() && !s.equals("C")) {
|
if (isAnyMana() && !s.equals("C")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String origProduced = getOrigProduced();
|
String origProduced = getOrigProduced();
|
||||||
if (origProduced.contains("Chosen") && sourceCard != null ) {
|
if (origProduced.contains("Chosen") && spellAbility != null ) {
|
||||||
if (getSourceCard().hasChosenColor() && MagicColor.toShortString(getSourceCard().getChosenColor()).contains(s)) {
|
if (spellAbility.hasChosenColor() && MagicColor.toShortString(spellAbility.getChosenColor()).contains(s)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public final class AbilitySub extends SpellAbility implements java.io.Serializab
|
|||||||
effect = api.getSpellEffect();
|
effect = api.getSpellEffect();
|
||||||
|
|
||||||
if (api.equals(ApiType.Mana) || api.equals(ApiType.ManaReflected)) {
|
if (api.equals(ApiType.Mana) || api.equals(ApiType.ManaReflected)) {
|
||||||
this.setManaPart(new AbilityManaPart(ca, mapParams));
|
this.setManaPart(new AbilityManaPart(ca, this, mapParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api.equals(ApiType.ChangeZone) || api.equals(ApiType.ChangeZoneAll)) {
|
if (api.equals(ApiType.ChangeZone) || api.equals(ApiType.ChangeZoneAll)) {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
|
|
||||||
public boolean canThisProduce(final String s) {
|
public boolean canThisProduce(final String s) {
|
||||||
AbilityManaPart mp = getManaPart();
|
AbilityManaPart mp = getManaPart();
|
||||||
if (mp != null && metConditions() && mp.canProduce(s, this)) {
|
if (mp != null && metConditions() && mp.canProduce(s)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -993,7 +993,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
|
|
||||||
clone.setPayCosts(getPayCosts().copy());
|
clone.setPayCosts(getPayCosts().copy());
|
||||||
if (manaPart != null) {
|
if (manaPart != null) {
|
||||||
clone.manaPart = new AbilityManaPart(host, mapParams);
|
clone.manaPart = new AbilityManaPart(host, clone, mapParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to copy the damage tables
|
// need to copy the damage tables
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.getColorToCheck() != null) {
|
if (this.getColorToCheck() != null) {
|
||||||
if (!sa.getHostCard().hasChosenColor(this.getColorToCheck())) {
|
if (!sa.hasChosenColor(this.getColorToCheck())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getColorToCheck() != null) {
|
if (getColorToCheck() != null) {
|
||||||
if (!sa.getHostCard().hasChosenColor(getColorToCheck())) {
|
if (!sa.hasChosenColor(getColorToCheck())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ public final class StaticAbilityContinuous {
|
|||||||
Iterables.removeIf(addKeywords, new Predicate<String>() {
|
Iterables.removeIf(addKeywords, new Predicate<String>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(String input) {
|
public boolean apply(String input) {
|
||||||
if (!hostCard.hasChosenColor() && input.contains("ChosenColor")) {
|
if (!stAb.hasChosenColor() && input.contains("ChosenColor")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!hostCard.hasChosenType() && input.contains("ChosenType")) {
|
if (!hostCard.hasChosenType() && input.contains("ChosenType")) {
|
||||||
@@ -294,9 +294,9 @@ public final class StaticAbilityContinuous {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apply(String input) {
|
public String apply(String input) {
|
||||||
if (hostCard.hasChosenColor()) {
|
if (stAb.hasChosenColor()) {
|
||||||
input = input.replaceAll("ChosenColor", StringUtils.capitalize(hostCard.getChosenColor()));
|
input = input.replaceAll("ChosenColor", StringUtils.capitalize(stAb.getChosenColor()));
|
||||||
input = input.replaceAll("chosenColor", hostCard.getChosenColor().toLowerCase());
|
input = input.replaceAll("chosenColor", stAb.getChosenColor().toLowerCase());
|
||||||
}
|
}
|
||||||
if (hostCard.hasChosenType()) {
|
if (hostCard.hasChosenType()) {
|
||||||
input = input.replaceAll("ChosenType", hostCard.getChosenType());
|
input = input.replaceAll("ChosenType", hostCard.getChosenType());
|
||||||
@@ -458,7 +458,7 @@ public final class StaticAbilityContinuous {
|
|||||||
if (params.containsKey("AddColor")) {
|
if (params.containsKey("AddColor")) {
|
||||||
final String colors = params.get("AddColor");
|
final String colors = params.get("AddColor");
|
||||||
if (colors.equals("ChosenColor")) {
|
if (colors.equals("ChosenColor")) {
|
||||||
addColors = CardUtil.getShortColorsString(hostCard.getChosenColors());
|
addColors = CardUtil.getShortColorsString(stAb.getChosenColors());
|
||||||
} else if (colors.equals("All")) {
|
} else if (colors.equals("All")) {
|
||||||
addColors = "W U B R G";
|
addColors = "W U B R G";
|
||||||
} else {
|
} else {
|
||||||
@@ -469,7 +469,7 @@ public final class StaticAbilityContinuous {
|
|||||||
if (params.containsKey("SetColor")) {
|
if (params.containsKey("SetColor")) {
|
||||||
final String colors = params.get("SetColor");
|
final String colors = params.get("SetColor");
|
||||||
if (colors.equals("ChosenColor")) {
|
if (colors.equals("ChosenColor")) {
|
||||||
addColors = CardUtil.getShortColorsString(hostCard.getChosenColors());
|
addColors = CardUtil.getShortColorsString(stAb.getChosenColors());
|
||||||
} else if (colors.equals("All")) {
|
} else if (colors.equals("All")) {
|
||||||
addColors = "W U B R G";
|
addColors = "W U B R G";
|
||||||
} else {
|
} else {
|
||||||
@@ -619,8 +619,8 @@ public final class StaticAbilityContinuous {
|
|||||||
if (changeColorWordsTo != null) {
|
if (changeColorWordsTo != null) {
|
||||||
final byte color;
|
final byte color;
|
||||||
if (changeColorWordsTo.equals("ChosenColor")) {
|
if (changeColorWordsTo.equals("ChosenColor")) {
|
||||||
if (hostCard.hasChosenColor()) {
|
if (stAb.hasChosenColor()) {
|
||||||
color = MagicColor.fromName(Iterables.getFirst(hostCard.getChosenColors(), null));
|
color = MagicColor.fromName(stAb.getChosenColor());
|
||||||
} else {
|
} else {
|
||||||
color = 0;
|
color = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,14 @@ public class TriggerTapsForMana extends Trigger {
|
|||||||
}
|
}
|
||||||
String produced = (String) prod;
|
String produced = (String) prod;
|
||||||
if ("ChosenColor".equals(getParam("Produced"))) {
|
if ("ChosenColor".equals(getParam("Produced"))) {
|
||||||
if (!this.getHostCard().hasChosenColor() || !produced.contains(MagicColor.toShortString(this.getHostCard().getChosenColor()))) {
|
boolean found = false;
|
||||||
|
for (String color : this.getChosenColors()) {
|
||||||
|
if (produced.contains(MagicColor.toShortString(color))) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (!produced.contains(MagicColor.toShortString(this.getParam("Produced")))) {
|
} else if (!produced.contains(MagicColor.toShortString(this.getParam("Produced")))) {
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
|||||||
Player p = game.getPlayers().get(1);
|
Player p = game.getPlayers().get(1);
|
||||||
Card bear = addCard(bearCardName, p);
|
Card bear = addCard(bearCardName, p);
|
||||||
Card hall = addCard("Hall of Triumph", p);
|
Card hall = addCard("Hall of Triumph", p);
|
||||||
hall.setChosenColors(Lists.newArrayList("green"));
|
hall.setChosenColors(Lists.newArrayList("green"), hall.getFirstSpellAbility());
|
||||||
game.getPhaseHandler().devModeSet(PhaseType.MAIN2, p);
|
game.getPhaseHandler().devModeSet(PhaseType.MAIN2, p);
|
||||||
game.getAction().checkStateEffects(true);
|
game.getAction().checkStateEffects(true);
|
||||||
assertEquals(3, bear.getNetToughness());
|
assertEquals(3, bear.getNetToughness());
|
||||||
|
|||||||
@@ -2186,7 +2186,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
dummy.setOwner(pPriority);
|
dummy.setOwner(pPriority);
|
||||||
final Map<String, String> produced = Maps.newHashMap();
|
final Map<String, String> produced = Maps.newHashMap();
|
||||||
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
||||||
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
final AbilityManaPart abMana = new AbilityManaPart(dummy, null, produced);
|
||||||
getGame().getAction().invoke(new Runnable() {
|
getGame().getAction().invoke(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|||||||
Reference in New Issue
Block a user