@vylos/cli 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vylos/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/DevOpsBenjamin/Vylos"
@@ -17,7 +17,7 @@
17
17
  "tailwindcss": "^4.0.0",
18
18
  "@tailwindcss/vite": "^4.0.0",
19
19
  "tsx": "^4.19.2",
20
- "@vylos/core": "0.3.0"
20
+ "@vylos/core": "0.4.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "typescript": "^5.7.2"
@@ -0,0 +1,8 @@
1
+ *.png filter=lfs diff=lfs merge=lfs -text
2
+ *.jpg filter=lfs diff=lfs merge=lfs -text
3
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
4
+ *.webp filter=lfs diff=lfs merge=lfs -text
5
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
6
+ *.webm filter=lfs diff=lfs merge=lfs -text
7
+ *.ogg filter=lfs diff=lfs merge=lfs -text
8
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
@@ -0,0 +1,9 @@
1
+ import type { VylosCharacter } from '@vylos/core';
2
+
3
+ /** Extend VylosCharacter with your project-specific fields */
4
+ export interface Character extends VylosCharacter {
5
+ // portrait?: string;
6
+ // role?: string;
7
+ }
8
+
9
+ export const narrator: Character = { id: 'narrator', name: 'Narrator' };
@@ -1,9 +1,10 @@
1
- import type { VylosAction, BaseGameState } from '@vylos/core';
1
+ import type { VylosAction } from '@vylos/core';
2
+ import type { GameState } from '../../state';
2
3
 
3
- const wait: VylosAction = {
4
+ const wait: VylosAction<GameState> = {
4
5
  id: 'wait',
5
6
  label: 'Wait 1 Hour',
6
- execute(state: BaseGameState) {
7
+ execute(state: GameState) {
7
8
  state.gameTime += 1;
8
9
  },
9
10
  };
@@ -1,10 +1,12 @@
1
- import type { VylosEvent, VylosAPI, BaseGameState } from '@vylos/core';
1
+ import type { VylosEvent, VylosAPI } from '@vylos/core';
2
+ import type { GameState } from '../../state';
3
+ import { narrator } from '../../characters';
2
4
 
3
- const intro: VylosEvent = {
5
+ const intro: VylosEvent<GameState> = {
4
6
  id: 'intro',
5
7
  conditions: (state) => !state.flags['intro_done'],
6
- async execute(engine: VylosAPI, state: BaseGameState) {
7
- await engine.say('Welcome to your Vylos game!');
8
+ async execute(engine: VylosAPI, state: GameState) {
9
+ await engine.say('Welcome to your Vylos game!', { from: narrator });
8
10
  await engine.say('This is a starter template. Edit the events to build your story.');
9
11
 
10
12
  const pick = await engine.choice([
package/templates/main.ts CHANGED
@@ -6,7 +6,6 @@ import {
6
6
  GameShell,
7
7
  createEngine,
8
8
  useEngineStateStore,
9
- useGameStateStore,
10
9
  ENGINE_INJECT_KEY,
11
10
  CONFIG_INJECT_KEY,
12
11
  EnginePhase,
@@ -14,8 +13,10 @@ import {
14
13
  ActionManager,
15
14
  type EventRunnerCallbacks,
16
15
  type TextEntry,
16
+ type VylosCharacter,
17
17
  } from '@vylos/core';
18
18
  import config from './vylos.config';
19
+ import { useGameStore } from './state';
19
20
 
20
21
  // Locations
21
22
  import home from './locations/home/location';
@@ -31,7 +32,7 @@ const pinia = createPinia();
31
32
  app.use(pinia);
32
33
 
33
34
  const engineState = useEngineStateStore(pinia);
34
- const gameState = useGameStateStore(pinia);
35
+ const gameState = useGameStore(pinia);
35
36
 
36
37
  // Location manager
37
38
  const locationManager = new LocationManager();
@@ -42,7 +43,7 @@ const actionManager = new ActionManager();
42
43
  actionManager.registerAll([wait]);
43
44
 
44
45
  const callbacks: EventRunnerCallbacks = {
45
- onSay(text, speaker) {
46
+ onSay(text: string, speaker: VylosCharacter | null) {
46
47
  engineState.setDialogue({ text, speaker, isNarration: !speaker });
47
48
  },
48
49
  onChoice(options) {
@@ -8,8 +8,8 @@
8
8
  "build": "vylos build"
9
9
  },
10
10
  "dependencies": {
11
- "@vylos/core": "^0.2.1",
12
- "@vylos/cli": "^0.2.1",
11
+ "@vylos/core": "^0.4.0",
12
+ "@vylos/cli": "^0.4.0",
13
13
  "vue": "^3.5.13",
14
14
  "pinia": "^2.3.0",
15
15
  "reflect-metadata": "^0.2.2",
@@ -0,0 +1,16 @@
1
+ import type { Character } from './characters';
2
+
3
+ /** Extend Character with your player-specific fields */
4
+ export interface Player extends Character {
5
+ // health: number;
6
+ // gold: number;
7
+ }
8
+
9
+ export function createDefaultPlayer(): Player {
10
+ return {
11
+ id: 'player',
12
+ name: 'Player',
13
+ // health: 100,
14
+ // gold: 0,
15
+ };
16
+ }
@@ -0,0 +1,39 @@
1
+ import { defineStore } from 'pinia';
2
+ import { ref } from 'vue';
3
+ import type { VylosGameState } from '@vylos/core';
4
+ import { deepMerge } from '@vylos/core';
5
+ import { type Player, createDefaultPlayer } from './player';
6
+
7
+ /** Your game state — extends VylosGameState with your own fields */
8
+ export interface GameState extends VylosGameState {
9
+ player: Player;
10
+ }
11
+
12
+ export function createDefaultState(): GameState {
13
+ return {
14
+ locationId: '',
15
+ gameTime: 8,
16
+ flags: {},
17
+ counters: {},
18
+ player: createDefaultPlayer(),
19
+ inventories: {},
20
+ };
21
+ }
22
+
23
+ export const useGameStore = defineStore('gameState', () => {
24
+ const state = ref<GameState>(createDefaultState());
25
+
26
+ function getState(): GameState {
27
+ return state.value;
28
+ }
29
+
30
+ function setState(newState: Partial<GameState>) {
31
+ state.value = deepMerge(createDefaultState(), newState) as GameState;
32
+ }
33
+
34
+ function $reset() {
35
+ state.value = createDefaultState();
36
+ }
37
+
38
+ return { state, getState, setState, $reset };
39
+ });