mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Little cleanup in card class.
- Added removeKeyword, isValid and hasProperty functions to the player class.
This commit is contained in:
@@ -4736,7 +4736,6 @@ public class Card extends MyObservable implements Comparable<Card> {
|
|||||||
public boolean isValid(final String Restriction, final Player sourceController, final Card source) {
|
public boolean isValid(final String Restriction, final Player sourceController, final Card source) {
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -757,6 +757,10 @@ public abstract class Player extends MyObservable {
|
|||||||
this.keywords.add(keyword);
|
this.keywords.add(keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeKeyword(String keyword){
|
||||||
|
this.keywords.remove(keyword);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasKeyword(String keyword){
|
public boolean hasKeyword(String keyword){
|
||||||
return this.keywords.contains(keyword);
|
return this.keywords.contains(keyword);
|
||||||
}
|
}
|
||||||
@@ -1665,6 +1669,41 @@ public abstract class Player extends MyObservable {
|
|||||||
prowl = new ArrayList<String>();
|
prowl = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValid(final String Restriction, final Player sourceController, final Card source) {
|
||||||
|
|
||||||
|
String incR[] = Restriction.split("\\.");
|
||||||
|
|
||||||
|
if (!incR[0].equals("Player") &&
|
||||||
|
!(incR[0].equals("Opponent") && !this.equals(sourceController)) &&
|
||||||
|
!(incR[0].equals("You") && this.equals(sourceController)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (incR.length > 1) {
|
||||||
|
final String excR = incR[1];
|
||||||
|
String exR[] = excR.split("\\+"); // Exclusive Restrictions are ...
|
||||||
|
for (int j = 0; j < exR.length; j++)
|
||||||
|
if (hasProperty(exR[j], sourceController, source) == false) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasProperty(String Property, final Player sourceController, final Card source) {
|
||||||
|
|
||||||
|
if (Property.equals("You")) {
|
||||||
|
if (!this.equals(sourceController)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Property.equals("Opponent")) {
|
||||||
|
if (this.equals(sourceController)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private ArrayList<HandSizeOp> handSizeOperations;
|
private ArrayList<HandSizeOp> handSizeOperations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user