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

View File

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

View File

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

View File

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