diff --git a/forge-core/src/main/java/forge/card/CardRules.java b/forge-core/src/main/java/forge/card/CardRules.java index 8ec2da57cb7..a199b31349e 100644 --- a/forge-core/src/main/java/forge/card/CardRules.java +++ b/forge-core/src/main/java/forge/card/CardRules.java @@ -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(":"); diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index b5727b9cbec..d41735da5fa 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -184,7 +184,7 @@ public final class CardRulesPredicates { return new Predicate() { @Override public boolean apply(final CardRules card) { - return card.hasKeyword(keyword); + return card.hasStartOfKeyword(keyword); } }; } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ClashEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ClashEffect.java index 062eaa833da..c790777399d 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ClashEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ClashEffect.java @@ -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"; diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 4720c7b4072..2b385150452 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -3408,7 +3408,7 @@ public class Player extends GameEntity implements Comparable { 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() { diff --git a/forge-gui/res/cardsfolder/h/hordewing_skaab.txt b/forge-gui/res/cardsfolder/h/hordewing_skaab.txt index 1f1cb54e59d..e1e46e616b8 100644 --- a/forge-gui/res/cardsfolder/h/hordewing_skaab.txt +++ b/forge-gui/res/cardsfolder/h/hordewing_skaab.txt @@ -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.