@rpgjs/action-battle 5.0.0-beta.3 → 5.0.0-beta.5

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 (52) hide show
  1. package/README.md +137 -0
  2. package/dist/ai.server.d.ts +8 -1
  3. package/dist/client/index.js +8 -4
  4. package/dist/client/index10.js +97 -330
  5. package/dist/client/index11.js +25 -0
  6. package/dist/client/index12.js +1222 -0
  7. package/dist/client/index13.js +46 -0
  8. package/dist/client/index14.js +10 -0
  9. package/dist/client/index15.js +448 -0
  10. package/dist/client/index2.js +30 -0
  11. package/dist/client/index3.js +33 -1
  12. package/dist/client/index4.js +7 -3
  13. package/dist/client/index7.js +76 -32
  14. package/dist/client/index8.js +24 -4
  15. package/dist/client/index9.js +94 -1165
  16. package/dist/core/context.d.ts +5 -0
  17. package/dist/core/defaults.d.ts +81 -0
  18. package/dist/core/hit.d.ts +2 -0
  19. package/dist/enemies/factory.d.ts +7 -0
  20. package/dist/index.d.ts +6 -1
  21. package/dist/server/index.js +7 -3
  22. package/dist/server/index10.js +10 -0
  23. package/dist/server/index2.js +23 -3
  24. package/dist/server/index3.js +30 -0
  25. package/dist/server/index4.js +137 -1163
  26. package/dist/server/index5.js +22 -34
  27. package/dist/server/index6.js +1190 -345
  28. package/dist/server/index7.js +37 -0
  29. package/dist/server/index8.js +46 -0
  30. package/dist/server/index9.js +447 -0
  31. package/dist/server.d.ts +2 -0
  32. package/dist/ui/state.d.ts +17 -0
  33. package/package.json +5 -5
  34. package/src/ai.server.ts +91 -24
  35. package/src/animations.ts +43 -4
  36. package/src/canvas-engine-shim.ts +4 -0
  37. package/src/client.ts +122 -2
  38. package/src/components/action-bar.ce +5 -3
  39. package/src/components/attack-preview.ce +90 -0
  40. package/src/config.ts +30 -0
  41. package/src/core/context.ts +35 -0
  42. package/src/core/contracts.ts +123 -0
  43. package/src/core/defaults.ts +162 -0
  44. package/src/core/hit.spec.ts +58 -0
  45. package/src/core/hit.ts +66 -0
  46. package/src/enemies/factory.ts +25 -0
  47. package/src/index.ts +40 -0
  48. package/src/server.ts +235 -71
  49. package/src/targeting.spec.ts +24 -0
  50. package/src/types/canvas-engine.d.ts +4 -0
  51. package/src/types.ts +46 -1
  52. package/src/ui/state.ts +57 -0
@@ -1,37 +1,25 @@
1
- //#region src/targeting.ts
2
- var normalizeMaskRows = (mask) => {
3
- if (!mask) return ["#"];
4
- if (Array.isArray(mask)) return mask;
5
- return mask.trim().split("\n").map((row) => row.replace(/\r/g, ""));
6
- };
7
- var parseAoeMask = (mask) => {
8
- const rows = normalizeMaskRows(mask);
9
- const height = rows.length;
10
- const width = rows.reduce((max, row) => Math.max(max, row.length), 0);
11
- const centerX = Math.floor(width / 2);
12
- const centerY = Math.floor(height / 2);
13
- const cells = [];
14
- rows.forEach((row, y) => {
15
- for (let x = 0; x < row.length; x++) {
16
- const char = row[x];
17
- if (char && char !== "." && char !== " ") cells.push({
18
- dx: x - centerX,
19
- dy: y - centerY
20
- });
1
+ import { defaultActionBattleSystems } from "./index4.js";
2
+ //#region src/core/context.ts
3
+ var mergeSystems = (options = {}) => ({
4
+ combat: {
5
+ ...defaultActionBattleSystems.combat,
6
+ resolveDamage: options.systems?.combat?.damage ?? defaultActionBattleSystems.combat.resolveDamage,
7
+ resolveKnockback: options.systems?.combat?.knockback ?? defaultActionBattleSystems.combat.resolveKnockback,
8
+ hooks: {
9
+ ...defaultActionBattleSystems.combat.hooks,
10
+ ...options.systems?.combat?.hooks
21
11
  }
22
- });
23
- if (cells.length === 0) cells.push({
24
- dx: 0,
25
- dy: 0
26
- });
27
- return {
28
- width,
29
- height,
30
- centerX,
31
- centerY,
32
- cells
33
- };
12
+ },
13
+ ai: { behaviors: {
14
+ ...defaultActionBattleSystems.ai.behaviors,
15
+ ...options.systems?.ai?.behaviors
16
+ } }
17
+ });
18
+ var currentActionBattleSystems = mergeSystems();
19
+ var setActionBattleSystems = (options = {}) => {
20
+ currentActionBattleSystems = mergeSystems(options);
34
21
  };
35
- var manhattanDistance = (a, b) => Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
22
+ var getActionBattleSystems = () => currentActionBattleSystems;
23
+ var createActionBattleSystems = mergeSystems;
36
24
  //#endregion
37
- export { manhattanDistance, parseAoeMask };
25
+ export { createActionBattleSystems, getActionBattleSystems, setActionBattleSystems };