warscript 0.0.1-dev.c677d41 → 0.0.1-dev.c762beb

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/core/types/handle.lua +1 -1
  2. package/core/types/sound.lua +1 -1
  3. package/engine/behaviour/ability/damage.d.ts +3 -0
  4. package/engine/behaviour/ability/damage.lua +8 -2
  5. package/engine/behaviour/ability.d.ts +9 -5
  6. package/engine/behaviour/ability.lua +29 -0
  7. package/engine/buff.d.ts +49 -17
  8. package/engine/buff.lua +241 -118
  9. package/engine/internal/object-data/attribute-bonus.lua +2 -2
  10. package/engine/internal/object-data/health-bonus.d.ts +2 -0
  11. package/engine/internal/object-data/health-bonus.lua +16 -0
  12. package/engine/internal/object-data/mana-bonus.d.ts +2 -0
  13. package/engine/internal/object-data/mana-bonus.lua +16 -0
  14. package/engine/internal/unit/bonus.d.ts +4 -0
  15. package/engine/internal/unit/bonus.lua +23 -3
  16. package/engine/internal/unit/item.lua +1 -1
  17. package/engine/internal/unit/range-event.d.ts +12 -0
  18. package/engine/internal/unit/range-event.lua +90 -0
  19. package/engine/internal/unit+bonus.lua +3 -3
  20. package/engine/internal/unit.d.ts +1 -1
  21. package/engine/internal/unit.lua +9 -30
  22. package/engine/object-data/auxiliary/unit-attribute.lua +1 -1
  23. package/engine/object-data/entry/ability-type/{armor-increase.d.ts → armor-bonus.d.ts} +3 -3
  24. package/engine/object-data/entry/ability-type/{armor-increase.lua → armor-bonus.lua} +9 -9
  25. package/engine/object-data/entry/ability-type/health-bonus.d.ts +8 -0
  26. package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
  27. package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
  28. package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
  29. package/engine/object-data/entry/ability-type/reincarnation.d.ts +8 -0
  30. package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
  31. package/engine/object-data/entry/ability-type.d.ts +2 -0
  32. package/engine/object-data/entry/ability-type.lua +84 -4
  33. package/engine/object-data/entry/buff-type/applicable.lua +113 -109
  34. package/engine/object-field/ability.lua +2 -2
  35. package/engine/object-field.d.ts +1 -1
  36. package/engine/object-field.lua +9 -7
  37. package/engine/random.d.ts +1 -0
  38. package/engine/random.lua +8 -0
  39. package/engine/unit.d.ts +1 -0
  40. package/engine/unit.lua +1 -0
  41. package/lualib_bundle.lua +118 -47
  42. package/objutil/object.lua +1 -1
  43. package/operation.lua +23 -17
  44. package/package.json +4 -4
  45. package/utility/linked-map.d.ts +9 -1
  46. package/utility/linked-map.lua +35 -0
  47. package/utility/linked-set.d.ts +2 -1
  48. package/utility/linked-set.lua +17 -0
  49. /package/engine/internal/object-data/{armor-increase.d.ts → armor-bonus.d.ts} +0 -0
  50. /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
  51. /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
  52. /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
package/operation.lua CHANGED
@@ -22,10 +22,7 @@ OperationMonitor.name = "OperationMonitor"
22
22
  __TS__ClassExtends(OperationMonitor, __TS__Promise)
23
23
  function OperationMonitor.prototype.____constructor(self, operation, ...)
24
24
  local args = {...}
25
- __TS__Promise.prototype.____constructor(
26
- self,
27
- table.unpack(args)
28
- )
25
+ __TS__Promise.prototype.____constructor(self, ...)
29
26
  self.o = operation
30
27
  end
31
28
  function OperationMonitor.prototype.cancel(self)
@@ -57,6 +54,7 @@ function Operation.prototype.execute(self)
57
54
  return __TS__AsyncAwaiter(function(____awaiter_resolve)
58
55
  local result
59
56
  local progress = self.progress
57
+ local ____hasReturned, ____returnValue
60
58
  local ____try = __TS__AsyncAwaiter(function()
61
59
  local maximum = __TS__Await(self:estimate())
62
60
  self.maximum = maximum
@@ -79,7 +77,8 @@ function Operation.prototype.execute(self)
79
77
  if onComplete ~= nil then
80
78
  Event.invoke(onComplete, self, false, reason)
81
79
  end
82
- return ____awaiter_resolve(nil)
80
+ ____hasReturned = true
81
+ return
83
82
  end
84
83
  result = __TS__Await(self:work())
85
84
  if self.progress ~= progress or self.maximum ~= maximum then
@@ -93,21 +92,28 @@ function Operation.prototype.execute(self)
93
92
  end
94
93
  until not (result == OperationContinue)
95
94
  end)
96
- __TS__Await(____try.catch(
95
+ ____try = ____try.catch(
97
96
  ____try,
98
97
  function(____, reason)
99
- reject(nil, reason)
100
- local onFailure = ____rawget(self, "onFailure")
101
- if onFailure ~= nil then
102
- Event.invoke(onFailure, self, reason)
103
- end
104
- local onComplete = ____rawget(self, "onComplete")
105
- if onComplete ~= nil then
106
- Event.invoke(onComplete, self, false, reason)
107
- end
108
- return ____awaiter_resolve(nil)
98
+ return __TS__AsyncAwaiter(function()
99
+ reject(nil, reason)
100
+ local onFailure = ____rawget(self, "onFailure")
101
+ if onFailure ~= nil then
102
+ Event.invoke(onFailure, self, reason)
103
+ end
104
+ local onComplete = ____rawget(self, "onComplete")
105
+ if onComplete ~= nil then
106
+ Event.invoke(onComplete, self, false, reason)
107
+ end
108
+ ____hasReturned = true
109
+ return
110
+ end)
109
111
  end
110
- ))
112
+ )
113
+ __TS__Await(____try)
114
+ if ____hasReturned then
115
+ return ____awaiter_resolve(nil, ____returnValue)
116
+ end
111
117
  resolve(nil, result)
112
118
  local onSuccess = ____rawget(self, "onSuccess")
113
119
  if onSuccess ~= nil then
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "warscript",
4
- "version": "0.0.1-dev.c677d41",
4
+ "version": "0.0.1-dev.c762beb",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@warscript/language-extensions": "^0.0.1",
25
- "@warscript/tstl-plugin": "^0.0.4",
25
+ "@warscript/tstl-plugin": "^0.0.5",
26
26
  "lua-types": "^2.13.1",
27
27
  "warpack": "0.0.1-dev.e490aaf"
28
28
  },
29
29
  "devDependencies": {
30
- "@typescript-eslint/eslint-plugin": "^8.13.0",
31
- "@typescript-eslint/parser": "^8.13.0",
30
+ "@typescript-eslint/eslint-plugin": "^8.61.1",
31
+ "@typescript-eslint/parser": "^8.61.1",
32
32
  "async": "^3.2.6",
33
33
  "copyfiles": "^2.4.1",
34
34
  "eslint": "^9.14.0",
@@ -8,10 +8,16 @@ type IteratorState<K extends AnyNotNil, V> = {
8
8
  type OneSidedTypeGuard = {
9
9
  readonly __oneSidedTypeGuard: unique symbol;
10
10
  };
11
+ export interface ReadonlyLinkedMap<K extends AnyNotNil, V> extends LuaPairsIterable<K, V> {
12
+ readonly keys: ReadonlyLinkedSet<K>;
13
+ get(key: K): V | undefined;
14
+ contains(key: AnyNotNil): key is K & OneSidedTypeGuard;
15
+ readonly size: number;
16
+ }
11
17
  export interface LinkedMap<K extends AnyNotNil, V> extends LuaPairsIterable<K, V> {
12
18
  readonly __linkedSet: unique symbol;
13
19
  }
14
- export declare class LinkedMap<K extends AnyNotNil, V> {
20
+ export declare class LinkedMap<K extends AnyNotNil, V> implements ReadonlyLinkedMap<K, V> {
15
21
  private k;
16
22
  private v;
17
23
  get keys(): ReadonlyLinkedSet<K>;
@@ -23,4 +29,6 @@ export declare class LinkedMap<K extends AnyNotNil, V> {
23
29
  get size(): number;
24
30
  protected __pairs(this: LinkedMap<K, V>): LuaIterator<LuaMultiReturn<[K | undefined, V | undefined]>, IteratorState<K, V>>;
25
31
  }
32
+ export declare const emptyLinkedMap: <K extends AnyNotNil, V>() => ReadonlyLinkedMap<K, V>;
33
+ export declare const mutableLinkedMap: <K extends AnyNotNil, V>() => LinkedMap<K, V>;
26
34
  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 ____linked_2Dset = require("utility.linked-set")
7
8
  local LinkedSet = ____linked_2Dset.LinkedSet
9
+ local ____exception = require("exception")
10
+ local UnsupportedOperationException = ____exception.UnsupportedOperationException
8
11
  local function linkedMapNext(state)
9
12
  local n = state.n
10
13
  state.n = state.t[n]
@@ -63,4 +66,36 @@ __TS__SetDescriptor(
63
66
  end},
64
67
  true
65
68
  )
69
+ local emptyIteratorState = {t = {}, v = {}}
70
+ local EmptyLinkedMap = __TS__Class()
71
+ EmptyLinkedMap.name = "EmptyLinkedMap"
72
+ __TS__ClassExtends(EmptyLinkedMap, ____exports.LinkedMap)
73
+ function EmptyLinkedMap.prototype.getOrPut(self)
74
+ error(
75
+ __TS__New(UnsupportedOperationException),
76
+ 0
77
+ )
78
+ end
79
+ function EmptyLinkedMap.prototype.put(self)
80
+ error(
81
+ __TS__New(UnsupportedOperationException),
82
+ 0
83
+ )
84
+ end
85
+ function EmptyLinkedMap.prototype.remove(self)
86
+ error(
87
+ __TS__New(UnsupportedOperationException),
88
+ 0
89
+ )
90
+ end
91
+ function EmptyLinkedMap.prototype.__pairs(self)
92
+ return linkedMapNext, emptyIteratorState, nil
93
+ end
94
+ local EMPTY_LINKED_MAP = __TS__New(EmptyLinkedMap)
95
+ ____exports.emptyLinkedMap = function()
96
+ return EMPTY_LINKED_MAP
97
+ end
98
+ ____exports.mutableLinkedMap = function()
99
+ return __TS__New(____exports.LinkedMap)
100
+ end
66
101
  return ____exports
@@ -14,7 +14,7 @@ export interface ReadonlyLinkedSet<T extends AnyNotNil> extends LuaPairsKeyItera
14
14
  next(key: T): T | undefined;
15
15
  previous(key: T): T | undefined;
16
16
  contains(key: AnyNotNil): key is T & OneSidedTypeGuard;
17
- size: number;
17
+ readonly size: number;
18
18
  forEach<Args extends any[]>(action: (value: T, ...args: Args) => void, ...args: Args): void;
19
19
  toArray(): T[];
20
20
  sumOf(selector: ((value: T) => number) | KeysOfType<T, number>): number;
@@ -40,6 +40,7 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
40
40
  next(key: T): T | undefined;
41
41
  previous(key: T): T | undefined;
42
42
  add(key: T): boolean;
43
+ protected addBefore(value: T, key: T): boolean;
43
44
  remove(key: T): boolean;
44
45
  contains(key: AnyNotNil): key is T & OneSidedTypeGuard;
45
46
  clear(): void;
@@ -85,6 +85,23 @@ function LinkedSet.prototype.add(self, key)
85
85
  end
86
86
  return true
87
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
88
105
  function LinkedSet.prototype.remove(self, key)
89
106
  local n = self.n
90
107
  local next = n[key]