Skip to content

Commit b994c83

Browse files
committed
Support decapitation victory condition and have fallback for future
1 parent 931f7ad commit b994c83

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed
Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,16 @@
11
package com.faforever.commons.api.dto;
22

3+
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
34
import lombok.AllArgsConstructor;
4-
import lombok.Getter;
5-
import lombok.extern.slf4j.Slf4j;
65

7-
import java.util.HashMap;
8-
import java.util.Map;
9-
10-
@Slf4j
11-
@Getter
126
@AllArgsConstructor
137
public enum VictoryCondition {
14-
// Order is crucial
15-
DEMORALIZATION(0),
16-
DOMINATION(1),
17-
ERADICATION(2),
18-
SANDBOX(3),
19-
UNKNOWN("unknown");
20-
21-
private static final Map<Object, VictoryCondition> fromNumber;
22-
23-
static {
24-
fromNumber = new HashMap<>();
25-
for (VictoryCondition victoryCondition : values()) {
26-
fromNumber.put(victoryCondition.value, victoryCondition);
27-
}
28-
}
29-
30-
private final Object value;
31-
32-
public static VictoryCondition fromNumber(Object number) {
33-
VictoryCondition victoryCondition = fromNumber.get(number);
34-
if (victoryCondition == null) {
35-
log.warn("Unknown victory condition: {}", number);
36-
return UNKNOWN;
37-
}
38-
return victoryCondition;
39-
}
8+
// Order is crucial
9+
DEMORALIZATION,
10+
DOMINATION,
11+
ERADICATION,
12+
SANDBOX,
13+
DECAPITATION,
14+
@JsonEnumDefaultValue
15+
UNKNOWN;
4016
}

0 commit comments

Comments
 (0)