Fact.kt
Branches > main > e39f879 > files / src / main / kotlin / net / bowmap / stormbow / fact / Fact.kt
package net.bowmap.stormbow.fact
import kotlinx.collections.immutable.*
import net.bowmap.stormbow.effect.Effect
import net.bowmap.stormbow.registry
// Fact is a thing that happened (immutable)
// And they can be created by the user just fine which is good
interface Fact
// Can be empty, of course
fun handle(fact: Fact): PersistentList<Effect> {
var effects: PersistentList<Effect> = persistentListOf()
registry[fact::class]?.forEach { handler ->
effects = effects.addingAll(handler(fact))
}
return effects
}