bard-legends-framework 0.9.6 → 0.9.7

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 (238) hide show
  1. package/dist/_interfaces/index.d.ts +2 -2
  2. package/dist/_interfaces/index.js +2 -3
  3. package/dist/game-entities/attachable/attachable.d.ts +6 -6
  4. package/dist/game-entities/attachable/attachable.js +28 -30
  5. package/dist/game-entities/attachable/attachable.spec.js +129 -128
  6. package/dist/game-entities/attachable/attachable.store.d.ts +5 -5
  7. package/dist/game-entities/attachable/attachable.store.js +34 -32
  8. package/dist/game-entities/attachable/attachable.test.js +132 -131
  9. package/dist/game-entities/attachable/destroyable.d.ts +13 -13
  10. package/dist/game-entities/attachable/destroyable.js +64 -69
  11. package/dist/game-entities/attachable/helpers/decorate-actions-lib.d.ts +15 -15
  12. package/dist/game-entities/attachable/helpers/decorate-actions-lib.js +125 -116
  13. package/dist/game-entities/attachable/helpers/referance-variable.d.ts +15 -15
  14. package/dist/game-entities/attachable/helpers/referance-variable.js +47 -48
  15. package/dist/game-entities/attachable/interfaces.d.ts +6 -6
  16. package/dist/game-entities/attachable/interfaces.js +2 -3
  17. package/dist/game-entities/base/helpers/decorate-actions-lib.js +0 -1
  18. package/dist/game-entities/controller/controller.js +0 -1
  19. package/dist/game-entities/controller/controller.spec.js +128 -125
  20. package/dist/game-entities/entity/entity.spec.js +263 -293
  21. package/dist/game-entities/entity/helpers/view-creation.helper.d.ts +7 -7
  22. package/dist/game-entities/entity/helpers/view-creation.helper.js +48 -48
  23. package/dist/game-entities/scene/scene.spec.js +219 -223
  24. package/dist/game-entities/service/service.js +0 -4
  25. package/dist/game-entities/service/service.spec.js +265 -237
  26. package/dist/game-entities/service/service.test.js +4 -2
  27. package/dist/game-entities/update-loop.d.ts +18 -18
  28. package/dist/game-entities/update-loop.js +46 -28
  29. package/dist/game-entities/view/view.spec.js +490 -506
  30. package/dist/game-entities/view/view.test.js +1 -1
  31. package/dist/lib/animator/animations.d.ts +13 -13
  32. package/dist/lib/animator/animations.js +43 -40
  33. package/dist/lib/animator/animator.d.ts +41 -41
  34. package/dist/lib/animator/animator.js +194 -197
  35. package/dist/lib/animator/animator.spec.js +699 -612
  36. package/dist/lib/animator/index.js +24 -19
  37. package/dist/lib/libraries/animator/animations.d.ts +13 -13
  38. package/dist/lib/libraries/animator/animations.js +43 -40
  39. package/dist/lib/libraries/animator/animator.d.ts +41 -41
  40. package/dist/lib/libraries/animator/animator.js +194 -197
  41. package/dist/lib/libraries/animator/animator.spec.js +699 -612
  42. package/dist/lib/libraries/animator/index.js +24 -19
  43. package/dist/lib/libraries/path-finder/path-finder.d.ts +2 -2
  44. package/dist/lib/libraries/path-finder/path-finder.js +19 -20
  45. package/dist/lib/path-finder/path-finder.d.ts +2 -2
  46. package/dist/lib/path-finder/path-finder.js +19 -20
  47. package/dist/lib/services/keyboard/keyboard.d.ts +4 -4
  48. package/dist/lib/services/keyboard/keyboard.js +39 -31
  49. package/dist/lib/services/mouse/mouse.service.d.ts +8 -8
  50. package/dist/lib/services/mouse/mouse.service.js +65 -53
  51. package/dist/lib/services/mouse/mouser-target-focus.service.d.ts +11 -11
  52. package/dist/lib/services/mouse/mouser-target-focus.service.js +83 -81
  53. package/dist/lib/update-loop.d.ts +10 -10
  54. package/dist/lib/update-loop.js +35 -27
  55. package/dist/physics/entitity-types/immovable-physics-entity.d.ts +6 -6
  56. package/dist/physics/entitity-types/immovable-physics-entity.js +23 -24
  57. package/dist/physics/entitity-types/movable-entity.d.ts +6 -6
  58. package/dist/physics/entitity-types/movable-entity.js +21 -22
  59. package/dist/physics/entitity-types/movable-physics-entity.d.ts +14 -14
  60. package/dist/physics/entitity-types/movable-physics-entity.js +83 -88
  61. package/dist/physics/entitity-types/physics-entity.d.ts +23 -23
  62. package/dist/physics/entitity-types/physics-entity.js +97 -88
  63. package/dist/physics/helpers/closest-available-space.helper.d.ts +16 -16
  64. package/dist/physics/helpers/closest-available-space.helper.js +98 -96
  65. package/dist/physics/helpers/closest-available-space.helper.spec.js +115 -68
  66. package/dist/physics/helpers/p2js.helper.d.ts +3 -3
  67. package/dist/physics/helpers/p2js.helper.js +21 -22
  68. package/dist/physics/helpers/shape-factory.d.ts +9 -4
  69. package/dist/physics/helpers/shape-factory.js +99 -75
  70. package/dist/physics/libs/p2js.helper.js +1 -1
  71. package/dist/physics/libs/position-to-grid-position-converter.d.ts +3 -3
  72. package/dist/physics/libs/position-to-grid-position-converter.js +15 -13
  73. package/dist/physics/module//360/237/223/220services/availability-grid.service.d.ts +10 -5
  74. package/dist/physics/module//360/237/223/220services/availability-grid.service.js +77 -57
  75. package/dist/physics/module//360/237/223/220services/border.service.d.ts +2 -2
  76. package/dist/physics/module//360/237/223/220services/border.service.js +57 -37
  77. package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +1 -1
  78. package/dist/physics/module//360/237/223/220services/collisions.service.d.ts +7 -7
  79. package/dist/physics/module//360/237/223/220services/collisions.service.js +110 -98
  80. package/dist/physics/module//360/237/223/220services/debug-visuals.service.d.ts +28 -6
  81. package/dist/physics/module//360/237/223/220services/debug-visuals.service.js +121 -89
  82. package/dist/physics/module//360/237/223/220services/eliptic-explosion.service.d.ts +15 -7
  83. package/dist/physics/module//360/237/223/220services/eliptic-explosion.service.js +117 -93
  84. package/dist/physics/module//360/237/223/220services/explosion.service.d.ts +14 -7
  85. package/dist/physics/module//360/237/223/220services/explosion.service.js +102 -77
  86. package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.d.ts +15 -7
  87. package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.js +117 -93
  88. package/dist/physics/module//360/237/223/220services/explosions/explosion.service.d.ts +14 -7
  89. package/dist/physics/module//360/237/223/220services/explosions/explosion.service.js +102 -77
  90. package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.d.ts +3 -3
  91. package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.js +71 -67
  92. package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.d.ts +3 -3
  93. package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.js +71 -67
  94. package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +1 -1
  95. package/dist/physics/module//360/237/223/220services/materials.service.d.ts +16 -11
  96. package/dist/physics/module//360/237/223/220services/materials.service.js +118 -108
  97. package/dist/physics/module//360/237/223/220services/path-finder.service.d.ts +19 -8
  98. package/dist/physics/module//360/237/223/220services/path-finder.service.js +121 -82
  99. package/dist/physics/module//360/237/223/220services/physics-world.service.d.ts +30 -15
  100. package/dist/physics/module//360/237/223/220services/physics-world.service.js +122 -100
  101. package/dist/physics/module//360/237/223/220services/ray-casting.service.d.ts +3 -3
  102. package/dist/physics/module//360/237/223/220services/ray-casting.service.js +87 -86
  103. package/dist/physics/module//360/237/223/220services/shape-creation.service.d.ts +9 -4
  104. package/dist/physics/module//360/237/223/220services/shape-creation.service.js +113 -84
  105. package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +2 -1
  106. package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.d.ts +8 -8
  107. package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.js +32 -33
  108. package/dist/physics/physics-world.d.ts +50 -34
  109. package/dist/physics/physics-world.js +142 -133
  110. package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.d.ts +3 -3
  111. package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.js +15 -13
  112. package/dist/physics/sub-elements/available-spaces/physics-availability-grid.d.ts +9 -9
  113. package/dist/physics/sub-elements/available-spaces/physics-availability-grid.js +82 -77
  114. package/dist/physics/sub-elements/available-spaces/physics-available-spaces.d.ts +18 -14
  115. package/dist/physics/sub-elements/available-spaces/physics-available-spaces.js +91 -79
  116. package/dist/physics/sub-elements/collisions/contact-equation-orginiser.d.ts +11 -11
  117. package/dist/physics/sub-elements/collisions/contact-equation-orginiser.js +84 -76
  118. package/dist/physics/sub-elements/collisions/physics-collision.d.ts +7 -7
  119. package/dist/physics/sub-elements/collisions/physics-collision.js +43 -44
  120. package/dist/physics/sub-elements/elements/physics-body-groups.d.ts +11 -11
  121. package/dist/physics/sub-elements/elements/physics-body-groups.js +54 -54
  122. package/dist/physics/sub-elements/elements/physics-materials.d.ts +15 -10
  123. package/dist/physics/sub-elements/elements/physics-materials.js +101 -100
  124. package/dist/physics/sub-elements/elements/physics-world-borders.d.ts +3 -3
  125. package/dist/physics/sub-elements/elements/physics-world-borders.js +69 -45
  126. package/dist/physics/sub-elements/physics-body-groups.d.ts +8 -8
  127. package/dist/physics/sub-elements/physics-body-groups.js +41 -42
  128. package/dist/physics/sub-elements/physics-collision.d.ts +16 -16
  129. package/dist/physics/sub-elements/physics-collision.js +141 -121
  130. package/dist/physics/sub-elements/physics-materials.d.ts +15 -10
  131. package/dist/physics/sub-elements/physics-materials.js +101 -100
  132. package/dist/physics/sub-elements/physics-world-borders.d.ts +2 -2
  133. package/dist/physics/sub-elements/physics-world-borders.js +25 -26
  134. package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.d.ts +15 -11
  135. package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.js +59 -59
  136. package/dist/physics/sub-elements/raycasting/physics-explosion.d.ts +13 -6
  137. package/dist/physics/sub-elements/raycasting/physics-explosion.js +108 -73
  138. package/dist/physics/sub-elements/raycasting/ray-cast.d.ts +19 -19
  139. package/dist/physics/sub-elements/raycasting/ray-cast.js +93 -98
  140. package/dist/pixi/display-object/components/filters.d.ts +18 -18
  141. package/dist/pixi/display-object/components/filters.js +106 -81
  142. package/dist/pixi/display-object/components/glow-effect.d.ts +8 -8
  143. package/dist/pixi/display-object/components/glow-effect.js +33 -36
  144. package/dist/pixi/display-object/components/glow-filter.d.ts +8 -8
  145. package/dist/pixi/display-object/components/glow-filter.js +33 -36
  146. package/dist/pixi/display-object/container-attributes.js +1 -1
  147. package/dist/pixi/display-object/display-object-attributes.d.ts +41 -41
  148. package/dist/pixi/display-object/display-object-attributes.js +148 -150
  149. package/dist/pixi/display-object/display-object.d.ts +17 -17
  150. package/dist/pixi/display-object/display-object.js +79 -75
  151. package/dist/pixi/display-object/filters/base-filters/alpha-primer-color.filter.d.ts +9 -4
  152. package/dist/pixi/display-object/filters/base-filters/alpha-primer-color.filter.js +89 -77
  153. package/dist/pixi/display-object/filters/base-filters/blur.filter.js +30 -30
  154. package/dist/pixi/display-object/filters/base-filters/contrast-filter.d.ts +9 -4
  155. package/dist/pixi/display-object/filters/base-filters/contrast-filter.js +62 -53
  156. package/dist/pixi/display-object/filters/base-filters/expand-with-alpha-color.d.ts +10 -5
  157. package/dist/pixi/display-object/filters/base-filters/expand-with-alpha-color.js +93 -81
  158. package/dist/pixi/display-object/filters/base-filters/expand-with-color-gradient.d.ts +12 -7
  159. package/dist/pixi/display-object/filters/base-filters/expand-with-color-gradient.js +120 -109
  160. package/dist/pixi/display-object/filters/base-filters/expand-with-color.d.ts +10 -5
  161. package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +32 -32
  162. package/dist/pixi/display-object/filters/base-filters/expand-with-color.js +92 -85
  163. package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +28 -28
  164. package/dist/pixi/display-object/filters/templates/plane.template.js +20 -20
  165. package/dist/pixi/display-object/filters.js +20 -4
  166. package/dist/pixi/display-object/objects/components/filters.d.ts +18 -18
  167. package/dist/pixi/display-object/objects/components/filters.js +106 -81
  168. package/dist/pixi/display-object/objects/container.d.ts +2 -2
  169. package/dist/pixi/display-object/objects/container.js +39 -30
  170. package/dist/pixi/display-object/objects/graphics.d.ts +28 -28
  171. package/dist/pixi/display-object/objects/graphics.js +218 -202
  172. package/dist/pixi/display-object/objects/helpers/filters.d.ts +25 -25
  173. package/dist/pixi/display-object/objects/helpers/filters.js +150 -124
  174. package/dist/pixi/display-object/objects/helpers/glow-sprite-generator.d.ts +7 -7
  175. package/dist/pixi/display-object/objects/helpers/glow-sprite-generator.js +114 -95
  176. package/dist/pixi/display-object/objects/premade-objects/sprite-with-glowing-shapes.d.ts +5 -5
  177. package/dist/pixi/display-object/objects/premade-objects/sprite-with-glowing-shapes.js +81 -57
  178. package/dist/pixi/display-object/objects/sprite.d.ts +43 -43
  179. package/dist/pixi/display-object/objects/sprite.js +248 -233
  180. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +1 -1
  181. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +9 -9
  182. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +1 -1
  183. package/dist/pixi/display-object/objects/text.d.ts +25 -25
  184. package/dist/pixi/display-object/objects/text.js +111 -102
  185. package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.d.ts +13 -9
  186. package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.js +96 -67
  187. package/dist/pixi/game.d.ts +1 -1
  188. package/dist/pixi/game.js +2 -2
  189. package/dist/pixi/helpers/glow-sprite-generator.d.ts +6 -6
  190. package/dist/pixi/helpers/glow-sprite-generator.js +99 -84
  191. package/dist/pixi/helpers/pixi-container.helper.d.ts +1 -1
  192. package/dist/pixi/helpers/pixi-container.helper.js +10 -8
  193. package/dist/pixi/helpers/screen-position-to-stage.helper.d.ts +1 -1
  194. package/dist/pixi/helpers/screen-position-to-stage.helper.js +12 -12
  195. package/dist/pixi/helpers/screen-position-to-stage.helper.test.js +174 -79
  196. package/dist/pixi/modules/CAMERA/index.d.ts +1 -1
  197. package/dist/pixi/modules/CAMERA/index.js +3 -3
  198. package/dist/services/keyboard/keyboard.d.ts +4 -4
  199. package/dist/services/keyboard/keyboard.js +39 -31
  200. package/dist/services/mouse/mouse.service.d.ts +8 -8
  201. package/dist/services/mouse/mouse.service.js +65 -53
  202. package/dist/services/mouse/mouser-target-focus.service.d.ts +11 -11
  203. package/dist/services/mouse/mouser-target-focus.service.js +83 -81
  204. package/dist/utilities/libraries/animator/animating-content/state-animation.d.ts +29 -26
  205. package/dist/utilities/libraries/animator/animating-content/state-animation.js +159 -165
  206. package/dist/utilities/libraries/animator/animating-content/state-animation.test.js +386 -375
  207. package/dist/utilities/libraries/animator/animator.spec.js +765 -656
  208. package/dist/utilities/libraries/binary-heap/binary-heap.d.ts +11 -11
  209. package/dist/utilities/libraries/binary-heap/binary-heap.js +79 -81
  210. package/dist/utilities/libraries/data-structures/binary-heap/binary-heap.d.ts +11 -11
  211. package/dist/utilities/libraries/data-structures/binary-heap/binary-heap.js +79 -81
  212. package/dist/utilities/libraries/data-structures/grid/grid.d.ts +35 -31
  213. package/dist/utilities/libraries/data-structures/grid/grid.js +128 -117
  214. package/dist/utilities/libraries/data-structures/grid/grid.spec.js +176 -138
  215. package/dist/utilities/libraries/data-structures/grid/grid.test.js +218 -141
  216. package/dist/utilities/libraries/data-structures/grid/position-to-grid-position-converter.d.ts +3 -3
  217. package/dist/utilities/libraries/data-structures/grid/position-to-grid-position-converter.js +15 -13
  218. package/dist/utilities/libraries/data-structures/queue/queue.d.ts +21 -21
  219. package/dist/utilities/libraries/data-structures/queue/queue.js +63 -66
  220. package/dist/utilities/libraries/data-structures/queue/queue.test.js +54 -55
  221. package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.spec.js +122 -68
  222. package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.spec.js +140 -135
  223. package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.spec.js +293 -229
  224. package/dist/utilities/libraries/path-finder/path-finder.d.ts +7 -7
  225. package/dist/utilities/libraries/path-finder/path-finder.js +113 -109
  226. package/dist/utilities/libraries/path-finder/path-finder.spec.js +131 -106
  227. package/dist/utilities/services/keyboard/keyboard.d.ts +4 -4
  228. package/dist/utilities/services/keyboard/keyboard.js +42 -34
  229. package/dist/utilities/services/mouse/helpers/mouse-position.helper.d.ts +1 -1
  230. package/dist/utilities/services/mouse/helpers/mouse-position.helper.js +12 -12
  231. package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.js +168 -73
  232. package/dist/utilities/services/mouse/mouse-target-focus.service.d.ts +15 -15
  233. package/dist/utilities/services/mouse/mouse-target-focus.service.js +79 -76
  234. package/dist/utilities/services/mouse/mouse.service.d.ts +9 -9
  235. package/dist/utilities/services/mouse/mouse.service.js +86 -72
  236. package/dist/utilities/services/mouse/mouser-target-focus.service.d.ts +11 -11
  237. package/dist/utilities/services/mouse/mouser-target-focus.service.js +83 -81
  238. package/package.json +4 -10
@@ -1,58 +1,57 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const queue_1 = require("./queue");
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const vitest_1 = require('vitest');
3
+ const queue_1 = require('./queue');
5
4
  (0, vitest_1.describe)('Queue', () => {
6
- (0, vitest_1.describe)('Basic', () => {
7
- (0, vitest_1.test)('should return undefined when queue is empty', () => {
8
- let queue = new queue_1.Queue();
9
- (0, vitest_1.expect)(queue.pop()).toBe(undefined);
10
- });
11
- (0, vitest_1.test)('should return false when queue is not empty', () => {
12
- let queue = new queue_1.Queue(1);
13
- (0, vitest_1.expect)(queue.isEmpty).toBe(false);
14
- });
15
- (0, vitest_1.test)('should add elements to the queue', () => {
16
- let queue = new queue_1.Queue();
17
- queue.add(1, 2, 3);
18
- (0, vitest_1.expect)(queue.pop()).toBe(1);
19
- (0, vitest_1.expect)(queue.pop()).toBe(2);
20
- (0, vitest_1.expect)(queue.pop()).toBe(3);
21
- });
22
- (0, vitest_1.test)('should add elements to the queue with first element', () => {
23
- let queue = new queue_1.Queue(1);
24
- queue.add(2, 3);
25
- (0, vitest_1.expect)(queue.pop()).toBe(1);
26
- (0, vitest_1.expect)(queue.pop()).toBe(2);
27
- (0, vitest_1.expect)(queue.pop()).toBe(3);
28
- });
29
- (0, vitest_1.test)('peek should return the first element in the queue without removing it', () => {
30
- let queue = new queue_1.Queue(1);
31
- (0, vitest_1.expect)(queue.peek()).toBe(1);
32
- (0, vitest_1.expect)(queue.pop()).toBe(1);
33
- });
34
- });
35
- (0, vitest_1.describe)('Duplicate', () => {
36
- (0, vitest_1.test)('empty queue', () => {
37
- let queue = new queue_1.Queue();
38
- let duplicate = queue.duplicate();
39
- (0, vitest_1.expect)(duplicate.pop()).toBe(undefined);
40
- });
41
- (0, vitest_1.test)('queue with elements', () => {
42
- let queue = new queue_1.Queue(1);
43
- queue.add(2, 3);
44
- let duplicate = queue.duplicate();
45
- (0, vitest_1.expect)(duplicate.pop()).toBe(1);
46
- (0, vitest_1.expect)(duplicate.pop()).toBe(2);
47
- (0, vitest_1.expect)(duplicate.pop()).toBe(3);
48
- });
49
- (0, vitest_1.test)('duplicate with deep copy', () => {
50
- let queue = new queue_1.Queue({ value: 1 });
51
- let duplicate = queue.duplicate(item => ({ value: item.value }));
52
- (0, vitest_1.expect)(duplicate.peek()).toStrictEqual({ value: 1 });
53
- (0, vitest_1.expect)(queue.peek()).toStrictEqual({ value: 1 });
54
- (0, vitest_1.expect)(duplicate.peek() !== queue.peek()).toBeTruthy();
55
- });
5
+ (0, vitest_1.describe)('Basic', () => {
6
+ (0, vitest_1.test)('should return undefined when queue is empty', () => {
7
+ const queue = new queue_1.Queue();
8
+ (0, vitest_1.expect)(queue.pop()).toBe(undefined);
56
9
  });
10
+ (0, vitest_1.test)('should return false when queue is not empty', () => {
11
+ const queue = new queue_1.Queue(1);
12
+ (0, vitest_1.expect)(queue.isEmpty).toBe(false);
13
+ });
14
+ (0, vitest_1.test)('should add elements to the queue', () => {
15
+ const queue = new queue_1.Queue();
16
+ queue.add(1, 2, 3);
17
+ (0, vitest_1.expect)(queue.pop()).toBe(1);
18
+ (0, vitest_1.expect)(queue.pop()).toBe(2);
19
+ (0, vitest_1.expect)(queue.pop()).toBe(3);
20
+ });
21
+ (0, vitest_1.test)('should add elements to the queue with first element', () => {
22
+ const queue = new queue_1.Queue(1);
23
+ queue.add(2, 3);
24
+ (0, vitest_1.expect)(queue.pop()).toBe(1);
25
+ (0, vitest_1.expect)(queue.pop()).toBe(2);
26
+ (0, vitest_1.expect)(queue.pop()).toBe(3);
27
+ });
28
+ (0, vitest_1.test)('peek should return the first element in the queue without removing it', () => {
29
+ const queue = new queue_1.Queue(1);
30
+ (0, vitest_1.expect)(queue.peek()).toBe(1);
31
+ (0, vitest_1.expect)(queue.pop()).toBe(1);
32
+ });
33
+ });
34
+ (0, vitest_1.describe)('Duplicate', () => {
35
+ (0, vitest_1.test)('empty queue', () => {
36
+ const queue = new queue_1.Queue();
37
+ const duplicate = queue.duplicate();
38
+ (0, vitest_1.expect)(duplicate.pop()).toBe(undefined);
39
+ });
40
+ (0, vitest_1.test)('queue with elements', () => {
41
+ const queue = new queue_1.Queue(1);
42
+ queue.add(2, 3);
43
+ const duplicate = queue.duplicate();
44
+ (0, vitest_1.expect)(duplicate.pop()).toBe(1);
45
+ (0, vitest_1.expect)(duplicate.pop()).toBe(2);
46
+ (0, vitest_1.expect)(duplicate.pop()).toBe(3);
47
+ });
48
+ (0, vitest_1.test)('duplicate with deep copy', () => {
49
+ const queue = new queue_1.Queue({ value: 1 });
50
+ const duplicate = queue.duplicate(item => ({ value: item.value }));
51
+ (0, vitest_1.expect)(duplicate.peek()).toStrictEqual({ value: 1 });
52
+ (0, vitest_1.expect)(queue.peek()).toStrictEqual({ value: 1 });
53
+ (0, vitest_1.expect)(duplicate.peek() !== queue.peek()).toBeTruthy();
54
+ });
55
+ });
57
56
  });
58
- //# sourceMappingURL=queue.test.js.map
57
+ //# sourceMappingURL=queue.test.js.map
@@ -1,70 +1,124 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const closest_available_space_helper_1 = require("./closest-available-space.helper");
5
- const grid_1 = require("../../data-structures/grid/grid");
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const vitest_1 = require('vitest');
3
+ const closest_available_space_helper_1 = require('./closest-available-space.helper');
4
+ const grid_1 = require('../../data-structures/grid/grid');
6
5
  (0, vitest_1.describe)('findClosestAvailableSpace', () => {
7
- let grid;
8
- (0, vitest_1.beforeEach)(() => {
9
- grid = grid_1.Grid.createNew({ x: 10, y: 10 }, true);
10
- });
11
- (0, vitest_1.test)('should return no change vector if the location is available', () => {
12
- let boundingBox = { topLeft: { x: 50, y: 50 }, bottomRight: { x: 60, y: 60 } };
13
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: 0, y: 0 });
14
- });
15
- (0, vitest_1.test)('should support object positions outside of the world size', () => {
16
- let boundingBox = { topLeft: { x: -5, y: -5 }, bottomRight: { x: 5, y: 5 } };
17
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: 5, y: 5 });
18
- boundingBox = { topLeft: { x: -5, y: -5 }, bottomRight: { x: 15, y: 15 } };
19
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: 5, y: 5 });
20
- boundingBox = { topLeft: { x: 95, y: 95 }, bottomRight: { x: 105, y: 105 } };
21
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: -5, y: -5 });
22
- boundingBox = { topLeft: { x: 85, y: 85 }, bottomRight: { x: 105, y: 105 } };
23
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: -5, y: -5 });
24
- });
25
- (0, vitest_1.test)('should find the no change vector space next to an existing object', () => {
26
- grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } }, false);
27
- let boundingBox = { topLeft: { x: 10, y: 10 }, bottomRight: { x: 20, y: 20 } };
28
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: 0, y: 0 });
29
- });
30
- (0, vitest_1.test)('should find the closest available space if trying to spawn in occupied space', () => {
31
- grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 1, y: 1 } }, false);
32
- let boundingBox = { topLeft: { x: 5, y: 5 }, bottomRight: { x: 15, y: 15 } };
33
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: -5, y: 15 });
34
- });
35
- (0, vitest_1.test)('should find the closest available space if trying to spawn in crowded space', () => {
36
- // Crowded space
37
- // 0 1 2 3 4 5 6 7 8 9
38
- // 0 □ 1 1 1 2 2 □ □ □ □
39
- // 1 □ 1 1 1 2 2 □ □ □ □
40
- // 2 □ 1 1 1 2 2 □ □ □ □
41
- // 3 3 3 3 ■ ■ ■ □ □ □ □
42
- // 4 □ □ □ ■ ■ ■ □ □ □ □
43
- // 5 4 ■ ■ 6 6 6 □
44
- // 6 4 5 5 5 □ □ □ □
45
- grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 3, y: 2 } }, false); // 1
46
- grid.setArea({ topLeft: { x: 4, y: 0 }, bottomRight: { x: 5, y: 2 } }, false); // 2
47
- grid.setArea({ topLeft: { x: 0, y: 3 }, bottomRight: { x: 1, y: 3 } }, false); // 3
48
- grid.setArea({ topLeft: { x: 2, y: 5 }, bottomRight: { x: 2, y: 6 } }, false); // 4
49
- grid.setArea({ topLeft: { x: 3, y: 6 }, bottomRight: { x: 5, y: 6 } }, false); // 5
50
- grid.setArea({ topLeft: { x: 6, y: 5 }, bottomRight: { x: 8, y: 5 } }, false); // 6
51
- let boundingBox = { topLeft: { x: 10, y: 20 }, bottomRight: { x: 40, y: 50 } };
52
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: 20, y: 10 });
53
- });
54
- (0, vitest_1.test)('should not fooled by initial position occupying more space in grid and find narrower gap 1', () => {
55
- grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 4, y: 3 } }, false);
56
- let boundingBox = { topLeft: { x: 4, y: 2 }, bottomRight: { x: 12, y: 20 } };
57
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: -3, y: -1 });
58
- });
59
- (0, vitest_1.test)('should not fooled by initial position occupying more space in grid and find narrower gap 2', () => {
60
- grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 4, y: 3 } }, false);
61
- let boundingBox = { topLeft: { x: -6, y: -8 }, bottomRight: { x: 2, y: 10 } };
62
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toEqual({ x: 7, y: 9 });
63
- });
64
- (0, vitest_1.test)('should return undefined if there is no available space', () => {
65
- grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 9, y: 9 } }, false);
66
- let boundingBox = { topLeft: { x: 0, y: 0 }, bottomRight: { x: 10, y: 10 } };
67
- (0, vitest_1.expect)(closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)).toBeUndefined();
68
- });
6
+ let grid;
7
+ (0, vitest_1.beforeEach)(() => {
8
+ grid = grid_1.Grid.createNew({ x: 10, y: 10 }, true);
9
+ });
10
+ (0, vitest_1.test)('should return no change vector if the location is available', () => {
11
+ const boundingBox = {
12
+ topLeft: { x: 50, y: 50 },
13
+ bottomRight: { x: 60, y: 60 }
14
+ };
15
+ (0, vitest_1.expect)(
16
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
17
+ ).toEqual({ x: 0, y: 0 });
18
+ });
19
+ (0, vitest_1.test)('should support object positions outside of the world size', () => {
20
+ let boundingBox = {
21
+ topLeft: { x: -5, y: -5 },
22
+ bottomRight: { x: 5, y: 5 }
23
+ };
24
+ (0, vitest_1.expect)(
25
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
26
+ ).toEqual({ x: 5, y: 5 });
27
+ boundingBox = {
28
+ topLeft: { x: -5, y: -5 },
29
+ bottomRight: { x: 15, y: 15 }
30
+ };
31
+ (0, vitest_1.expect)(
32
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
33
+ ).toEqual({ x: 5, y: 5 });
34
+ boundingBox = {
35
+ topLeft: { x: 95, y: 95 },
36
+ bottomRight: { x: 105, y: 105 }
37
+ };
38
+ (0, vitest_1.expect)(
39
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
40
+ ).toEqual({ x: -5, y: -5 });
41
+ boundingBox = {
42
+ topLeft: { x: 85, y: 85 },
43
+ bottomRight: { x: 105, y: 105 }
44
+ };
45
+ (0, vitest_1.expect)(
46
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
47
+ ).toEqual({ x: -5, y: -5 });
48
+ });
49
+ (0, vitest_1.test)('should find the no change vector space next to an existing object', () => {
50
+ grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } }, false);
51
+ const boundingBox = {
52
+ topLeft: { x: 10, y: 10 },
53
+ bottomRight: { x: 20, y: 20 }
54
+ };
55
+ (0, vitest_1.expect)(
56
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
57
+ ).toEqual({ x: 0, y: 0 });
58
+ });
59
+ (0, vitest_1.test)('should find the closest available space if trying to spawn in occupied space', () => {
60
+ grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 1, y: 1 } }, false);
61
+ const boundingBox = {
62
+ topLeft: { x: 5, y: 5 },
63
+ bottomRight: { x: 15, y: 15 }
64
+ };
65
+ (0, vitest_1.expect)(
66
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
67
+ ).toEqual({ x: -5, y: 15 });
68
+ });
69
+ (0, vitest_1.test)('should find the closest available space if trying to spawn in crowded space', () => {
70
+ // Crowded space
71
+ // 0 1 2 3 4 5 6 7 8 9
72
+ // 0 □ 1 1 1 2 2 □ □ □ □
73
+ // 1 □ 1 1 1 2 2 □ □ □ □
74
+ // 2 □ 1 1 1 2 2 □ □ □ □
75
+ // 3 3 3 3 ■ ■ ■ □ □ □ □
76
+ // 4 □ □ □ ■ ■ ■ □ □ □ □
77
+ // 5 □ □ 4 ■ ■ ■ 6 6 6 □
78
+ // 6 □ □ 4 5 5 5 □ □ □ □
79
+ grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 3, y: 2 } }, false); // 1
80
+ grid.setArea({ topLeft: { x: 4, y: 0 }, bottomRight: { x: 5, y: 2 } }, false); // 2
81
+ grid.setArea({ topLeft: { x: 0, y: 3 }, bottomRight: { x: 1, y: 3 } }, false); // 3
82
+ grid.setArea({ topLeft: { x: 2, y: 5 }, bottomRight: { x: 2, y: 6 } }, false); // 4
83
+ grid.setArea({ topLeft: { x: 3, y: 6 }, bottomRight: { x: 5, y: 6 } }, false); // 5
84
+ grid.setArea({ topLeft: { x: 6, y: 5 }, bottomRight: { x: 8, y: 5 } }, false); // 6
85
+ const boundingBox = {
86
+ topLeft: { x: 10, y: 20 },
87
+ bottomRight: { x: 40, y: 50 }
88
+ };
89
+ (0, vitest_1.expect)(
90
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
91
+ ).toEqual({ x: 20, y: 10 });
92
+ });
93
+ (0, vitest_1.test)('should not fooled by initial position occupying more space in grid and find narrower gap 1', () => {
94
+ grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 4, y: 3 } }, false);
95
+ const boundingBox = {
96
+ topLeft: { x: 4, y: 2 },
97
+ bottomRight: { x: 12, y: 20 }
98
+ };
99
+ (0, vitest_1.expect)(
100
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
101
+ ).toEqual({ x: -3, y: -1 });
102
+ });
103
+ (0, vitest_1.test)('should not fooled by initial position occupying more space in grid and find narrower gap 2', () => {
104
+ grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 4, y: 3 } }, false);
105
+ const boundingBox = {
106
+ topLeft: { x: -6, y: -8 },
107
+ bottomRight: { x: 2, y: 10 }
108
+ };
109
+ (0, vitest_1.expect)(
110
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
111
+ ).toEqual({ x: 7, y: 9 });
112
+ });
113
+ (0, vitest_1.test)('should return undefined if there is no available space', () => {
114
+ grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 9, y: 9 } }, false);
115
+ const boundingBox = {
116
+ topLeft: { x: 0, y: 0 },
117
+ bottomRight: { x: 10, y: 10 }
118
+ };
119
+ (0, vitest_1.expect)(
120
+ closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
121
+ ).toBeUndefined();
122
+ });
69
123
  });
70
- //# sourceMappingURL=closest-available-space.helper.spec.js.map
124
+ //# sourceMappingURL=closest-available-space.helper.spec.js.map
@@ -1,146 +1,151 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const grid_1 = require("../../data-structures/grid/grid");
5
- const path_finder_1 = require("./path-finder");
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const vitest_1 = require('vitest');
3
+ const grid_1 = require('../../data-structures/grid/grid');
4
+ const path_finder_1 = require('./path-finder');
6
5
  (0, vitest_1.describe)('PATH_FINDER', () => {
7
- (0, vitest_1.test)('basic 1', () => {
8
- let grid = grid_1.Grid.createByValues([[true]]);
9
- let result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 0, y: 0 }, { includeDiagonals: true });
10
- (0, vitest_1.expect)(result).toEqual({ directPathAvailable: true, path: [{ x: 0, y: 0 }] });
6
+ (0, vitest_1.test)('basic 1', () => {
7
+ const grid = grid_1.Grid.createByValues([[true]]);
8
+ const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 0, y: 0 }, { includeDiagonals: true });
9
+ (0, vitest_1.expect)(result).toEqual({
10
+ directPathAvailable: true,
11
+ path: [{ x: 0, y: 0 }]
11
12
  });
12
- (0, vitest_1.test)('basic 2', () => {
13
- let grid = grid_1.Grid.createByValues([[false]]);
14
- let result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 0, y: 0 }, { includeDiagonals: true });
15
- (0, vitest_1.expect)(result).toEqual({ directPathAvailable: true, path: [{ x: 0, y: 0 }] });
13
+ });
14
+ (0, vitest_1.test)('basic 2', () => {
15
+ const grid = grid_1.Grid.createByValues([[false]]);
16
+ const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 0, y: 0 }, { includeDiagonals: true });
17
+ (0, vitest_1.expect)(result).toEqual({
18
+ directPathAvailable: true,
19
+ path: [{ x: 0, y: 0 }]
16
20
  });
17
- (0, vitest_1.test)('should give the shortest path without diagonals', () => {
18
- let grid = grid_1.Grid.createByValues([
19
- [true, true, true, true],
20
- [true, false, false, true],
21
- [true, false, false, true],
22
- [true, false, false, true]
23
- ]);
24
- let result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: false });
25
- (0, vitest_1.expect)(result).toEqual({
26
- directPathAvailable: true,
27
- path: [
28
- { x: 0, y: 0 },
29
- { x: 1, y: 0 },
30
- { x: 2, y: 0 },
31
- { x: 3, y: 0 },
32
- { x: 3, y: 1 },
33
- { x: 3, y: 2 },
34
- { x: 3, y: 3 }
35
- ]
36
- });
21
+ });
22
+ (0, vitest_1.test)('should give the shortest path without diagonals', () => {
23
+ const grid = grid_1.Grid.createByValues([
24
+ [true, true, true, true],
25
+ [true, false, false, true],
26
+ [true, false, false, true],
27
+ [true, false, false, true]
28
+ ]);
29
+ const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: false });
30
+ (0, vitest_1.expect)(result).toEqual({
31
+ directPathAvailable: true,
32
+ path: [
33
+ { x: 0, y: 0 },
34
+ { x: 1, y: 0 },
35
+ { x: 2, y: 0 },
36
+ { x: 3, y: 0 },
37
+ { x: 3, y: 1 },
38
+ { x: 3, y: 2 },
39
+ { x: 3, y: 3 }
40
+ ]
37
41
  });
38
- (0, vitest_1.test)('should give the shortest path 1', () => {
39
- let grid = grid_1.Grid.createByValues([
40
- [true, true, true, true],
41
- [true, false, false, true],
42
- [true, false, false, true],
43
- [true, false, false, true]
44
- ]);
45
- let result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
46
- (0, vitest_1.expect)(result).toEqual({
47
- directPathAvailable: true,
48
- path: [
49
- { x: 0, y: 0 },
50
- { x: 1, y: 0 },
51
- { x: 2, y: 0 },
52
- { x: 3, y: 1 },
53
- { x: 3, y: 2 },
54
- { x: 3, y: 3 }
55
- ]
56
- });
42
+ });
43
+ (0, vitest_1.test)('should give the shortest path 1', () => {
44
+ const grid = grid_1.Grid.createByValues([
45
+ [true, true, true, true],
46
+ [true, false, false, true],
47
+ [true, false, false, true],
48
+ [true, false, false, true]
49
+ ]);
50
+ const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
51
+ (0, vitest_1.expect)(result).toEqual({
52
+ directPathAvailable: true,
53
+ path: [
54
+ { x: 0, y: 0 },
55
+ { x: 1, y: 0 },
56
+ { x: 2, y: 0 },
57
+ { x: 3, y: 1 },
58
+ { x: 3, y: 2 },
59
+ { x: 3, y: 3 }
60
+ ]
57
61
  });
58
- (0, vitest_1.test)('should give the shortest path 2', () => {
59
- let grid = grid_1.Grid.createByValues([
60
- [true, true, true, false],
61
- [true, false, false, false],
62
- [true, true, false, true],
63
- [true, false, true, true]
64
- ]);
65
- let result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
66
- (0, vitest_1.expect)(result).toEqual({
67
- directPathAvailable: true,
68
- path: [
69
- { x: 0, y: 0 },
70
- { x: 0, y: 1 },
71
- { x: 1, y: 2 },
72
- { x: 2, y: 3 },
73
- { x: 3, y: 3 }
74
- ]
75
- });
62
+ });
63
+ (0, vitest_1.test)('should give the shortest path 2', () => {
64
+ const grid = grid_1.Grid.createByValues([
65
+ [true, true, true, false],
66
+ [true, false, false, false],
67
+ [true, true, false, true],
68
+ [true, false, true, true]
69
+ ]);
70
+ const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
71
+ (0, vitest_1.expect)(result).toEqual({
72
+ directPathAvailable: true,
73
+ path: [
74
+ { x: 0, y: 0 },
75
+ { x: 0, y: 1 },
76
+ { x: 1, y: 2 },
77
+ { x: 2, y: 3 },
78
+ { x: 3, y: 3 }
79
+ ]
76
80
  });
77
- (0, vitest_1.test)('should give the shortest path 3', () => {
78
- let grid = grid_1.Grid.createByValues([
79
- [true, false, false, true, false],
80
- [true, false, true, false, true],
81
- [true, false, true, false, true],
82
- [false, true, false, false, true]
83
- ]);
84
- let result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 4, y: 3 }, { includeDiagonals: true });
85
- (0, vitest_1.expect)(result).toEqual({
86
- directPathAvailable: true,
87
- path: [
88
- { x: 0, y: 0 },
89
- { x: 0, y: 1 },
90
- { x: 0, y: 2 },
91
- { x: 1, y: 3 },
92
- { x: 2, y: 2 },
93
- { x: 2, y: 1 },
94
- { x: 3, y: 0 },
95
- { x: 4, y: 1 },
96
- { x: 4, y: 2 },
97
- { x: 4, y: 3 }
98
- ]
99
- });
81
+ });
82
+ (0, vitest_1.test)('should give the shortest path 3', () => {
83
+ const grid = grid_1.Grid.createByValues([
84
+ [true, false, false, true, false],
85
+ [true, false, true, false, true],
86
+ [true, false, true, false, true],
87
+ [false, true, false, false, true]
88
+ ]);
89
+ const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 4, y: 3 }, { includeDiagonals: true });
90
+ (0, vitest_1.expect)(result).toEqual({
91
+ directPathAvailable: true,
92
+ path: [
93
+ { x: 0, y: 0 },
94
+ { x: 0, y: 1 },
95
+ { x: 0, y: 2 },
96
+ { x: 1, y: 3 },
97
+ { x: 2, y: 2 },
98
+ { x: 2, y: 1 },
99
+ { x: 3, y: 0 },
100
+ { x: 4, y: 1 },
101
+ { x: 4, y: 2 },
102
+ { x: 4, y: 3 }
103
+ ]
100
104
  });
101
- (0, vitest_1.test)('should give the shortest path backwards 3', () => {
102
- let grid = grid_1.Grid.createByValues([
103
- [true, false, false, true, false],
104
- [true, false, true, false, true],
105
- [true, false, true, false, true],
106
- [false, true, false, false, true]
107
- ]);
108
- let result = path_finder_1.PathFinder.findPath(grid, { x: 4, y: 3 }, { x: 0, y: 0 }, { includeDiagonals: true });
109
- (0, vitest_1.expect)(result).toEqual({
110
- directPathAvailable: true,
111
- path: [
112
- { x: 4, y: 3 },
113
- { x: 4, y: 2 },
114
- { x: 4, y: 1 },
115
- { x: 3, y: 0 },
116
- { x: 2, y: 1 },
117
- { x: 2, y: 2 },
118
- { x: 1, y: 3 },
119
- { x: 0, y: 2 },
120
- { x: 0, y: 1 },
121
- { x: 0, y: 0 }
122
- ]
123
- });
105
+ });
106
+ (0, vitest_1.test)('should give the shortest path backwards 3', () => {
107
+ const grid = grid_1.Grid.createByValues([
108
+ [true, false, false, true, false],
109
+ [true, false, true, false, true],
110
+ [true, false, true, false, true],
111
+ [false, true, false, false, true]
112
+ ]);
113
+ const result = path_finder_1.PathFinder.findPath(grid, { x: 4, y: 3 }, { x: 0, y: 0 }, { includeDiagonals: true });
114
+ (0, vitest_1.expect)(result).toEqual({
115
+ directPathAvailable: true,
116
+ path: [
117
+ { x: 4, y: 3 },
118
+ { x: 4, y: 2 },
119
+ { x: 4, y: 1 },
120
+ { x: 3, y: 0 },
121
+ { x: 2, y: 1 },
122
+ { x: 2, y: 2 },
123
+ { x: 1, y: 3 },
124
+ { x: 0, y: 2 },
125
+ { x: 0, y: 1 },
126
+ { x: 0, y: 0 }
127
+ ]
124
128
  });
125
- (0, vitest_1.test)('should give the shortest path to closest position', () => {
126
- let grid = grid_1.Grid.createByValues([
127
- [true, true, true, false],
128
- [true, false, false, false],
129
- [true, false, false, false],
130
- [true, true, false, true]
131
- ]);
132
- let result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
133
- (0, vitest_1.expect)(result).toEqual({
134
- directPathAvailable: false,
135
- path: [
136
- { x: 0, y: 0 },
137
- { x: 0, y: 1 },
138
- { x: 0, y: 2 },
139
- { x: 1, y: 3 }
140
- ]
141
- });
129
+ });
130
+ (0, vitest_1.test)('should give the shortest path to closest position', () => {
131
+ const grid = grid_1.Grid.createByValues([
132
+ [true, true, true, false],
133
+ [true, false, false, false],
134
+ [true, false, false, false],
135
+ [true, true, false, true]
136
+ ]);
137
+ const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
138
+ (0, vitest_1.expect)(result).toEqual({
139
+ directPathAvailable: false,
140
+ path: [
141
+ { x: 0, y: 0 },
142
+ { x: 0, y: 1 },
143
+ { x: 0, y: 2 },
144
+ { x: 1, y: 3 }
145
+ ]
142
146
  });
143
- /*
147
+ });
148
+ /*
144
149
  test('stress test', () => {
145
150
  let size = 800;
146
151
  let centerPos = { x: Math.floor(size / 2), y: Math.floor(size / 2) };
@@ -161,4 +166,4 @@ const path_finder_1 = require("./path-finder");
161
166
  console.info(end.getTime() - start.getTime());
162
167
  });*/
163
168
  });
164
- //# sourceMappingURL=path-finder.spec.js.map
169
+ //# sourceMappingURL=path-finder.spec.js.map