Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/RollbackImplementationPlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ Rollback restores:

Rollback does not restore:

- global-device variables
- global-account variables
- device variables
- account variables
- seen registries

Implementation rule:
Expand Down
6 changes: 3 additions & 3 deletions docs/SaveLoad.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Rollback data lives inside context state and is therefore part of saved story st

Persistent global variables are variables with scope:

- `global-device`
- `global-account`
- `device`
- `account`

These are not story-local and should not be stored inside save slot state.

Expand Down Expand Up @@ -161,7 +161,7 @@ This is a product decision, not an implementation detail.

### Persistent globals stay outside save slots

`global-device` and `global-account` variables are intentionally not saved into slots.
`device` and `account` variables are intentionally not saved into slots.

Load should not roll them back or replace them from slot data.

Expand Down
6 changes: 3 additions & 3 deletions docs/StorySessionReset.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ where the engine should:
- clear rollback/session-local history
- clear seen/viewed state
- clear transient runtime UI/playback state
- preserve `global-device` and `global-account` variables
- preserve `device` and `account` variables

without introducing dedicated `startGame` / `exitGame` engine actions.

Expand Down Expand Up @@ -58,7 +58,7 @@ When `resetStorySession` runs, the engine should:
### Preserve

- current context read pointer
- `global.variables` for `global-device` and `global-account`
- `global.variables` for `device` and `account`
- `projectData`
- `global.saveSlots`

Expand Down Expand Up @@ -233,7 +233,7 @@ actions:
- resets rollback to a single checkpoint anchored at the current read pointer
- clears `viewedRegistry.sections`
- clears `viewedRegistry.resources`
- preserves `global-device` and `global-account` variables
- preserves `device` and `account` variables
- clears transient globals and queues timer-clear effects
- appends effects instead of replacing the pending queue
- when ordered after `sectionTransition` in the same batch, anchors rollback at
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "route-engine-js",
"version": "0.7.6",
"version": "0.8.0",
"description": "A lightweight Visual Novel engine built in JavaScript for creating interactive narrative games with branching storylines",
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions spec/system/actions/resetStorySession.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ in:
default: false
volume:
type: number
scope: global-device
scope: device
default: 80
unlockedEnding:
type: boolean
scope: global-account
scope: account
default: false
story:
initialSceneId: scene1
Expand Down Expand Up @@ -132,11 +132,11 @@ out:
default: false
volume:
type: number
scope: global-device
scope: device
default: 80
unlockedEnding:
type: boolean
scope: global-account
scope: account
default: false
story:
initialSceneId: scene1
Expand Down
4 changes: 2 additions & 2 deletions spec/system/actions/rollbackToLine.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ in:
variables:
volume:
type: number
scope: global-device
scope: device
default: 50
global:
variables:
Expand Down Expand Up @@ -720,7 +720,7 @@ out:
variables:
volume:
type: number
scope: global-device
scope: device
default: 50
global:
variables:
Expand Down
34 changes: 17 additions & 17 deletions spec/system/actions/updateVariable.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ out:
- variables:
playerName: "Alice"
---
case: set global-device variable
case: set device variable
in:
- state:
projectData:
resources:
variables:
volume:
type: number
scope: global-device
scope: device
default: 50
global:
variables:
Expand All @@ -69,7 +69,7 @@ out:
variables:
volume:
type: number
scope: global-device
scope: device
default: 50
global:
variables:
Expand All @@ -83,15 +83,15 @@ out:
contexts:
- variables: {}
---
case: set global-account variable
case: set account variable
in:
- state:
projectData:
resources:
variables:
achievement1:
type: boolean
scope: global-account
scope: account
default: false
global:
variables:
Expand All @@ -110,7 +110,7 @@ out:
variables:
achievement1:
type: boolean
scope: global-account
scope: account
default: false
global:
variables:
Expand Down Expand Up @@ -196,15 +196,15 @@ out:
- variables:
soundEnabled: false
---
case: toggle global-device boolean
case: toggle device boolean
in:
- state:
projectData:
resources:
variables:
notificationsOn:
type: boolean
scope: global-device
scope: device
default: false
global:
variables:
Expand All @@ -222,7 +222,7 @@ out:
variables:
notificationsOn:
type: boolean
scope: global-device
scope: device
default: false
global:
variables:
Expand All @@ -248,11 +248,11 @@ in:
default: 0
volume:
type: number
scope: global-device
scope: device
default: 50
achievement1:
type: boolean
scope: global-account
scope: account
default: false
global:
variables:
Expand Down Expand Up @@ -282,11 +282,11 @@ out:
default: 0
volume:
type: number
scope: global-device
scope: device
default: 50
achievement1:
type: boolean
scope: global-account
scope: account
default: false
global:
variables:
Expand Down Expand Up @@ -564,7 +564,7 @@ in:
- variableId: badVar
op: set
value: 10
throws: "Invalid variable scope: invalid for variable badVar. Expected one of: context, global-device, global-account"
throws: "Invalid variable scope: invalid for variable badVar. Expected one of: context, device, account"
---
case: error - unknown variable type
in:
Expand Down Expand Up @@ -723,15 +723,15 @@ out:
- id: sword
name: Steel Sword
---
case: set global-device object variable
case: set device object variable
in:
- state:
projectData:
resources:
variables:
pageButtons:
type: object
scope: global-device
scope: device
default:
items: []
global:
Expand All @@ -757,7 +757,7 @@ out:
variables:
pageButtons:
type: object
scope: global-device
scope: device
default:
items: []
global:
Expand Down
16 changes: 8 additions & 8 deletions spec/system/createInitialState.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ in:
name: Steel Sword
pageButtons:
type: object
scope: global-device
scope: device
default:
items:
- label: A
Expand Down Expand Up @@ -142,7 +142,7 @@ out:
name: Steel Sword
pageButtons:
type: object
scope: global-device
scope: device
default:
items:
- label: A
Expand Down Expand Up @@ -277,15 +277,15 @@ in:
variables:
volume:
type: number
scope: global-device
scope: device
default: 50
achievement1:
type: boolean
scope: global-account
scope: account
default: false
newVariable:
type: string
scope: global-device
scope: device
default: "default"
story:
initialSceneId: "scene1"
Expand Down Expand Up @@ -326,15 +326,15 @@ out:
variables:
volume:
type: number
scope: global-device
scope: device
default: 50
achievement1:
type: boolean
scope: global-account
scope: account
default: false
newVariable:
type: string
scope: global-device
scope: device
default: "default"
story:
initialSceneId: "scene1"
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/projectData/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ properties:
enum: [string, boolean, number, object]
scope:
type: string
enum: [context, global-device, global-account]
enum: [context, device, account]
default:
description: Default initial value for the variable. Runtime accepts any YAML value and uses it as-is
additionalProperties: true
Expand Down
4 changes: 2 additions & 2 deletions src/schemas/systemState/effects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ anyOf:
required: [name, payload]
additionalProperties: false

- title: Save global-device variables effect
- title: Save device variables effect
type: object
properties:
name:
Expand All @@ -51,7 +51,7 @@ anyOf:
required: [name, payload]
additionalProperties: false

- title: Save global-account variables effect
- title: Save account variables effect
type: object
properties:
name:
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/systemState/systemState.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ properties:
$ref: "./effects.yaml"
variables:
type: object
description: Global-device and global-account variables
description: Device- and account-scoped variables
additionalProperties: true
saveSlots:
type: object
Expand Down
12 changes: 6 additions & 6 deletions src/stores/system.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2688,9 +2688,9 @@ export const updateVariable = ({ state }, payload) => {
if (scope === "context") {
contextVariableModified = true;
contextOperations.push({ variableId, op, value });
} else if (scope === "global-device") {
} else if (scope === "device") {
globalDeviceModified = true;
} else if (scope === "global-account") {
} else if (scope === "account") {
globalAccountModified = true;
}

Expand All @@ -2705,12 +2705,12 @@ export const updateVariable = ({ state }, payload) => {
});
}

// Save global-device variables if any were modified
// Save device-scoped variables if any were modified
if (globalDeviceModified) {
const globalDeviceVars = filterVariablesByScope(
state.global.variables,
state.projectData.resources?.variables,
"global-device",
"device",
);
state.global.pendingEffects.push({
name: "saveGlobalDeviceVariables",
Expand All @@ -2720,12 +2720,12 @@ export const updateVariable = ({ state }, payload) => {
});
}

// Save global-account variables if any were modified
// Save account-scoped variables if any were modified
if (globalAccountModified) {
const globalAccountVars = filterVariablesByScope(
state.global.variables,
state.projectData.resources?.variables,
"global-account",
"account",
);
state.global.pendingEffects.push({
name: "saveGlobalAccountVariables",
Expand Down
Loading
Loading