@datamoc/mw_games 0.4.1 → 0.4.2
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/README.md +1 -1
- package/dist/assets/binary.d.ts +52 -0
- package/dist/assets/binary.d.ts.map +1 -0
- package/dist/assets/binary.js +57 -0
- package/dist/assets/binary.js.map +1 -0
- package/dist/assets/index.d.ts +10 -5
- package/dist/assets/index.d.ts.map +1 -1
- package/dist/assets/index.js +9 -5
- package/dist/assets/index.js.map +1 -1
- package/dist/board/Army.d.ts +75 -0
- package/dist/board/Army.d.ts.map +1 -1
- package/dist/board/Army.js +75 -0
- package/dist/board/Army.js.map +1 -1
- package/dist/board/Classics.d.ts +297 -1
- package/dist/board/Classics.d.ts.map +1 -1
- package/dist/board/Classics.js +297 -1
- package/dist/board/Classics.js.map +1 -1
- package/dist/board/Engine.d.ts +23 -0
- package/dist/board/Engine.d.ts.map +1 -1
- package/dist/board/Engine.js +23 -0
- package/dist/board/Engine.js.map +1 -1
- package/dist/board/FogOfWar.d.ts +20 -0
- package/dist/board/FogOfWar.d.ts.map +1 -1
- package/dist/board/FogOfWar.js +20 -0
- package/dist/board/FogOfWar.js.map +1 -1
- package/dist/board/Tactics.d.ts +158 -1
- package/dist/board/Tactics.d.ts.map +1 -1
- package/dist/board/Tactics.js +125 -1
- package/dist/board/Tactics.js.map +1 -1
- package/dist/board/chess.d.ts +87 -3
- package/dist/board/chess.d.ts.map +1 -1
- package/dist/board/chess.js +96 -4
- package/dist/board/chess.js.map +1 -1
- package/dist/i18n/Content.d.ts +151 -0
- package/dist/i18n/Content.d.ts.map +1 -0
- package/dist/i18n/Content.js +219 -0
- package/dist/i18n/Content.js.map +1 -0
- package/dist/i18n/index.d.ts +35 -3
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +88 -6
- package/dist/i18n/index.js.map +1 -1
- package/dist/mw_games.global.js +89 -89
- package/dist/roguelike/Placement.d.ts +62 -0
- package/dist/roguelike/Placement.d.ts.map +1 -0
- package/dist/roguelike/Placement.js +79 -0
- package/dist/roguelike/Placement.js.map +1 -0
- package/dist/roguelike/index.d.ts +2 -0
- package/dist/roguelike/index.d.ts.map +1 -1
- package/dist/roguelike/index.js +1 -0
- package/dist/roguelike/index.js.map +1 -1
- package/dist/three-d/Models.d.ts +38 -1
- package/dist/three-d/Models.d.ts.map +1 -1
- package/dist/three-d/Models.js +66 -3
- package/dist/three-d/Models.js.map +1 -1
- package/dist/two-d/render/ActorAnimator.d.ts +32 -0
- package/dist/two-d/render/ActorAnimator.d.ts.map +1 -1
- package/dist/two-d/render/ActorAnimator.js +21 -0
- package/dist/two-d/render/ActorAnimator.js.map +1 -1
- package/dist/two-d/render/AnimatedSprite.d.ts +24 -4
- package/dist/two-d/render/AnimatedSprite.d.ts.map +1 -1
- package/dist/two-d/render/AnimatedSprite.js +24 -4
- package/dist/two-d/render/AnimatedSprite.js.map +1 -1
- package/dist/two-d/render/Autotile.d.ts +33 -1
- package/dist/two-d/render/Autotile.d.ts.map +1 -1
- package/dist/two-d/render/Autotile.js +33 -1
- package/dist/two-d/render/Autotile.js.map +1 -1
- package/dist/two-d/render/Camera.d.ts +53 -1
- package/dist/two-d/render/Camera.d.ts.map +1 -1
- package/dist/two-d/render/Camera.js +36 -1
- package/dist/two-d/render/Camera.js.map +1 -1
- package/dist/two-d/render/Capabilities.d.ts +33 -0
- package/dist/two-d/render/Capabilities.d.ts.map +1 -1
- package/dist/two-d/render/Capabilities.js +33 -0
- package/dist/two-d/render/Capabilities.js.map +1 -1
- package/dist/two-d/render/ColorBlindness.d.ts +23 -0
- package/dist/two-d/render/ColorBlindness.d.ts.map +1 -1
- package/dist/two-d/render/ColorBlindness.js +23 -4
- package/dist/two-d/render/ColorBlindness.js.map +1 -1
- package/dist/two-d/render/ColorTransformBatcher.d.ts +67 -1
- package/dist/two-d/render/ColorTransformBatcher.d.ts.map +1 -1
- package/dist/two-d/render/ColorTransformBatcher.js +57 -1
- package/dist/two-d/render/ColorTransformBatcher.js.map +1 -1
- package/dist/two-d/render/LayeredSprite.d.ts +19 -0
- package/dist/two-d/render/LayeredSprite.d.ts.map +1 -1
- package/dist/two-d/render/LayeredSprite.js +19 -0
- package/dist/two-d/render/LayeredSprite.js.map +1 -1
- package/dist/two-d/render/Minimap.d.ts +25 -1
- package/dist/two-d/render/Minimap.d.ts.map +1 -1
- package/dist/two-d/render/Minimap.js +25 -1
- package/dist/two-d/render/Minimap.js.map +1 -1
- package/dist/two-d/render/Particles.d.ts +26 -2
- package/dist/two-d/render/Particles.d.ts.map +1 -1
- package/dist/two-d/render/Particles.js +23 -0
- package/dist/two-d/render/Particles.js.map +1 -1
- package/dist/two-d/render/Projectile.d.ts +14 -0
- package/dist/two-d/render/Projectile.d.ts.map +1 -1
- package/dist/two-d/render/Projectile.js +14 -0
- package/dist/two-d/render/Projectile.js.map +1 -1
- package/dist/two-d/render/ScreenEffects.d.ts +15 -0
- package/dist/two-d/render/ScreenEffects.d.ts.map +1 -1
- package/dist/two-d/render/ScreenEffects.js +15 -0
- package/dist/two-d/render/ScreenEffects.js.map +1 -1
- package/dist/two-d/render/Shape2D.d.ts +58 -1
- package/dist/two-d/render/Shape2D.d.ts.map +1 -1
- package/dist/two-d/render/Shape2D.js +58 -1
- package/dist/two-d/render/Shape2D.js.map +1 -1
- package/dist/two-d/render/StatusVisuals.d.ts +22 -0
- package/dist/two-d/render/StatusVisuals.d.ts.map +1 -1
- package/dist/two-d/render/StatusVisuals.js +22 -0
- package/dist/two-d/render/StatusVisuals.js.map +1 -1
- package/dist/two-d/render/TileMap.d.ts +65 -3
- package/dist/two-d/render/TileMap.d.ts.map +1 -1
- package/dist/two-d/render/TileMap.js +65 -3
- package/dist/two-d/render/TileMap.js.map +1 -1
- package/dist/two-d/render/TiledMap.d.ts +9 -3
- package/dist/two-d/render/TiledMap.d.ts.map +1 -1
- package/dist/two-d/render/TiledMap.js +9 -3
- package/dist/two-d/render/TiledMap.js.map +1 -1
- package/dist/two-d/render/TintedSprite.d.ts +9 -2
- package/dist/two-d/render/TintedSprite.d.ts.map +1 -1
- package/dist/two-d/render/TintedSprite.js +9 -2
- package/dist/two-d/render/TintedSprite.js.map +1 -1
- package/dist/two-d/render/Types2D.d.ts +14 -2
- package/dist/two-d/render/Types2D.d.ts.map +1 -1
- package/dist/two-d/render/Types2D.js +14 -2
- package/dist/two-d/render/Types2D.js.map +1 -1
- package/dist/two-d/render/Viewport.d.ts +22 -0
- package/dist/two-d/render/Viewport.d.ts.map +1 -1
- package/dist/two-d/render/Viewport.js +22 -0
- package/dist/two-d/render/Viewport.js.map +1 -1
- package/dist/two-d/ui/Bar.d.ts +16 -3
- package/dist/two-d/ui/Bar.d.ts.map +1 -1
- package/dist/two-d/ui/Bar.js +16 -1
- package/dist/two-d/ui/Bar.js.map +1 -1
- package/dist/two-d/ui/BitmapLabel.d.ts +23 -1
- package/dist/two-d/ui/BitmapLabel.d.ts.map +1 -1
- package/dist/two-d/ui/BitmapLabel.js +23 -1
- package/dist/two-d/ui/BitmapLabel.js.map +1 -1
- package/dist/two-d/ui/Button.d.ts +15 -0
- package/dist/two-d/ui/Button.d.ts.map +1 -1
- package/dist/two-d/ui/Button.js +15 -0
- package/dist/two-d/ui/Button.js.map +1 -1
- package/dist/two-d/ui/FloatingText.d.ts +15 -0
- package/dist/two-d/ui/FloatingText.d.ts.map +1 -1
- package/dist/two-d/ui/FloatingText.js +15 -0
- package/dist/two-d/ui/FloatingText.js.map +1 -1
- package/dist/two-d/ui/HelpScreen.d.ts +16 -0
- package/dist/two-d/ui/HelpScreen.d.ts.map +1 -1
- package/dist/two-d/ui/HelpScreen.js +23 -3
- package/dist/two-d/ui/HelpScreen.js.map +1 -1
- package/dist/two-d/ui/IconGrid.d.ts +25 -0
- package/dist/two-d/ui/IconGrid.d.ts.map +1 -1
- package/dist/two-d/ui/IconGrid.js +37 -5
- package/dist/two-d/ui/IconGrid.js.map +1 -1
- package/dist/two-d/ui/Label.d.ts +10 -0
- package/dist/two-d/ui/Label.d.ts.map +1 -1
- package/dist/two-d/ui/Label.js +10 -0
- package/dist/two-d/ui/Label.js.map +1 -1
- package/dist/two-d/ui/ListView.d.ts +19 -0
- package/dist/two-d/ui/ListView.d.ts.map +1 -1
- package/dist/two-d/ui/ListView.js +19 -0
- package/dist/two-d/ui/ListView.js.map +1 -1
- package/dist/two-d/ui/LoadingScreen.d.ts +24 -1
- package/dist/two-d/ui/LoadingScreen.d.ts.map +1 -1
- package/dist/two-d/ui/LoadingScreen.js +24 -1
- package/dist/two-d/ui/LoadingScreen.js.map +1 -1
- package/dist/two-d/ui/MessageBox.d.ts +21 -2
- package/dist/two-d/ui/MessageBox.d.ts.map +1 -1
- package/dist/two-d/ui/MessageBox.js +19 -0
- package/dist/two-d/ui/MessageBox.js.map +1 -1
- package/dist/two-d/ui/NinePatch.d.ts +12 -0
- package/dist/two-d/ui/NinePatch.d.ts.map +1 -1
- package/dist/two-d/ui/NinePatch.js +12 -0
- package/dist/two-d/ui/NinePatch.js.map +1 -1
- package/dist/two-d/ui/RebindScreen.d.ts +15 -0
- package/dist/two-d/ui/RebindScreen.d.ts.map +1 -1
- package/dist/two-d/ui/RebindScreen.js +15 -0
- package/dist/two-d/ui/RebindScreen.js.map +1 -1
- package/dist/two-d/ui/StatsScreen.d.ts +15 -0
- package/dist/two-d/ui/StatsScreen.d.ts.map +1 -1
- package/dist/two-d/ui/StatsScreen.js +15 -0
- package/dist/two-d/ui/StatsScreen.js.map +1 -1
- package/dist/two-d/ui/Toast.d.ts +12 -0
- package/dist/two-d/ui/Toast.d.ts.map +1 -1
- package/dist/two-d/ui/Toast.js +12 -0
- package/dist/two-d/ui/Toast.js.map +1 -1
- package/dist/two-d/ui/Tooltip.d.ts +14 -0
- package/dist/two-d/ui/Tooltip.d.ts.map +1 -1
- package/dist/two-d/ui/Tooltip.js +14 -0
- package/dist/two-d/ui/Tooltip.js.map +1 -1
- package/dist/two-d/ui/VerticalLabel.d.ts +18 -0
- package/dist/two-d/ui/VerticalLabel.d.ts.map +1 -1
- package/dist/two-d/ui/VerticalLabel.js +18 -0
- package/dist/two-d/ui/VerticalLabel.js.map +1 -1
- package/dist/two-d/ui/Window.d.ts +12 -0
- package/dist/two-d/ui/Window.d.ts.map +1 -1
- package/dist/two-d/ui/Window.js +12 -0
- package/dist/two-d/ui/Window.js.map +1 -1
- package/dist/two-d/ui/theme.d.ts +45 -1
- package/dist/two-d/ui/theme.d.ts.map +1 -1
- package/dist/two-d/ui/theme.js +45 -1
- package/dist/two-d/ui/theme.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type AssetProgress } from './paths.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Raw asset bytes, cached and progress-reported the same way `loader.ts`'s texture cache is -
|
|
4
|
+
* but renderer-free, so a Babylon-only game (or anything else that just wants an
|
|
5
|
+
* `ArrayBuffer`) gets the same `load`/`isLoaded`/`release` shape a 2D game's textures already
|
|
6
|
+
* have, without pulling Pixi in. `Vox.parseVox` is the direct beneficiary: it takes an
|
|
7
|
+
* `ArrayBuffer` a game previously had to fetch and cache by hand.
|
|
8
|
+
*
|
|
9
|
+
* Kept out of `loader.ts` itself for the same reason `paths.ts` is its own file: `loader.ts`
|
|
10
|
+
* is allowed to know about Pixi, `three-d` is allowed to know about Babylon, but neither
|
|
11
|
+
* should have to import the other's renderer just to share a byte cache.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { loadBinary, getBinary } from '@datamoc/mw_games/assets';
|
|
16
|
+
* import { parseVox, createVoxModel3D } from '@datamoc/mw_games/3d';
|
|
17
|
+
*
|
|
18
|
+
* await loadBinary(['models/rock.vox']);
|
|
19
|
+
* const model = parseVox(getBinary('models/rock.vox'));
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export interface LoadBinaryOptions {
|
|
23
|
+
/** overrides the fetch used to load bytes; defaults to `globalThis.fetch` */
|
|
24
|
+
fetch?: typeof globalThis.fetch;
|
|
25
|
+
}
|
|
26
|
+
/** Loads and caches raw bytes for every path not already cached; a path already loaded is a no-op. */
|
|
27
|
+
export declare function loadBinary(paths: string[], onProgress?: AssetProgress, options?: LoadBinaryOptions): Promise<void>;
|
|
28
|
+
/** a loaded asset's raw bytes, by the same path it was loaded with */
|
|
29
|
+
export declare function getBinary(path: string): ArrayBuffer;
|
|
30
|
+
/**
|
|
31
|
+
* true once `loadBinary` has resolved for this path and it has not since been `releaseBinary`d
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { isBinaryLoaded } from '@datamoc/mw_games/assets';
|
|
36
|
+
*
|
|
37
|
+
* console.log(isBinaryLoaded('models/rock.vox')); // false until loadBinary resolves for it
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function isBinaryLoaded(path: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Frees cached bytes; a path never loaded (or already released) is silently skipped.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { releaseBinary } from '@datamoc/mw_games/assets';
|
|
47
|
+
*
|
|
48
|
+
* releaseBinary(['models/rock.vox']); // frees the cached bytes once the model is placed
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function releaseBinary(paths: string[]): void;
|
|
52
|
+
//# sourceMappingURL=binary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../src/assets/binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,iBAAiB;IACjC,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CAChC;AAID,sGAAsG;AACtG,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,EAAE,aAAa,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB5H;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAInD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAEnD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { resolve } from './paths.js';
|
|
2
|
+
const cache = new Map();
|
|
3
|
+
/** Loads and caches raw bytes for every path not already cached; a path already loaded is a no-op. */
|
|
4
|
+
export async function loadBinary(paths, onProgress, options = {}) {
|
|
5
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
6
|
+
if (!doFetch)
|
|
7
|
+
throw new Error('fetch is unavailable; provide LoadBinaryOptions.fetch');
|
|
8
|
+
const pending = paths.filter((path) => !cache.has(path));
|
|
9
|
+
if (pending.length === 0) {
|
|
10
|
+
onProgress?.(1);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
let done = 0;
|
|
14
|
+
await Promise.all(pending.map(async (path) => {
|
|
15
|
+
const response = await doFetch(resolve(path));
|
|
16
|
+
if (!response.ok)
|
|
17
|
+
throw new Error(`failed to load binary asset "${path}": ${response.status}`);
|
|
18
|
+
cache.set(path, await response.arrayBuffer());
|
|
19
|
+
done++;
|
|
20
|
+
onProgress?.(done / pending.length);
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
/** a loaded asset's raw bytes, by the same path it was loaded with */
|
|
24
|
+
export function getBinary(path) {
|
|
25
|
+
const data = cache.get(path);
|
|
26
|
+
if (!data)
|
|
27
|
+
throw new Error(`binary asset "${path}" has not been loaded - pass it to loadBinary() first`);
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* true once `loadBinary` has resolved for this path and it has not since been `releaseBinary`d
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { isBinaryLoaded } from '@datamoc/mw_games/assets';
|
|
36
|
+
*
|
|
37
|
+
* console.log(isBinaryLoaded('models/rock.vox')); // false until loadBinary resolves for it
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function isBinaryLoaded(path) {
|
|
41
|
+
return cache.has(path);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Frees cached bytes; a path never loaded (or already released) is silently skipped.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { releaseBinary } from '@datamoc/mw_games/assets';
|
|
49
|
+
*
|
|
50
|
+
* releaseBinary(['models/rock.vox']); // frees the cached bytes once the model is placed
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function releaseBinary(paths) {
|
|
54
|
+
for (const path of paths)
|
|
55
|
+
cache.delete(path);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=binary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../../src/assets/binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,MAAM,YAAY,CAAC;AA4BzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;AAE7C,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAe,EAAE,UAA0B,EAAE,OAAO,GAAsB,EAAE;IAC5G,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IAClD,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,uDAAuD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AC5C,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/assets/index.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `file://` story,
|
|
2
|
+
* The `file://` story, split by how renderer-specific each piece is.
|
|
3
3
|
*
|
|
4
4
|
* `paths.ts` resolves an asset path against the compiled `data:` URI map (or the dev server)
|
|
5
|
-
* and needs no renderer at all; `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* and needs no renderer at all; `binary.ts` caches raw bytes the same renderer-free way, for
|
|
6
|
+
* anything (`three-d`'s VOX loader, most directly) that wants an `ArrayBuffer` rather than a
|
|
7
|
+
* decoded texture; `loader.ts` fetches and decodes textures through Pixi specifically. This
|
|
8
|
+
* barrel exposes all three, so `import { load, resolve } from '@datamoc/mw_games/assets'` is
|
|
9
|
+
* unchanged - but a game rendering through something else imports
|
|
10
|
+
* `@datamoc/mw_games/assets/paths` or `@datamoc/mw_games/assets/binary` instead and pays
|
|
11
|
+
* nothing for Pixi.
|
|
9
12
|
*/
|
|
10
13
|
export { setBase, isCompiled, paths, has, resolve } from './paths.ts';
|
|
11
14
|
export type { AssetProgress } from './paths.ts';
|
|
12
15
|
export { load, texture, get, isLoaded, release } from './loader.ts';
|
|
16
|
+
export { loadBinary, getBinary, isBinaryLoaded, releaseBinary } from './binary.ts';
|
|
17
|
+
export type { LoadBinaryOptions } from './binary.ts';
|
|
13
18
|
export { AssetStream } from './Streaming.ts';
|
|
14
19
|
export type { AssetBundle, AssetStreamOptions } from './Streaming.ts';
|
|
15
20
|
export { fetchWithByteProgress } from './ByteProgress.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACtE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnF,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/assets/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `file://` story,
|
|
2
|
+
* The `file://` story, split by how renderer-specific each piece is.
|
|
3
3
|
*
|
|
4
4
|
* `paths.ts` resolves an asset path against the compiled `data:` URI map (or the dev server)
|
|
5
|
-
* and needs no renderer at all; `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* and needs no renderer at all; `binary.ts` caches raw bytes the same renderer-free way, for
|
|
6
|
+
* anything (`three-d`'s VOX loader, most directly) that wants an `ArrayBuffer` rather than a
|
|
7
|
+
* decoded texture; `loader.ts` fetches and decodes textures through Pixi specifically. This
|
|
8
|
+
* barrel exposes all three, so `import { load, resolve } from '@datamoc/mw_games/assets'` is
|
|
9
|
+
* unchanged - but a game rendering through something else imports
|
|
10
|
+
* `@datamoc/mw_games/assets/paths` or `@datamoc/mw_games/assets/binary` instead and pays
|
|
11
|
+
* nothing for Pixi.
|
|
9
12
|
*/
|
|
10
13
|
export { setBase, isCompiled, paths, has, resolve } from './paths.js';
|
|
11
14
|
export { load, texture, get, isLoaded, release } from './loader.js';
|
|
15
|
+
export { loadBinary, getBinary, isBinaryLoaded, releaseBinary } from './binary.js';
|
|
12
16
|
export { AssetStream } from './Streaming.js';
|
|
13
17
|
export { fetchWithByteProgress } from './ByteProgress.js';
|
|
14
18
|
//# sourceMappingURL=index.js.map
|
package/dist/assets/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGtE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGnF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/board/Army.d.ts
CHANGED
|
@@ -4,14 +4,89 @@ export interface ArmyState {
|
|
|
4
4
|
currency: number;
|
|
5
5
|
pool: UnitTemplate[];
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Recruit/income economy layered on top of `Tactics`'s board: a currency total plus a pool of
|
|
9
|
+
* banked unit templates waiting to be recalled onto the map. See `recruit`/`bankUnit`/
|
|
10
|
+
* `recall`/`armyIncome`/`applyUpkeep` for the rest of the economy this state drives.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { startingArmy } from '@datamoc/mw_games/board';
|
|
15
|
+
*
|
|
16
|
+
* console.log(startingArmy(100)); // { currency: 100, pool: [] }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
7
19
|
export declare function startingArmy(currency: number): ArmyState;
|
|
20
|
+
/**
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { startingArmy, recruit, startingTactics } from '@datamoc/mw_games/board';
|
|
24
|
+
*
|
|
25
|
+
* const board = startingTactics(6, 6, 'square');
|
|
26
|
+
* const army = startingArmy(100);
|
|
27
|
+
*
|
|
28
|
+
* recruit(army, board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 }, 30);
|
|
29
|
+
* console.log(army.currency); // 70 - 100 minus the 30 cost
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
8
32
|
export declare function recruit(army: ArmyState, board: TacticalState, unit: TacticalUnit, cost: number): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { startingArmy, recruit, bankUnit, recall, startingTactics } from '@datamoc/mw_games/board';
|
|
37
|
+
*
|
|
38
|
+
* const board = startingTactics(6, 6, 'square');
|
|
39
|
+
* const army = startingArmy(100);
|
|
40
|
+
* recruit(army, board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 }, 30);
|
|
41
|
+
* bankUnit(army, board, 'scout');
|
|
42
|
+
*
|
|
43
|
+
* recall(army, board, 'scout', 1, 1);
|
|
44
|
+
* console.log(board.units.some((unit) => unit.id === 'scout')); // true - fielded again, at its new position
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
9
47
|
export declare function recall(army: ArmyState, board: TacticalState, unitId: string, x: number, y: number): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { startingArmy, recruit, bankUnit, startingTactics } from '@datamoc/mw_games/board';
|
|
52
|
+
*
|
|
53
|
+
* const board = startingTactics(6, 6, 'square');
|
|
54
|
+
* const army = startingArmy(100);
|
|
55
|
+
* recruit(army, board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 }, 30);
|
|
56
|
+
*
|
|
57
|
+
* bankUnit(army, board, 'scout');
|
|
58
|
+
* console.log(board.units.length, army.pool.length); // 0 1 - pulled off the map, into the pool
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
10
61
|
export declare function bankUnit(army: ArmyState, board: TacticalState, unitId: string): boolean;
|
|
11
62
|
export interface UpkeepRates {
|
|
12
63
|
incomePerUnit: number;
|
|
13
64
|
upkeepPerUnit: number;
|
|
14
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import { startingTactics, addTacticalUnit, armyIncome } from '@datamoc/mw_games/board';
|
|
70
|
+
*
|
|
71
|
+
* const board = startingTactics(6, 6, 'square');
|
|
72
|
+
* addTacticalUnit(board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 });
|
|
73
|
+
*
|
|
74
|
+
* console.log(armyIncome(board, 'blue', { incomePerUnit: 5, upkeepPerUnit: 2 })); // 3 - one unit, net of upkeep
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
15
77
|
export declare function armyIncome(board: TacticalState, owner: string, rates: UpkeepRates): number;
|
|
78
|
+
/**
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { startingArmy, startingTactics, addTacticalUnit, applyUpkeep } from '@datamoc/mw_games/board';
|
|
82
|
+
*
|
|
83
|
+
* const board = startingTactics(6, 6, 'square');
|
|
84
|
+
* addTacticalUnit(board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 });
|
|
85
|
+
* const army = startingArmy(100);
|
|
86
|
+
*
|
|
87
|
+
* applyUpkeep(army, board, 'blue', { incomePerUnit: 5, upkeepPerUnit: 2 });
|
|
88
|
+
* console.log(army.currency); // 103 - this turn's net income applied
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
16
91
|
export declare function applyUpkeep(army: ArmyState, board: TacticalState, owner: string, rates: UpkeepRates): number;
|
|
17
92
|
//# sourceMappingURL=Army.d.ts.map
|
package/dist/board/Army.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Army.d.ts","sourceRoot":"","sources":["../../src/board/Army.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKhE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;AAEzD,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,YAAY,EAAE,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAExD;AAKD,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKxG;AAID,wBAAgB,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAM3G;AAID,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAOvF;AAED,MAAM,WAAW,WAAW;IAAG,aAAa,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;CAAE;AAK9E,wBAAgB,UAAU,CAAC,K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,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAG1F;AAGD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAG5G"}
|
package/dist/board/Army.js
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
import { addTacticalUnit, canPlaceTacticalUnit } from './Tactics.js';
|
|
2
|
+
/**
|
|
3
|
+
* Recruit/income economy layered on top of `Tactics`'s board: a currency total plus a pool of
|
|
4
|
+
* banked unit templates waiting to be recalled onto the map. See `recruit`/`bankUnit`/
|
|
5
|
+
* `recall`/`armyIncome`/`applyUpkeep` for the rest of the economy this state drives.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { startingArmy } from '@datamoc/mw_games/board';
|
|
10
|
+
*
|
|
11
|
+
* console.log(startingArmy(100)); // { currency: 100, pool: [] }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
2
14
|
export function startingArmy(currency) {
|
|
3
15
|
return { currency, pool: [] };
|
|
4
16
|
}
|
|
5
17
|
//deducts cost and places a fresh unit, all-or-nothing like actors.Shop's buy/sell: touches
|
|
6
18
|
//neither currency nor the board unless every check already passed - canPlaceTacticalUnit is
|
|
7
19
|
//checked up front rather than letting addTacticalUnit's own throw escape a boolean contract
|
|
20
|
+
/**
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { startingArmy, recruit, startingTactics } from '@datamoc/mw_games/board';
|
|
24
|
+
*
|
|
25
|
+
* const board = startingTactics(6, 6, 'square');
|
|
26
|
+
* const army = startingArmy(100);
|
|
27
|
+
*
|
|
28
|
+
* recruit(army, board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 }, 30);
|
|
29
|
+
* console.log(army.currency); // 70 - 100 minus the 30 cost
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
8
32
|
export function recruit(army, board, unit, cost) {
|
|
9
33
|
if (army.currency < cost || !canPlaceTacticalUnit(board, unit.x, unit.y))
|
|
10
34
|
return false;
|
|
@@ -14,6 +38,20 @@ export function recruit(army, board, unit, cost) {
|
|
|
14
38
|
}
|
|
15
39
|
//pulls a previously-fielded unit back onto the map instead of minting a fresh one - the
|
|
16
40
|
//template stays in the pool until recalled, then leaves it the way stock leaves a shop's shelf
|
|
41
|
+
/**
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { startingArmy, recruit, bankUnit, recall, startingTactics } from '@datamoc/mw_games/board';
|
|
45
|
+
*
|
|
46
|
+
* const board = startingTactics(6, 6, 'square');
|
|
47
|
+
* const army = startingArmy(100);
|
|
48
|
+
* recruit(army, board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 }, 30);
|
|
49
|
+
* bankUnit(army, board, 'scout');
|
|
50
|
+
*
|
|
51
|
+
* recall(army, board, 'scout', 1, 1);
|
|
52
|
+
* console.log(board.units.some((unit) => unit.id === 'scout')); // true - fielded again, at its new position
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
17
55
|
export function recall(army, board, unitId, x, y) {
|
|
18
56
|
const index = army.pool.findIndex((template) => template.id === unitId);
|
|
19
57
|
if (index === -1 || !canPlaceTacticalUnit(board, x, y))
|
|
@@ -24,6 +62,19 @@ export function recall(army, board, unitId, x, y) {
|
|
|
24
62
|
}
|
|
25
63
|
//moves a fielded unit into the recall pool instead of discarding it outright - the inverse of
|
|
26
64
|
//recall, for retreating a unit off the map between engagements rather than losing it for good
|
|
65
|
+
/**
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { startingArmy, recruit, bankUnit, startingTactics } from '@datamoc/mw_games/board';
|
|
69
|
+
*
|
|
70
|
+
* const board = startingTactics(6, 6, 'square');
|
|
71
|
+
* const army = startingArmy(100);
|
|
72
|
+
* recruit(army, board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 }, 30);
|
|
73
|
+
*
|
|
74
|
+
* bankUnit(army, board, 'scout');
|
|
75
|
+
* console.log(board.units.length, army.pool.length); // 0 1 - pulled off the map, into the pool
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
27
78
|
export function bankUnit(army, board, unitId) {
|
|
28
79
|
const index = board.units.findIndex((unit) => unit.id === unitId);
|
|
29
80
|
if (index === -1)
|
|
@@ -36,11 +87,35 @@ export function bankUnit(army, board, unitId) {
|
|
|
36
87
|
//net currency delta for one turn's income minus upkeep, purely a function of how many units
|
|
37
88
|
//an owner controls on the board - no formula beyond that belongs here, per this project's
|
|
38
89
|
//policy against borrowing any specific game's numbers
|
|
90
|
+
/**
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { startingTactics, addTacticalUnit, armyIncome } from '@datamoc/mw_games/board';
|
|
94
|
+
*
|
|
95
|
+
* const board = startingTactics(6, 6, 'square');
|
|
96
|
+
* addTacticalUnit(board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 });
|
|
97
|
+
*
|
|
98
|
+
* console.log(armyIncome(board, 'blue', { incomePerUnit: 5, upkeepPerUnit: 2 })); // 3 - one unit, net of upkeep
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
39
101
|
export function armyIncome(board, owner, rates) {
|
|
40
102
|
const controlled = board.units.filter((unit) => unit.owner === owner).length;
|
|
41
103
|
return controlled * (rates.incomePerUnit - rates.upkeepPerUnit);
|
|
42
104
|
}
|
|
43
105
|
//applies one turn's income/upkeep tick to an army's currency and returns the new total
|
|
106
|
+
/**
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { startingArmy, startingTactics, addTacticalUnit, applyUpkeep } from '@datamoc/mw_games/board';
|
|
110
|
+
*
|
|
111
|
+
* const board = startingTactics(6, 6, 'square');
|
|
112
|
+
* addTacticalUnit(board, { id: 'scout', owner: 'blue', x: 0, y: 0, hp: 6, maxHp: 6, actions: 2 });
|
|
113
|
+
* const army = startingArmy(100);
|
|
114
|
+
*
|
|
115
|
+
* applyUpkeep(army, board, 'blue', { incomePerUnit: 5, upkeepPerUnit: 2 });
|
|
116
|
+
* console.log(army.currency); // 103 - this turn's net income applied
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
44
119
|
export function applyUpkeep(army, board, owner, rates) {
|
|
45
120
|
army.currency += armyIncome(board, owner, rates);
|
|
46
121
|
return army.currency;
|
package/dist/board/Army.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Army.js","sourceRoot":"","sources":["../../src/board/Army.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAWrE,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC5C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAC/B,CAAC;AAED,2FAA2F;AAC3F,4FAA4F;AAC5F,4FAA4F;AAC5F,MAAM,UAAU,OAAO,CAAC,IAAe,EAAE,KAAoB,EAAE,IAAkB,EAAE,IAAY;IAC9F,IAAI,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACvF,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;IACtB,OAAO,IAAI,CAAC;AACb,CAAC;AAED,wFAAwF;AACxF,+FAA+F;AAC/F,MAAM,UAAU,MAAM,CAAC,IAAe,EAAE,KAAoB,EAAE,MAAc,EAAE,CAAS,EAAE,CAAS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