Start creating test battle
This commit is contained in:
parent
2683ce69a9
commit
49f469475d
45
core/src/me/msoucy/ptures/PTureTest.kt
Normal file
45
core/src/me/msoucy/ptures/PTureTest.kt
Normal file
@ -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<String>) {
|
||||
println("Hello, world!")
|
||||
val e = Engine(TestBattle)
|
||||
e.resolveTurn(BattleViewText())
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ class SkillViewText(skill: Skill) : SkillView(skill) {
|
||||
}
|
||||
|
||||
override fun displayEnumerated(idx : Int) {
|
||||
println("${idx + 1}: ${skill.name}")
|
||||
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<Creature>): List<Creature> {
|
||||
@ -69,3 +71,7 @@ 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() {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user