forked from yairm210/Unciv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First Kotlin change - FullStats and CivStats
- Loading branch information
Showing
12 changed files
with
84 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.unciv.models.stats | ||
|
||
open class CivStats { | ||
@JvmField var gold = 0f | ||
@JvmField var science = 0f | ||
@JvmField var culture = 0f | ||
@JvmField var happiness = 0f | ||
|
||
fun add(other: CivStats) { | ||
gold += other.gold | ||
science += other.science | ||
happiness += other.happiness | ||
culture += other.culture | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.unciv.models.stats | ||
|
||
import java.util.HashMap | ||
|
||
|
||
open class FullStats : CivStats() | ||
{ | ||
@JvmField var production: Float = 0f | ||
@JvmField var food: Float = 0f | ||
|
||
fun add(other: FullStats) { | ||
production += other.production | ||
food += other.food | ||
super.add(other) | ||
} | ||
|
||
fun clone():FullStats { | ||
val FS = FullStats() | ||
FS.add(this) | ||
return FS | ||
} | ||
|
||
fun getMinus(): FullStats { | ||
val stats = FullStats() | ||
stats.food = -food | ||
stats.food = -food | ||
stats.gold = -gold | ||
stats.science = -science | ||
stats.culture = -culture | ||
stats.happiness = -happiness | ||
return stats; | ||
} | ||
|
||
operator fun times(number: Float): FullStats{ | ||
val FS = FullStats() | ||
FS.production = production * number | ||
FS.food = food*number | ||
FS.gold = gold*number | ||
FS.science = science*number | ||
FS.culture = culture*number | ||
FS.happiness = happiness*number | ||
return FS | ||
} | ||
|
||
override fun toString(): String { | ||
return toDict().filter{it.value!=0}.map{it.key+": "+it.value}.joinToString(",") | ||
} | ||
|
||
fun toDict(): HashMap<String, Int> { | ||
return hashMapOf("Production" to production.toInt(), | ||
"Food" to food.toInt(), | ||
"Gold" to gold.toInt(), | ||
"Science" to science.toInt(), | ||
"Culture" to culture.toInt() | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters