Fix DeckHints only finding SimpleKeyword (#3191)

* Fix DeckHints only finding SimpleKeyword

* Reveal clash correctly

---------

Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.59>
This commit is contained in:
tool4ever
2023-06-03 12:58:23 +02:00
committed by GitHub
parent da71b9480d
commit 65d385d531
5 changed files with 36 additions and 33 deletions

View File

@@ -671,6 +671,16 @@ public final class CardRules implements ICardCharacteristics {
return Iterables.contains(mainPart.getKeywords(), k); return Iterables.contains(mainPart.getKeywords(), k);
} }
public boolean hasStartOfKeyword(final String k) {
for (final String inst : mainPart.getKeywords()) {
final String[] parts = inst.split(":");
if (parts[0].equals(k)) {
return true;
}
}
return false;
}
public Integer getKeywordMagnitude(final String k) { public Integer getKeywordMagnitude(final String k) {
for (final String inst : mainPart.getKeywords()) { for (final String inst : mainPart.getKeywords()) {
final String[] parts = inst.split(":"); final String[] parts = inst.split(":");

View File

@@ -184,7 +184,7 @@ public final class CardRulesPredicates {
return new Predicate<CardRules>() { return new Predicate<CardRules>() {
@Override @Override
public boolean apply(final CardRules card) { public boolean apply(final CardRules card) {
return card.hasKeyword(keyword); return card.hasStartOfKeyword(keyword);
} }
}; };
} }

View File

@@ -83,7 +83,7 @@ public class ClashEffect extends SpellAbilityEffect {
final PlayerZone pLib = player.getZone(lib); final PlayerZone pLib = player.getZone(lib);
final PlayerZone oLib = opponent.getZone(lib); final PlayerZone oLib = opponent.getZone(lib);
if ((pLib.size() == 0) && (oLib.size() == 0)) { if (pLib.isEmpty() && oLib.isEmpty()) {
return null; return null;
} }
@@ -91,56 +91,49 @@ public class ClashEffect extends SpellAbilityEffect {
reveal.append("OVERRIDE "); //will return substring with the original message parsed here.. reveal.append("OVERRIDE "); //will return substring with the original message parsed here..
Card pCard = null; Card pCard = null;
Card oCard = null; Card oCard = null;
final CardCollection toReveal = new CardCollection();
if (pLib.size() > 0) { int pCMC = -1;
pCard = pLib.get(0); int oCMC = -1;
}
if (oLib.size() > 0) {
oCard = oLib.get(0);
}
int pCMC = 0;
int oCMC = 0;
if (!pLib.isEmpty()) { if (!pLib.isEmpty()) {
pCard = pLib.get(0);
pCMC = pCard.getCMC(); pCMC = pCard.getCMC();
toReveal.add(pCard);
reveal.append(player).append(" " + Localizer.getInstance().getMessage("lblReveals") + ": ").append(pCard.getName()).append(". " + Localizer.getInstance().getMessage("lblCMC") + "= ").append(pCMC); reveal.append(player).append(" " + Localizer.getInstance().getMessage("lblReveals") + ": ").append(pCard.getName()).append(". " + Localizer.getInstance().getMessage("lblCMC") + "= ").append(pCMC);
reveal.append("\n"); reveal.append("\n");
clashMoveToTopOrBottom(player, pCard, sa);
}
else {
pCMC = -1;
} }
if (!oLib.isEmpty()) { if (!oLib.isEmpty()) {
oCard = oLib.get(0);
oCMC = oCard.getCMC(); oCMC = oCard.getCMC();
toReveal.add(oCard);
reveal.append(opponent).append(" " + Localizer.getInstance().getMessage("lblReveals") + ": ").append(oCard.getName()).append(". " + Localizer.getInstance().getMessage("lblCMC") + "= ").append(oCMC); reveal.append(opponent).append(" " + Localizer.getInstance().getMessage("lblReveals") + ": ").append(oCard.getName()).append(". " + Localizer.getInstance().getMessage("lblCMC") + "= ").append(oCMC);
reveal.append("\n"); reveal.append("\n");
clashMoveToTopOrBottom(opponent, oCard, sa);
} }
else {
oCMC = -1; Player winner = null;
}
final CardCollection toReveal = new CardCollection();
if (pCard != null)
toReveal.add(pCard);
if (oCard != null)
toReveal.add(oCard);
// no winner, still show the revealed cards rather than do nothing // no winner, still show the revealed cards rather than do nothing
if (pCMC == oCMC) { if (pCMC == oCMC) {
reveal.append(Localizer.getInstance().getMessage("lblNoWinner")); reveal.append(Localizer.getInstance().getMessage("lblNoWinner"));
player.getGame().getAction().revealTo(toReveal, player.getGame().getPlayers(), reveal.toString()); } else {
return null; winner = pCMC > oCMC ? player : opponent;
reveal.append(winner + " " + Localizer.getInstance().getMessage("lblWinsClash") + ".");
} }
reveal.append(pCMC > oCMC ? player + " " + Localizer.getInstance().getMessage("lblWinsClash") + "." : opponent + " " + Localizer.getInstance().getMessage("lblWinsClash") + ".");
player.getGame().getAction().revealTo(toReveal, player.getGame().getPlayers(), reveal.toString()); player.getGame().getAction().revealTo(toReveal, player.getGame().getPlayers(), reveal.toString());
return pCMC > oCMC ? player : opponent;
clashMoveToTopOrBottom(player, pCard, sa);
clashMoveToTopOrBottom(opponent, oCard, sa);
return winner;
} }
private static void clashMoveToTopOrBottom(final Player p, final Card c, final SpellAbility sa) { private static void clashMoveToTopOrBottom(final Player p, final Card c, final SpellAbility sa) {
if (c == null) {
return;
}
final GameAction action = p.getGame().getAction(); final GameAction action = p.getGame().getAction();
final boolean putOnTop = p.getController().willPutCardOnTop(c); final boolean putOnTop = p.getController().willPutCardOnTop(c);
final String location = putOnTop ? "top" : "bottom"; final String location = putOnTop ? "top" : "bottom";

View File

@@ -3408,7 +3408,7 @@ public class Player extends GameEntity implements Comparable<Player> {
return false; return false;
} }
return targetPlayer == null || !targetPlayer.equals(sa.getActivatingPlayer()) return targetPlayer == null || !targetPlayer.equals(sa.getActivatingPlayer())
|| !hasKeyword("Spells and abilities you control can't cause you to search your library."); || !hasKeyword("Spells and abilities you control can't cause you to search your library.");
} }
public Card getKeywordCard() { public Card getKeywordCard() {

View File

@@ -3,12 +3,12 @@ ManaCost:4 U
Types:Creature Zombie Horror Types:Creature Zombie Horror
PT:3/3 PT:3/3
K:Flying K:Flying
S:Mode$ Continuous | Affected$ Zombie.YouCtrl+Other | AddKeyword$ Flying | Description$ Other zombies you control have flying. S:Mode$ Continuous | Affected$ Zombie.YouCtrl+Other | AddKeyword$ Flying | Description$ Other Zombies you control have flying.
T:Mode$ DamageAll | ValidSource$ Creature.Zombie+YouCtrl | ValidTarget$ Player.Opponent | CombatDamage$ True | TriggerZones$ Battlefield | Execute$ TrigDraw | OptionalDecider$ You | TriggerDescription$ Whenever one or more zombies you control deal combat damage to one or more of your opponents, you may draw cards equal to the number of opponents dealt damage this way. If you do, discard that many cards. T:Mode$ DamageAll | ValidSource$ Creature.Zombie+YouCtrl | ValidTarget$ Player.Opponent | CombatDamage$ True | TriggerZones$ Battlefield | Execute$ TrigDraw | OptionalDecider$ You | TriggerDescription$ Whenever one or more Zombies you control deal combat damage to one or more of your opponents, you may draw cards equal to the number of opponents dealt damage this way. If you do, discard that many cards.
SVar:TrigDraw:DB$ Draw | Defined$ You | NumCards$ X | RememberDrawn$ True | SubAbility$ DBDiscard SVar:TrigDraw:DB$ Draw | Defined$ You | NumCards$ X | RememberDrawn$ True | SubAbility$ DBDiscard
SVar:DBDiscard:DB$ Discard | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ GEX | Defined$ You | Mode$ TgtChoose | NumCards$ X | SubAbility$ DBCleanup SVar:DBDiscard:DB$ Discard | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ GEX | Defined$ You | Mode$ TgtChoose | NumCards$ X | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:TriggeredPlayersTargets$Amount SVar:X:TriggeredPlayersTargets$Amount
DeckHints:Type$Zombie DeckHints:Type$Zombie
DeckHas:Ability$Discard DeckHas:Ability$Discard
Oracle:Flying\nOther zombies you control have flying.\nWhenever one or more zombies you control deal combat damage to one or more of your opponents, you may draw cards equal to the number of opponents dealt damage this way. If you do, discard that many cards. Oracle:Flying\nOther Zombies you control have flying.\nWhenever one or more Zombies you control deal combat damage to one or more of your opponents, you may draw cards equal to the number of opponents dealt damage this way. If you do, discard that many cards.