diff --git a/core/src/me/msoucy/ptures/model/Creature.kt b/core/src/me/msoucy/ptures/model/Creature.kt index f1ce883..08226fc 100644 --- a/core/src/me/msoucy/ptures/model/Creature.kt +++ b/core/src/me/msoucy/ptures/model/Creature.kt @@ -6,6 +6,7 @@ import com.badlogic.gdx.math.MathUtils.random class Stats(var atk : Int, var def : Int, var spd : Int, var hp : Int) class Creature { + var name = "" val genes = Stats(5,5,5,5) val growth = Stats(0,0,0,0) val attributes = mutableMapOf() @@ -25,7 +26,7 @@ class Creature { val atkAttribute = attacker.attributes.getOrElse(dmg.attribute) {1.0f} val defAttribute = attributes.getOrElse(dmg.attribute) {1.0f} val effectiveness = atkAttribute / defAttribute - val modifier = critical * randVal * effectiveness + val modifier = critical * randVal * effectiveness * attacker.atkMod() * defMod() val power = (((0.4 * attacker.level) + 2) * dmg.power * (attacker.atk / def)) / 50 + 2 val total = (power * modifier).toInt() currentHp = clamp(currentHp - total, 0, maxHp) @@ -60,6 +61,9 @@ class Creature { inline fun hasStatus() = statuses.filterIsInstance().isNotEmpty() + private fun atkMod() = statuses.fold(1.0) { value, status -> value * status.attackMod(this) } + private fun defMod() = statuses.map{ it.defenseMod(this) }.fold(1.0) { a, b -> a * b } + 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 } \ No newline at end of file diff --git a/core/src/me/msoucy/ptures/model/Skills.kt b/core/src/me/msoucy/ptures/model/Skills.kt index dfda39f..b849f8f 100644 --- a/core/src/me/msoucy/ptures/model/Skills.kt +++ b/core/src/me/msoucy/ptures/model/Skills.kt @@ -65,35 +65,38 @@ fun skill(name : String, attribute : Attribute = Attribute.Neutral, block : Skil return ret } -val Ignore = skill("Ignore") { -} +object Skills { -val Tackle = skill("Tackle") { - damage(20) -} + val Ignore = skill("Ignore") { + } -val DoubleKick = skill("Double Kick") { - repeat(2) { - damage(35) { - accuracy = 85 + val Tackle = skill("Tackle") { + damage(20) + } + + val DoubleKick = skill("Double Kick") { + repeat(2) { + damage(35) { + accuracy = 85 + } } } -} -val DoubleEdge = skill("Double Edge") { - damage(80) - damage(15) { - target = Target.Self + val DoubleEdge = skill("Double Edge") { + damage(80) + damage(15) { + target = Target.Self + } } -} -val Fly = skill("Fly") { - addStatus(Flying(), Target.Self) -} + val Fly = skill("Fly") { + addStatus(Flying(), Target.Self) + } -val Ember = skill("Ember", Attribute.Fire) { - damage(40) { - status = {Burned} - statusChance = 10 + val Ember = skill("Ember", Attribute.Fire) { + damage(40) { + status = { Burned } + statusChance = 10 + } } } \ No newline at end of file diff --git a/core/src/me/msoucy/ptures/model/Status.kt b/core/src/me/msoucy/ptures/model/Status.kt index 68cc61c..82d34c2 100644 --- a/core/src/me/msoucy/ptures/model/Status.kt +++ b/core/src/me/msoucy/ptures/model/Status.kt @@ -13,6 +13,9 @@ sealed class Status { open fun onTurnEnd(engine : Engine) { // Do nothing } + + open fun attackMod(creature : Creature) = 1.0 + open fun defenseMod(creature : Creature) = 1.0 } sealed class VisibleStatus(val label : String = "") : Status() diff --git a/core/src/me/msoucy/ptures/view/TextView.kt b/core/src/me/msoucy/ptures/view/TextView.kt new file mode 100644 index 0000000..a67677b --- /dev/null +++ b/core/src/me/msoucy/ptures/view/TextView.kt @@ -0,0 +1,56 @@ +package me.msoucy.ptures.view + +import me.msoucy.ptures.model.Creature +import me.msoucy.ptures.model.Skill +import me.msoucy.ptures.model.Skills +import me.msoucy.ptures.model.VisibleStatus + +class SkillViewText(val skill : Skill) : SkillView() { + override fun display() { + println(skill.name) + } + + override fun displayEnumerated(idx: Int) { + println("${idx}: ${skill.name}") + } +} + +class CreatureViewText(val creature : Creature) : CreatureView() { + + private val skillViews = creature.skills.map { SkillViewText(it) } + + override val skillChoice : Skill get() { + println("Skills:") + println("=======") + skillViews.forEachIndexed { index, skillView -> + skillView.displayEnumerated(index) + } + var idx = -1 + while(idx != -1) { + print("> ") + val tmpIdx = readLine()?.toIntOrNull() ?: -1 + if (tmpIdx in creature.skills.indices) + { + idx = tmpIdx + } + } + + return creature.skills[idx] + } + + override fun displayName() { + println(creature.name) + } + + override fun displaySkills() { + skillViews.forEach { skillView -> + skillView.display() + } + } + + override fun displayStatuses() { + creature.statuses.filterIsInstance().forEach { + println(it.label) + } + } +} \ No newline at end of file diff --git a/core/src/me/msoucy/ptures/view/ViewBase.kt b/core/src/me/msoucy/ptures/view/ViewBase.kt new file mode 100644 index 0000000..d4bb977 --- /dev/null +++ b/core/src/me/msoucy/ptures/view/ViewBase.kt @@ -0,0 +1,17 @@ +package me.msoucy.ptures.view + +import me.msoucy.ptures.model.Skill + +abstract class SkillView { + abstract fun display() + abstract fun displayEnumerated(idx : Int) +} + +abstract class CreatureView { + + abstract val skillChoice : Skill + + abstract fun displayName() + abstract fun displaySkills() + abstract fun displayStatuses() +} \ No newline at end of file