warscript 0.0.1-dev.85b1c63 → 0.0.1-dev.870376f

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 (95) hide show
  1. package/attributes.d.ts +1 -0
  2. package/attributes.lua +9 -0
  3. package/core/types/frame.lua +14 -9
  4. package/core/types/player.d.ts +16 -0
  5. package/core/types/player.lua +57 -14
  6. package/core/types/playerCamera.lua +44 -0
  7. package/core/types/tileCell.d.ts +11 -1
  8. package/core/types/tileCell.lua +97 -0
  9. package/core/types/timer.d.ts +3 -2
  10. package/core/types/timer.lua +8 -2
  11. package/decl/native.d.ts +2 -2
  12. package/destroyable.d.ts +1 -0
  13. package/destroyable.lua +9 -0
  14. package/engine/behavior.d.ts +11 -2
  15. package/engine/behavior.lua +174 -71
  16. package/engine/behaviour/ability/apply-buff.lua +4 -4
  17. package/engine/behaviour/ability/remove-buffs.d.ts +9 -0
  18. package/engine/behaviour/ability/remove-buffs.lua +21 -0
  19. package/engine/behaviour/ability.d.ts +6 -1
  20. package/engine/behaviour/ability.lua +31 -1
  21. package/engine/behaviour/unit/stun-immunity.d.ts +9 -5
  22. package/engine/behaviour/unit/stun-immunity.lua +17 -7
  23. package/engine/behaviour/unit.d.ts +9 -3
  24. package/engine/behaviour/unit.lua +108 -26
  25. package/engine/buff.d.ts +19 -4
  26. package/engine/buff.lua +122 -41
  27. package/engine/internal/ability.lua +6 -5
  28. package/engine/internal/item.d.ts +13 -15
  29. package/engine/internal/item.lua +59 -48
  30. package/engine/internal/mechanics/cast-ability.lua +6 -3
  31. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
  32. package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
  33. package/engine/internal/unit/ability.d.ts +14 -14
  34. package/engine/internal/unit/ability.lua +72 -45
  35. package/engine/internal/unit/attributes.d.ts +17 -0
  36. package/engine/internal/unit/attributes.lua +46 -0
  37. package/engine/internal/unit/bonus.d.ts +2 -0
  38. package/engine/internal/unit/bonus.lua +10 -0
  39. package/engine/internal/unit/fly-height.d.ts +7 -0
  40. package/engine/internal/unit/fly-height.lua +20 -0
  41. package/engine/internal/unit/interrupts.d.ts +12 -0
  42. package/engine/internal/unit/interrupts.lua +28 -0
  43. package/engine/internal/unit/main-selected.lua +12 -27
  44. package/engine/internal/unit/range-event.d.ts +12 -0
  45. package/engine/internal/unit/range-event.lua +90 -0
  46. package/engine/internal/unit/scale.d.ts +7 -0
  47. package/engine/internal/unit/scale.lua +20 -0
  48. package/engine/internal/unit-missile-launch.lua +51 -20
  49. package/engine/internal/unit.d.ts +17 -21
  50. package/engine/internal/unit.lua +166 -188
  51. package/engine/local-client.d.ts +2 -0
  52. package/engine/local-client.lua +30 -0
  53. package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
  54. package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
  55. package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
  56. package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
  57. package/engine/object-data/entry/ability-type/reincarnation.d.ts +8 -0
  58. package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
  59. package/engine/object-data/entry/ability-type.lua +4 -1
  60. package/engine/object-data/entry/destructible-type.d.ts +27 -1
  61. package/engine/object-data/entry/destructible-type.lua +155 -0
  62. package/engine/object-data/entry/unit-type.d.ts +4 -0
  63. package/engine/object-data/entry/unit-type.lua +76 -32
  64. package/engine/object-field/unit.d.ts +20 -5
  65. package/engine/object-field/unit.lua +61 -0
  66. package/engine/object-field.d.ts +9 -1
  67. package/engine/object-field.lua +265 -122
  68. package/engine/random.d.ts +10 -0
  69. package/engine/random.lua +21 -0
  70. package/engine/standard/fields/ability.d.ts +2 -2
  71. package/engine/standard/fields/ability.lua +2 -2
  72. package/engine/standard/fields/unit.d.ts +11 -3
  73. package/engine/standard/fields/unit.lua +15 -2
  74. package/engine/synchronization.d.ts +11 -0
  75. package/engine/synchronization.lua +77 -0
  76. package/engine/text-tag.lua +3 -2
  77. package/engine/unit.d.ts +5 -0
  78. package/engine/unit.lua +5 -0
  79. package/net/socket.lua +1 -1
  80. package/objutil/buff.lua +10 -8
  81. package/package.json +2 -2
  82. package/patch-lua.lua +15 -0
  83. package/patch-lualib.lua +1 -1
  84. package/utility/arrays.d.ts +1 -0
  85. package/utility/arrays.lua +8 -0
  86. package/utility/callback-array.d.ts +5 -1
  87. package/utility/callback-array.lua +16 -1
  88. package/utility/linked-map.d.ts +34 -0
  89. package/utility/linked-map.lua +101 -0
  90. package/utility/linked-set.d.ts +3 -1
  91. package/utility/linked-set.lua +40 -1
  92. package/utility/lua-maps.d.ts +11 -2
  93. package/utility/lua-maps.lua +33 -2
  94. package/utility/records.lua +20 -1
  95. package/utility/types.d.ts +3 -0
@@ -42,6 +42,23 @@ end
42
42
  function LinkedSet.prototype.last(self)
43
43
  return self.l
44
44
  end
45
+ function LinkedSet.prototype.pop(self)
46
+ local f = self.f
47
+ if f == nil then
48
+ return nil
49
+ end
50
+ local n = self.n
51
+ local next = n[f]
52
+ n[f] = nil
53
+ self.f = next
54
+ if next ~= nil then
55
+ self.p[next] = nil
56
+ else
57
+ self.l = nil
58
+ end
59
+ self.s = self.s - 1
60
+ return f
61
+ end
45
62
  function LinkedSet.prototype.next(self, key)
46
63
  return self.n[key]
47
64
  end
@@ -68,6 +85,23 @@ function LinkedSet.prototype.add(self, key)
68
85
  end
69
86
  return true
70
87
  end
88
+ function LinkedSet.prototype.addBefore(self, value, key)
89
+ local n = self.n
90
+ local p = self.p
91
+ local previous = p[value]
92
+ if previous ~= nil then
93
+ n[previous] = key
94
+ p[key] = previous
95
+ elseif value == self.f then
96
+ self.f = key
97
+ else
98
+ return false
99
+ end
100
+ n[key] = value
101
+ p[value] = key
102
+ self.s = self.s + 1
103
+ return true
104
+ end
71
105
  function LinkedSet.prototype.remove(self, key)
72
106
  local n = self.n
73
107
  local next = n[key]
@@ -107,8 +141,9 @@ function LinkedSet.prototype.forEach(self, action, ...)
107
141
  local n = self.n
108
142
  local c = self.f
109
143
  while c ~= nil do
144
+ local next = n[c]
110
145
  action(c, ...)
111
- c = n[c]
146
+ c = next
112
147
  end
113
148
  end
114
149
  function LinkedSet.prototype.toArray(self)
@@ -164,6 +199,7 @@ __TS__SetDescriptor(
164
199
  end},
165
200
  true
166
201
  )
202
+ local emptyIteratorState = {t = {}}
167
203
  local EmptyLinkedSet = __TS__Class()
168
204
  EmptyLinkedSet.name = "EmptyLinkedSet"
169
205
  __TS__ClassExtends(EmptyLinkedSet, ____exports.LinkedSet)
@@ -173,6 +209,9 @@ function EmptyLinkedSet.prototype.add(self)
173
209
  0
174
210
  )
175
211
  end
212
+ function EmptyLinkedSet.prototype.__pairs(self)
213
+ return linkedSetNext, emptyIteratorState, nil
214
+ end
176
215
  local EMPTY_LINKED_SET = __TS__New(EmptyLinkedSet)
177
216
  ____exports.emptyLinkedSet = function()
178
217
  return EMPTY_LINKED_SET
@@ -4,6 +4,15 @@ export declare const emptyLuaMap: <K extends AnyNotNil, V>() => ReadonlyLuaMap<K
4
4
  export declare const mutableLuaMap: <K extends AnyNotNil, V>() => LuaMap<K, V>;
5
5
  export declare const mutableWeakLuaMap: <K extends AnyNotNil, V>() => LuaMap<K, V>;
6
6
  export declare const luaMapOf: <K extends AnyNotNil, V>(...pairs: Flatten<TupleOf<[K, V], 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40>>) => LuaMap<K, V>;
7
- export declare const luaMapInvert: <K extends AnyNotNil, V extends AnyNotNil>(luaMap: LuaMap<K, V>) => LuaMap<V, K>;
8
- export declare const mapValues: <K extends AnyNotNil, V1, V2>(luaMap: LuaMap<K, V1>, transform: (value: V1) => V2) => LuaMap<K, V2>;
7
+ export declare const luaMapInvert: <K extends AnyNotNil, V extends AnyNotNil>(luaMap: ReadonlyLuaMap<K, V | undefined | null>) => LuaMap<V, K>;
8
+ export declare const toLuaMap: <K extends PropertyKey, V>(record: Record<K, V>) => LuaMap<K, V>;
9
+ export declare const flattenKeys: <K extends AnyNotNil, V>(luaMap: ReadonlyLuaMap<readonly K[], V> | ReadonlyLuaMap<K[], V>) => LuaMap<K, V>;
10
+ export declare const mapKeys: {
11
+ <K1 extends AnyNotNil, K2 extends AnyNotNil, V>(luaMap: ReadonlyLuaMap<K1, V>, transform: (value: K1) => K2): LuaMap<K2, V>;
12
+ <K1 extends AnyNotNil, K2 extends keyof K1, V>(luaMap: ReadonlyLuaMap<K1, V>, key: K2): K1[K2] extends AnyNotNil ? LuaMap<K1[K2], V> : never;
13
+ };
14
+ export declare const mapValues: {
15
+ <K extends AnyNotNil, V1, V2>(luaMap: ReadonlyLuaMap<K, V1>, transform: (value: V1) => V2): LuaMap<K, V2>;
16
+ <K extends AnyNotNil, V1, V2 extends keyof V1>(luaMap: ReadonlyLuaMap<K, V1>, key: V2): LuaMap<K, V1[V2]>;
17
+ };
9
18
  export declare const getOrPut: <K extends AnyNotNil, V>(luaMap: LuaMap<K, V>, key: K, defaultValue: () => V) => V;
@@ -27,10 +27,41 @@ ____exports.luaMapInvert = function(luaMap)
27
27
  end
28
28
  return invertLuaMap
29
29
  end
30
+ ____exports.toLuaMap = function(record)
31
+ return record
32
+ end
33
+ ____exports.flattenKeys = function(luaMap)
34
+ local result = {}
35
+ for keys, value in pairs(luaMap) do
36
+ for ____, key in ipairs(keys) do
37
+ result[key] = value
38
+ end
39
+ end
40
+ return result
41
+ end
42
+ ____exports.mapKeys = function(luaMap, transform)
43
+ local result = {}
44
+ if type(transform) == "function" then
45
+ for key, value in pairs(luaMap) do
46
+ result[transform(key)] = value
47
+ end
48
+ else
49
+ for key, value in pairs(luaMap) do
50
+ result[key[transform]] = value
51
+ end
52
+ end
53
+ return result
54
+ end
30
55
  ____exports.mapValues = function(luaMap, transform)
31
56
  local result = {}
32
- for key, value in pairs(luaMap) do
33
- result[key] = transform(value)
57
+ if type(transform) == "function" then
58
+ for key, value in pairs(luaMap) do
59
+ result[key] = transform(value)
60
+ end
61
+ else
62
+ for key, value in pairs(luaMap) do
63
+ result[key] = value[transform]
64
+ end
34
65
  end
35
66
  return result
36
67
  end
@@ -1,9 +1,28 @@
1
1
  local ____exports = {}
2
+ local ____pairs = _G.pairs
3
+ local tableSort = table.sort
2
4
  ____exports.invertRecord = function(record)
3
5
  local invertRecord = {}
4
- for key, value in pairs(record) do
6
+ for key, value in ____pairs(record) do
5
7
  invertRecord[value] = key
6
8
  end
7
9
  return invertRecord
8
10
  end
11
+ local sortedKeysInternal = {}
12
+ local lastSortedKeysLength = 0
13
+ ---
14
+ -- @internal For use by internal systems only.
15
+ ____exports.sortedKeysUnnested = function(record)
16
+ local length = 0
17
+ for key in ____pairs(record) do
18
+ length = length + 1
19
+ sortedKeysInternal[length] = key
20
+ end
21
+ for i = length + 1, lastSortedKeysLength do
22
+ sortedKeysInternal[i] = nil
23
+ end
24
+ lastSortedKeysLength = length
25
+ tableSort(sortedKeysInternal)
26
+ return sortedKeysInternal
27
+ end
9
28
  return ____exports
@@ -37,4 +37,7 @@ export type Flatten<T extends readonly any[], A extends readonly any[] = []> = T
37
37
  export type Prohibit<T, K extends keyof any> = T & {
38
38
  [P in K]?: never;
39
39
  };
40
+ type TupleSplit<T, N extends number, O extends readonly any[] = readonly []> = O["length"] extends N ? [O, T] : T extends readonly [infer F, ...infer R] ? TupleSplit<readonly [...R], N, readonly [...O, F]> : [O, T];
41
+ export type TakeFirst<T extends readonly any[], N extends number> = TupleSplit<T, N>[0];
42
+ export type SkipFirst<T extends readonly any[], N extends number> = TupleSplit<T, N>[1];
40
43
  export {};