UI: added mulligan option to new tournament dialog, added mulligan type saving;

This commit is contained in:
Oleg Agafonov 2019-03-23 05:49:21 +04:00
parent b925977efd
commit 42658d5cff
5 changed files with 46 additions and 18 deletions

View file

@ -1,5 +1,7 @@
package mage.game.mulligan;
import java.util.Locale;
public enum MulliganType {
GAME_DEFAULT("Game Default"),
@ -15,7 +17,7 @@ public enum MulliganType {
}
public Mulligan getMulligan(int freeMulligans) {
switch(this) {
switch (this) {
case PARIS:
return new ParisMulligan(freeMulligans);
case CANADIAN_HIGHLANDER:
@ -33,6 +35,20 @@ public enum MulliganType {
return displayName;
}
public static MulliganType valueByName(String name) {
String search = (name != null ? name : "").toUpperCase(Locale.ENGLISH);
MulliganType res = GAME_DEFAULT;
for (MulliganType m : values()) {
if (m.displayName.toUpperCase(Locale.ENGLISH).equals(search)) {
res = m;
break;
}
}
return res;
}
public MulliganType orDefault(MulliganType defaultMulligan) {
if (this == GAME_DEFAULT) {
return defaultMulligan;