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) {
|
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 ->
|
skillViews.forEachIndexed { index, skillView ->
|
||||||
skillView.displayEnumerated(index)
|
skillView.displayEnumerated(index)
|
||||||
}
|
}
|
||||||
var idx = -1
|
var chosenSkill : Skill? = null
|
||||||
while (idx != -1) {
|
while (chosenSkill == null) {
|
||||||
print("> ")
|
print("> ")
|
||||||
val tmpIdx = readLine()?.toIntOrNull() ?: -1
|
val tmpName = readLine() ?: ""
|
||||||
if (tmpIdx in creature.skills.indices) {
|
val possibleSkills = creature.skills.filter { it.name == tmpName }
|
||||||
idx = tmpIdx
|
if(possibleSkills.isNotEmpty())
|
||||||
|
{
|
||||||
|
chosenSkill = possibleSkills.first()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return creature.skills[idx]
|
return chosenSkill
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseTarget(skill: Skill, possibleTargets: List<Creature>): List<Creature> {
|
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) {
|
class PlayerViewText(playerId: Int) : PlayerView(playerId) {
|
||||||
override fun creatureViewFor(creature: Creature) = CreatureViewText(playerId, creature)
|
override fun creatureViewFor(creature: Creature) = CreatureViewText(playerId, creature)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BattleViewText : BattleView() {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user