From cb9687a1c9c8b9e5eee854f6e4dd06c95c6cee83 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 7 Jul 2020 23:26:24 +0300 Subject: [PATCH] Added Faith to stats --- core/src/com/unciv/models/stats/Stat.kt | 3 +- core/src/com/unciv/models/stats/Stats.kt | 37 ++++++++++++++---------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/core/src/com/unciv/models/stats/Stat.kt b/core/src/com/unciv/models/stats/Stat.kt index bfafb7a8b4..0b4b95cb00 100644 --- a/core/src/com/unciv/models/stats/Stat.kt +++ b/core/src/com/unciv/models/stats/Stat.kt @@ -6,5 +6,6 @@ enum class Stat{ Gold, Science, Culture, - Happiness + Happiness, + Faith } \ No newline at end of file diff --git a/core/src/com/unciv/models/stats/Stats.kt b/core/src/com/unciv/models/stats/Stats.kt index 9a6cfa31ce..effabf115d 100644 --- a/core/src/com/unciv/models/stats/Stats.kt +++ b/core/src/com/unciv/models/stats/Stats.kt @@ -10,6 +10,7 @@ open class Stats() { var science: Float=0f var culture: Float=0f var happiness: Float=0f + var faith: Float=0f constructor(hashMap: HashMap) : this() { setStats(hashMap) @@ -22,6 +23,7 @@ open class Stats() { science = 0f culture = 0f happiness = 0f + faith = 0f } fun add(other: Stats) { @@ -32,6 +34,7 @@ open class Stats() { science += other.science culture += other.culture happiness += other.happiness + faith += other.faith } @@ -71,29 +74,33 @@ open class Stats() { Stat.Gold to gold, Stat.Food to food, Stat.Happiness to happiness, - Stat.Science to science) + Stat.Science to science, + Stat.Faith to faith + ) } fun get(stat:Stat):Float{ return this.toHashMap()[stat]!! } - private fun setStats(hashMap:HashMap){ - culture=hashMap[Stat.Culture]!! - gold=hashMap[Stat.Gold]!! - production=hashMap[Stat.Production]!! - food=hashMap[Stat.Food]!! - happiness=hashMap[Stat.Happiness]!! - science=hashMap[Stat.Science]!! + private fun setStats(hashMap:HashMap) { + culture = hashMap[Stat.Culture]!! + gold = hashMap[Stat.Gold]!! + production = hashMap[Stat.Production]!! + food = hashMap[Stat.Food]!! + happiness = hashMap[Stat.Happiness]!! + science = hashMap[Stat.Science]!! + faith = hashMap[Stat.Faith]!! } - fun equals(otherStats: Stats):Boolean{ - return culture==otherStats.culture - && gold==otherStats.gold - && production==otherStats.production - && food==otherStats.food - && happiness==otherStats.happiness - && science==otherStats.science + fun equals(otherStats: Stats):Boolean { + return culture == otherStats.culture + && gold == otherStats.gold + && production == otherStats.production + && food == otherStats.food + && happiness == otherStats.happiness + && science == otherStats.science + && faith == otherStats.faith } }