std-turn-based-battle
Level: Molecule | Entity: BattleUnit | Persistence: runtime
4 states, 9 events, 11 transitions
Live Preview
orbital BattleUnitOrbital {
entity BattleUnit [runtime] {
id : string
name : string
description : string
status : string
createdAt : string
turn : number
score : number
}
trait BattleUnitBattleFlow -> BattleUnit [interaction] {
initial: menu
state menu {
INIT -> menu
(fetch BattleUnit)
(render-ui main { type: "game-menu", title: "Battle Arena", subtitle: "Turn-Based Strategy", menuItems: [{ label: "Start Battle", event: "START", variant: "primary" }] })
START -> playing
(render-ui main { type: "game-hud", stats: [{ label: "Turn", value: "@entity.turn" }, { label: "Score", value: "@entity.score" }] })
NAVIGATE -> menu
}
state playing {
END_TURN -> playing
(set @entity.turn (+ @entity.turn 1))
(render-ui main { type: "game-hud", stats: [{ label: "Turn", value: "@entity.turn" }, { label: "Score", value: "@entity.score" }] })
PAUSE -> paused
(render-ui modal { type: "game-menu", title: "Paused", menuItems: [{ label: "Resume", event: "RESUME", variant: "primary" }, { label: "Quit", event: "RESTART", variant: "ghost" }] })
GAME_OVER -> gameover
(render-ui main { type: "game-over-screen", title: "Battle Over", stats: [{ label: "Turns", value: "@entity.turn" }, { label: "Score", value: "@entity.score" }], menuItems: [{ label: "Play Again", event: "RESTART", variant: "primary" }, { label: "Main Menu", event: "RESTART", variant: "secondary" }] })
}
state paused {
NAVIGATE -> paused
RESUME -> playing
(render-ui modal null)
(render-ui main { type: "game-hud", stats: [{ label: "Turn", value: "@entity.turn" }, { label: "Score", value: "@entity.score" }] })
CLOSE -> playing
(render-ui modal null)
(render-ui main { type: "game-hud", stats: [{ label: "Turn", value: "@entity.turn" }, { label: "Score", value: "@entity.score" }] })
RESTART -> menu
(render-ui modal null)
(render-ui main { type: "game-menu", title: "Battle Arena", subtitle: "Turn-Based Strategy", menuItems: [{ label: "Start Battle", event: "START", variant: "primary" }] })
}
state gameover {
RESTART -> menu
(render-ui main { type: "game-menu", title: "Battle Arena", subtitle: "Turn-Based Strategy", menuItems: [{ label: "Start Battle", event: "START", variant: "primary" }] })
}
}
trait BattleUnitCombatLog -> BattleUnit [interaction] {
state idle {
INIT -> idle
(fetch BattleUnit)
LOG_EVENT -> idle
(render-ui main { type: "combat-log", events: "@BattleUnit", maxVisible: 10, autoScroll: true, showTimestamps: true, title: "Combat Log" })
CLEAR -> idle
(render-ui main { type: "combat-log", events: "@BattleUnit", maxVisible: 10, autoScroll: true, showTimestamps: true, title: "Combat Log" })
}
}
page "/battleunits" -> BattleUnitBattleFlow, BattleUnitCombatLog
}
Loading preview...
Orbital Visualization
Loading visualization...
Entity Fields
| Field | Type | Default |
|---|---|---|
| id | string | - |
| name | string | - |
| description | string | - |
| status | string | "active" |
| createdAt | string | - |
| turn | number | 0 |
| score | number | 0 |
States
| State | Type |
|---|---|
| menu | Initial |
| playing | - |
| paused | - |
| gameover | - |
Events
| Event | Payload |
|---|---|
| INIT | - |
| START | - |
| END_TURN | - |
| PAUSE | - |
| RESUME | - |
| GAME_OVER | - |
| RESTART | - |
| CLOSE | - |
| NAVIGATE | - |
Transitions
| From | Event | To | Effects |
|---|---|---|---|
| menu | INIT | menu | 2 effects |
| menu | START | playing | 1 effect |
| playing | END_TURN | playing | 2 effects |
| menu | NAVIGATE | menu | - |
| paused | NAVIGATE | paused | - |
| playing | PAUSE | paused | 1 effect |
| paused | RESUME | playing | 2 effects |
| paused | CLOSE | playing | 2 effects |
| playing | GAME_OVER | gameover | 1 effect |
| gameover | RESTART | menu | 1 effect |
| paused | RESTART | menu | 2 effects |