Battle Prototype

This commit is contained in:
Matt Soucy 2019-12-07 12:40:46 -05:00
parent 49f469475d
commit 5f7199e229
4 changed files with 26 additions and 4 deletions

View File

@ -14,6 +14,7 @@ val CreatureA = with(Creature()) {
genes.def = 3 genes.def = 3
skills.add(Skills.Tackle) skills.add(Skills.Tackle)
skills.add(Skills.DoubleKick) skills.add(Skills.DoubleKick)
fullHeal()
this this
} }
@ -21,6 +22,7 @@ val CreatureB = with(Creature()) {
name = "CreatureB" name = "CreatureB"
skills.add(Skills.Tackle) skills.add(Skills.Tackle)
skills.add(Skills.Ember) skills.add(Skills.Ember)
fullHeal()
this this
} }
@ -40,6 +42,8 @@ object PTureTest {
fun main(arg: Array<String>) { fun main(arg: Array<String>) {
println("Hello, world!") println("Hello, world!")
val e = Engine(TestBattle) val e = Engine(TestBattle)
e.resolveTurn(BattleViewText()) val v = BattleViewText()
e.resolveTurn(v)
e.report(v)
} }
} }

View File

@ -50,8 +50,16 @@ class Engine(private val battle: BattleType) {
.filter { !it.creature.hasStatus<KnockedOut>() } .filter { !it.creature.hasStatus<KnockedOut>() }
.sortedBy { it.creature.spd } .sortedBy { it.creature.spd }
fun report(view : BattleView) {
creatures.forEach {
it.displayHeader()
}
}
fun resolveTurn(view: BattleView) { fun resolveTurn(view: BattleView) {
report(view)
// All preconditions // All preconditions
for (creature in activeCreatures) { for (creature in activeCreatures) {
for (status in creature.creature.statuses) { for (status in creature.creature.statuses) {

View File

@ -11,7 +11,7 @@ class SkillViewText(skill: Skill) : SkillView(skill) {
} }
override fun displayEnumerated(idx : Int) { 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() { override fun displayName() {
println(creature.name) println(creature.name)
} }
@ -62,8 +66,13 @@ class CreatureViewText(playerId: Int, creature: Creature) : CreatureView(playerI
} }
override fun displayStatuses() { override fun displayStatuses() {
creature.statuses.filterIsInstance<VisibleStatus>().forEach { val displayables = creature.statuses.filterIsInstance<VisibleStatus>()
println(it.label) if(displayables.isNotEmpty()) {
println("Statuses")
println("--------")
displayables.forEach {
println(it.label)
}
} }
} }
} }

View File

@ -13,6 +13,7 @@ abstract class CreatureView(val playerId : Int, val creature: Creature) {
abstract fun chooseSkill(possibleTargets : List<Creature>) abstract fun chooseSkill(possibleTargets : List<Creature>)
abstract fun displayHeader()
abstract fun displayName() abstract fun displayName()
abstract fun displaySkills() abstract fun displaySkills()
abstract fun displayStatuses() abstract fun displayStatuses()