Fix statistics

This commit is contained in:
Matt Soucy 2019-12-01 20:16:51 -05:00
parent e9f4b367a6
commit 815ab5b372
2 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,5 @@
buildscript { buildscript {
ext.kotlinVersion = '1.3.60' ext.kotlinVersion = '1.3.61'
repositories { repositories {
mavenLocal() mavenLocal()

View File

@ -15,9 +15,9 @@ class Creature {
val statuses = mutableListOf<Status>() val statuses = mutableListOf<Status>()
val atk : Int get() = statFormula(genes.atk, growth.atk) val atk : Int get() = statFormula(genes.atk, growth.atk)
val def : Int get() = statFormula(genes.atk, growth.atk) val def : Int get() = statFormula(genes.def, growth.def)
val spd : Int get() = statFormula(genes.atk, growth.atk) val spd : Int get() = statFormula(genes.spd, growth.spd)
val maxHp : Int get() = statFormula(genes.atk, growth.atk) val maxHp : Int get() = hpStatFormula(genes.hp, growth.hp)
fun apply(dmg : Damage, attacker : Creature) { fun apply(dmg : Damage, attacker : Creature) {
val critical = if (random(32) < attacker.genes.spd) { 1.5 } else { 1.0 } val critical = if (random(32) < attacker.genes.spd) { 1.5 } else { 1.0 }
@ -61,4 +61,5 @@ class Creature {
inline fun <reified S : Status> hasStatus() = statuses.filterIsInstance<S>().isNotEmpty() inline fun <reified S : Status> hasStatus() = statuses.filterIsInstance<S>().isNotEmpty()
private fun statFormula(gene : Int, growth : Int) = (2 * gene + growth / 4) * level / 100 + 5 private fun statFormula(gene : Int, growth : Int) = (2 * gene + growth / 4) * level / 100 + 5
private fun hpStatFormula(gene : Int, growth : Int) = (2 * gene + growth / 4) * level / 100 + level + 10
} }