From 6f27c0748151c0697d620fb28ad9f7c7b90efbd1 Mon Sep 17 00:00:00 2001 From: Sloth Date: Fri, 29 Jun 2012 17:02:17 +0000 Subject: [PATCH] - Fixed Whimwader. - Converted Kulrath Knight to script. - Performance update in canAttackNextTurn. --- res/cardsfolder/k/kulrath_knight.txt | 3 +- src/main/java/forge/Card.java | 4 + src/main/java/forge/CardList.java | 1 - .../java/forge/game/phase/CombatUtil.java | 110 ++++++------------ 4 files changed, 44 insertions(+), 74 deletions(-) diff --git a/res/cardsfolder/k/kulrath_knight.txt b/res/cardsfolder/k/kulrath_knight.txt index 5f11f04f646..1e2de004a16 100644 --- a/res/cardsfolder/k/kulrath_knight.txt +++ b/res/cardsfolder/k/kulrath_knight.txt @@ -1,10 +1,11 @@ Name:Kulrath Knight ManaCost:3 BR BR Types:Creature Elemental Knight -Text:Creatures your opponents control with counters on them can't attack or block. +Text:no text PT:3/3 K:Flying K:Wither +S:Mode$ Continuous | Affected$ Creature.YouDontCtrl+HasCounters | AddHiddenKeyword$ HIDDEN CARDNAME can't attack or block. | Description$ Creatures your opponents control with counters on them can't attack or block. SVar:Rarity:Uncommon SVar:Picture:http://www.wizards.com/global/images/magic/general/kulrath_knight.jpg SetInfo:SHM|Uncommon|http://magiccards.info/scans/en/shm/190.jpg diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index b4bcdef3b30..fd9ba5d7adf 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -7118,6 +7118,10 @@ public class Card extends GameEntity implements Comparable { if (!((this.getAbilityText().trim().equals("") || this.isFaceDown()) && (this.getUnhiddenKeyword().size() == 0))) { return false; } + } else if (property.equals("HasCounters")) { + if (!this.hasCounters()) { + return false; + } } else if (property.equals("SameNameAsImprinted")) { boolean b = false; for (final Card card : source.getImprinted()) { diff --git a/src/main/java/forge/CardList.java b/src/main/java/forge/CardList.java index cbac2c85ff1..f0b5e8a09f7 100644 --- a/src/main/java/forge/CardList.java +++ b/src/main/java/forge/CardList.java @@ -137,7 +137,6 @@ public class CardList implements Iterable { list.add(c); } } - return list; } // getColor() diff --git a/src/main/java/forge/game/phase/CombatUtil.java b/src/main/java/forge/game/phase/CombatUtil.java index a961a9c2a64..f325aef24d3 100644 --- a/src/main/java/forge/game/phase/CombatUtil.java +++ b/src/main/java/forge/game/phase/CombatUtil.java @@ -32,6 +32,7 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.CardListFilter; +import forge.CardListUtil; import forge.Command; import forge.Constant; import forge.Counters; @@ -130,18 +131,6 @@ public class CombatUtil { return false; } - final CardList kulrath = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Kulrath Knight"); - if (kulrath.size() > 0) { - for (int i = 0; i < kulrath.size(); i++) { - final Card cKK = kulrath.get(i); - final Player oppKK = cKK.getController().getOpponent(); - - if (blocker.getController().equals(oppKK) && blocker.hasCounters()) { - return false; - } - } - } - return true; } @@ -768,49 +757,46 @@ public class CombatUtil { final CardList list = c.getController().getOpponent().getCardsIn(ZoneType.Battlefield); CardList temp; - - if (c.hasKeyword("CARDNAME can't attack unless defending player controls an Island.")) { - temp = list.getType("Island"); - if (temp.isEmpty()) { + for (String keyword : c.getKeyword()) { + if (keyword.equals("CARDNAME can't attack.") || keyword.equals("CARDNAME can't attack or block.")) { return false; - } - } - - if (c.hasKeyword("CARDNAME can't attack unless defending player controls a Forest.")) { - temp = list.getType("Forest"); - if (temp.isEmpty()) { + } else if (keyword.equals("Defender") && !c.hasKeyword("CARDNAME can attack as though it didn't have defender.")) { return false; - } - } - - if (c.hasKeyword("CARDNAME can't attack unless defending player controls a Swamp.")) { - temp = list.getType("Swamp"); - if (temp.isEmpty()) { - return false; - } - } - if (c.hasKeyword("CARDNAME can't attack unless defending player controls a Mountain.")) { - temp = list.getType("Montain"); - if (temp.isEmpty()) { - return false; - } - } - if (c.hasKeyword("CARDNAME can't attack unless defending player controls a snow land.")) { - temp = list.filter(new CardListFilter() { - @Override - public boolean addCard(final Card c) { - return c.isLand() && c.isSnow(); + } else if (keyword.equals("CARDNAME can't attack unless defending player controls an Island.")) { + temp = list.getType("Island"); + if (temp.isEmpty()) { + return false; + } + } else if (keyword.equals("CARDNAME can't attack unless defending player controls a Forest.")) { + temp = list.getType("Forest"); + if (temp.isEmpty()) { + return false; + } + } else if (keyword.equals("CARDNAME can't attack unless defending player controls a Swamp.")) { + temp = list.getType("Swamp"); + if (temp.isEmpty()) { + return false; + } + } else if (keyword.equals("CARDNAME can't attack unless defending player controls a Mountain.")) { + temp = list.getType("Mountain"); + if (temp.isEmpty()) { + return false; + } + } else if (keyword.equals("CARDNAME can't attack unless defending player controls a snow land.")) { + temp = list.filter(new CardListFilter() { + @Override + public boolean addCard(final Card c) { + return c.isLand() && c.isSnow(); + } + }); + if (temp.isEmpty()) { + return false; + } + } else if (keyword.equals("CARDNAME can't attack unless defending player controls a blue permanent.")) { + temp = CardListUtil.getColor(list, Constant.Color.BLUE); + if (temp.isEmpty()) { + return false; } - }); - if (temp.isEmpty()) { - return false; - } - } - - if (c.hasKeyword("CARDNAME can't attack unless defending player controls a blue permanent.")) { - temp = list.getColor(Constant.Color.BLUE); - if (temp.isEmpty()) { - return false; } } @@ -826,26 +812,6 @@ public class CombatUtil { return false; } - if (c.hasKeyword("CARDNAME can't attack.") || c.hasKeyword("CARDNAME can't attack or block.")) { - return false; - } - - if (c.hasKeyword("Defender") && !c.hasKeyword("CARDNAME can attack as though it didn't have defender.")) { - return false; - } - - if (AllZoneUtil.isCardInPlay("Kulrath Knight")) { - final CardList all = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Kulrath Knight"); - for (int i = 0; i < all.size(); i++) { - final Card cKK = all.get(i); - final Player oppKK = cKK.getController().getOpponent(); - - if (c.getController().equals(oppKK) && c.hasCounters()) { - return false; - } - } - } - return true; } // canAttack()