fix: make character selection use characterIDs and not indices
This commit is contained in:
@ -22,6 +22,7 @@ public class CharacterConfig {
|
||||
|
||||
@JsonIgnore private Map<String, CharacterProperties> propertyMap;
|
||||
@JsonIgnore private Map<String, CharacterProperties> unmodifiablePropertyMap;
|
||||
@JsonIgnore private Map<Integer, CharacterProperties> idToCharacter;
|
||||
|
||||
/**
|
||||
* @return a unmodifiable {@link Map}<{@link String}, {@link CharacterProperties}> containing all properties.
|
||||
@ -41,6 +42,23 @@ public class CharacterConfig {
|
||||
return unmodifiablePropertyMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a {@link Map}<{@link Integer}, {@link CharacterProperties}> from characterID to character.
|
||||
* If not yet existent, initialize the Map
|
||||
*/
|
||||
@JsonIgnore
|
||||
public Map<Integer, CharacterProperties> getIDMap() {
|
||||
// lazy initialization
|
||||
if (idToCharacter == null) {
|
||||
idToCharacter = new HashMap<>();
|
||||
for (CharacterProperties property: characters) {
|
||||
idToCharacter.put(property.characterID, property);
|
||||
}
|
||||
}
|
||||
|
||||
return idToCharacter;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Tuple<CharacterProperties[], CharacterProperties[]> getDisjointSetsOfPropertiesOfSize(int size) {
|
||||
if ((size * 2) > characters.length) {
|
||||
|
Reference in New Issue
Block a user