refactor: moved config and messages out of JSON
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* POJO describing the CharacterConfig as defined by the standard document.
|
||||
*/
|
||||
public class CharacterConfig {
|
||||
public CharacterProperties[] characters;
|
||||
|
||||
@JsonIgnore private Map<String, CharacterProperties> propertyMap;
|
||||
@JsonIgnore private Map<String, CharacterProperties> unmodifiablePropertyMap;
|
||||
|
||||
/**
|
||||
* @return a unmodifiable {@link Map}<{@link String}, {@link CharacterProperties}> containing all properties.
|
||||
* If not yet existent, initialize the Map
|
||||
*/
|
||||
@JsonIgnore
|
||||
public Map<String, CharacterProperties> getMap() {
|
||||
// lazy initialization
|
||||
if (propertyMap == null) {
|
||||
propertyMap = new HashMap<>();
|
||||
for (CharacterProperties property: characters) {
|
||||
propertyMap.put(property.name, property);
|
||||
}
|
||||
unmodifiablePropertyMap = Collections.unmodifiableMap(propertyMap);
|
||||
}
|
||||
|
||||
return unmodifiablePropertyMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CharacterConfig that = (CharacterConfig) o;
|
||||
return Arrays.equals(characters, that.characters) && Objects.equals(propertyMap, that.propertyMap) && Objects.equals(unmodifiablePropertyMap, that.unmodifiablePropertyMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Objects.hash(propertyMap, unmodifiablePropertyMap);
|
||||
result = 31 * result + Arrays.hashCode(characters);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@JsonPropertyOrder({"characterID", "name", "HP", "MP", "AP", "meleeDamage", "rangeCombatDamage", "rangeCombatReach"})
|
||||
/**
|
||||
* Represents properties of a character in the {@link CharacterConfig}.
|
||||
*/
|
||||
public class CharacterProperties {
|
||||
public int characterID;
|
||||
public String name;
|
||||
public int HP;
|
||||
public int MP;
|
||||
public int AP;
|
||||
public int meleeDamage;
|
||||
@JsonProperty("rangeCombatDamage")
|
||||
public int rangedDamage;
|
||||
@JsonProperty("rangeCombatReach")
|
||||
public int attackRange;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CharacterProperties that = (CharacterProperties) o;
|
||||
return characterID == that.characterID && HP == that.HP && MP == that.MP && AP == that.AP && meleeDamage == that.meleeDamage && rangedDamage == that.rangedDamage && attackRange == that.attackRange && Objects.equals(name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(characterID, name, HP, MP, AP, meleeDamage, rangedDamage, attackRange);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.config;
|
||||
|
||||
/**
|
||||
* Enum defining the different field types as described by standard document
|
||||
*/
|
||||
public enum FieldType {
|
||||
GRASS,
|
||||
ROCK,
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.config;
|
||||
|
||||
/**
|
||||
* POJO describing the PartyConfig as defined by the standard document
|
||||
*/
|
||||
public class PartyConfig {
|
||||
/** Max round amount in a match */
|
||||
public int maxRounds;
|
||||
|
||||
/** Max round time in a match in seconds */
|
||||
public int maxRoundTime;
|
||||
|
||||
/** Max overall time in a match in seconds */
|
||||
public int maxGameTime;
|
||||
|
||||
/** Max time a single animation might take up in seconds */
|
||||
public int maxAnimationTime;
|
||||
|
||||
/** Cooldown of the space stone in rounds */
|
||||
public int spaceStoneCD;
|
||||
|
||||
/** Cooldown of the mind stone in rounds */
|
||||
public int mindStoneCD;
|
||||
|
||||
/** Cooldown of the reality stone in rounds */
|
||||
public int realityStoneCD;
|
||||
|
||||
/** Cooldown of the power stone in rounds */
|
||||
public int powerStoneCD;
|
||||
|
||||
/** Cooldown of the time stone in rounds */
|
||||
public int timeStoneCD;
|
||||
|
||||
/** Cooldown of the soul stone in rounds */
|
||||
public int soulStoneCD;
|
||||
|
||||
/** Damage the mind stone does when used */
|
||||
public int mindStoneDMG;
|
||||
|
||||
/** Max pause time. Optional */
|
||||
public int maxPauseTime;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.config;
|
||||
|
||||
/**
|
||||
* POJO describing the ScenarioConfig as defined by the standard document
|
||||
*/
|
||||
public class ScenarioConfig {
|
||||
/** An array containing the map based on the {@link FieldType} enum. So, ROCK and GRASS basically. */
|
||||
public FieldType[][] scenario;
|
||||
|
||||
/** A string containing the name of the author of the scenario config */
|
||||
public String author;
|
||||
|
||||
/** A string containing the name of the scenario configuration (so basically the map title) */
|
||||
public String name;
|
||||
}
|
Reference in New Issue
Block a user