From 5f7199e2296da5f9e74fcbab4098ec65ea84e5dc Mon Sep 17 00:00:00 2001 From: Matt Soucy Date: Sat, 7 Dec 2019 12:40:46 -0500 Subject: [PATCH] Battle Prototype --- core/src/me/msoucy/ptures/PTureTest.kt | 6 +++++- core/src/me/msoucy/ptures/controller/Engine.kt | 8 ++++++++ core/src/me/msoucy/ptures/view/TextView.kt | 15 ++++++++++++--- core/src/me/msoucy/ptures/view/ViewBase.kt | 1 + 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/src/me/msoucy/ptures/PTureTest.kt b/core/src/me/msoucy/ptures/PTureTest.kt index 1e572c0..4fde9c7 100644 --- a/core/src/me/msoucy/ptures/PTureTest.kt +++ b/core/src/me/msoucy/ptures/PTureTest.kt @@ -14,6 +14,7 @@ val CreatureA = with(Creature()) { genes.def = 3 skills.add(Skills.Tackle) skills.add(Skills.DoubleKick) + fullHeal() this } @@ -21,6 +22,7 @@ val CreatureB = with(Creature()) { name = "CreatureB" skills.add(Skills.Tackle) skills.add(Skills.Ember) + fullHeal() this } @@ -40,6 +42,8 @@ object PTureTest { fun main(arg: Array) { println("Hello, world!") val e = Engine(TestBattle) - e.resolveTurn(BattleViewText()) + val v = BattleViewText() + e.resolveTurn(v) + e.report(v) } } \ No newline at end of file diff --git a/core/src/me/msoucy/ptures/controller/Engine.kt b/core/src/me/msoucy/ptures/controller/Engine.kt index 7c24424..2d1f5d0 100644 --- a/core/src/me/msoucy/ptures/controller/Engine.kt +++ b/core/src/me/msoucy/ptures/controller/Engine.kt @@ -50,8 +50,16 @@ class Engine(private val battle: BattleType) { .filter { !it.creature.hasStatus() } .sortedBy { it.creature.spd } + fun report(view : BattleView) { + creatures.forEach { + it.displayHeader() + } + } + fun resolveTurn(view: BattleView) { + report(view) + // All preconditions for (creature in activeCreatures) { for (status in creature.creature.statuses) { diff --git a/core/src/me/msoucy/ptures/view/TextView.kt b/core/src/me/msoucy/ptures/view/TextView.kt index 16a9c9f..7e4ca9b 100644 --- a/core/src/me/msoucy/ptures/view/TextView.kt +++ b/core/src/me/msoucy/ptures/view/TextView.kt @@ -11,7 +11,7 @@ class SkillViewText(skill: Skill) : SkillView(skill) { } override fun displayEnumerated(idx : Int) { - println("-: ${skill.name}") + println("- ${skill.name}") } } @@ -51,6 +51,10 @@ class CreatureViewText(playerId: Int, creature: Creature) : CreatureView(playerI } } + override fun displayHeader() { + println("${creature.name}: ${creature.currentHp}/${creature.maxHp}") + } + override fun displayName() { println(creature.name) } @@ -62,8 +66,13 @@ class CreatureViewText(playerId: Int, creature: Creature) : CreatureView(playerI } override fun displayStatuses() { - creature.statuses.filterIsInstance().forEach { - println(it.label) + val displayables = creature.statuses.filterIsInstance() + if(displayables.isNotEmpty()) { + println("Statuses") + println("--------") + displayables.forEach { + println(it.label) + } } } } diff --git a/core/src/me/msoucy/ptures/view/ViewBase.kt b/core/src/me/msoucy/ptures/view/ViewBase.kt index 98d246f..aebad59 100644 --- a/core/src/me/msoucy/ptures/view/ViewBase.kt +++ b/core/src/me/msoucy/ptures/view/ViewBase.kt @@ -13,6 +13,7 @@ abstract class CreatureView(val playerId : Int, val creature: Creature) { abstract fun chooseSkill(possibleTargets : List) + abstract fun displayHeader() abstract fun displayName() abstract fun displaySkills() abstract fun displayStatuses()