warscript 0.0.1-dev.4414935 → 0.0.1-dev.459629d
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.
- package/core/types/frame.d.ts +1 -0
- package/core/types/frame.lua +112 -37
- package/core/types/handle.lua +6 -9
- package/core/types/item.d.ts +1 -0
- package/core/types/item.lua +1 -0
- package/core/types/player.d.ts +1 -1
- package/core/types/player.lua +12 -11
- package/core/types/sound.lua +1 -1
- package/engine/behaviour/ability/damage.d.ts +3 -0
- package/engine/behaviour/ability/damage.lua +8 -2
- package/engine/behaviour/ability/emulate-impact.lua +5 -4
- package/engine/behaviour/ability.d.ts +9 -5
- package/engine/behaviour/ability.lua +29 -0
- package/engine/buff.d.ts +49 -17
- package/engine/buff.lua +241 -118
- package/engine/internal/ability.lua +15 -15
- package/engine/internal/item/fields.d.ts +12 -0
- package/engine/internal/item/fields.lua +33 -0
- package/engine/internal/item.d.ts +4 -5
- package/engine/internal/item.lua +37 -40
- package/engine/internal/object-data/attribute-bonus.lua +2 -2
- package/engine/internal/object-data/health-bonus.d.ts +2 -0
- package/engine/internal/object-data/health-bonus.lua +16 -0
- package/engine/internal/object-data/mana-bonus.d.ts +2 -0
- package/engine/internal/object-data/mana-bonus.lua +16 -0
- package/engine/internal/unit/bonus.d.ts +4 -0
- package/engine/internal/unit/bonus.lua +23 -3
- package/engine/internal/unit/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit+bonus.lua +3 -3
- package/engine/internal/unit.d.ts +1 -1
- package/engine/internal/unit.lua +25 -38
- package/engine/local-client.d.ts +5 -0
- package/engine/local-client.lua +56 -1
- package/engine/object-data/auxiliary/unit-attribute.lua +1 -1
- package/engine/object-data/entry/ability-type/{armor-increase.d.ts → armor-bonus.d.ts} +3 -3
- package/engine/object-data/entry/ability-type/{armor-increase.lua → armor-bonus.lua} +9 -9
- package/engine/object-data/entry/ability-type/health-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/health-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/mana-bonus.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-bonus.lua +26 -0
- package/engine/object-data/entry/ability-type/reincarnation.d.ts +8 -0
- package/engine/object-data/entry/ability-type/reincarnation.lua +26 -0
- package/engine/object-data/entry/ability-type.d.ts +2 -0
- package/engine/object-data/entry/ability-type.lua +84 -4
- package/engine/object-data/entry/buff-type/applicable.lua +113 -109
- package/engine/object-field/ability.lua +2 -2
- package/engine/object-field/item.d.ts +22 -0
- package/engine/object-field/item.lua +118 -0
- package/engine/object-field.d.ts +1 -1
- package/engine/object-field.lua +9 -7
- package/engine/random.d.ts +1 -0
- package/engine/random.lua +8 -0
- package/engine/standard/fields/item.d.ts +4 -0
- package/engine/standard/fields/item.lua +6 -0
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/lualib_bundle.lua +1 -1
- package/math.d.ts +2 -0
- package/math.lua +14 -0
- package/network.lua +25 -1
- package/objutil/object.lua +1 -1
- package/operation.d.ts +8 -1
- package/operation.lua +38 -18
- package/package.json +4 -4
- package/patch-lua.lua +15 -0
- package/utility/linked-map.d.ts +11 -2
- package/utility/linked-map.lua +41 -0
- package/utility/linked-set.d.ts +3 -1
- package/utility/linked-set.lua +23 -0
- package/utility/random.d.ts +102 -0
- package/utility/random.lua +273 -0
- package/utility/unordered-map.d.ts +27 -0
- package/utility/unordered-map.lua +99 -0
- /package/engine/internal/object-data/{armor-increase.d.ts → armor-bonus.d.ts} +0 -0
- /package/engine/internal/object-data/{armor-increase.lua → armor-bonus.lua} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.d.ts → attribute-bonus.d.ts} +0 -0
- /package/engine/object-data/entry/ability-type/{attribute-increase.lua → attribute-bonus.lua} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { ObjectField } from "../object-field";
|
|
3
|
+
import { Item } from "../internal/item";
|
|
4
|
+
import { ItemType, ItemTypeId } from "../object-data/entry/item-type";
|
|
5
|
+
export declare abstract class ItemField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = any> extends ObjectField<ItemType, Item, ValueType, NativeFieldType> {
|
|
6
|
+
protected get instanceClass(): typeof Item;
|
|
7
|
+
protected getObjectDataEntryId(instance: Item): ItemTypeId;
|
|
8
|
+
}
|
|
9
|
+
export declare class ItemBooleanField extends ItemField<boolean, jitembooleanfield> {
|
|
10
|
+
protected get defaultValue(): boolean;
|
|
11
|
+
protected getNativeFieldById(id: number): jitembooleanfield;
|
|
12
|
+
protected hasNativeFieldValue(): boolean;
|
|
13
|
+
protected getNativeFieldValue(instance: Item): boolean;
|
|
14
|
+
protected setNativeFieldValue(instance: Item, value: boolean): boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class ItemIntegerField extends ItemField<number, jitemintegerfield> {
|
|
17
|
+
protected get defaultValue(): number;
|
|
18
|
+
protected getNativeFieldById(id: number): jitemintegerfield;
|
|
19
|
+
protected hasNativeFieldValue(): boolean;
|
|
20
|
+
protected getNativeFieldValue(instance: Item): number;
|
|
21
|
+
protected setNativeFieldValue(instance: Item, value: number): boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____object_2Dfield = require("engine.object-field")
|
|
7
|
+
local ObjectField = ____object_2Dfield.ObjectField
|
|
8
|
+
local ____item = require("engine.internal.item")
|
|
9
|
+
local Item = ____item.Item
|
|
10
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
12
|
+
local convertItemBooleanField = ConvertItemBooleanField
|
|
13
|
+
local convertItemIntegerField = ConvertItemIntegerField
|
|
14
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
15
|
+
local getItemIntegerField = BlzGetItemIntegerField
|
|
16
|
+
local isItemPawnable = IsItemPawnable
|
|
17
|
+
local isItemPowerup = IsItemPowerup
|
|
18
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
19
|
+
local setItemDropOnDeath = SetItemDropOnDeath
|
|
20
|
+
local setItemDroppable = SetItemDroppable
|
|
21
|
+
local setItemPawnable = SetItemPawnable
|
|
22
|
+
local setItemIntegerField = BlzSetItemIntegerField
|
|
23
|
+
____exports.ItemField = __TS__Class()
|
|
24
|
+
local ItemField = ____exports.ItemField
|
|
25
|
+
ItemField.name = "ItemField"
|
|
26
|
+
__TS__ClassExtends(ItemField, ObjectField)
|
|
27
|
+
function ItemField.prototype.getObjectDataEntryId(self, instance)
|
|
28
|
+
return instance.typeId
|
|
29
|
+
end
|
|
30
|
+
__TS__SetDescriptor(
|
|
31
|
+
ItemField.prototype,
|
|
32
|
+
"instanceClass",
|
|
33
|
+
{get = function(self)
|
|
34
|
+
return Item
|
|
35
|
+
end},
|
|
36
|
+
true
|
|
37
|
+
)
|
|
38
|
+
local nativeItemBooleanFieldIds = luaSetOf(
|
|
39
|
+
fourCC("ipaw"),
|
|
40
|
+
fourCC("iusa")
|
|
41
|
+
)
|
|
42
|
+
____exports.ItemBooleanField = __TS__Class()
|
|
43
|
+
local ItemBooleanField = ____exports.ItemBooleanField
|
|
44
|
+
ItemBooleanField.name = "ItemBooleanField"
|
|
45
|
+
__TS__ClassExtends(ItemBooleanField, ____exports.ItemField)
|
|
46
|
+
function ItemBooleanField.prototype.getNativeFieldById(self, id)
|
|
47
|
+
return convertItemBooleanField(id)
|
|
48
|
+
end
|
|
49
|
+
function ItemBooleanField.prototype.hasNativeFieldValue(self)
|
|
50
|
+
return nativeItemBooleanFieldIds[self.id] ~= nil
|
|
51
|
+
end
|
|
52
|
+
function ItemBooleanField.prototype.getNativeFieldValue(self, instance)
|
|
53
|
+
return getItemBooleanField(instance.handle, self.nativeField)
|
|
54
|
+
end
|
|
55
|
+
function ItemBooleanField.prototype.setNativeFieldValue(self, instance, value)
|
|
56
|
+
if self.id == fourCC("iusa") then
|
|
57
|
+
local handle = instance.handle
|
|
58
|
+
local powerUp = isItemPowerup(handle)
|
|
59
|
+
local perishes = getItemBooleanField(handle, ITEM_BF_PERISHABLE)
|
|
60
|
+
local dropsOnDeath = getItemBooleanField(handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
61
|
+
local canBeDropped = getItemBooleanField(handle, ITEM_BF_CAN_BE_DROPPED)
|
|
62
|
+
local canBeSold = isItemPawnable(handle)
|
|
63
|
+
local result = setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, value)
|
|
64
|
+
setItemPawnable(handle, canBeSold)
|
|
65
|
+
setItemDroppable(handle, canBeDropped)
|
|
66
|
+
setItemDropOnDeath(handle, dropsOnDeath)
|
|
67
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
68
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
69
|
+
return result
|
|
70
|
+
end
|
|
71
|
+
return setItemBooleanField(instance.handle, self.nativeField, value)
|
|
72
|
+
end
|
|
73
|
+
__TS__SetDescriptor(
|
|
74
|
+
ItemBooleanField.prototype,
|
|
75
|
+
"defaultValue",
|
|
76
|
+
{get = function(self)
|
|
77
|
+
return false
|
|
78
|
+
end},
|
|
79
|
+
true
|
|
80
|
+
)
|
|
81
|
+
local nativeItemIntegerFieldIds = luaSetOf(
|
|
82
|
+
fourCC("ilev"),
|
|
83
|
+
fourCC("iuse"),
|
|
84
|
+
fourCC("icid"),
|
|
85
|
+
fourCC("ihtp"),
|
|
86
|
+
fourCC("ihpc"),
|
|
87
|
+
fourCC("ipri"),
|
|
88
|
+
fourCC("iarm"),
|
|
89
|
+
fourCC("iclr"),
|
|
90
|
+
fourCC("iclg"),
|
|
91
|
+
fourCC("iclb"),
|
|
92
|
+
fourCC("ical")
|
|
93
|
+
)
|
|
94
|
+
____exports.ItemIntegerField = __TS__Class()
|
|
95
|
+
local ItemIntegerField = ____exports.ItemIntegerField
|
|
96
|
+
ItemIntegerField.name = "ItemIntegerField"
|
|
97
|
+
__TS__ClassExtends(ItemIntegerField, ____exports.ItemField)
|
|
98
|
+
function ItemIntegerField.prototype.getNativeFieldById(self, id)
|
|
99
|
+
return convertItemIntegerField(id)
|
|
100
|
+
end
|
|
101
|
+
function ItemIntegerField.prototype.hasNativeFieldValue(self)
|
|
102
|
+
return nativeItemIntegerFieldIds[self.id] ~= nil
|
|
103
|
+
end
|
|
104
|
+
function ItemIntegerField.prototype.getNativeFieldValue(self, instance)
|
|
105
|
+
return getItemIntegerField(instance.handle, self.nativeField)
|
|
106
|
+
end
|
|
107
|
+
function ItemIntegerField.prototype.setNativeFieldValue(self, instance, value)
|
|
108
|
+
return setItemIntegerField(instance.handle, self.nativeField, value)
|
|
109
|
+
end
|
|
110
|
+
__TS__SetDescriptor(
|
|
111
|
+
ItemIntegerField.prototype,
|
|
112
|
+
"defaultValue",
|
|
113
|
+
{get = function(self)
|
|
114
|
+
return 0
|
|
115
|
+
end},
|
|
116
|
+
true
|
|
117
|
+
)
|
|
118
|
+
return ____exports
|
package/engine/object-field.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export declare abstract class ObjectLevelField<ObjectDataEntryType extends Objec
|
|
|
88
88
|
protected abstract getNativeFieldValue(instance: InstanceType, level: number): ValueType;
|
|
89
89
|
protected abstract setNativeFieldValue(instance: InstanceType, level: number, value: ValueType): boolean;
|
|
90
90
|
protected abstract getLevelCount(entry: ObjectDataEntryType | InstanceType): number;
|
|
91
|
-
getValue<LevelType extends [number] | []>(entry: ObjectDataEntryType | InstanceType, ...[level]: LevelType): LevelType extends [number] ? ValueType : ValueType[];
|
|
91
|
+
getValue<LevelType extends [number, boolean?] | [boolean?]>(entry: ObjectDataEntryType | InstanceType, ...[level, includeModifiers]: LevelType): LevelType extends [number, boolean?] ? ValueType : ValueType[];
|
|
92
92
|
setValue(entry: ObjectDataEntryType | InstanceType, ...[levelOrValue, value]: [value: ObjectDataEntryLevelFieldValueSupplier<InputValueType, ValueType>] | [level: number, value: InputValueType]): boolean;
|
|
93
93
|
updateActualValue(instance: InstanceType, level?: number): void;
|
|
94
94
|
applyModifier(instance: InstanceType, modifier: ObjectLevelFieldModifier<InstanceType, ValueType>): void;
|
package/engine/object-field.lua
CHANGED
|
@@ -403,12 +403,12 @@ ____exports.ObjectLevelField = __TS__Class()
|
|
|
403
403
|
local ObjectLevelField = ____exports.ObjectLevelField
|
|
404
404
|
ObjectLevelField.name = "ObjectLevelField"
|
|
405
405
|
__TS__ClassExtends(ObjectLevelField, ObjectFieldBase)
|
|
406
|
-
function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
406
|
+
function ObjectLevelField.prototype.getValue(self, entry, level, includeModifiers)
|
|
407
407
|
if level == nil then
|
|
408
408
|
local result = {}
|
|
409
409
|
local levelCount = self:getLevelCount(entry)
|
|
410
410
|
for i = 0, levelCount - 1 do
|
|
411
|
-
result[i + 1] = self:getValue(entry, i)
|
|
411
|
+
result[i + 1] = self:getValue(entry, i, includeModifiers)
|
|
412
412
|
end
|
|
413
413
|
return result
|
|
414
414
|
end
|
|
@@ -426,11 +426,13 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
426
426
|
end
|
|
427
427
|
return self.defaultValue
|
|
428
428
|
end
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
429
|
+
if not includeModifiers then
|
|
430
|
+
local ____opt_22 = self.originalValueByLevelByInstance
|
|
431
|
+
local ____opt_20 = ____opt_22 and ____opt_22[entry]
|
|
432
|
+
local originalValue = ____opt_20 and ____opt_20[level]
|
|
433
|
+
if originalValue ~= nil then
|
|
434
|
+
return originalValue
|
|
435
|
+
end
|
|
434
436
|
end
|
|
435
437
|
return self:getActualValue(entry, level)
|
|
436
438
|
end
|
package/engine/random.d.ts
CHANGED
package/engine/random.lua
CHANGED
|
@@ -28,4 +28,12 @@ ____exports.random = function(...)
|
|
|
28
28
|
...
|
|
29
29
|
))
|
|
30
30
|
end
|
|
31
|
+
____exports.shuffle = function(array)
|
|
32
|
+
for i = #array - 1, 1 do
|
|
33
|
+
local j = getRandomInt(0, i)
|
|
34
|
+
local value = array[i + 1]
|
|
35
|
+
array[i + 1] = array[j + 1]
|
|
36
|
+
array[j + 1] = value
|
|
37
|
+
end
|
|
38
|
+
end
|
|
31
39
|
return ____exports
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____item = require("engine.object-field.item")
|
|
3
|
+
local ItemBooleanField = ____item.ItemBooleanField
|
|
4
|
+
____exports.CAN_BE_SOLD_TO_MERCHANTS_ITEM_FIELD = ItemBooleanField:create(fourCC("ipaw"))
|
|
5
|
+
____exports.IS_ACTIVELY_USED_ITEM_FIELD = ItemBooleanField:create(fourCC("iusa"))
|
|
6
|
+
return ____exports
|
package/engine/unit.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import "./internal/unit/attributes";
|
|
|
23
23
|
import "./internal/unit/fly-height";
|
|
24
24
|
import "./internal/unit/scale";
|
|
25
25
|
import "./internal/unit/interrupts";
|
|
26
|
+
import "./internal/unit/range-event";
|
|
26
27
|
import "./internal/unit/band-aids/ancestral-spirit-cannibalize";
|
|
27
28
|
export { Unit, DamagingEvent, DamageEvent } from "./internal/unit";
|
|
28
29
|
export * from "./internal/unit+damage";
|
package/engine/unit.lua
CHANGED
|
@@ -23,6 +23,7 @@ require("engine.internal.unit.attributes")
|
|
|
23
23
|
require("engine.internal.unit.fly-height")
|
|
24
24
|
require("engine.internal.unit.scale")
|
|
25
25
|
require("engine.internal.unit.interrupts")
|
|
26
|
+
require("engine.internal.unit.range-event")
|
|
26
27
|
require("engine.internal.unit.band-aids.ancestral-spirit-cannibalize")
|
|
27
28
|
do
|
|
28
29
|
local ____unit = require("engine.internal.unit")
|
package/lualib_bundle.lua
CHANGED
|
@@ -2241,7 +2241,7 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
2241
2241
|
end
|
|
2242
2242
|
local result = string.gsub(
|
|
2243
2243
|
trace,
|
|
2244
|
-
"(
|
|
2244
|
+
"([^%s<]+)%.lua:(%d+)",
|
|
2245
2245
|
function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
|
|
2246
2246
|
)
|
|
2247
2247
|
local function stringReplacer(____, file, line)
|
package/math.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare const floor: typeof math.floor;
|
|
|
23
23
|
export declare const log: typeof math.log;
|
|
24
24
|
export declare const max: typeof math.max;
|
|
25
25
|
export declare const min: typeof math.min;
|
|
26
|
+
export declare const sum: (x: number, ...numbers: number[]) => number;
|
|
27
|
+
export declare const product: (x: number, ...numbers: number[]) => number;
|
|
26
28
|
/** Returns the signum function of the argument;
|
|
27
29
|
* zero if the argument is zero,
|
|
28
30
|
* 1.0 if the argument is greater than zero,
|
package/math.lua
CHANGED
|
@@ -39,6 +39,20 @@ ____exports.floor = math.floor
|
|
|
39
39
|
____exports.log = math.log
|
|
40
40
|
____exports.max = math.max
|
|
41
41
|
____exports.min = math.min
|
|
42
|
+
____exports.sum = function(x, ...)
|
|
43
|
+
for i = 1, select("#", ...) do
|
|
44
|
+
local number = select(i, ...)
|
|
45
|
+
x = x + number
|
|
46
|
+
end
|
|
47
|
+
return x
|
|
48
|
+
end
|
|
49
|
+
____exports.product = function(x, ...)
|
|
50
|
+
for i = 1, select("#", ...) do
|
|
51
|
+
local number = select(i, ...)
|
|
52
|
+
x = x * number
|
|
53
|
+
end
|
|
54
|
+
return x
|
|
55
|
+
end
|
|
42
56
|
--- Returns the signum function of the argument;
|
|
43
57
|
-- zero if the argument is zero,
|
|
44
58
|
-- 1.0 if the argument is greater than zero,
|
package/network.lua
CHANGED
|
@@ -8,6 +8,7 @@ local ____exports = {}
|
|
|
8
8
|
local ____event = require("event")
|
|
9
9
|
local TriggerEvent = ____event.TriggerEvent
|
|
10
10
|
local ____exception = require("exception")
|
|
11
|
+
local CancellationException = ____exception.CancellationException
|
|
11
12
|
local IllegalArgumentException = ____exception.IllegalArgumentException
|
|
12
13
|
local ____player = require("core.types.player")
|
|
13
14
|
local Player = ____player.Player
|
|
@@ -86,6 +87,9 @@ function SyncOperation.prototype.____constructor(self, player, data)
|
|
|
86
87
|
self.l = #self.d
|
|
87
88
|
end
|
|
88
89
|
function SyncOperation.prototype.estimate(self)
|
|
90
|
+
if self.isCanceled or not self.player.isPlaying then
|
|
91
|
+
return __TS__Promise.reject(__TS__New(CancellationException))
|
|
92
|
+
end
|
|
89
93
|
if self.player.isLocal then
|
|
90
94
|
sendSyncData(
|
|
91
95
|
"__oh",
|
|
@@ -98,6 +102,7 @@ function SyncOperation.prototype.estimate(self)
|
|
|
98
102
|
end
|
|
99
103
|
function SyncOperation.prototype.work(self)
|
|
100
104
|
if self.progress >= self.maximum then
|
|
105
|
+
syncOperationById[self.x] = nil
|
|
101
106
|
return decode(concat(self.c))
|
|
102
107
|
end
|
|
103
108
|
self.s = packetsPerRound
|
|
@@ -116,7 +121,18 @@ function SyncOperation.prototype.work(self)
|
|
|
116
121
|
return __TS__New(__TS__Promise, syncPromiseExecutor)
|
|
117
122
|
end
|
|
118
123
|
function SyncOperation.prototype.doCancel(self)
|
|
119
|
-
|
|
124
|
+
if not (syncOperationById[self.x] ~= nil) then
|
|
125
|
+
return false
|
|
126
|
+
end
|
|
127
|
+
syncOperationById[self.x] = nil
|
|
128
|
+
local ____opt_1 = self.r
|
|
129
|
+
if ____opt_1 ~= nil then
|
|
130
|
+
____opt_1(
|
|
131
|
+
self,
|
|
132
|
+
__TS__New(CancellationException)
|
|
133
|
+
)
|
|
134
|
+
end
|
|
135
|
+
return true
|
|
120
136
|
end
|
|
121
137
|
__TS__ObjectDefineProperty(
|
|
122
138
|
SyncOperation,
|
|
@@ -178,6 +194,7 @@ SyncOperation._ = (function()
|
|
|
178
194
|
local resolveWork = syncOperation.w
|
|
179
195
|
if resolveWork then
|
|
180
196
|
if syncOperation.progress >= syncOperation.maximum then
|
|
197
|
+
syncOperationById[id] = nil
|
|
181
198
|
resolveWork(
|
|
182
199
|
nil,
|
|
183
200
|
decode(concat(chunks))
|
|
@@ -188,6 +205,13 @@ SyncOperation._ = (function()
|
|
|
188
205
|
end
|
|
189
206
|
end
|
|
190
207
|
end)
|
|
208
|
+
Player.onLeave:addListener(function(player)
|
|
209
|
+
for ____, operation in pairs(syncOperationById) do
|
|
210
|
+
if operation.player == player then
|
|
211
|
+
operation:cancel()
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end)
|
|
191
215
|
end)()
|
|
192
216
|
function ____exports.synchronize(player, data)
|
|
193
217
|
return __TS__New(____exports.SyncOperation, player, data):execute()
|
package/objutil/object.lua
CHANGED
|
@@ -153,7 +153,7 @@ end
|
|
|
153
153
|
function ObjectDefinition.getLevelArrayFieldValue(self, level, value, values)
|
|
154
154
|
return type(values) == "function" and values(level, value) or (__TS__ArrayIsArray(values[1]) and values[1] or values)
|
|
155
155
|
end
|
|
156
|
-
____exports.ObjectType = ObjectType or ({})
|
|
156
|
+
____exports.ObjectType = ____exports.ObjectType or ({})
|
|
157
157
|
____exports.ObjectType.ABILITY = 0
|
|
158
158
|
____exports.ObjectType[____exports.ObjectType.ABILITY] = "ABILITY"
|
|
159
159
|
____exports.ObjectType.ITEM = 1
|
package/operation.d.ts
CHANGED
|
@@ -16,9 +16,11 @@ export { OperationContinue };
|
|
|
16
16
|
export declare abstract class Operation<T> {
|
|
17
17
|
protected constructor();
|
|
18
18
|
private started;
|
|
19
|
+
private settled;
|
|
20
|
+
private canceled;
|
|
19
21
|
protected progress: number;
|
|
20
22
|
protected maximum: number;
|
|
21
|
-
isCanceled: boolean;
|
|
23
|
+
get isCanceled(): boolean;
|
|
22
24
|
get isStarted(): boolean;
|
|
23
25
|
execute(): OperationMonitor<T>;
|
|
24
26
|
protected abstract estimate(): number | Promise<number>;
|
|
@@ -30,6 +32,11 @@ export declare abstract class Operation<T> {
|
|
|
30
32
|
...result: [success: true, result: T] | [success: false, reason?: any]
|
|
31
33
|
]>;
|
|
32
34
|
get onProgress(): Event<[operation: Operation<T>]>;
|
|
35
|
+
/**
|
|
36
|
+
* Invoked with `isCanceled` already set. Should unblock any pending `estimate`/`work` promise
|
|
37
|
+
* (e.g. by rejecting it) and return whether cancellation is possible; on `false` the canceled
|
|
38
|
+
* state is reverted.
|
|
39
|
+
*/
|
|
33
40
|
protected abstract doCancel(): boolean;
|
|
34
41
|
cancel(): boolean;
|
|
35
42
|
}
|
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)
|
|
@@ -38,9 +35,10 @@ local Operation = ____exports.Operation
|
|
|
38
35
|
Operation.name = "Operation"
|
|
39
36
|
function Operation.prototype.____constructor(self)
|
|
40
37
|
self.started = false
|
|
38
|
+
self.settled = false
|
|
39
|
+
self.canceled = false
|
|
41
40
|
self.progress = 0
|
|
42
41
|
self.maximum = 0
|
|
43
|
-
self.isCanceled = false
|
|
44
42
|
end
|
|
45
43
|
function Operation.prototype.execute(self)
|
|
46
44
|
if self.started then
|
|
@@ -58,6 +56,12 @@ function Operation.prototype.execute(self)
|
|
|
58
56
|
local result
|
|
59
57
|
local progress = self.progress
|
|
60
58
|
local ____try = __TS__AsyncAwaiter(function()
|
|
59
|
+
if self.canceled then
|
|
60
|
+
error(
|
|
61
|
+
__TS__New(CancellationException),
|
|
62
|
+
0
|
|
63
|
+
)
|
|
64
|
+
end
|
|
61
65
|
local maximum = __TS__Await(self:estimate())
|
|
62
66
|
self.maximum = maximum
|
|
63
67
|
if maximum ~= 0 then
|
|
@@ -68,20 +72,19 @@ function Operation.prototype.execute(self)
|
|
|
68
72
|
end
|
|
69
73
|
repeat
|
|
70
74
|
do
|
|
71
|
-
if self.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Event.invoke(onFailure, self, reason)
|
|
77
|
-
end
|
|
78
|
-
local onComplete = ____rawget(self, "onComplete")
|
|
79
|
-
if onComplete ~= nil then
|
|
80
|
-
Event.invoke(onComplete, self, false, reason)
|
|
81
|
-
end
|
|
82
|
-
return ____awaiter_resolve(nil)
|
|
75
|
+
if self.canceled then
|
|
76
|
+
error(
|
|
77
|
+
__TS__New(CancellationException),
|
|
78
|
+
0
|
|
79
|
+
)
|
|
83
80
|
end
|
|
84
81
|
result = __TS__Await(self:work())
|
|
82
|
+
if self.canceled then
|
|
83
|
+
error(
|
|
84
|
+
__TS__New(CancellationException),
|
|
85
|
+
0
|
|
86
|
+
)
|
|
87
|
+
end
|
|
85
88
|
if self.progress ~= progress or self.maximum ~= maximum then
|
|
86
89
|
progress = self.progress
|
|
87
90
|
maximum = self.maximum
|
|
@@ -96,6 +99,7 @@ function Operation.prototype.execute(self)
|
|
|
96
99
|
__TS__Await(____try.catch(
|
|
97
100
|
____try,
|
|
98
101
|
function(____, reason)
|
|
102
|
+
self.settled = true
|
|
99
103
|
reject(nil, reason)
|
|
100
104
|
local onFailure = ____rawget(self, "onFailure")
|
|
101
105
|
if onFailure ~= nil then
|
|
@@ -108,6 +112,7 @@ function Operation.prototype.execute(self)
|
|
|
108
112
|
return ____awaiter_resolve(nil)
|
|
109
113
|
end
|
|
110
114
|
))
|
|
115
|
+
self.settled = true
|
|
111
116
|
resolve(nil, result)
|
|
112
117
|
local onSuccess = ____rawget(self, "onSuccess")
|
|
113
118
|
if onSuccess ~= nil then
|
|
@@ -122,12 +127,27 @@ function Operation.prototype.execute(self)
|
|
|
122
127
|
)
|
|
123
128
|
end
|
|
124
129
|
function Operation.prototype.cancel(self)
|
|
130
|
+
if self.canceled then
|
|
131
|
+
return true
|
|
132
|
+
end
|
|
133
|
+
if self.settled then
|
|
134
|
+
return false
|
|
135
|
+
end
|
|
136
|
+
self.canceled = true
|
|
125
137
|
if self:doCancel() then
|
|
126
|
-
self.isCanceled = true
|
|
127
138
|
return true
|
|
128
139
|
end
|
|
140
|
+
self.canceled = false
|
|
129
141
|
return false
|
|
130
142
|
end
|
|
143
|
+
__TS__SetDescriptor(
|
|
144
|
+
Operation.prototype,
|
|
145
|
+
"isCanceled",
|
|
146
|
+
{get = function(self)
|
|
147
|
+
return self.canceled
|
|
148
|
+
end},
|
|
149
|
+
true
|
|
150
|
+
)
|
|
131
151
|
__TS__SetDescriptor(
|
|
132
152
|
Operation.prototype,
|
|
133
153
|
"isStarted",
|
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.
|
|
4
|
+
"version": "0.0.1-dev.459629d",
|
|
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.
|
|
25
|
+
"@warscript/tstl-plugin": "^0.0.6",
|
|
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.
|
|
31
|
-
"@typescript-eslint/parser": "^8.
|
|
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",
|
package/patch-lua.lua
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
local error = _G.error
|
|
1
2
|
local getmetatable = _G.getmetatable
|
|
2
3
|
local ipairs = _G.ipairs
|
|
4
|
+
local select = _G.select
|
|
5
|
+
local tostring = _G.tostring
|
|
6
|
+
local tableconcat = table.concat
|
|
3
7
|
|
|
4
8
|
_G.ipairs = function(t)
|
|
5
9
|
local metatable = getmetatable(t)
|
|
@@ -8,3 +12,14 @@ _G.ipairs = function(t)
|
|
|
8
12
|
end
|
|
9
13
|
return ipairs(t)
|
|
10
14
|
end
|
|
15
|
+
|
|
16
|
+
_G.assert = function(v, ...)
|
|
17
|
+
if not v then
|
|
18
|
+
local args = {}
|
|
19
|
+
for i = 1, select("#", ...) do
|
|
20
|
+
args[i] = tostring(select(i, ...))
|
|
21
|
+
end
|
|
22
|
+
error(tableconcat(args, " "))
|
|
23
|
+
end
|
|
24
|
+
return v, ...
|
|
25
|
+
end
|
package/utility/linked-map.d.ts
CHANGED
|
@@ -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
|
-
readonly
|
|
18
|
+
readonly __linkedMap: 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>;
|
|
@@ -21,6 +27,9 @@ export declare class LinkedMap<K extends AnyNotNil, V> {
|
|
|
21
27
|
remove(key: K): boolean;
|
|
22
28
|
contains(key: AnyNotNil): key is K & OneSidedTypeGuard;
|
|
23
29
|
get size(): number;
|
|
30
|
+
protected __len(): number;
|
|
24
31
|
protected __pairs(this: LinkedMap<K, V>): LuaIterator<LuaMultiReturn<[K | undefined, V | undefined]>, IteratorState<K, V>>;
|
|
25
32
|
}
|
|
33
|
+
export declare const emptyLinkedMap: <K extends AnyNotNil, V>() => ReadonlyLinkedMap<K, V>;
|
|
34
|
+
export declare const mutableLinkedMap: <K extends AnyNotNil, V>() => LinkedMap<K, V>;
|
|
26
35
|
export {};
|
package/utility/linked-map.lua
CHANGED
|
@@ -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]
|
|
@@ -44,6 +47,9 @@ end
|
|
|
44
47
|
function LinkedMap.prototype.contains(self, key)
|
|
45
48
|
return self.keys:contains(key)
|
|
46
49
|
end
|
|
50
|
+
function LinkedMap.prototype.__len(self)
|
|
51
|
+
return self.keys.size
|
|
52
|
+
end
|
|
47
53
|
function LinkedMap.prototype.__pairs(self)
|
|
48
54
|
return linkedMapNext, {n = self.k.f, t = self.k.n, v = self.v}, nil
|
|
49
55
|
end
|
|
@@ -63,4 +69,39 @@ __TS__SetDescriptor(
|
|
|
63
69
|
end},
|
|
64
70
|
true
|
|
65
71
|
)
|
|
72
|
+
local emptyIteratorState = {t = {}, v = {}}
|
|
73
|
+
local EmptyLinkedMap = __TS__Class()
|
|
74
|
+
EmptyLinkedMap.name = "EmptyLinkedMap"
|
|
75
|
+
__TS__ClassExtends(EmptyLinkedMap, ____exports.LinkedMap)
|
|
76
|
+
function EmptyLinkedMap.prototype.getOrPut(self)
|
|
77
|
+
error(
|
|
78
|
+
__TS__New(UnsupportedOperationException),
|
|
79
|
+
0
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
function EmptyLinkedMap.prototype.put(self)
|
|
83
|
+
error(
|
|
84
|
+
__TS__New(UnsupportedOperationException),
|
|
85
|
+
0
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
function EmptyLinkedMap.prototype.remove(self)
|
|
89
|
+
error(
|
|
90
|
+
__TS__New(UnsupportedOperationException),
|
|
91
|
+
0
|
|
92
|
+
)
|
|
93
|
+
end
|
|
94
|
+
function EmptyLinkedMap.prototype.__len(self)
|
|
95
|
+
return 0
|
|
96
|
+
end
|
|
97
|
+
function EmptyLinkedMap.prototype.__pairs(self)
|
|
98
|
+
return linkedMapNext, emptyIteratorState, nil
|
|
99
|
+
end
|
|
100
|
+
local EMPTY_LINKED_MAP = __TS__New(EmptyLinkedMap)
|
|
101
|
+
____exports.emptyLinkedMap = function()
|
|
102
|
+
return EMPTY_LINKED_MAP
|
|
103
|
+
end
|
|
104
|
+
____exports.mutableLinkedMap = function()
|
|
105
|
+
return __TS__New(____exports.LinkedMap)
|
|
106
|
+
end
|
|
66
107
|
return ____exports
|
package/utility/linked-set.d.ts
CHANGED
|
@@ -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;
|
|
@@ -48,6 +49,7 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
|
|
|
48
49
|
toArray(): T[];
|
|
49
50
|
sumOf(selector: ((value: T) => number) | KeysOfType<T, number>): number;
|
|
50
51
|
sortBy<R>(selector: ((value: T) => R) | KeysOfType<T, R>): void;
|
|
52
|
+
protected __len(): number;
|
|
51
53
|
protected __pairs(this: LinkedSet<T>): LuaIterator<T | undefined, IteratorState<T>>;
|
|
52
54
|
}
|
|
53
55
|
export declare const emptyLinkedSet: <T extends AnyNotNil>() => ReadonlyLinkedSet<T>;
|