@datamoc/mw_games 0.6.0 → 0.7.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.
Files changed (54) hide show
  1. package/README.md +51 -1
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/mw_games.global.js +24 -21
  7. package/dist/mwl/actors.d.ts +16 -0
  8. package/dist/mwl/actors.d.ts.map +1 -0
  9. package/dist/mwl/actors.js +25 -0
  10. package/dist/mwl/actors.js.map +1 -0
  11. package/dist/mwl/catalog.d.ts +13 -0
  12. package/dist/mwl/catalog.d.ts.map +1 -0
  13. package/dist/mwl/catalog.js +52 -0
  14. package/dist/mwl/catalog.js.map +1 -0
  15. package/dist/mwl/compiler.d.ts +45 -0
  16. package/dist/mwl/compiler.d.ts.map +1 -0
  17. package/dist/mwl/compiler.js +69 -0
  18. package/dist/mwl/compiler.js.map +1 -0
  19. package/dist/mwl/content.d.ts +54 -0
  20. package/dist/mwl/content.d.ts.map +1 -0
  21. package/dist/mwl/content.js +97 -0
  22. package/dist/mwl/content.js.map +1 -0
  23. package/dist/mwl/expression.d.ts +21 -0
  24. package/dist/mwl/expression.d.ts.map +1 -0
  25. package/dist/mwl/expression.js +100 -0
  26. package/dist/mwl/expression.js.map +1 -0
  27. package/dist/mwl/grammar.d.ts +39 -0
  28. package/dist/mwl/grammar.d.ts.map +1 -0
  29. package/dist/mwl/grammar.js +204 -0
  30. package/dist/mwl/grammar.js.map +1 -0
  31. package/dist/mwl/hooks.d.ts +81 -0
  32. package/dist/mwl/hooks.d.ts.map +1 -0
  33. package/dist/mwl/hooks.js +78 -0
  34. package/dist/mwl/hooks.js.map +1 -0
  35. package/dist/mwl/index.d.ts +21 -0
  36. package/dist/mwl/index.d.ts.map +1 -0
  37. package/dist/mwl/index.js +11 -0
  38. package/dist/mwl/index.js.map +1 -0
  39. package/dist/mwl/persistence.d.ts +15 -0
  40. package/dist/mwl/persistence.d.ts.map +1 -0
  41. package/dist/mwl/persistence.js +33 -0
  42. package/dist/mwl/persistence.js.map +1 -0
  43. package/dist/mwl/runtime.d.ts +169 -0
  44. package/dist/mwl/runtime.d.ts.map +1 -0
  45. package/dist/mwl/runtime.js +519 -0
  46. package/dist/mwl/runtime.js.map +1 -0
  47. package/dist/mwl/schema.d.ts +20 -0
  48. package/dist/mwl/schema.d.ts.map +1 -0
  49. package/dist/mwl/schema.js +351 -0
  50. package/dist/mwl/schema.js.map +1 -0
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +7 -1
  54. package/tools/mwl.mjs +153 -0
package/README.md CHANGED
@@ -11,7 +11,7 @@ of their own; improvements to `mwg`'s own files are shared back.
11
11
  **[Live examples and API docs](https://datamoc.github.io/mwg/)**: every example below,
12
12
  playable in the browser with no download, plus the generated API reference.
13
13
 
14
- > **Status: pre-alpha (v0.6.0).** Every module in the shared floor below, plus optional
14
+ > **Status: pre-alpha (v0.7.0).** Every module in the shared floor below, plus optional
15
15
  > 3D, mobile (Capacitor) and desktop (WebView2) packaging, is built and tested - see
16
16
  > [ROADMAP.md](ROADMAP.md) for the full, numbered history.
17
17
  >
@@ -373,6 +373,56 @@ with `advanceToInput`.
373
373
  See [ROADMAP.md](ROADMAP.md) for the full, numbered build order and implementation notes.
374
374
  The optional 3D group is now implemented without changing the existing 2D entry point.
375
375
 
376
+ ## MWL
377
+
378
+ MWL is the framework's declarative, WML-inspired authoring layer. It describes
379
+ game data and commands while `mwg` remains responsible for execution, rendering,
380
+ input, audio, and saves. MWL is a new language, not a WML compatibility layer.
381
+ The Wesnoth port can nevertheless use its native `.cfg` files as build inputs:
382
+ the port-owned WML front end parses them, the adapter converts the supported
383
+ nodes to MWL, and the normal MWL compiler emits the runtime module.
384
+
385
+ The framework exposes the parser, validator, compiler, runtime, i18n extraction,
386
+ and the hook contract through `@datamoc/mw_games/mwl`. Compile source at build
387
+ time with:
388
+
389
+ ```sh
390
+ npm run mwl -- validate game.mwl
391
+ npm run mwl -- build game.mwl -o generated/
392
+ npm run mwl -- compile game.mwl -o generated/game-data.ts
393
+ npm run mwl -- extract-i18n game.mwl -o generated/i18n.json
394
+ npm run mwl -- hooks game.mwl --manifest hooks.json -o generated/hooks.mjs
395
+ ```
396
+
397
+ `mwl build` is the normal game command: it produces `game-data.ts`, `i18n.json`,
398
+ and `assets.json` in one build-time step. The game imports the generated module;
399
+ it never calls `Mwl.compile()` at runtime. MWG also provides generic helpers for
400
+ turning item effects into `actors` modifiers and for versioned, migratable MWL
401
+ saves. Asset attributes such as `image`, `image_icon`, `profile`, `icon`, `file`,
402
+ `sound`, and `*_sound` are collected into the manifest, including comma-separated
403
+ sound lists and Wesnoth `~` image modifiers. Item slots, formulas, hooks, and
404
+ business rules remain defined by the game.
405
+
406
+ Translation messages are the values marked `_ "..."` in the source; the
407
+ extracted catalog matches `@datamoc/mw_games/i18n`. Hooks are referenced as
408
+ `type:name`, declared in a manifest, and bundled with esbuild, which a game
409
+ project installs itself (`npm install --save-dev esbuild`). The framework does
410
+ not depend on esbuild, so a game without hooks pays nothing for the feature.
411
+
412
+ `MwlRuntime` runs compiled content: it loads the map, sides, units, and leaders
413
+ (leaders spawn on their keep with stats from `[unit_type]`), runs `on=` events
414
+ with filters and conditions, tracks movement points, advances the `[schedule]`
415
+ on `[end_turn]`, evaluates `[objectives]`, hosts command and predicate hooks,
416
+ and saves and restores the world. Pathfinding and combat formulas stay in a
417
+ game's engine adapter, because they need that game's real data. A command hook
418
+ receives the `[hook]` attributes as its context; a `condition=hook` objective
419
+ receives its other attributes, so content can parameterize an engine predicate
420
+ (`value` is the generic integer parameter).
421
+
422
+ The generated data is plain TypeScript and works with the same local-file build
423
+ pipeline as the rest of the framework. Wesnoth-specific MWL source belongs in
424
+ the Wesnoth port, not in this framework package.
425
+
376
426
  ## Licence and provenance
377
427
 
378
428
  `mwg` is MPL-2.0. Its dependencies are permissive and compatible: PixiJS and Babylon.js are
package/dist/index.d.ts CHANGED
@@ -20,4 +20,5 @@ export * as Battle from './battle/index.ts';
20
20
  export * as Board from './board/index.ts';
21
21
  export * as Audio from './audio/index.ts';
22
22
  export * as Simulation from './simulation/index.ts';
23
+ export * as Mwl from './mwl/index.ts';
23
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -20,4 +20,5 @@ export * as Battle from './battle/index.js';
20
20
  export * as Board from './board/index.js';
21
21
  export * as Audio from './audio/index.js';
22
22
  export * as Simulation from './simulation/index.js';
23
+ export * as Mwl from './mwl/index.js';
23
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC"}