إنتقل إلى المحتوى الرئيسي

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

FieldTypeDefault
idstring-
namestring-
descriptionstring-
statusstring"active"
createdAtstring-
turnnumber0
scorenumber0

States

StateType
menuInitial
playing-
paused-
gameover-

Events

EventPayload
INIT-
START-
END_TURN-
PAUSE-
RESUME-
GAME_OVER-
RESTART-
CLOSE-
NAVIGATE-

Transitions

FromEventToEffects
menuINITmenu2 effects
menuSTARTplaying1 effect
playingEND_TURNplaying2 effects
menuNAVIGATEmenu-
pausedNAVIGATEpaused-
playingPAUSEpaused1 effect
pausedRESUMEplaying2 effects
pausedCLOSEplaying2 effects
playingGAME_OVERgameover1 effect
gameoverRESTARTmenu1 effect
pausedRESTARTmenu2 effects