Added Faith to stats

This commit is contained in:
Yair Morgenstern 2020-07-07 23:26:24 +03:00
parent 210011fb15
commit cb9687a1c9
2 changed files with 24 additions and 16 deletions

View File

@ -6,5 +6,6 @@ enum class Stat{
Gold, Gold,
Science, Science,
Culture, Culture,
Happiness Happiness,
Faith
} }

View File

@ -10,6 +10,7 @@ open class Stats() {
var science: Float=0f var science: Float=0f
var culture: Float=0f var culture: Float=0f
var happiness: Float=0f var happiness: Float=0f
var faith: Float=0f
constructor(hashMap: HashMap<Stat, Float>) : this() { constructor(hashMap: HashMap<Stat, Float>) : this() {
setStats(hashMap) setStats(hashMap)
@ -22,6 +23,7 @@ open class Stats() {
science = 0f science = 0f
culture = 0f culture = 0f
happiness = 0f happiness = 0f
faith = 0f
} }
fun add(other: Stats) { fun add(other: Stats) {
@ -32,6 +34,7 @@ open class Stats() {
science += other.science science += other.science
culture += other.culture culture += other.culture
happiness += other.happiness happiness += other.happiness
faith += other.faith
} }
@ -71,29 +74,33 @@ open class Stats() {
Stat.Gold to gold, Stat.Gold to gold,
Stat.Food to food, Stat.Food to food,
Stat.Happiness to happiness, Stat.Happiness to happiness,
Stat.Science to science) Stat.Science to science,
Stat.Faith to faith
)
} }
fun get(stat:Stat):Float{ fun get(stat:Stat):Float{
return this.toHashMap()[stat]!! return this.toHashMap()[stat]!!
} }
private fun setStats(hashMap:HashMap<Stat, Float>){ private fun setStats(hashMap:HashMap<Stat, Float>) {
culture=hashMap[Stat.Culture]!! culture = hashMap[Stat.Culture]!!
gold=hashMap[Stat.Gold]!! gold = hashMap[Stat.Gold]!!
production=hashMap[Stat.Production]!! production = hashMap[Stat.Production]!!
food=hashMap[Stat.Food]!! food = hashMap[Stat.Food]!!
happiness=hashMap[Stat.Happiness]!! happiness = hashMap[Stat.Happiness]!!
science=hashMap[Stat.Science]!! science = hashMap[Stat.Science]!!
faith = hashMap[Stat.Faith]!!
} }
fun equals(otherStats: Stats):Boolean{ fun equals(otherStats: Stats):Boolean {
return culture==otherStats.culture return culture == otherStats.culture
&& gold==otherStats.gold && gold == otherStats.gold
&& production==otherStats.production && production == otherStats.production
&& food==otherStats.food && food == otherStats.food
&& happiness==otherStats.happiness && happiness == otherStats.happiness
&& science==otherStats.science && science == otherStats.science
&& faith == otherStats.faith
} }
} }