From 49f469475d4e02e02e08a631b983c59097041f03 Mon Sep 17 00:00:00 2001 From: Matt Soucy Date: Sat, 7 Dec 2019 12:30:21 -0500 Subject: [PATCH] Start creating test battle --- core/src/me/msoucy/ptures/PTureTest.kt | 45 ++++++++++++++++++++++ core/src/me/msoucy/ptures/view/TextView.kt | 22 +++++++---- 2 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 core/src/me/msoucy/ptures/PTureTest.kt diff --git a/core/src/me/msoucy/ptures/PTureTest.kt b/core/src/me/msoucy/ptures/PTureTest.kt new file mode 100644 index 0000000..1e572c0 --- /dev/null +++ b/core/src/me/msoucy/ptures/PTureTest.kt @@ -0,0 +1,45 @@ +package me.msoucy.ptures + +import me.msoucy.ptures.controller.Engine +import me.msoucy.ptures.controller.SingleBattle +import me.msoucy.ptures.model.Creature +import me.msoucy.ptures.model.Skills +import me.msoucy.ptures.model.Team +import me.msoucy.ptures.view.BattleViewText +import me.msoucy.ptures.view.PlayerViewText + +val CreatureA = with(Creature()) { + name = "CreatureA" + genes.atk = 7 + genes.def = 3 + skills.add(Skills.Tackle) + skills.add(Skills.DoubleKick) + this +} + +val CreatureB = with(Creature()) { + name = "CreatureB" + skills.add(Skills.Tackle) + skills.add(Skills.Ember) + this +} + +val TeamA = with(Team(PlayerViewText(1))) { + creatures.add(CreatureA) + this +} +val TeamB = with(Team(PlayerViewText(2))) { + creatures.add(CreatureB) + this +} + +val TestBattle = SingleBattle(TeamA, TeamB) + +object PTureTest { + @JvmStatic + fun main(arg: Array) { + println("Hello, world!") + val e = Engine(TestBattle) + e.resolveTurn(BattleViewText()) + } +} \ No newline at end of file diff --git a/core/src/me/msoucy/ptures/view/TextView.kt b/core/src/me/msoucy/ptures/view/TextView.kt index 09b3376..16a9c9f 100644 --- a/core/src/me/msoucy/ptures/view/TextView.kt +++ b/core/src/me/msoucy/ptures/view/TextView.kt @@ -10,8 +10,8 @@ class SkillViewText(skill: Skill) : SkillView(skill) { println(skill.name) } - override fun displayEnumerated(idx: Int) { - println("${idx + 1}: ${skill.name}") + override fun displayEnumerated(idx : Int) { + println("-: ${skill.name}") } } @@ -25,15 +25,17 @@ class CreatureViewText(playerId: Int, creature: Creature) : CreatureView(playerI skillViews.forEachIndexed { index, skillView -> skillView.displayEnumerated(index) } - var idx = -1 - while (idx != -1) { + var chosenSkill : Skill? = null + while (chosenSkill == null) { print("> ") - val tmpIdx = readLine()?.toIntOrNull() ?: -1 - if (tmpIdx in creature.skills.indices) { - idx = tmpIdx + val tmpName = readLine() ?: "" + val possibleSkills = creature.skills.filter { it.name == tmpName } + if(possibleSkills.isNotEmpty()) + { + chosenSkill = possibleSkills.first() } } - return creature.skills[idx] + return chosenSkill } private fun chooseTarget(skill: Skill, possibleTargets: List): List { @@ -68,4 +70,8 @@ class CreatureViewText(playerId: Int, creature: Creature) : CreatureView(playerI class PlayerViewText(playerId: Int) : PlayerView(playerId) { override fun creatureViewFor(creature: Creature) = CreatureViewText(playerId, creature) +} + +class BattleViewText : BattleView() { + } \ No newline at end of file