- Added the option Other to isValidCard with card as argument.

- Made restrictions like Artifact.YouCtrl,Enchantment possible.
This commit is contained in:
jendave
2011-08-06 09:30:00 +00:00
parent dcc6400139
commit a55c7dc7e3

View File

@@ -2186,16 +2186,80 @@ public class Card extends MyObservable {
return false; return false;
} }
// This takes a player and a card argument for YouCtrl and Other
public boolean isValidCard(String Restris[], Player You, Card source) {
public boolean isValidCard(String Restris[], Player You) { String Restriction[] = new String[Restris.length];
/////////////////// temporary DEBUG code String st = "";
System.out.println("DEBUG: "+this.getName()+" - isValidCard Restrictions length: "+Restris.length); for (int i=0; i<Restris.length; i++)
System.out.print("DEBUG: "+this.getName()+" - isValidCard Restrictions: "); {
for(String a:Restris) { Restriction[i] = Restris[i];
System.out.print("|"+a); if (Restriction[i].contains("Other"))
{
if (this.equals(source)) {
st = "False"; //False restriction entries in the array will return false
} }
System.out.println("|"); else st = Restriction[i].replaceAll(".Other", "");
////////////////// end temp DEBUG code Restriction[i] = st;
}
else if (Restriction[i].contains("Self"))
{
if (!this.equals(source)) {
st = "False"; //False restriction entries in the array will return false
}
else st = Restriction[i].replaceAll(".Self", "");
Restriction[i] = st;
}
if (Restriction[i].contains("YouCtrl"))
{
if (!getController().isPlayer(You)) {
st = "False"; //False restriction entries in the array will return false
}
else st = Restriction[i].replaceAll(".YouCtrl", "");
Restriction[i] = st;
}
else if (Restriction[i].contains("YouDontCtrl"))
{
if (getController().isPlayer(You)) {
st = "False"; //False restriction entries in the array will return false
}
else st = Restriction[i].replaceAll(".YouDontCtrl", "");
Restriction[i] = st;
}
}
return isValidCard(Restriction);
}
// This takes a card argument Self and Other
public boolean isValidCard(String Restris[], Card source) {
String Restriction[] = new String[Restris.length];
String st = "";
for (int i=0; i<Restris.length; i++)
{
Restriction[i] = Restris[i];
if (Restriction[i].contains("Other"))
{
if (this.equals(source)) {
st = "False"; //False restriction entries in the array will return false;
}
else st = Restriction[i].replaceAll(".Other", "");
Restriction[i] = st;
}
else if (Restriction[i].contains("Self"))
{
if (!this.equals(source)) {
st = "False"; //False restriction entries in the array will return false
}
else st = Restriction[i].replaceAll(".Self", "");
Restriction[i] = st;
}
}
return isValidCard(Restriction);
}
// This takes a player argument YouCtrl and YouDontCtrl
public boolean isValidCard(String Restris[], Player You) {
String Restriction[] = new String[Restris.length]; String Restriction[] = new String[Restris.length];
String st = ""; String st = "";
@@ -2205,7 +2269,7 @@ public class Card extends MyObservable {
if (Restriction[i].contains("YouCtrl")) if (Restriction[i].contains("YouCtrl"))
{ {
if (!getController().isPlayer(You)) { if (!getController().isPlayer(You)) {
return false; st = "False"; //False restriction entries in the array will return false
} }
st = Restriction[i].replaceAll(".YouCtrl", ""); st = Restriction[i].replaceAll(".YouCtrl", "");
Restriction[i] = st; Restriction[i] = st;
@@ -2213,7 +2277,7 @@ public class Card extends MyObservable {
else if (Restriction[i].contains("YouDontCtrl")) else if (Restriction[i].contains("YouDontCtrl"))
{ {
if (getController().isPlayer(You)) { if (getController().isPlayer(You)) {
return false; st = "False"; //False restriction entries in the array will return false
} }
st = Restriction[i].replaceAll(".YouDontCtrl", ""); st = Restriction[i].replaceAll(".YouDontCtrl", "");
Restriction[i] = st; Restriction[i] = st;
@@ -2240,6 +2304,7 @@ public class Card extends MyObservable {
public boolean isValid(String Restriction) { public boolean isValid(String Restriction) {
if (getName().equals("Mana Pool") || isImmutable()) return false; if (getName().equals("Mana Pool") || isImmutable()) return false;
if (Restriction.equals("False")) return false;
String incR[] = Restriction.split("\\."); // Inclusive restrictions are Card types String incR[] = Restriction.split("\\."); // Inclusive restrictions are Card types