mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
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:
@@ -671,6 +671,16 @@ public final class CardRules implements ICardCharacteristics {
|
||||
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) {
|
||||
for (final String inst : mainPart.getKeywords()) {
|
||||
final String[] parts = inst.split(":");
|
||||
|
||||
@@ -184,7 +184,7 @@ public final class CardRulesPredicates {
|
||||
return new Predicate<CardRules>() {
|
||||
@Override
|
||||
public boolean apply(final CardRules card) {
|
||||
return card.hasKeyword(keyword);
|
||||
return card.hasStartOfKeyword(keyword);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
final PlayerZone pLib = player.getZone(lib);
|
||||
final PlayerZone oLib = opponent.getZone(lib);
|
||||
|
||||
if ((pLib.size() == 0) && (oLib.size() == 0)) {
|
||||
if (pLib.isEmpty() && oLib.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -91,56 +91,49 @@ public class ClashEffect extends SpellAbilityEffect {
|
||||
reveal.append("OVERRIDE "); //will return substring with the original message parsed here..
|
||||
Card pCard = null;
|
||||
Card oCard = null;
|
||||
|
||||
if (pLib.size() > 0) {
|
||||
pCard = pLib.get(0);
|
||||
}
|
||||
if (oLib.size() > 0) {
|
||||
oCard = oLib.get(0);
|
||||
}
|
||||
|
||||
int pCMC = 0;
|
||||
int oCMC = 0;
|
||||
final CardCollection toReveal = new CardCollection();
|
||||
int pCMC = -1;
|
||||
int oCMC = -1;
|
||||
|
||||
if (!pLib.isEmpty()) {
|
||||
pCard = pLib.get(0);
|
||||
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("\n");
|
||||
clashMoveToTopOrBottom(player, pCard, sa);
|
||||
}
|
||||
else {
|
||||
pCMC = -1;
|
||||
}
|
||||
if (!oLib.isEmpty()) {
|
||||
oCard = oLib.get(0);
|
||||
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("\n");
|
||||
clashMoveToTopOrBottom(opponent, oCard, sa);
|
||||
}
|
||||
else {
|
||||
oCMC = -1;
|
||||
}
|
||||
final CardCollection toReveal = new CardCollection();
|
||||
if (pCard != null)
|
||||
toReveal.add(pCard);
|
||||
if (oCard != null)
|
||||
toReveal.add(oCard);
|
||||
|
||||
Player winner = null;
|
||||
|
||||
// no winner, still show the revealed cards rather than do nothing
|
||||
if (pCMC == oCMC) {
|
||||
reveal.append(Localizer.getInstance().getMessage("lblNoWinner"));
|
||||
player.getGame().getAction().revealTo(toReveal, player.getGame().getPlayers(), reveal.toString());
|
||||
return null;
|
||||
} else {
|
||||
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());
|
||||
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) {
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
final GameAction action = p.getGame().getAction();
|
||||
final boolean putOnTop = p.getController().willPutCardOnTop(c);
|
||||
final String location = putOnTop ? "top" : "bottom";
|
||||
|
||||
@@ -3408,7 +3408,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
return false;
|
||||
}
|
||||
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() {
|
||||
|
||||
@@ -3,12 +3,12 @@ ManaCost:4 U
|
||||
Types:Creature Zombie Horror
|
||||
PT:3/3
|
||||
K: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.
|
||||
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.
|
||||
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:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
||||
SVar:X:TriggeredPlayersTargets$Amount
|
||||
DeckHints:Type$Zombie
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user