[LTR] Implement Glamdring (#10574)

This commit is contained in:
Bobby McCann 2023-07-13 00:39:31 +01:00 committed by GitHub
parent cbd5651f80
commit 09530f1cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 196 additions and 23 deletions

View file

@ -39,12 +39,14 @@ public class ControlsPermanentsComparedToOpponentsCondition implements Condition
@Override
public String toString() {
StringBuilder sb = new StringBuilder("if you control ");
sb.append(type.getText1()).append(" ");
sb.append(filterPermanent.getMessage()).append(" ");
sb.append(type.getText2());
sb.append(" each opponent");
return sb.toString();
switch (type) {
case EQUAL_TO: return String.format("equal %s to each opponent", filterPermanent.getMessage());
case FEWER_THAN: return String.format("fewer %s than each opponent", filterPermanent.getMessage());
case MORE_THAN: return String.format("more %s than each opponent", filterPermanent.getMessage());
case OR_LESS: return String.format("fewer or equal %s than each opponent", filterPermanent.getMessage());
case OR_GREATER: return String.format("more or equal %s than each opponent", filterPermanent.getMessage());
default: throw new IllegalArgumentException("comparison rules for " + type + " missing");
}
}
}

View file

@ -4,18 +4,16 @@ package mage.constants;
* Created by IGOUDT on 5-3-2017.
*/
public enum ComparisonType {
FEWER_THAN("<", "fewer", "than"),
EQUAL_TO("==", "equal", "to"),
MORE_THAN(">", "more", "than");
FEWER_THAN("<"),
OR_LESS("<="),
EQUAL_TO("=="),
MORE_THAN(">"),
OR_GREATER(">=");
String operator;
String text1;
String text2;
final String operator;
ComparisonType(String op, String text1, String text2) {
ComparisonType(String op) {
this.operator = op;
this.text1 = text1;
this.text2 = text2;
}
@Override
@ -23,14 +21,6 @@ public enum ComparisonType {
return operator;
}
public String getText1() {
return text1;
}
public String getText2() {
return text2;
}
public static boolean compare(int source, ComparisonType comparison, int target) {
switch (comparison) {
case MORE_THAN:
@ -39,6 +29,10 @@ public enum ComparisonType {
return source < target;
case EQUAL_TO:
return source == target;
case OR_GREATER:
return source >= target;
case OR_LESS:
return source <= target;
default:
throw new IllegalArgumentException("comparison rules for " + comparison + " missing");
}