Tests: improved addCard command, now it can add card from specific set (use 40K:Plains as card name param, #10139)

This commit is contained in:
Oleg Agafonov 2023-03-23 23:05:33 +04:00
parent 92706d23cb
commit d019acbd55
8 changed files with 125 additions and 24 deletions

View file

@ -77,6 +77,8 @@ public final class CardUtil {
"put", "return", "exile", "discard", "sacrifice", "remove", "tap", "reveal", "pay"
);
public static final int TESTS_SET_CODE_LOOKUP_LENGTH = 10; // search set code in commands like "set:card_name"
/**
* Increase spell or ability cost to be paid.
*
@ -1741,4 +1743,18 @@ public final class CardUtil {
throw new IllegalArgumentException("Can't use KeySet as param, use new LinkedHashSet<>(data.keySet()) instead");
}
}
/**
* Don't raise exception, so must be used instead standard substring calls all the time
*
* @param str
* @param maxLength
* @return
*/
public static String substring(String str, int maxLength) {
if (str == null || str.isEmpty()) {
return str;
}
return str.substring(0, Math.min(str.length(), maxLength));
}
}