From 9e15b95f00840f2da0eaef704f27e098220eb02a Mon Sep 17 00:00:00 2001 From: Sloth Date: Mon, 5 Dec 2011 18:17:45 +0000 Subject: [PATCH] - Added the property "sharesCreatureTypeWith". - Fixed Kinship cards that changed their creature types. --- src/main/java/forge/Card.java | 26 ++++++++++++++++++++++ src/main/java/forge/Upkeep.java | 38 +++++++++++---------------------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index 4d585344ce4..7535296cd97 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -6807,6 +6807,10 @@ public class Card extends GameEntity implements Comparable { } } } + } else if (property.startsWith("sharesCreatureTypeWith")) { + if (!this.sharesCreatureTypeWith(source)) { + return false; + } } else if (property.startsWith("withFlashback")) { boolean fb = false; if (this.hasStartOfUnHiddenKeyword("Flashback")) { @@ -7255,6 +7259,28 @@ public class Card extends GameEntity implements Comparable { shares |= (this.isWhite() && c1.isWhite()); return shares; } + + /** + *

+ * sharesColorWith. + *

+ * + * @param c1 + * a {@link forge.Card} object. + * @return a boolean. + */ + public final boolean sharesCreatureTypeWith(final Card c1) { + + for (String type : this.getType()) { + if (type.equals("AllCreatureTypes")) { + return true; + } + if (CardUtil.isACreatureType(type) && c1.isType(type)) { + return true; + } + } + return false; + } /** *

diff --git a/src/main/java/forge/Upkeep.java b/src/main/java/forge/Upkeep.java index 464b5ed3b0d..c1eaef84fd0 100644 --- a/src/main/java/forge/Upkeep.java +++ b/src/main/java/forge/Upkeep.java @@ -933,7 +933,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Merfolk", "Wizard" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -957,7 +956,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1019,8 +1018,7 @@ public class Upkeep implements java.io.Serializable { if ((kinship.size() == 0) || (library.size() <= 0)) { return; } - - final String[] shareTypes = { "Kithkin", "Soldier" }; + final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1044,7 +1042,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1123,7 +1121,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Treefolk", "Shaman" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1147,7 +1144,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1224,7 +1221,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Goblin", "Warrior" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1248,7 +1244,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1323,7 +1319,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Faerie", "Wizard" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1347,7 +1342,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1408,7 +1403,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Elemental", "Shaman" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1441,7 +1435,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1509,7 +1503,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Goblin", "Shaman" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1534,7 +1527,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1602,7 +1595,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Goblin", "Shaman" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1626,7 +1618,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1688,7 +1680,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Giant", "Wizard" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1712,7 +1703,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1773,7 +1764,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Merfolk", "Wizard" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1797,7 +1787,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1879,7 +1869,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Elf", "Warrior" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1903,7 +1892,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -1964,7 +1953,6 @@ public class Upkeep implements java.io.Serializable { return; } - final String[] shareTypes = { "Elf", "Shaman" }; final Card[] prevCardShown = { null }; final Card[] peek = { null }; @@ -1988,7 +1976,7 @@ public class Upkeep implements java.io.Serializable { // Dialogs outside of the Ability appear at the previous end // of turn phase !!! - if (peek[0].isValid(shareTypes, k.getController(), k)) { + if (peek[0].isValid("Card.sharesCreatureTypeWith", k.getController(), k)) { if (player.isHuman()) { final StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName());