From 429cdd2e42fe41d11db94f4ba02a111793dfc771 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Thu, 3 Jun 2021 19:13:21 +0200 Subject: [PATCH] refactor: generated equals ... toString for configs --- .../config/CharacterProperties.java | 14 ++++++++ .../gamelibrary/config/PartyConfig.java | 33 +++++++++++++++++++ .../gamelibrary/config/ScenarioConfig.java | 27 +++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/config/CharacterProperties.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/config/CharacterProperties.java index 54ad275..b0abad8 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/config/CharacterProperties.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/config/CharacterProperties.java @@ -33,4 +33,18 @@ public class CharacterProperties { public int hashCode() { return Objects.hash(characterID, name, HP, MP, AP, meleeDamage, rangedDamage, attackRange); } + + @Override + public String toString() { + return "CharacterProperties{" + + "characterID=" + characterID + + ", name='" + name + '\'' + + ", HP=" + HP + + ", MP=" + MP + + ", AP=" + AP + + ", meleeDamage=" + meleeDamage + + ", rangedDamage=" + rangedDamage + + ", attackRange=" + attackRange + + '}'; + } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/config/PartyConfig.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/config/PartyConfig.java index 96e3438..9b4b4f0 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/config/PartyConfig.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/config/PartyConfig.java @@ -1,5 +1,7 @@ package uulm.teamname.marvelous.gamelibrary.config; +import java.util.Objects; + /** * POJO describing the PartyConfig as defined by the standard document */ @@ -39,4 +41,35 @@ public class PartyConfig { /** Max pause time. Optional */ public int maxPauseTime; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PartyConfig that = (PartyConfig) o; + return maxRounds == that.maxRounds && maxRoundTime == that.maxRoundTime && maxGameTime == that.maxGameTime && maxAnimationTime == that.maxAnimationTime && spaceStoneCD == that.spaceStoneCD && mindStoneCD == that.mindStoneCD && realityStoneCD == that.realityStoneCD && powerStoneCD == that.powerStoneCD && timeStoneCD == that.timeStoneCD && soulStoneCD == that.soulStoneCD && mindStoneDMG == that.mindStoneDMG && maxPauseTime == that.maxPauseTime; + } + + @Override + public int hashCode() { + return Objects.hash(maxRounds, maxRoundTime, maxGameTime, maxAnimationTime, spaceStoneCD, mindStoneCD, realityStoneCD, powerStoneCD, timeStoneCD, soulStoneCD, mindStoneDMG, maxPauseTime); + } + + @Override + public String toString() { + return "PartyConfig{" + + "maxRounds=" + maxRounds + + ", maxRoundTime=" + maxRoundTime + + ", maxGameTime=" + maxGameTime + + ", maxAnimationTime=" + maxAnimationTime + + ", spaceStoneCD=" + spaceStoneCD + + ", mindStoneCD=" + mindStoneCD + + ", realityStoneCD=" + realityStoneCD + + ", powerStoneCD=" + powerStoneCD + + ", timeStoneCD=" + timeStoneCD + + ", soulStoneCD=" + soulStoneCD + + ", mindStoneDMG=" + mindStoneDMG + + ", maxPauseTime=" + maxPauseTime + + '}'; + } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/config/ScenarioConfig.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/config/ScenarioConfig.java index 3a995ed..e961eec 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/config/ScenarioConfig.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/config/ScenarioConfig.java @@ -1,5 +1,8 @@ package uulm.teamname.marvelous.gamelibrary.config; +import java.util.Arrays; +import java.util.Objects; + /** * POJO describing the ScenarioConfig as defined by the standard document */ @@ -12,4 +15,28 @@ public class ScenarioConfig { /** A string containing the name of the scenario configuration (so basically the map title) */ public String name; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ScenarioConfig that = (ScenarioConfig) o; + return Arrays.deepEquals(scenario, that.scenario) && Objects.equals(author, that.author) && Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + int result = Objects.hash(author, name); + result = 31 * result + Arrays.hashCode(scenario); + return result; + } + + @Override + public String toString() { + return "ScenarioConfig{" + + "scenario=" + Arrays.deepToString(scenario) + + ", author='" + author + '\'' + + ", name='" + name + '\'' + + '}'; + } }