warscript 0.0.1-dev.aae5649 → 0.0.1-dev.ab8c392

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 (37) hide show
  1. package/attributes.d.ts +13 -0
  2. package/attributes.lua +16 -0
  3. package/core/types/handle.d.ts +2 -1
  4. package/core/types/handle.lua +5 -0
  5. package/engine/behaviour/ability/apply-unit-behavior.d.ts +8 -4
  6. package/engine/behaviour/ability/apply-unit-behavior.lua +31 -9
  7. package/engine/internal/ability.d.ts +1 -1
  8. package/engine/internal/mechanics/ability-duration.d.ts +1 -3
  9. package/engine/internal/mechanics/ability-duration.lua +2 -0
  10. package/engine/internal/mechanics/cast-ability.d.ts +2 -0
  11. package/engine/internal/mechanics/cast-ability.lua +86 -0
  12. package/engine/internal/unit/detach-missiles.d.ts +7 -0
  13. package/engine/internal/unit/detach-missiles.lua +30 -0
  14. package/engine/object-data/entry/ability-type/blink.d.ts +10 -0
  15. package/engine/object-data/entry/ability-type/blink.lua +39 -0
  16. package/engine/object-data/entry/ability-type.d.ts +1 -0
  17. package/engine/object-data/entry/ability-type.lua +1 -0
  18. package/engine/object-data/entry/buff-type/applicable.lua +27 -71
  19. package/engine/object-data/entry/unit-type.d.ts +21 -0
  20. package/engine/object-data/entry/unit-type.lua +198 -44
  21. package/engine/object-field/ability.d.ts +7 -5
  22. package/engine/object-field/ability.lua +6 -0
  23. package/engine/object-field/unit.d.ts +1 -0
  24. package/engine/object-field/unit.lua +3 -0
  25. package/engine/object-field.d.ts +6 -3
  26. package/engine/object-field.lua +38 -12
  27. package/engine/standard/entries/unit-type.d.ts +3 -0
  28. package/engine/standard/entries/unit-type.lua +3 -0
  29. package/engine/unit.d.ts +1 -0
  30. package/engine/unit.lua +1 -0
  31. package/global/vec2.lua +1 -0
  32. package/package.json +3 -4
  33. package/string.d.ts +14 -0
  34. package/string.lua +9 -0
  35. package/utility/linked-set.d.ts +1 -0
  36. package/utility/linked-set.lua +16 -0
  37. package/utility/types.d.ts +2 -2
package/string.d.ts CHANGED
@@ -103,4 +103,18 @@ declare global {
103
103
  function isNotBlank(string: string): boolean;
104
104
  }
105
105
  }
106
+ declare global {
107
+ namespace string {
108
+ /**
109
+ * Returns the number of characters matching the given predicate.
110
+ */
111
+ function count(string: string, predicate: (char: string) => boolean): number;
112
+ }
113
+ interface String {
114
+ /**
115
+ * Returns the number of characters matching the given predicate.
116
+ */
117
+ count(predicate: (char: string) => boolean): number;
118
+ }
119
+ }
106
120
  export {};
package/string.lua CHANGED
@@ -31,4 +31,13 @@ end
31
31
  _G.string.isNotBlank = function(____string)
32
32
  return (match(____string, "^%s*$")) == nil
33
33
  end
34
+ _G.string.count = function(____string, predicate)
35
+ local result = 0
36
+ for i = 1, #____string do
37
+ if predicate(sub(____string, i, i)) then
38
+ result = result + 1
39
+ end
40
+ end
41
+ return result
42
+ end
34
43
  return ____exports
@@ -44,6 +44,7 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
44
44
  sortBy<R>(selector: ((value: T) => R) | KeysOfType<T, R>): void;
45
45
  protected __pairs(this: LinkedSet<T>): LuaIterator<T | undefined, IteratorState<T>>;
46
46
  }
47
+ export declare const emptyLinkedSet: <T extends AnyNotNil>() => ReadonlyLinkedSet<T>;
47
48
  export declare const linkedSetOf: <T extends AnyNotNil>(...elements: readonly T[]) => LinkedSet<T>;
48
49
  export declare const linkedSetOfNotNull: <T extends AnyNotNil>(...elements: readonly (T | null | undefined)[]) => LinkedSet<T>;
49
50
  export {};
@@ -2,9 +2,12 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
5
6
  local ____exports = {}
6
7
  local ____arrays = require("utility.arrays")
7
8
  local sortBy = ____arrays.sortBy
9
+ local ____exception = require("exception")
10
+ local UnsupportedOperationException = ____exception.UnsupportedOperationException
8
11
  local function linkedSetNext(state)
9
12
  local n = state.n
10
13
  state.n = state.t[n]
@@ -161,6 +164,19 @@ __TS__SetDescriptor(
161
164
  end},
162
165
  true
163
166
  )
167
+ local EmptyLinkedSet = __TS__Class()
168
+ EmptyLinkedSet.name = "EmptyLinkedSet"
169
+ __TS__ClassExtends(EmptyLinkedSet, ____exports.LinkedSet)
170
+ function EmptyLinkedSet.prototype.add(self)
171
+ error(
172
+ __TS__New(UnsupportedOperationException),
173
+ 0
174
+ )
175
+ end
176
+ local EMPTY_LINKED_SET = __TS__New(EmptyLinkedSet)
177
+ ____exports.emptyLinkedSet = function()
178
+ return EMPTY_LINKED_SET
179
+ end
164
180
  ____exports.linkedSetOf = function(...)
165
181
  local linkedSet = __TS__New(____exports.LinkedSet)
166
182
  for i = 1, select("#", ...) do
@@ -12,14 +12,14 @@ export type ValueOf<T> = T[keyof T];
12
12
  export type EntryOf<T> = ValueOf<{
13
13
  [K in keyof T]: [K, T[K]];
14
14
  }>;
15
- export type MutableKeys<T extends object> = {
15
+ export type MutableKeys<T extends object> = keyof T & {
16
16
  [P in keyof T]-?: IfEquals<{
17
17
  [Q in P]: T[P];
18
18
  }, {
19
19
  -readonly [Q in P]: T[P];
20
20
  }, P>;
21
21
  }[keyof T];
22
- export type ReadonlyKeys<T extends object> = {
22
+ export type ReadonlyKeys<T extends object> = keyof T & {
23
23
  [P in keyof T]-?: IfEquals<{
24
24
  [Q in P]: T[P];
25
25
  }, {