Start integrating forced skills

This commit is contained in:
Matt Soucy 2019-12-03 10:17:18 -05:00
parent fd3a4670ea
commit 83edd7190d
4 changed files with 28 additions and 13 deletions

View File

@ -1,5 +1,7 @@
package me.msoucy.ptures.model
import me.msoucy.ptures.view.BattleView
class Engine(private vararg val creatures : Pair<Creature, Int>) {
init {
assert(creatures.isNotEmpty())
@ -11,21 +13,31 @@ class Engine(private vararg val creatures : Pair<Creature, Int>) {
return creatures[currentCreature].first
}
val forcedSkills = mutableMapOf<Creature, Skill>()
val activeCreatures get() = creatures.withIndex()
.filter { (_, c) -> !c.first.hasStatus<KnockedOut>() }
.sortedBy { (_, c) -> c.first.spd }
.map { (i, _) -> i}
fun resolveTurn() {
fun resolveTurn(view : BattleView) {
forcedSkills.clear()
// All preconditions
for (i in activeCreatures) {
val creature = creatures[i]
for (status in creature.first.statuses) {
status.onTurnStart(this)
status.onTurnStart(this, creature.first)
}
}
// Get the moves each creature will use this turn
val moves = activeCreatures.map { i -> Pair(Ignore, nextOpponent(i)) }
val moves = activeCreatures.map { i ->
if (creatures[i].first in forcedSkills) {
Pair(forcedSkills[creatures[i].first], nextOpponent(i))
} else {
TODO("Fill in view here")
}
}
// Resolve each move
for (i in activeCreatures) {
// Resolve move
val (skill, target) = moves[i]

View File

@ -2,7 +2,7 @@ package me.msoucy.ptures.model
sealed class Status {
open fun onTurnStart(engine : Engine) {
open fun onTurnStart(engine : Engine, creature : Creature) {
// Do nothing
}

View File

@ -2,7 +2,6 @@ package me.msoucy.ptures.view
import me.msoucy.ptures.model.Creature
import me.msoucy.ptures.model.Skill
import me.msoucy.ptures.model.Skills
import me.msoucy.ptures.model.VisibleStatus
class SkillViewText(val skill : Skill) : SkillView() {

View File

@ -2,16 +2,20 @@ package me.msoucy.ptures.view
import me.msoucy.ptures.model.Skill
abstract class SkillView {
abstract fun display()
abstract fun displayEnumerated(idx : Int)
interface SkillView {
fun display()
fun displayEnumerated(idx : Int)
}
abstract class CreatureView {
interface CreatureView {
abstract val skillChoice : Skill
val skillChoice : Skill
abstract fun displayName()
abstract fun displaySkills()
abstract fun displayStatuses()
fun displayName()
fun displaySkills()
fun displayStatuses()
}
interface BattleView {
//
}