Merge pull request #1754 from tool4ever/colorFix

Fix color choice
This commit is contained in:
Anthony Calosa
2022-10-29 18:55:20 +08:00
committed by GitHub
11 changed files with 19 additions and 32 deletions

View File

@@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -1082,8 +1081,7 @@ public class ComputerUtilCard {
//chosen.add(MagicColor.Constant.GREEN); //chosen.add(MagicColor.Constant.GREEN);
chosen.add(getMostProminentColor(ai.getAllCards(), colorChoices)); chosen.add(getMostProminentColor(ai.getAllCards(), colorChoices));
} }
//convert to proper case same with the colorChoices.. return chosen;
return chosen.stream().map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1)).collect(Collectors.toList());
} }
public static boolean useRemovalNow(final SpellAbility sa, final Card c, final int dmg, ZoneType destination) { public static boolean useRemovalNow(final SpellAbility sa, final Card c, final int dmg, ZoneType destination) {

View File

@@ -1317,22 +1317,6 @@ public class AbilityUtils {
final Object o = root.getTriggeringObject(AbilityKey.fromString(triggeringType)); final Object o = root.getTriggeringObject(AbilityKey.fromString(triggeringType));
if (o instanceof SpellAbility) { if (o instanceof SpellAbility) {
s = (SpellAbility) o; s = (SpellAbility) o;
// if there is no target information in SA but targets are listed in SpellAbilityTargeting cards, copy that
// information so it's not lost if the calling code is interested in targets of the triggered SA.
if (triggeringType.equals("SpellAbility")) {
final List<GameEntity> tgtList = (List<GameEntity>) root.getTriggeringObject(AbilityKey.SpellAbilityTargets);
if (s.getTargets() != null && s.getTargets().size() == 0) {
if (tgtList != null && tgtList.size() > 0) {
TargetChoices tc = new TargetChoices();
for (GameEntity ge : tgtList) {
if (ge instanceof Card) {
tc.add((Card) ge);
}
}
s.setTargets(tc);
}
}
}
} else if (o instanceof SpellAbilityStackInstance) { } else if (o instanceof SpellAbilityStackInstance) {
s = ((SpellAbilityStackInstance) o).getSpellAbility(true); s = ((SpellAbilityStackInstance) o).getSpellAbility(true);
} }

View File

@@ -82,14 +82,13 @@ public class ChooseColorEffect extends SpellAbilityEffect {
} }
noNotify = null; noNotify = null;
} else { } else {
colorChoices = colorChoices.stream().map(DeckRecognizer::getLocalisedMagicColorName).collect(Collectors.toList());
chosenColors = p.getController().chooseColors(prompt, sa, cntMin, cntMax, colorChoices); chosenColors = p.getController().chooseColors(prompt, sa, cntMin, cntMax, colorChoices);
chosenColors = chosenColors.stream().map(DeckRecognizer::getColorNameByLocalisedName).collect(Collectors.toList());
} }
if (chosenColors.isEmpty()) { if (chosenColors.isEmpty()) {
return; return;
} }
card.setChosenColors(chosenColors); card.setChosenColors(chosenColors);
chosenColors = chosenColors.stream().map(DeckRecognizer::getLocalisedMagicColorName).collect(Collectors.toList());
p.getGame().getAction().notifyOfValue(sa, p, Lang.joinHomogenous(chosenColors), noNotify); p.getGame().getAction().notifyOfValue(sa, p, Lang.joinHomogenous(chosenColors), noNotify);
} }
} }

View File

@@ -303,10 +303,13 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
// Send all mana back to your mana pool, before accounting for it. // Send all mana back to your mana pool, before accounting for it.
// move non-undoable paying mana back to floating // move non-undoable paying mana back to floating
refundMana(sa.getPayingMana(), owner, sa); refundMana(sa.getPayingMana(), owner, sa);
List<SpellAbility> payingAbilities = sa.getPayingManaAbilities(); List<SpellAbility> payingAbilities = sa.getPayingManaAbilities();
// start with the most recent
Collections.reverse(payingAbilities);
for (final SpellAbility am : payingAbilities) { for (final SpellAbility am : payingAbilities) {
// undo paying abilities if we can // undo paying abilities if we can
am.undo(); am.undo();

View File

@@ -561,7 +561,7 @@ public class TriggerHandler {
sa.setTriggerRemembered(regtrig.getTriggerRemembered()); sa.setTriggerRemembered(regtrig.getTriggerRemembered());
if (regtrig.hasParam("TriggerController")) { if (regtrig.hasParam("TriggerController")) {
Player p = AbilityUtils.getDefinedPlayers(regtrig.getHostCard(), regtrig.getParam("TriggerController"), sa).get(0); Player p = AbilityUtils.getDefinedPlayers(host, regtrig.getParam("TriggerController"), sa).get(0);
sa.setActivatingPlayer(p); sa.setActivatingPlayer(p);
} }

View File

@@ -210,12 +210,12 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
for (SpellAbility sa : sas) { for (SpellAbility sa : sas) {
// reset in case a trigger stopped it on a previous activation // reset in case a trigger stopped it on a previous activation
sa.setUndoable(true); sa.setUndoable(true);
undoStack.remove(undoStack.lastIndexOf(sa));
} }
undoStack.removeAll(sas);
} }
public final void clearUndoStack() { public final void clearUndoStack() {
if (undoStackOwner == null) { return; } if (undoStackOwner == null) { return; }
clearUndoStack(undoStack); clearUndoStack(Lists.newArrayList(undoStack));
undoStackOwner = null; undoStackOwner = null;
} }
public Iterable<SpellAbility> filterUndoStackByHost(final Card c) { public Iterable<SpellAbility> filterUndoStackByHost(final Card c) {

View File

@@ -1,6 +1,6 @@
Name:Blood Divination Name:Blood Divination
ManaCost:3 B ManaCost:3 B
Types:Sorcery Types:Sorcery
A:SP$ Draw | Cost$ 3 B Sac<1/Creature> | NumCards$ 3 | SpellDescription$ As an additional cost to cast this spell, sacrifice a creature. Draw three cards. A:SP$ Draw | Cost$ 3 B Sac<1/Creature> | NumCards$ 3 | SpellDescription$ Draw three cards.
SVar:AIPreference:SacCost$Creature.token,Creature.cmcLE3 SVar:AIPreference:SacCost$Creature.token,Creature.cmcLE3
Oracle:As an additional cost to cast this spell, sacrifice a creature.\nDraw three cards. Oracle:As an additional cost to cast this spell, sacrifice a creature.\nDraw three cards.

View File

@@ -1,7 +1,7 @@
Name:Charge of the Forever-Beast Name:Charge of the Forever-Beast
ManaCost:2 G ManaCost:2 G
Types:Sorcery Types:Sorcery
A:SP$ DealDamage | Cost$ 2 G Reveal<1/Creature> | ValidTgts$ Creature,Planeswalker | TgtPrompt$ Select target creature or planeswalker | NumDmg$ X | SpellDescription$ As an additional cost to cast this spell, reveal a creature card from your hand. CARDNAME deals damage to target creature or planeswalker equal to the revealed card's power. A:SP$ DealDamage | Cost$ 2 G Reveal<1/Creature> | ValidTgts$ Creature,Planeswalker | TgtPrompt$ Select target creature or planeswalker | NumDmg$ X | SpellDescription$ CARDNAME deals damage to target creature or planeswalker equal to the revealed card's power.
SVar:X:Revealed$CardPower SVar:X:Revealed$CardPower
AI:RemoveDeck:All AI:RemoveDeck:All
Oracle:As an additional cost to cast this spell, reveal a creature card from your hand.\nCharge of the Forever-Beast deals damage to target creature or planeswalker equal to the revealed card's power. Oracle:As an additional cost to cast this spell, reveal a creature card from your hand.\nCharge of the Forever-Beast deals damage to target creature or planeswalker equal to the revealed card's power.

View File

@@ -7,5 +7,4 @@ T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.S
SVar:TrigExile:DB$ Dig | DigNum$ 1 | ChangeNum$ All | Defined$ Player | DestinationZone$ Exile | ExileWithCounter$ COLLECTION SVar:TrigExile:DB$ Dig | DigNum$ 1 | ChangeNum$ All | Defined$ Player | DestinationZone$ Exile | ExileWithCounter$ COLLECTION
S:Mode$ Continuous | MayPlayLimit$ 1 | Affected$ Card.ExiledByYou+counters_GE1_COLLECTION | AffectedZone$ Exile | MayPlay$ True | MayPlayIgnoreColor$ True | Description$ Once each turn, you may play a card from exile with a collection counter on it if it was exiled by an ability you controlled, and you may spend mana as though it were any color to cast it. S:Mode$ Continuous | MayPlayLimit$ 1 | Affected$ Card.ExiledByYou+counters_GE1_COLLECTION | AffectedZone$ Exile | MayPlay$ True | MayPlayIgnoreColor$ True | Description$ Once each turn, you may play a card from exile with a collection counter on it if it was exiled by an ability you controlled, and you may spend mana as though it were any color to cast it.
DeckHints:Type$Vampire DeckHints:Type$Vampire
Oracle:Flash\nWhenever Evelyn, the Covetous or another Vampire enters the battlefield under your control, exile the top card of each player's library with a collection counter on it. Oracle:Flash\nWhenever Evelyn, the Covetous or another Vampire enters the battlefield under your control, exile the top card of each player's library with a collection counter on it.\nOnce each turn, you may play a card from exile with a collection counter on it if it was exiled by an ability you controlled, and you may spend mana as though it were mana of any color to cast it.
\nOnce each turn, you may play a card from exile with a collection counter on it if it was exiled by an ability you controlled, and you may spend mana as though it were mana of any color to cast it.

View File

@@ -1,7 +1,7 @@
Name:Swallow Whole Name:Swallow Whole
ManaCost:W ManaCost:W
Types:Sorcery Types:Sorcery
A:SP$ ChangeZone | Cost$ W tapXType<1/Creature> | ValidTgts$ Creature.tapped | TgtPrompt$ Select target tapped creature | Origin$ Battlefield | Destination$ Exile | SubAbility$ DBPutCounter | SpellDescription$ As an additional cost to cast this spell, tap an untapped creature you control. Exile target tapped creature. A:SP$ ChangeZone | Cost$ W tapXType<1/Creature> | ValidTgts$ Creature.tapped | TgtPrompt$ Select target tapped creature | Origin$ Battlefield | Destination$ Exile | SubAbility$ DBPutCounter | SpellDescription$ Exile target tapped creature.
SVar:DBPutCounter:DB$ PutCounter | Defined$ Tapped | CounterType$ P1P1 | SpellDescription$ Put a +1/+1 counter on the creature tapped to cast this spell. SVar:DBPutCounter:DB$ PutCounter | Defined$ Tapped | CounterType$ P1P1 | SpellDescription$ Put a +1/+1 counter on the creature tapped to cast this spell.
DeckHas:Ability$Counters DeckHas:Ability$Counters
Oracle:As an additional cost to cast this spell, tap an untapped creature you control.\nExile target tapped creature. Put a +1/+1 counter on the creature tapped to pay this spell's additional cost. Oracle:As an additional cost to cast this spell, tap an untapped creature you control.\nExile target tapped creature. Put a +1/+1 counter on the creature tapped to pay this spell's additional cost.

View File

@@ -16,6 +16,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.TreeSet; import java.util.TreeSet;
import forge.util.ImageUtil; import forge.util.ImageUtil;
@@ -49,6 +50,7 @@ import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostShard; import forge.card.mana.ManaCostShard;
import forge.deck.CardPool; import forge.deck.CardPool;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckRecognizer;
import forge.deck.DeckSection; import forge.deck.DeckSection;
import forge.game.Game; import forge.game.Game;
import forge.game.GameEntity; import forge.game.GameEntity;
@@ -1712,8 +1714,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override @Override
public List<String> chooseColors(final String message, final SpellAbility sa, final int min, final int max, public List<String> chooseColors(final String message, final SpellAbility sa, final int min, final int max,
final List<String> options) { List<String> options) {
return getGui().getChoices(message, min, max, options); options = options.stream().map(DeckRecognizer::getLocalisedMagicColorName).collect(Collectors.toList());
List<String> choices = getGui().getChoices(message, min, max, options);
return choices.stream().map(DeckRecognizer::getColorNameByLocalisedName).collect(Collectors.toList());
} }
@Override @Override