From f9f7fb74a5e2ca555e0b194502ed669b98ab9b37 Mon Sep 17 00:00:00 2001 From: Ben Carter Date: Mon, 12 Feb 2024 14:19:38 -0500 Subject: [PATCH] Added transpiled modules for ease of copy grab --- dist/common/lualib_bundle.lua | 2630 +++++++++++++++++ .../commands/set-xp-rate/set-xp-rate.lua | 97 + .../gameobjects/soulswapper/soulswapper.lua | 149 + .../achievement-tokens/achievement-tokens.lua | 43 + dist/module/gameplay/worgoblin/worgoblin.lua | 33 + dist/module/shared/account.lua | 29 + dist/module/shared/money.lua | 33 + dist/module/shared/stats.lua | 129 + dist/module/shared/triggers.lua | 23 + dist/module/shared/ui-utils.lua | 19 + .../module/special/gambler/gambler.client.lua | 194 ++ .../module/special/gambler/gambler.server.lua | 70 + 12 files changed, 3449 insertions(+) create mode 100644 dist/common/lualib_bundle.lua create mode 100644 dist/module/commands/set-xp-rate/set-xp-rate.lua create mode 100644 dist/module/gameobjects/soulswapper/soulswapper.lua create mode 100644 dist/module/gameplay/achievement-tokens/achievement-tokens.lua create mode 100644 dist/module/gameplay/worgoblin/worgoblin.lua create mode 100644 dist/module/shared/account.lua create mode 100644 dist/module/shared/money.lua create mode 100644 dist/module/shared/stats.lua create mode 100644 dist/module/shared/triggers.lua create mode 100644 dist/module/shared/ui-utils.lua create mode 100644 dist/module/special/gambler/gambler.client.lua create mode 100644 dist/module/special/gambler/gambler.server.lua diff --git a/dist/common/lualib_bundle.lua b/dist/common/lualib_bundle.lua new file mode 100644 index 0000000..001222d --- /dev/null +++ b/dist/common/lualib_bundle.lua @@ -0,0 +1,2630 @@ +local function __TS__ArrayAt(self, relativeIndex) + local absoluteIndex = relativeIndex < 0 and #self + relativeIndex or relativeIndex + if absoluteIndex >= 0 and absoluteIndex < #self then + return self[absoluteIndex + 1] + end + return nil +end + +local function __TS__ArrayIsArray(value) + return type(value) == "table" and (value[1] ~= nil or next(value) == nil) +end + +local function __TS__ArrayConcat(self, ...) + local items = {...} + local result = {} + local len = 0 + for i = 1, #self do + len = len + 1 + result[len] = self[i] + end + for i = 1, #items do + local item = items[i] + if __TS__ArrayIsArray(item) then + for j = 1, #item do + len = len + 1 + result[len] = item[j] + end + else + len = len + 1 + result[len] = item + end + end + return result +end + +local __TS__Symbol, Symbol +do + local symbolMetatable = {__tostring = function(self) + return ("Symbol(" .. (self.description or "")) .. ")" + end} + function __TS__Symbol(description) + return setmetatable({description = description}, symbolMetatable) + end + Symbol = { + asyncDispose = __TS__Symbol("Symbol.asyncDispose"), + dispose = __TS__Symbol("Symbol.dispose"), + iterator = __TS__Symbol("Symbol.iterator"), + hasInstance = __TS__Symbol("Symbol.hasInstance"), + species = __TS__Symbol("Symbol.species"), + toStringTag = __TS__Symbol("Symbol.toStringTag") + } +end + +local function __TS__ArrayEntries(array) + local key = 0 + return { + [Symbol.iterator] = function(self) + return self + end, + next = function(self) + local result = {done = array[key + 1] == nil, value = {key, array[key + 1]}} + key = key + 1 + return result + end + } +end + +local function __TS__ArrayEvery(self, callbackfn, thisArg) + for i = 1, #self do + if not callbackfn(thisArg, self[i], i - 1, self) then + return false + end + end + return true +end + +local function __TS__ArrayFill(self, value, start, ____end) + local relativeStart = start or 0 + local relativeEnd = ____end or #self + if relativeStart < 0 then + relativeStart = relativeStart + #self + end + if relativeEnd < 0 then + relativeEnd = relativeEnd + #self + end + do + local i = relativeStart + while i < relativeEnd do + self[i + 1] = value + i = i + 1 + end + end + return self +end + +local function __TS__ArrayFilter(self, callbackfn, thisArg) + local result = {} + local len = 0 + for i = 1, #self do + if callbackfn(thisArg, self[i], i - 1, self) then + len = len + 1 + result[len] = self[i] + end + end + return result +end + +local function __TS__ArrayForEach(self, callbackFn, thisArg) + for i = 1, #self do + callbackFn(thisArg, self[i], i - 1, self) + end +end + +local function __TS__ArrayFind(self, predicate, thisArg) + for i = 1, #self do + local elem = self[i] + if predicate(thisArg, elem, i - 1, self) then + return elem + end + end + return nil +end + +local function __TS__ArrayFindIndex(self, callbackFn, thisArg) + for i = 1, #self do + if callbackFn(thisArg, self[i], i - 1, self) then + return i - 1 + end + end + return -1 +end + +local __TS__Iterator +do + local function iteratorGeneratorStep(self) + local co = self.____coroutine + local status, value = coroutine.resume(co) + if not status then + error(value, 0) + end + if coroutine.status(co) == "dead" then + return + end + return true, value + end + local function iteratorIteratorStep(self) + local result = self:next() + if result.done then + return + end + return true, result.value + end + local function iteratorStringStep(self, index) + index = index + 1 + if index > #self then + return + end + return index, string.sub(self, index, index) + end + function __TS__Iterator(iterable) + if type(iterable) == "string" then + return iteratorStringStep, iterable, 0 + elseif iterable.____coroutine ~= nil then + return iteratorGeneratorStep, iterable + elseif iterable[Symbol.iterator] then + local iterator = iterable[Symbol.iterator](iterable) + return iteratorIteratorStep, iterator + else + return ipairs(iterable) + end + end +end + +local __TS__ArrayFrom +do + local function arrayLikeStep(self, index) + index = index + 1 + if index > self.length then + return + end + return index, self[index] + end + local function arrayLikeIterator(arr) + if type(arr.length) == "number" then + return arrayLikeStep, arr, 0 + end + return __TS__Iterator(arr) + end + function __TS__ArrayFrom(arrayLike, mapFn, thisArg) + local result = {} + if mapFn == nil then + for ____, v in arrayLikeIterator(arrayLike) do + result[#result + 1] = v + end + else + for i, v in arrayLikeIterator(arrayLike) do + result[#result + 1] = mapFn(thisArg, v, i - 1) + end + end + return result + end +end + +local function __TS__ArrayIncludes(self, searchElement, fromIndex) + if fromIndex == nil then + fromIndex = 0 + end + local len = #self + local k = fromIndex + if fromIndex < 0 then + k = len + fromIndex + end + if k < 0 then + k = 0 + end + for i = k + 1, len do + if self[i] == searchElement then + return true + end + end + return false +end + +local function __TS__ArrayIndexOf(self, searchElement, fromIndex) + if fromIndex == nil then + fromIndex = 0 + end + local len = #self + if len == 0 then + return -1 + end + if fromIndex >= len then + return -1 + end + if fromIndex < 0 then + fromIndex = len + fromIndex + if fromIndex < 0 then + fromIndex = 0 + end + end + for i = fromIndex + 1, len do + if self[i] == searchElement then + return i - 1 + end + end + return -1 +end + +local function __TS__ArrayJoin(self, separator) + if separator == nil then + separator = "," + end + local parts = {} + for i = 1, #self do + parts[i] = tostring(self[i]) + end + return table.concat(parts, separator) +end + +local function __TS__ArrayMap(self, callbackfn, thisArg) + local result = {} + for i = 1, #self do + result[i] = callbackfn(thisArg, self[i], i - 1, self) + end + return result +end + +local function __TS__ArrayPush(self, ...) + local items = {...} + local len = #self + for i = 1, #items do + len = len + 1 + self[len] = items[i] + end + return len +end + +local function __TS__ArrayPushArray(self, items) + local len = #self + for i = 1, #items do + len = len + 1 + self[len] = items[i] + end + return len +end + +local function __TS__CountVarargs(...) + return select("#", ...) +end + +local function __TS__ArrayReduce(self, callbackFn, ...) + local len = #self + local k = 0 + local accumulator = nil + if __TS__CountVarargs(...) ~= 0 then + accumulator = ... + elseif len > 0 then + accumulator = self[1] + k = 1 + else + error("Reduce of empty array with no initial value", 0) + end + for i = k + 1, len do + accumulator = callbackFn( + nil, + accumulator, + self[i], + i - 1, + self + ) + end + return accumulator +end + +local function __TS__ArrayReduceRight(self, callbackFn, ...) + local len = #self + local k = len - 1 + local accumulator = nil + if __TS__CountVarargs(...) ~= 0 then + accumulator = ... + elseif len > 0 then + accumulator = self[k + 1] + k = k - 1 + else + error("Reduce of empty array with no initial value", 0) + end + for i = k + 1, 1, -1 do + accumulator = callbackFn( + nil, + accumulator, + self[i], + i - 1, + self + ) + end + return accumulator +end + +local function __TS__ArrayReverse(self) + local i = 1 + local j = #self + while i < j do + local temp = self[j] + self[j] = self[i] + self[i] = temp + i = i + 1 + j = j - 1 + end + return self +end + +local function __TS__ArrayUnshift(self, ...) + local items = {...} + local numItemsToInsert = #items + if numItemsToInsert == 0 then + return #self + end + for i = #self, 1, -1 do + self[i + numItemsToInsert] = self[i] + end + for i = 1, numItemsToInsert do + self[i] = items[i] + end + return #self +end + +local function __TS__ArraySort(self, compareFn) + if compareFn ~= nil then + table.sort( + self, + function(a, b) return compareFn(nil, a, b) < 0 end + ) + else + table.sort(self) + end + return self +end + +local function __TS__ArraySlice(self, first, last) + local len = #self + first = first or 0 + if first < 0 then + first = len + first + if first < 0 then + first = 0 + end + else + if first > len then + first = len + end + end + last = last or len + if last < 0 then + last = len + last + if last < 0 then + last = 0 + end + else + if last > len then + last = len + end + end + local out = {} + first = first + 1 + last = last + 1 + local n = 1 + while first < last do + out[n] = self[first] + first = first + 1 + n = n + 1 + end + return out +end + +local function __TS__ArraySome(self, callbackfn, thisArg) + for i = 1, #self do + if callbackfn(thisArg, self[i], i - 1, self) then + return true + end + end + return false +end + +local function __TS__ArraySplice(self, ...) + local args = {...} + local len = #self + local actualArgumentCount = __TS__CountVarargs(...) + local start = args[1] + local deleteCount = args[2] + if start < 0 then + start = len + start + if start < 0 then + start = 0 + end + elseif start > len then + start = len + end + local itemCount = actualArgumentCount - 2 + if itemCount < 0 then + itemCount = 0 + end + local actualDeleteCount + if actualArgumentCount == 0 then + actualDeleteCount = 0 + elseif actualArgumentCount == 1 then + actualDeleteCount = len - start + else + actualDeleteCount = deleteCount or 0 + if actualDeleteCount < 0 then + actualDeleteCount = 0 + end + if actualDeleteCount > len - start then + actualDeleteCount = len - start + end + end + local out = {} + for k = 1, actualDeleteCount do + local from = start + k + if self[from] ~= nil then + out[k] = self[from] + end + end + if itemCount < actualDeleteCount then + for k = start + 1, len - actualDeleteCount do + local from = k + actualDeleteCount + local to = k + itemCount + if self[from] then + self[to] = self[from] + else + self[to] = nil + end + end + for k = len - actualDeleteCount + itemCount + 1, len do + self[k] = nil + end + elseif itemCount > actualDeleteCount then + for k = len - actualDeleteCount, start + 1, -1 do + local from = k + actualDeleteCount + local to = k + itemCount + if self[from] then + self[to] = self[from] + else + self[to] = nil + end + end + end + local j = start + 1 + for i = 3, actualArgumentCount do + self[j] = args[i] + j = j + 1 + end + for k = #self, len - actualDeleteCount + itemCount + 1, -1 do + self[k] = nil + end + return out +end + +local function __TS__ArrayToObject(self) + local object = {} + for i = 1, #self do + object[i - 1] = self[i] + end + return object +end + +local function __TS__ArrayFlat(self, depth) + if depth == nil then + depth = 1 + end + local result = {} + local len = 0 + for i = 1, #self do + local value = self[i] + if depth > 0 and __TS__ArrayIsArray(value) then + local toAdd + if depth == 1 then + toAdd = value + else + toAdd = __TS__ArrayFlat(value, depth - 1) + end + for j = 1, #toAdd do + local val = toAdd[j] + len = len + 1 + result[len] = val + end + else + len = len + 1 + result[len] = value + end + end + return result +end + +local function __TS__ArrayFlatMap(self, callback, thisArg) + local result = {} + local len = 0 + for i = 1, #self do + local value = callback(thisArg, self[i], i - 1, self) + if __TS__ArrayIsArray(value) then + for j = 1, #value do + len = len + 1 + result[len] = value[j] + end + else + len = len + 1 + result[len] = value + end + end + return result +end + +local function __TS__ArraySetLength(self, length) + if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then + error( + "invalid array length: " .. tostring(length), + 0 + ) + end + for i = length + 1, #self do + self[i] = nil + end + return length +end + +local __TS__Unpack = table.unpack or unpack + +local function __TS__ArrayToReversed(self) + local copy = {__TS__Unpack(self)} + __TS__ArrayReverse(copy) + return copy +end + +local function __TS__ArrayToSorted(self, compareFn) + local copy = {__TS__Unpack(self)} + __TS__ArraySort(copy, compareFn) + return copy +end + +local function __TS__ArrayToSpliced(self, start, deleteCount, ...) + local copy = {__TS__Unpack(self)} + __TS__ArraySplice(copy, start, deleteCount, ...) + return copy +end + +local function __TS__ArrayWith(self, index, value) + local copy = {__TS__Unpack(self)} + copy[index + 1] = value + return copy +end + +local function __TS__InstanceOf(obj, classTbl) + if type(classTbl) ~= "table" then + error("Right-hand side of 'instanceof' is not an object", 0) + end + if classTbl[Symbol.hasInstance] ~= nil then + return not not classTbl[Symbol.hasInstance](classTbl, obj) + end + if type(obj) == "table" then + local luaClass = obj.constructor + while luaClass ~= nil do + if luaClass == classTbl then + return true + end + luaClass = luaClass.____super + end + end + return false +end + +local function __TS__New(target, ...) + local instance = setmetatable({}, target.prototype) + instance:____constructor(...) + return instance +end + +local function __TS__Class(self) + local c = {prototype = {}} + c.prototype.__index = c.prototype + c.prototype.constructor = c + return c +end + +local function __TS__FunctionBind(fn, ...) + local boundArgs = {...} + return function(____, ...) + local args = {...} + __TS__ArrayUnshift( + args, + __TS__Unpack(boundArgs) + ) + return fn(__TS__Unpack(args)) + end +end + +local __TS__Promise +do + local function promiseDeferred(self) + local resolve + local reject + local promise = __TS__New( + __TS__Promise, + function(____, res, rej) + resolve = res + reject = rej + end + ) + return {promise = promise, resolve = resolve, reject = reject} + end + local function isPromiseLike(self, thing) + return __TS__InstanceOf(thing, __TS__Promise) + end + __TS__Promise = __TS__Class() + __TS__Promise.name = "__TS__Promise" + function __TS__Promise.prototype.____constructor(self, executor) + self.state = 0 + self.fulfilledCallbacks = {} + self.rejectedCallbacks = {} + self.finallyCallbacks = {} + do + local function ____catch(e) + self:reject(e) + end + local ____try, ____hasReturned = pcall(function() + executor( + nil, + __TS__FunctionBind(self.resolve, self), + __TS__FunctionBind(self.reject, self) + ) + end) + if not ____try then + ____catch(____hasReturned) + end + end + end + function __TS__Promise.resolve(data) + local promise = __TS__New( + __TS__Promise, + function() + end + ) + promise.state = 1 + promise.value = data + return promise + end + function __TS__Promise.reject(reason) + local promise = __TS__New( + __TS__Promise, + function() + end + ) + promise.state = 2 + promise.rejectionReason = reason + return promise + end + __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected) + local ____promiseDeferred_result_0 = promiseDeferred(nil) + local promise = ____promiseDeferred_result_0.promise + local resolve = ____promiseDeferred_result_0.resolve + local reject = ____promiseDeferred_result_0.reject + local isFulfilled = self.state == 1 + local isRejected = self.state == 2 + if onFulfilled then + local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject) + local ____self_fulfilledCallbacks_1 = self.fulfilledCallbacks + ____self_fulfilledCallbacks_1[#____self_fulfilledCallbacks_1 + 1] = internalCallback + if isFulfilled then + internalCallback(nil, self.value) + end + else + local ____self_fulfilledCallbacks_2 = self.fulfilledCallbacks + ____self_fulfilledCallbacks_2[#____self_fulfilledCallbacks_2 + 1] = function(____, v) return resolve(nil, v) end + end + if onRejected then + local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject) + local ____self_rejectedCallbacks_3 = self.rejectedCallbacks + ____self_rejectedCallbacks_3[#____self_rejectedCallbacks_3 + 1] = internalCallback + if isRejected then + internalCallback(nil, self.rejectionReason) + end + else + local ____self_rejectedCallbacks_4 = self.rejectedCallbacks + ____self_rejectedCallbacks_4[#____self_rejectedCallbacks_4 + 1] = function(____, err) return reject(nil, err) end + end + if isFulfilled then + resolve(nil, self.value) + end + if isRejected then + reject(nil, self.rejectionReason) + end + return promise + end + function __TS__Promise.prototype.catch(self, onRejected) + return self["then"](self, nil, onRejected) + end + function __TS__Promise.prototype.finally(self, onFinally) + if onFinally then + local ____self_finallyCallbacks_5 = self.finallyCallbacks + ____self_finallyCallbacks_5[#____self_finallyCallbacks_5 + 1] = onFinally + if self.state ~= 0 then + onFinally(nil) + end + end + return self + end + function __TS__Promise.prototype.resolve(self, data) + if __TS__InstanceOf(data, __TS__Promise) then + data["then"]( + data, + function(____, v) return self:resolve(v) end, + function(____, err) return self:reject(err) end + ) + return + end + if self.state == 0 then + self.state = 1 + self.value = data + for ____, callback in ipairs(self.fulfilledCallbacks) do + callback(nil, data) + end + for ____, callback in ipairs(self.finallyCallbacks) do + callback(nil) + end + end + end + function __TS__Promise.prototype.reject(self, reason) + if self.state == 0 then + self.state = 2 + self.rejectionReason = reason + for ____, callback in ipairs(self.rejectedCallbacks) do + callback(nil, reason) + end + for ____, callback in ipairs(self.finallyCallbacks) do + callback(nil) + end + end + end + function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject) + return function(____, value) + do + local function ____catch(e) + reject(nil, e) + end + local ____try, ____hasReturned = pcall(function() + self:handleCallbackData( + f(nil, value), + resolve, + reject + ) + end) + if not ____try then + ____catch(____hasReturned) + end + end + end + end + function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject) + if isPromiseLike(nil, data) then + local nextpromise = data + if nextpromise.state == 1 then + resolve(nil, nextpromise.value) + elseif nextpromise.state == 2 then + reject(nil, nextpromise.rejectionReason) + else + data["then"](data, resolve, reject) + end + else + resolve(nil, data) + end + end +end + +local function __TS__AsyncAwaiter(generator) + return __TS__New( + __TS__Promise, + function(____, resolve, reject) + local adopt, fulfilled, step, resolved, asyncCoroutine + function adopt(self, value) + return __TS__InstanceOf(value, __TS__Promise) and value or __TS__Promise.resolve(value) + end + function fulfilled(self, value) + local success, resultOrError = coroutine.resume(asyncCoroutine, value) + if success then + step(nil, resultOrError) + else + reject(nil, resultOrError) + end + end + function step(self, result) + if resolved then + return + end + if coroutine.status(asyncCoroutine) == "dead" then + resolve(nil, result) + else + local ____self_0 = adopt(nil, result) + ____self_0["then"](____self_0, fulfilled, reject) + end + end + resolved = false + asyncCoroutine = coroutine.create(generator) + local success, resultOrError = coroutine.resume( + asyncCoroutine, + function(____, v) + resolved = true + local ____self_1 = adopt(nil, v) + ____self_1["then"](____self_1, resolve, reject) + end + ) + if success then + step(nil, resultOrError) + else + reject(nil, resultOrError) + end + end + ) +end +local function __TS__Await(thing) + return coroutine.yield(thing) +end + +local function __TS__ClassExtends(target, base) + target.____super = base + local staticMetatable = setmetatable({__index = base}, base) + setmetatable(target, staticMetatable) + local baseMetatable = getmetatable(base) + if baseMetatable then + if type(baseMetatable.__index) == "function" then + staticMetatable.__index = baseMetatable.__index + end + if type(baseMetatable.__newindex) == "function" then + staticMetatable.__newindex = baseMetatable.__newindex + end + end + setmetatable(target.prototype, base.prototype) + if type(base.prototype.__index) == "function" then + target.prototype.__index = base.prototype.__index + end + if type(base.prototype.__newindex) == "function" then + target.prototype.__newindex = base.prototype.__newindex + end + if type(base.prototype.__tostring) == "function" then + target.prototype.__tostring = base.prototype.__tostring + end +end + +local function __TS__CloneDescriptor(____bindingPattern0) + local value + local writable + local set + local get + local configurable + local enumerable + enumerable = ____bindingPattern0.enumerable + configurable = ____bindingPattern0.configurable + get = ____bindingPattern0.get + set = ____bindingPattern0.set + writable = ____bindingPattern0.writable + value = ____bindingPattern0.value + local descriptor = {enumerable = enumerable == true, configurable = configurable == true} + local hasGetterOrSetter = get ~= nil or set ~= nil + local hasValueOrWritableAttribute = writable ~= nil or value ~= nil + if hasGetterOrSetter and hasValueOrWritableAttribute then + error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0) + end + if get or set then + descriptor.get = get + descriptor.set = set + else + descriptor.value = value + descriptor.writable = writable == true + end + return descriptor +end + +local function __TS__Decorate(self, originalValue, decorators, context) + local result = originalValue + do + local i = #decorators + while i >= 0 do + local decorator = decorators[i + 1] + if decorator ~= nil then + local ____decorator_result_0 = decorator(self, result, context) + if ____decorator_result_0 == nil then + ____decorator_result_0 = result + end + result = ____decorator_result_0 + end + i = i - 1 + end + end + return result +end + +local function __TS__ObjectAssign(target, ...) + local sources = {...} + for i = 1, #sources do + local source = sources[i] + for key in pairs(source) do + target[key] = source[key] + end + end + return target +end + +local function __TS__ObjectGetOwnPropertyDescriptor(object, key) + local metatable = getmetatable(object) + if not metatable then + return + end + if not rawget(metatable, "_descriptors") then + return + end + return rawget(metatable, "_descriptors")[key] +end + +local __TS__SetDescriptor +do + local function descriptorIndex(self, key) + local value = rawget(self, key) + if value ~= nil then + return value + end + local metatable = getmetatable(self) + while metatable do + local rawResult = rawget(metatable, key) + if rawResult ~= nil then + return rawResult + end + local descriptors = rawget(metatable, "_descriptors") + if descriptors then + local descriptor = descriptors[key] + if descriptor ~= nil then + if descriptor.get then + return descriptor.get(self) + end + return descriptor.value + end + end + metatable = getmetatable(metatable) + end + end + local function descriptorNewIndex(self, key, value) + local metatable = getmetatable(self) + while metatable do + local descriptors = rawget(metatable, "_descriptors") + if descriptors then + local descriptor = descriptors[key] + if descriptor ~= nil then + if descriptor.set then + descriptor.set(self, value) + else + if descriptor.writable == false then + error( + ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'", + 0 + ) + end + descriptor.value = value + end + return + end + end + metatable = getmetatable(metatable) + end + rawset(self, key, value) + end + function __TS__SetDescriptor(target, key, desc, isPrototype) + if isPrototype == nil then + isPrototype = false + end + local ____isPrototype_0 + if isPrototype then + ____isPrototype_0 = target + else + ____isPrototype_0 = getmetatable(target) + end + local metatable = ____isPrototype_0 + if not metatable then + metatable = {} + setmetatable(target, metatable) + end + local value = rawget(target, key) + if value ~= nil then + rawset(target, key, nil) + end + if not rawget(metatable, "_descriptors") then + metatable._descriptors = {} + end + metatable._descriptors[key] = __TS__CloneDescriptor(desc) + metatable.__index = descriptorIndex + metatable.__newindex = descriptorNewIndex + end +end + +local function __TS__DecorateLegacy(decorators, target, key, desc) + local result = target + do + local i = #decorators + while i >= 0 do + local decorator = decorators[i + 1] + if decorator ~= nil then + local oldResult = result + if key == nil then + result = decorator(nil, result) + elseif desc == true then + local value = rawget(target, key) + local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value}) + local desc = decorator(nil, target, key, descriptor) or descriptor + local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set + if isSimpleValue then + rawset(target, key, desc.value) + else + __TS__SetDescriptor( + target, + key, + __TS__ObjectAssign({}, descriptor, desc) + ) + end + elseif desc == false then + result = decorator(nil, target, key, desc) + else + result = decorator(nil, target, key) + end + result = result or oldResult + end + i = i - 1 + end + end + return result +end + +local function __TS__DecorateParam(paramIndex, decorator) + return function(____, target, key) return decorator(nil, target, key, paramIndex) end +end + +local function __TS__StringIncludes(self, searchString, position) + if not position then + position = 1 + else + position = position + 1 + end + local index = string.find(self, searchString, position, true) + return index ~= nil +end + +local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError +do + local function getErrorStack(self, constructor) + if debug == nil then + return nil + end + local level = 1 + while true do + local info = debug.getinfo(level, "f") + level = level + 1 + if not info then + level = 1 + break + elseif info.func == constructor then + break + end + end + if __TS__StringIncludes(_VERSION, "Lua 5.0") then + return debug.traceback(("[Level " .. tostring(level)) .. "]") + else + return debug.traceback(nil, level) + end + end + local function wrapErrorToString(self, getDescription) + return function(self) + local description = getDescription(self) + local caller = debug.getinfo(3, "f") + local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0") or _VERSION == "Lua 5.1" + if isClassicLua or caller and caller.func ~= error then + return description + else + return (description .. "\n") .. tostring(self.stack) + end + end + end + local function initErrorClass(self, Type, name) + Type.name = name + return setmetatable( + Type, + {__call = function(____, _self, message) return __TS__New(Type, message) end} + ) + end + local ____initErrorClass_1 = initErrorClass + local ____class_0 = __TS__Class() + ____class_0.name = "" + function ____class_0.prototype.____constructor(self, message) + if message == nil then + message = "" + end + self.message = message + self.name = "Error" + self.stack = getErrorStack(nil, self.constructor.new) + local metatable = getmetatable(self) + if metatable and not metatable.__errorToStringPatched then + metatable.__errorToStringPatched = true + metatable.__tostring = wrapErrorToString(nil, metatable.__tostring) + end + end + function ____class_0.prototype.__tostring(self) + return self.message ~= "" and (self.name .. ": ") .. self.message or self.name + end + Error = ____initErrorClass_1(nil, ____class_0, "Error") + local function createErrorClass(self, name) + local ____initErrorClass_3 = initErrorClass + local ____class_2 = __TS__Class() + ____class_2.name = ____class_2.name + __TS__ClassExtends(____class_2, Error) + function ____class_2.prototype.____constructor(self, ...) + ____class_2.____super.prototype.____constructor(self, ...) + self.name = name + end + return ____initErrorClass_3(nil, ____class_2, name) + end + RangeError = createErrorClass(nil, "RangeError") + ReferenceError = createErrorClass(nil, "ReferenceError") + SyntaxError = createErrorClass(nil, "SyntaxError") + TypeError = createErrorClass(nil, "TypeError") + URIError = createErrorClass(nil, "URIError") +end + +local function __TS__ObjectGetOwnPropertyDescriptors(object) + local metatable = getmetatable(object) + if not metatable then + return {} + end + return rawget(metatable, "_descriptors") or ({}) +end + +local function __TS__Delete(target, key) + local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target) + local descriptor = descriptors[key] + if descriptor then + if not descriptor.configurable then + error( + __TS__New( + TypeError, + ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "." + ), + 0 + ) + end + descriptors[key] = nil + return true + end + target[key] = nil + return true +end + +local function __TS__StringAccess(self, index) + if index >= 0 and index < #self then + return string.sub(self, index + 1, index + 1) + end +end + +local function __TS__DelegatedYield(iterable) + if type(iterable) == "string" then + for index = 0, #iterable - 1 do + coroutine.yield(__TS__StringAccess(iterable, index)) + end + elseif iterable.____coroutine ~= nil then + local co = iterable.____coroutine + while true do + local status, value = coroutine.resume(co) + if not status then + error(value, 0) + end + if coroutine.status(co) == "dead" then + return value + else + coroutine.yield(value) + end + end + elseif iterable[Symbol.iterator] then + local iterator = iterable[Symbol.iterator](iterable) + while true do + local result = iterator:next() + if result.done then + return result.value + else + coroutine.yield(result.value) + end + end + else + for ____, value in ipairs(iterable) do + coroutine.yield(value) + end + end +end + +local __TS__Generator +do + local function generatorIterator(self) + return self + end + local function generatorNext(self, ...) + local co = self.____coroutine + if coroutine.status(co) == "dead" then + return {done = true} + end + local status, value = coroutine.resume(co, ...) + if not status then + error(value, 0) + end + return { + value = value, + done = coroutine.status(co) == "dead" + } + end + function __TS__Generator(fn) + return function(...) + local args = {...} + local argsLength = __TS__CountVarargs(...) + return { + ____coroutine = coroutine.create(function() return fn(__TS__Unpack(args, 1, argsLength)) end), + [Symbol.iterator] = generatorIterator, + next = generatorNext + } + end + end +end + +local function __TS__InstanceOfObject(value) + local valueType = type(value) + return valueType == "table" or valueType == "function" +end + +local function __TS__LuaIteratorSpread(self, state, firstKey) + local results = {} + local key, value = self(state, firstKey) + while key do + results[#results + 1] = {key, value} + key, value = self(state, key) + end + return __TS__Unpack(results) +end + +local Map +do + Map = __TS__Class() + Map.name = "Map" + function Map.prototype.____constructor(self, entries) + self[Symbol.toStringTag] = "Map" + self.items = {} + self.size = 0 + self.nextKey = {} + self.previousKey = {} + if entries == nil then + return + end + local iterable = entries + if iterable[Symbol.iterator] then + local iterator = iterable[Symbol.iterator](iterable) + while true do + local result = iterator:next() + if result.done then + break + end + local value = result.value + self:set(value[1], value[2]) + end + else + local array = entries + for ____, kvp in ipairs(array) do + self:set(kvp[1], kvp[2]) + end + end + end + function Map.prototype.clear(self) + self.items = {} + self.nextKey = {} + self.previousKey = {} + self.firstKey = nil + self.lastKey = nil + self.size = 0 + end + function Map.prototype.delete(self, key) + local contains = self:has(key) + if contains then + self.size = self.size - 1 + local next = self.nextKey[key] + local previous = self.previousKey[key] + if next ~= nil and previous ~= nil then + self.nextKey[previous] = next + self.previousKey[next] = previous + elseif next ~= nil then + self.firstKey = next + self.previousKey[next] = nil + elseif previous ~= nil then + self.lastKey = previous + self.nextKey[previous] = nil + else + self.firstKey = nil + self.lastKey = nil + end + self.nextKey[key] = nil + self.previousKey[key] = nil + end + self.items[key] = nil + return contains + end + function Map.prototype.forEach(self, callback) + for ____, key in __TS__Iterator(self:keys()) do + callback(nil, self.items[key], key, self) + end + end + function Map.prototype.get(self, key) + return self.items[key] + end + function Map.prototype.has(self, key) + return self.nextKey[key] ~= nil or self.lastKey == key + end + function Map.prototype.set(self, key, value) + local isNewValue = not self:has(key) + if isNewValue then + self.size = self.size + 1 + end + self.items[key] = value + if self.firstKey == nil then + self.firstKey = key + self.lastKey = key + elseif isNewValue then + self.nextKey[self.lastKey] = key + self.previousKey[key] = self.lastKey + self.lastKey = key + end + return self + end + Map.prototype[Symbol.iterator] = function(self) + return self:entries() + end + function Map.prototype.entries(self) + local items = self.items + local nextKey = self.nextKey + local key = self.firstKey + return { + [Symbol.iterator] = function(self) + return self + end, + next = function(self) + local result = {done = not key, value = {key, items[key]}} + key = nextKey[key] + return result + end + } + end + function Map.prototype.keys(self) + local nextKey = self.nextKey + local key = self.firstKey + return { + [Symbol.iterator] = function(self) + return self + end, + next = function(self) + local result = {done = not key, value = key} + key = nextKey[key] + return result + end + } + end + function Map.prototype.values(self) + local items = self.items + local nextKey = self.nextKey + local key = self.firstKey + return { + [Symbol.iterator] = function(self) + return self + end, + next = function(self) + local result = {done = not key, value = items[key]} + key = nextKey[key] + return result + end + } + end + Map[Symbol.species] = Map +end + +local __TS__Match = string.match + +local __TS__MathAtan2 = math.atan2 or math.atan + +local __TS__MathModf = math.modf + +local function __TS__MathSign(val) + if val > 0 then + return 1 + elseif val < 0 then + return -1 + end + return 0 +end + +local function __TS__Number(value) + local valueType = type(value) + if valueType == "number" then + return value + elseif valueType == "string" then + local numberValue = tonumber(value) + if numberValue then + return numberValue + end + if value == "Infinity" then + return math.huge + end + if value == "-Infinity" then + return -math.huge + end + local stringWithoutSpaces = string.gsub(value, "%s", "") + if stringWithoutSpaces == "" then + return 0 + end + return 0 / 0 + elseif valueType == "boolean" then + return value and 1 or 0 + else + return 0 / 0 + end +end + +local function __TS__NumberIsFinite(value) + return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge +end + +local function __TS__NumberIsInteger(value) + return __TS__NumberIsFinite(value) and math.floor(value) == value +end + +local function __TS__NumberIsNaN(value) + return value ~= value +end + +local function __TS__StringSubstring(self, start, ____end) + if ____end ~= ____end then + ____end = 0 + end + if ____end ~= nil and start > ____end then + start, ____end = ____end, start + end + if start >= 0 then + start = start + 1 + else + start = 1 + end + if ____end ~= nil and ____end < 0 then + ____end = 0 + end + return string.sub(self, start, ____end) +end + +local __TS__ParseInt +do + local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ" + function __TS__ParseInt(numberString, base) + if base == nil then + base = 10 + local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]") + if hexMatch ~= nil then + base = 16 + numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(numberString, #hexMatch) or __TS__StringSubstring(numberString, #hexMatch) + end + end + if base < 2 or base > 36 then + return 0 / 0 + end + local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10)) + local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)" + local number = tonumber((__TS__Match(numberString, pattern)), base) + if number == nil then + return 0 / 0 + end + if number >= 0 then + return math.floor(number) + else + return math.ceil(number) + end + end +end + +local function __TS__ParseFloat(numberString) + local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)") + if infinityMatch ~= nil then + return __TS__StringAccess(infinityMatch, 0) == "-" and -math.huge or math.huge + end + local number = tonumber((__TS__Match(numberString, "^%s*(-?%d+%.?%d*)"))) + return number or 0 / 0 +end + +local __TS__NumberToString +do + local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz" + function __TS__NumberToString(self, radix) + if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then + return tostring(self) + end + radix = math.floor(radix) + if radix < 2 or radix > 36 then + error("toString() radix argument must be between 2 and 36", 0) + end + local integer, fraction = __TS__MathModf(math.abs(self)) + local result = "" + if radix == 8 then + result = string.format("%o", integer) + elseif radix == 16 then + result = string.format("%x", integer) + else + repeat + do + result = __TS__StringAccess(radixChars, integer % radix) .. result + integer = math.floor(integer / radix) + end + until not (integer ~= 0) + end + if fraction ~= 0 then + result = result .. "." + local delta = 1e-16 + repeat + do + fraction = fraction * radix + delta = delta * radix + local digit = math.floor(fraction) + result = result .. __TS__StringAccess(radixChars, digit) + fraction = fraction - digit + end + until not (fraction >= delta) + end + if self < 0 then + result = "-" .. result + end + return result + end +end + +local function __TS__NumberToFixed(self, fractionDigits) + if math.abs(self) >= 1e+21 or self ~= self then + return tostring(self) + end + local f = math.floor(fractionDigits or 0) + if f < 0 or f > 99 then + error("toFixed() digits argument must be between 0 and 99", 0) + end + return string.format( + ("%." .. tostring(f)) .. "f", + self + ) +end + +local function __TS__ObjectDefineProperty(target, key, desc) + local luaKey = type(key) == "number" and key + 1 or key + local value = rawget(target, luaKey) + local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil + local descriptor + if hasGetterOrSetter then + if value ~= nil then + error( + "Cannot redefine property: " .. tostring(key), + 0 + ) + end + descriptor = desc + else + local valueExists = value ~= nil + local ____desc_set_4 = desc.set + local ____desc_get_5 = desc.get + local ____temp_0 + if desc.configurable ~= nil then + ____temp_0 = desc.configurable + else + ____temp_0 = valueExists + end + local ____temp_1 + if desc.enumerable ~= nil then + ____temp_1 = desc.enumerable + else + ____temp_1 = valueExists + end + local ____temp_2 + if desc.writable ~= nil then + ____temp_2 = desc.writable + else + ____temp_2 = valueExists + end + local ____temp_3 + if desc.value ~= nil then + ____temp_3 = desc.value + else + ____temp_3 = value + end + descriptor = { + set = ____desc_set_4, + get = ____desc_get_5, + configurable = ____temp_0, + enumerable = ____temp_1, + writable = ____temp_2, + value = ____temp_3 + } + end + __TS__SetDescriptor(target, luaKey, descriptor) + return target +end + +local function __TS__ObjectEntries(obj) + local result = {} + local len = 0 + for key in pairs(obj) do + len = len + 1 + result[len] = {key, obj[key]} + end + return result +end + +local function __TS__ObjectFromEntries(entries) + local obj = {} + local iterable = entries + if iterable[Symbol.iterator] then + local iterator = iterable[Symbol.iterator](iterable) + while true do + local result = iterator:next() + if result.done then + break + end + local value = result.value + obj[value[1]] = value[2] + end + else + for ____, entry in ipairs(entries) do + obj[entry[1]] = entry[2] + end + end + return obj +end + +local function __TS__ObjectKeys(obj) + local result = {} + local len = 0 + for key in pairs(obj) do + len = len + 1 + result[len] = key + end + return result +end + +local function __TS__ObjectRest(target, usedProperties) + local result = {} + for property in pairs(target) do + if not usedProperties[property] then + result[property] = target[property] + end + end + return result +end + +local function __TS__ObjectValues(obj) + local result = {} + local len = 0 + for key in pairs(obj) do + len = len + 1 + result[len] = obj[key] + end + return result +end + +local function __TS__PromiseAll(iterable) + local results = {} + local toResolve = {} + local numToResolve = 0 + local i = 0 + for ____, item in __TS__Iterator(iterable) do + if __TS__InstanceOf(item, __TS__Promise) then + if item.state == 1 then + results[i + 1] = item.value + elseif item.state == 2 then + return __TS__Promise.reject(item.rejectionReason) + else + numToResolve = numToResolve + 1 + toResolve[i] = item + end + else + results[i + 1] = item + end + i = i + 1 + end + if numToResolve == 0 then + return __TS__Promise.resolve(results) + end + return __TS__New( + __TS__Promise, + function(____, resolve, reject) + for index, promise in pairs(toResolve) do + promise["then"]( + promise, + function(____, data) + results[index + 1] = data + numToResolve = numToResolve - 1 + if numToResolve == 0 then + resolve(nil, results) + end + end, + function(____, reason) + reject(nil, reason) + end + ) + end + end + ) +end + +local function __TS__PromiseAllSettled(iterable) + local results = {} + local toResolve = {} + local numToResolve = 0 + local i = 0 + for ____, item in __TS__Iterator(iterable) do + if __TS__InstanceOf(item, __TS__Promise) then + if item.state == 1 then + results[i + 1] = {status = "fulfilled", value = item.value} + elseif item.state == 2 then + results[i + 1] = {status = "rejected", reason = item.rejectionReason} + else + numToResolve = numToResolve + 1 + toResolve[i] = item + end + else + results[i + 1] = {status = "fulfilled", value = item} + end + i = i + 1 + end + if numToResolve == 0 then + return __TS__Promise.resolve(results) + end + return __TS__New( + __TS__Promise, + function(____, resolve) + for index, promise in pairs(toResolve) do + promise["then"]( + promise, + function(____, data) + results[index + 1] = {status = "fulfilled", value = data} + numToResolve = numToResolve - 1 + if numToResolve == 0 then + resolve(nil, results) + end + end, + function(____, reason) + results[index + 1] = {status = "rejected", reason = reason} + numToResolve = numToResolve - 1 + if numToResolve == 0 then + resolve(nil, results) + end + end + ) + end + end + ) +end + +local function __TS__PromiseAny(iterable) + local rejections = {} + local pending = {} + for ____, item in __TS__Iterator(iterable) do + if __TS__InstanceOf(item, __TS__Promise) then + if item.state == 1 then + return __TS__Promise.resolve(item.value) + elseif item.state == 2 then + rejections[#rejections + 1] = item.rejectionReason + else + pending[#pending + 1] = item + end + else + return __TS__Promise.resolve(item) + end + end + if #pending == 0 then + return __TS__Promise.reject("No promises to resolve with .any()") + end + local numResolved = 0 + return __TS__New( + __TS__Promise, + function(____, resolve, reject) + for ____, promise in ipairs(pending) do + promise["then"]( + promise, + function(____, data) + resolve(nil, data) + end, + function(____, reason) + rejections[#rejections + 1] = reason + numResolved = numResolved + 1 + if numResolved == #pending then + reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections}) + end + end + ) + end + end + ) +end + +local function __TS__PromiseRace(iterable) + local pending = {} + for ____, item in __TS__Iterator(iterable) do + if __TS__InstanceOf(item, __TS__Promise) then + if item.state == 1 then + return __TS__Promise.resolve(item.value) + elseif item.state == 2 then + return __TS__Promise.reject(item.rejectionReason) + else + pending[#pending + 1] = item + end + else + return __TS__Promise.resolve(item) + end + end + return __TS__New( + __TS__Promise, + function(____, resolve, reject) + for ____, promise in ipairs(pending) do + promise["then"]( + promise, + function(____, value) return resolve(nil, value) end, + function(____, reason) return reject(nil, reason) end + ) + end + end + ) +end + +local Set +do + Set = __TS__Class() + Set.name = "Set" + function Set.prototype.____constructor(self, values) + self[Symbol.toStringTag] = "Set" + self.size = 0 + self.nextKey = {} + self.previousKey = {} + if values == nil then + return + end + local iterable = values + if iterable[Symbol.iterator] then + local iterator = iterable[Symbol.iterator](iterable) + while true do + local result = iterator:next() + if result.done then + break + end + self:add(result.value) + end + else + local array = values + for ____, value in ipairs(array) do + self:add(value) + end + end + end + function Set.prototype.add(self, value) + local isNewValue = not self:has(value) + if isNewValue then + self.size = self.size + 1 + end + if self.firstKey == nil then + self.firstKey = value + self.lastKey = value + elseif isNewValue then + self.nextKey[self.lastKey] = value + self.previousKey[value] = self.lastKey + self.lastKey = value + end + return self + end + function Set.prototype.clear(self) + self.nextKey = {} + self.previousKey = {} + self.firstKey = nil + self.lastKey = nil + self.size = 0 + end + function Set.prototype.delete(self, value) + local contains = self:has(value) + if contains then + self.size = self.size - 1 + local next = self.nextKey[value] + local previous = self.previousKey[value] + if next ~= nil and previous ~= nil then + self.nextKey[previous] = next + self.previousKey[next] = previous + elseif next ~= nil then + self.firstKey = next + self.previousKey[next] = nil + elseif previous ~= nil then + self.lastKey = previous + self.nextKey[previous] = nil + else + self.firstKey = nil + self.lastKey = nil + end + self.nextKey[value] = nil + self.previousKey[value] = nil + end + return contains + end + function Set.prototype.forEach(self, callback) + for ____, key in __TS__Iterator(self:keys()) do + callback(nil, key, key, self) + end + end + function Set.prototype.has(self, value) + return self.nextKey[value] ~= nil or self.lastKey == value + end + Set.prototype[Symbol.iterator] = function(self) + return self:values() + end + function Set.prototype.entries(self) + local nextKey = self.nextKey + local key = self.firstKey + return { + [Symbol.iterator] = function(self) + return self + end, + next = function(self) + local result = {done = not key, value = {key, key}} + key = nextKey[key] + return result + end + } + end + function Set.prototype.keys(self) + local nextKey = self.nextKey + local key = self.firstKey + return { + [Symbol.iterator] = function(self) + return self + end, + next = function(self) + local result = {done = not key, value = key} + key = nextKey[key] + return result + end + } + end + function Set.prototype.values(self) + local nextKey = self.nextKey + local key = self.firstKey + return { + [Symbol.iterator] = function(self) + return self + end, + next = function(self) + local result = {done = not key, value = key} + key = nextKey[key] + return result + end + } + end + Set[Symbol.species] = Set +end + +local function __TS__SparseArrayNew(...) + local sparseArray = {...} + sparseArray.sparseLength = __TS__CountVarargs(...) + return sparseArray +end + +local function __TS__SparseArrayPush(sparseArray, ...) + local args = {...} + local argsLen = __TS__CountVarargs(...) + local listLen = sparseArray.sparseLength + for i = 1, argsLen do + sparseArray[listLen + i] = args[i] + end + sparseArray.sparseLength = listLen + argsLen +end + +local function __TS__SparseArraySpread(sparseArray) + local _unpack = unpack or table.unpack + return _unpack(sparseArray, 1, sparseArray.sparseLength) +end + +local WeakMap +do + WeakMap = __TS__Class() + WeakMap.name = "WeakMap" + function WeakMap.prototype.____constructor(self, entries) + self[Symbol.toStringTag] = "WeakMap" + self.items = {} + setmetatable(self.items, {__mode = "k"}) + if entries == nil then + return + end + local iterable = entries + if iterable[Symbol.iterator] then + local iterator = iterable[Symbol.iterator](iterable) + while true do + local result = iterator:next() + if result.done then + break + end + local value = result.value + self.items[value[1]] = value[2] + end + else + for ____, kvp in ipairs(entries) do + self.items[kvp[1]] = kvp[2] + end + end + end + function WeakMap.prototype.delete(self, key) + local contains = self:has(key) + self.items[key] = nil + return contains + end + function WeakMap.prototype.get(self, key) + return self.items[key] + end + function WeakMap.prototype.has(self, key) + return self.items[key] ~= nil + end + function WeakMap.prototype.set(self, key, value) + self.items[key] = value + return self + end + WeakMap[Symbol.species] = WeakMap +end + +local WeakSet +do + WeakSet = __TS__Class() + WeakSet.name = "WeakSet" + function WeakSet.prototype.____constructor(self, values) + self[Symbol.toStringTag] = "WeakSet" + self.items = {} + setmetatable(self.items, {__mode = "k"}) + if values == nil then + return + end + local iterable = values + if iterable[Symbol.iterator] then + local iterator = iterable[Symbol.iterator](iterable) + while true do + local result = iterator:next() + if result.done then + break + end + self.items[result.value] = true + end + else + for ____, value in ipairs(values) do + self.items[value] = true + end + end + end + function WeakSet.prototype.add(self, value) + self.items[value] = true + return self + end + function WeakSet.prototype.delete(self, value) + local contains = self:has(value) + self.items[value] = nil + return contains + end + function WeakSet.prototype.has(self, value) + return self.items[value] == true + end + WeakSet[Symbol.species] = WeakSet +end + +local function __TS__SourceMapTraceBack(fileName, sourceMap) + _G.__TS__sourcemap = _G.__TS__sourcemap or ({}) + _G.__TS__sourcemap[fileName] = sourceMap + if _G.__TS__originalTraceback == nil then + local originalTraceback = debug.traceback + _G.__TS__originalTraceback = originalTraceback + debug.traceback = function(thread, message, level) + local trace + if thread == nil and message == nil and level == nil then + trace = originalTraceback() + elseif __TS__StringIncludes(_VERSION, "Lua 5.0") then + trace = originalTraceback((("[Level " .. tostring(level)) .. "] ") .. tostring(message)) + else + trace = originalTraceback(thread, message, level) + end + if type(trace) ~= "string" then + return trace + end + local function replacer(____, file, srcFile, line) + local fileSourceMap = _G.__TS__sourcemap[file] + if fileSourceMap ~= nil and fileSourceMap[line] ~= nil then + local data = fileSourceMap[line] + if type(data) == "number" then + return (srcFile .. ":") .. tostring(data) + end + return (data.file .. ":") .. tostring(data.line) + end + return (file .. ":") .. line + end + local result = string.gsub( + trace, + "(%S+)%.lua:(%d+)", + function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end + ) + local function stringReplacer(____, file, line) + local fileSourceMap = _G.__TS__sourcemap[file] + if fileSourceMap ~= nil and fileSourceMap[line] ~= nil then + local chunkName = (__TS__Match(file, "%[string \"([^\"]+)\"%]")) + local sourceName = string.gsub(chunkName, ".lua$", ".ts") + local data = fileSourceMap[line] + if type(data) == "number" then + return (sourceName .. ":") .. tostring(data) + end + return (data.file .. ":") .. tostring(data.line) + end + return (file .. ":") .. line + end + result = string.gsub( + result, + "(%[string \"[^\"]+\"%]):(%d+)", + function(file, line) return stringReplacer(nil, file, line) end + ) + return result + end + end +end + +local function __TS__Spread(iterable) + local arr = {} + if type(iterable) == "string" then + for i = 0, #iterable - 1 do + arr[i + 1] = __TS__StringAccess(iterable, i) + end + else + local len = 0 + for ____, item in __TS__Iterator(iterable) do + len = len + 1 + arr[len] = item + end + end + return __TS__Unpack(arr) +end + +local function __TS__StringCharAt(self, pos) + if pos ~= pos then + pos = 0 + end + if pos < 0 then + return "" + end + return string.sub(self, pos + 1, pos + 1) +end + +local function __TS__StringCharCodeAt(self, index) + if index ~= index then + index = 0 + end + if index < 0 then + return 0 / 0 + end + return string.byte(self, index + 1) or 0 / 0 +end + +local function __TS__StringEndsWith(self, searchString, endPosition) + if endPosition == nil or endPosition > #self then + endPosition = #self + end + return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString +end + +local function __TS__StringPadEnd(self, maxLength, fillString) + if fillString == nil then + fillString = " " + end + if maxLength ~= maxLength then + maxLength = 0 + end + if maxLength == -math.huge or maxLength == math.huge then + error("Invalid string length", 0) + end + if #self >= maxLength or #fillString == 0 then + return self + end + maxLength = maxLength - #self + if maxLength > #fillString then + fillString = fillString .. string.rep( + fillString, + math.floor(maxLength / #fillString) + ) + end + return self .. string.sub( + fillString, + 1, + math.floor(maxLength) + ) +end + +local function __TS__StringPadStart(self, maxLength, fillString) + if fillString == nil then + fillString = " " + end + if maxLength ~= maxLength then + maxLength = 0 + end + if maxLength == -math.huge or maxLength == math.huge then + error("Invalid string length", 0) + end + if #self >= maxLength or #fillString == 0 then + return self + end + maxLength = maxLength - #self + if maxLength > #fillString then + fillString = fillString .. string.rep( + fillString, + math.floor(maxLength / #fillString) + ) + end + return string.sub( + fillString, + 1, + math.floor(maxLength) + ) .. self +end + +local __TS__StringReplace +do + local sub = string.sub + function __TS__StringReplace(source, searchValue, replaceValue) + local startPos, endPos = string.find(source, searchValue, nil, true) + if not startPos then + return source + end + local before = sub(source, 1, startPos - 1) + local replacement = type(replaceValue) == "string" and replaceValue or replaceValue(nil, searchValue, startPos - 1, source) + local after = sub(source, endPos + 1) + return (before .. replacement) .. after + end +end + +local __TS__StringSplit +do + local sub = string.sub + local find = string.find + function __TS__StringSplit(source, separator, limit) + if limit == nil then + limit = 4294967295 + end + if limit == 0 then + return {} + end + local result = {} + local resultIndex = 1 + if separator == nil or separator == "" then + for i = 1, #source do + result[resultIndex] = sub(source, i, i) + resultIndex = resultIndex + 1 + end + else + local currentPos = 1 + while resultIndex <= limit do + local startPos, endPos = find(source, separator, currentPos, true) + if not startPos then + break + end + result[resultIndex] = sub(source, currentPos, startPos - 1) + resultIndex = resultIndex + 1 + currentPos = endPos + 1 + end + if resultIndex <= limit then + result[resultIndex] = sub(source, currentPos) + end + end + return result + end +end + +local __TS__StringReplaceAll +do + local sub = string.sub + local find = string.find + function __TS__StringReplaceAll(source, searchValue, replaceValue) + if type(replaceValue) == "string" then + local concat = table.concat( + __TS__StringSplit(source, searchValue), + replaceValue + ) + if #searchValue == 0 then + return (replaceValue .. concat) .. replaceValue + end + return concat + end + local parts = {} + local partsIndex = 1 + if #searchValue == 0 then + parts[1] = replaceValue(nil, "", 0, source) + partsIndex = 2 + for i = 1, #source do + parts[partsIndex] = sub(source, i, i) + parts[partsIndex + 1] = replaceValue(nil, "", i, source) + partsIndex = partsIndex + 2 + end + else + local currentPos = 1 + while true do + local startPos, endPos = find(source, searchValue, currentPos, true) + if not startPos then + break + end + parts[partsIndex] = sub(source, currentPos, startPos - 1) + parts[partsIndex + 1] = replaceValue(nil, searchValue, startPos - 1, source) + partsIndex = partsIndex + 2 + currentPos = endPos + 1 + end + parts[partsIndex] = sub(source, currentPos) + end + return table.concat(parts) + end +end + +local function __TS__StringSlice(self, start, ____end) + if start == nil or start ~= start then + start = 0 + end + if ____end ~= ____end then + ____end = 0 + end + if start >= 0 then + start = start + 1 + end + if ____end ~= nil and ____end < 0 then + ____end = ____end - 1 + end + return string.sub(self, start, ____end) +end + +local function __TS__StringStartsWith(self, searchString, position) + if position == nil or position < 0 then + position = 0 + end + return string.sub(self, position + 1, #searchString + position) == searchString +end + +local function __TS__StringSubstr(self, from, length) + if from ~= from then + from = 0 + end + if length ~= nil then + if length ~= length or length <= 0 then + return "" + end + length = length + from + end + if from >= 0 then + from = from + 1 + end + return string.sub(self, from, length) +end + +local function __TS__StringTrim(self) + local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1") + return result +end + +local function __TS__StringTrimEnd(self) + local result = string.gsub(self, "[%s ]*$", "") + return result +end + +local function __TS__StringTrimStart(self) + local result = string.gsub(self, "^[%s ]*", "") + return result +end + +local __TS__SymbolRegistryFor, __TS__SymbolRegistryKeyFor +do + local symbolRegistry = {} + function __TS__SymbolRegistryFor(key) + if not symbolRegistry[key] then + symbolRegistry[key] = __TS__Symbol(key) + end + return symbolRegistry[key] + end + function __TS__SymbolRegistryKeyFor(sym) + for key in pairs(symbolRegistry) do + if symbolRegistry[key] == sym then + return key + end + end + return nil + end +end + +local function __TS__TypeOf(value) + local luaType = type(value) + if luaType == "table" then + return "object" + elseif luaType == "nil" then + return "undefined" + else + return luaType + end +end + +local function __TS__Using(self, cb, ...) + local args = {...} + local thrownError + local ok, result = xpcall( + function() return cb( + nil, + __TS__Unpack(args) + ) end, + function(err) + thrownError = err + return thrownError + end + ) + local argArray = {__TS__Unpack(args)} + do + local i = #argArray - 1 + while i >= 0 do + local ____self_0 = argArray[i + 1] + ____self_0[Symbol.dispose](____self_0) + i = i - 1 + end + end + if not ok then + error(thrownError, 0) + end + return result +end + +local function __TS__UsingAsync(self, cb, ...) + local args = {...} + return __TS__AsyncAwaiter(function(____awaiter_resolve) + local thrownError + local ok, result = xpcall( + function() return cb( + nil, + __TS__Unpack(args) + ) end, + function(err) + thrownError = err + return thrownError + end + ) + local argArray = {__TS__Unpack(args)} + do + local i = #argArray - 1 + while i >= 0 do + if argArray[i + 1][Symbol.dispose] ~= nil then + local ____self_0 = argArray[i + 1] + ____self_0[Symbol.dispose](____self_0) + end + if argArray[i + 1][Symbol.asyncDispose] ~= nil then + local ____self_1 = argArray[i + 1] + __TS__Await(____self_1[Symbol.asyncDispose](____self_1)) + end + i = i - 1 + end + end + if not ok then + error(thrownError, 0) + end + return ____awaiter_resolve(nil, result) + end) +end + +return { + __TS__ArrayAt = __TS__ArrayAt, + __TS__ArrayConcat = __TS__ArrayConcat, + __TS__ArrayEntries = __TS__ArrayEntries, + __TS__ArrayEvery = __TS__ArrayEvery, + __TS__ArrayFill = __TS__ArrayFill, + __TS__ArrayFilter = __TS__ArrayFilter, + __TS__ArrayForEach = __TS__ArrayForEach, + __TS__ArrayFind = __TS__ArrayFind, + __TS__ArrayFindIndex = __TS__ArrayFindIndex, + __TS__ArrayFrom = __TS__ArrayFrom, + __TS__ArrayIncludes = __TS__ArrayIncludes, + __TS__ArrayIndexOf = __TS__ArrayIndexOf, + __TS__ArrayIsArray = __TS__ArrayIsArray, + __TS__ArrayJoin = __TS__ArrayJoin, + __TS__ArrayMap = __TS__ArrayMap, + __TS__ArrayPush = __TS__ArrayPush, + __TS__ArrayPushArray = __TS__ArrayPushArray, + __TS__ArrayReduce = __TS__ArrayReduce, + __TS__ArrayReduceRight = __TS__ArrayReduceRight, + __TS__ArrayReverse = __TS__ArrayReverse, + __TS__ArrayUnshift = __TS__ArrayUnshift, + __TS__ArraySort = __TS__ArraySort, + __TS__ArraySlice = __TS__ArraySlice, + __TS__ArraySome = __TS__ArraySome, + __TS__ArraySplice = __TS__ArraySplice, + __TS__ArrayToObject = __TS__ArrayToObject, + __TS__ArrayFlat = __TS__ArrayFlat, + __TS__ArrayFlatMap = __TS__ArrayFlatMap, + __TS__ArraySetLength = __TS__ArraySetLength, + __TS__ArrayToReversed = __TS__ArrayToReversed, + __TS__ArrayToSorted = __TS__ArrayToSorted, + __TS__ArrayToSpliced = __TS__ArrayToSpliced, + __TS__ArrayWith = __TS__ArrayWith, + __TS__AsyncAwaiter = __TS__AsyncAwaiter, + __TS__Await = __TS__Await, + __TS__Class = __TS__Class, + __TS__ClassExtends = __TS__ClassExtends, + __TS__CloneDescriptor = __TS__CloneDescriptor, + __TS__CountVarargs = __TS__CountVarargs, + __TS__Decorate = __TS__Decorate, + __TS__DecorateLegacy = __TS__DecorateLegacy, + __TS__DecorateParam = __TS__DecorateParam, + __TS__Delete = __TS__Delete, + __TS__DelegatedYield = __TS__DelegatedYield, + Error = Error, + RangeError = RangeError, + ReferenceError = ReferenceError, + SyntaxError = SyntaxError, + TypeError = TypeError, + URIError = URIError, + __TS__FunctionBind = __TS__FunctionBind, + __TS__Generator = __TS__Generator, + __TS__InstanceOf = __TS__InstanceOf, + __TS__InstanceOfObject = __TS__InstanceOfObject, + __TS__Iterator = __TS__Iterator, + __TS__LuaIteratorSpread = __TS__LuaIteratorSpread, + Map = Map, + __TS__Match = __TS__Match, + __TS__MathAtan2 = __TS__MathAtan2, + __TS__MathModf = __TS__MathModf, + __TS__MathSign = __TS__MathSign, + __TS__New = __TS__New, + __TS__Number = __TS__Number, + __TS__NumberIsFinite = __TS__NumberIsFinite, + __TS__NumberIsInteger = __TS__NumberIsInteger, + __TS__NumberIsNaN = __TS__NumberIsNaN, + __TS__ParseInt = __TS__ParseInt, + __TS__ParseFloat = __TS__ParseFloat, + __TS__NumberToString = __TS__NumberToString, + __TS__NumberToFixed = __TS__NumberToFixed, + __TS__ObjectAssign = __TS__ObjectAssign, + __TS__ObjectDefineProperty = __TS__ObjectDefineProperty, + __TS__ObjectEntries = __TS__ObjectEntries, + __TS__ObjectFromEntries = __TS__ObjectFromEntries, + __TS__ObjectGetOwnPropertyDescriptor = __TS__ObjectGetOwnPropertyDescriptor, + __TS__ObjectGetOwnPropertyDescriptors = __TS__ObjectGetOwnPropertyDescriptors, + __TS__ObjectKeys = __TS__ObjectKeys, + __TS__ObjectRest = __TS__ObjectRest, + __TS__ObjectValues = __TS__ObjectValues, + __TS__ParseFloat = __TS__ParseFloat, + __TS__ParseInt = __TS__ParseInt, + __TS__Promise = __TS__Promise, + __TS__PromiseAll = __TS__PromiseAll, + __TS__PromiseAllSettled = __TS__PromiseAllSettled, + __TS__PromiseAny = __TS__PromiseAny, + __TS__PromiseRace = __TS__PromiseRace, + Set = Set, + __TS__SetDescriptor = __TS__SetDescriptor, + __TS__SparseArrayNew = __TS__SparseArrayNew, + __TS__SparseArrayPush = __TS__SparseArrayPush, + __TS__SparseArraySpread = __TS__SparseArraySpread, + WeakMap = WeakMap, + WeakSet = WeakSet, + __TS__SourceMapTraceBack = __TS__SourceMapTraceBack, + __TS__Spread = __TS__Spread, + __TS__StringAccess = __TS__StringAccess, + __TS__StringCharAt = __TS__StringCharAt, + __TS__StringCharCodeAt = __TS__StringCharCodeAt, + __TS__StringEndsWith = __TS__StringEndsWith, + __TS__StringIncludes = __TS__StringIncludes, + __TS__StringPadEnd = __TS__StringPadEnd, + __TS__StringPadStart = __TS__StringPadStart, + __TS__StringReplace = __TS__StringReplace, + __TS__StringReplaceAll = __TS__StringReplaceAll, + __TS__StringSlice = __TS__StringSlice, + __TS__StringSplit = __TS__StringSplit, + __TS__StringStartsWith = __TS__StringStartsWith, + __TS__StringSubstr = __TS__StringSubstr, + __TS__StringSubstring = __TS__StringSubstring, + __TS__StringTrim = __TS__StringTrim, + __TS__StringTrimEnd = __TS__StringTrimEnd, + __TS__StringTrimStart = __TS__StringTrimStart, + __TS__Symbol = __TS__Symbol, + Symbol = Symbol, + __TS__SymbolRegistryFor = __TS__SymbolRegistryFor, + __TS__SymbolRegistryKeyFor = __TS__SymbolRegistryKeyFor, + __TS__TypeOf = __TS__TypeOf, + __TS__Unpack = __TS__Unpack, + __TS__Using = __TS__Using, + __TS__UsingAsync = __TS__UsingAsync +} diff --git a/dist/module/commands/set-xp-rate/set-xp-rate.lua b/dist/module/commands/set-xp-rate/set-xp-rate.lua new file mode 100644 index 0000000..bee7d06 --- /dev/null +++ b/dist/module/commands/set-xp-rate/set-xp-rate.lua @@ -0,0 +1,97 @@ +local ____lualib = require("lualib_bundle") +local Map = ____lualib.Map +local __TS__New = ____lualib.__TS__New +local __TS__StringIncludes = ____lualib.__TS__StringIncludes +local __TS__StringSplit = ____lualib.__TS__StringSplit +local __TS__ParseInt = ____lualib.__TS__ParseInt +local ____exports = {} +local ____stats = require("shared.stats") +local PlayerStats = ____stats.PlayerStats +--- Configuration options +local MAX_XP_RATE = 5 +local xpCmd = "#xprate" +local showXPcmd = "#xprate show" +local setXPcmd = "#xprate set" +local XP_RATE_SETTING = "xp_rate" +local xpRateCache = __TS__New(Map) +local function XPRateHandler(____, event, player, message) + if __TS__StringIncludes(message, xpCmd) then + local args = __TS__StringSplit(message, " ") + local cmd = args[2] + local playerCustom = __TS__New(PlayerStats, player) + playerCustom:load() + if cmd == "show" then + local xpRate = xpRateCache:get(player:GetGUIDLow()) + if xpRate ~= nil then + player:SendBroadcastMessage(("Your current XP rate is " .. tostring(xpRate)) .. "x") + else + player:SendBroadcastMessage("Your current XP rate is 1x") + end + elseif cmd == "set" then + local rate = args[3] + local rateNum = __TS__ParseInt(rate) + if rateNum > MAX_XP_RATE then + player:SendNotification(("You cannot set your XP rate higher then " .. tostring(MAX_XP_RATE)) .. "x") + return false + end + playerCustom:setStat(XP_RATE_SETTING, rateNum) + playerCustom:save() + xpRateCache:set( + player:GetGUIDLow(), + rateNum + ) + player:SendBroadcastMessage(("Your XP rate has been set to " .. tostring(rateNum)) .. "x") + else + player:SendBroadcastMessage(("Usage: " .. xpCmd) .. " [show|set] [rate]") + end + return false + end + return true +end +--- Gives players extra XP based on their rate +-- +-- @param event \ +-- @param player +-- @param amount +-- @param victim +local function XPBonus(____, event, player, amount, victim) + local xpRate = xpRateCache:get(player:GetGUIDLow()) + if xpRate and xpRate > 1 then + player:GiveXP(amount * xpRate) + end +end +local function XPRateLoader(____, event, player) + local playerCustom = __TS__New(PlayerStats, player) + playerCustom:load() + local xpRate = playerCustom:getStat(XP_RATE_SETTING) + if xpRate then + xpRateCache:set( + player:GetGUIDLow(), + xpRate.value + ) + else + xpRateCache:set( + player:GetGUIDLow(), + 1 + ) + end +end +RegisterPlayerEvent( + 12, + function(...) return XPBonus(nil, ...) end +) +RegisterPlayerEvent( + 18, + function(...) return XPRateHandler(nil, ...) end +) +RegisterPlayerEvent( + 3, + function(...) return XPRateLoader(nil, ...) end +) +RegisterServerEvent( + 33, + function(...) + xpRateCache = PlayerStats:GetStatsByType("player", XP_RATE_SETTING) + end +) +return ____exports diff --git a/dist/module/gameobjects/soulswapper/soulswapper.lua b/dist/module/gameobjects/soulswapper/soulswapper.lua new file mode 100644 index 0000000..4f8e924 --- /dev/null +++ b/dist/module/gameobjects/soulswapper/soulswapper.lua @@ -0,0 +1,149 @@ +local ____lualib = require("lualib_bundle") +local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes +local __TS__New = ____lualib.__TS__New +local ____exports = {} +local ____money = require("shared.money") +local ToGold = ____money.ToGold +local ToCopper = ____money.ToCopper +local ____account = require("shared.account") +local AccountInfo = ____account.AccountInfo +--- This is the list of item classes that are allowed to be sent to other characters. +-- +-- @link https://www.azerothcore.org/wiki/item_template +local ALLOWED_ITEM_CLASSES = {2, 4, 9} +--- This is the number of characters an account can have. +local ALLOWED_ACCOUNT_CHARS = 15 +--- Base price for sending an item multipliers will be added on top +local SOULSWAP_BASE_PRICE = ToCopper(nil, 20) +--- The level the discount for sending items is no longer applied +local NO_DISCOUNT_LEVEL = 70 +--- Discount percentage applied per 10 levels +local DISCOUNT_ADJ = 3 +--- The id of the object that will interact with the player to handle the soulswap +local INTERACTIVE_OBJECT = 750000 +local selectedItem = {} +local function getCost(self, guid, player) + local itemGuid = GetItemGUID(guid) + local theItem = player:GetItemByGUID(itemGuid) + local discount = 1 + local iLevelModifer = theItem:GetItemLevel() / 40 + if player:GetLevel() < NO_DISCOUNT_LEVEL then + discount = (NO_DISCOUNT_LEVEL - player:GetLevel()) * DISCOUNT_ADJ + end + if discount > 100 then + discount = 90 + end + return SOULSWAP_BASE_PRICE * iLevelModifer * ((100 - discount) / 100) +end +local function GossipHello(____, event, player, gameobject) + player:GossipClearMenu() + local items = 0 + do + local i = 23 + while i <= 38 do + local item = player:GetItemByPos(255, i) + if item ~= nil then + local itemClass = item:GetClass() + if item:IsSoulBound() and __TS__ArrayIncludes(ALLOWED_ITEM_CLASSES, itemClass) then + local quality = item:GetQuality() + local quantity = item:GetCount() + local cost = getCost( + nil, + item:GetGUIDLow(), + player + ) + if quality > 2 and quantity == 1 then + items = items + 1 + player:GossipMenuAddItem( + 1, + ((("Item: " .. item:GetItemLink()) .. " (") .. tostring(ToGold(nil, cost))) .. "g)", + 1, + item:GetGUIDLow(), + nil, + nil + ) + end + end + end + i = i + 1 + end + end + if items == 0 then + player:SendNotification("You have no soulbound items in your backback to send to your other characters.") + end + player:GossipMenuAddItem(1, "Stop using the device", 1, 50500) + player:GossipSendMenu(1000, gameobject, 10000) + return true +end +local function GossipSelect(____, event, player, creature, selection, action, code, menuId) + local account = __TS__New( + AccountInfo, + player:GetAccountId() + ) + local characters = account:GetCharacters() + if action == 50500 then + player:GossipClearMenu() + player:GossipComplete() + return true + end + if action > ALLOWED_ACCOUNT_CHARS then + do + local numC = 0 + while numC < #characters do + local name = characters[numC + 1].name + if name ~= player:GetName() then + local cost = getCost(nil, action, player) + player:GossipMenuAddItem( + 2, + "Send to: " .. name, + 2, + numC + 1, + nil, + ("Are you sure you will to rebind this item? The item will be mailed to " .. name) .. "?", + cost + ) + end + numC = numC + 1 + end + end + selectedItem[player:GetName()] = action + player:GossipSendMenu(1000, creature, 10000) + end + if action <= ALLOWED_ACCOUNT_CHARS then + local itemToChange = selectedItem[player:GetName()] + local itemGuid = GetItemGUID(itemToChange) + local PlayerItem = player:GetItemByGUID(itemGuid) + print((("Item Info: " .. PlayerItem:GetOwner():GetName()) .. " owns ") .. PlayerItem:GetName()) + local newItemGuid = SendMail( + "Item Rebound " .. PlayerItem:GetName(), + "Soulbinder has sent you a gift " .. PlayerItem:GetName(), + characters[action].guid, + player:GetGUIDLow(), + 41, + 0, + 0, + 0, + PlayerItem:GetEntry(), + 1 + ) + player:RemoveItem( + PlayerItem, + PlayerItem:GetEntry(), + 1 + ) + player:GossipClearMenu() + player:GossipComplete() + end + return true +end +RegisterGameObjectGossipEvent( + INTERACTIVE_OBJECT, + 1, + function(...) return GossipHello(nil, ...) end +) +RegisterGameObjectGossipEvent( + INTERACTIVE_OBJECT, + 2, + function(...) return GossipSelect(nil, ...) end +) +return ____exports diff --git a/dist/module/gameplay/achievement-tokens/achievement-tokens.lua b/dist/module/gameplay/achievement-tokens/achievement-tokens.lua new file mode 100644 index 0000000..454823d --- /dev/null +++ b/dist/module/gameplay/achievement-tokens/achievement-tokens.lua @@ -0,0 +1,43 @@ +--- CONFIG OPTIONS +-- +-- @returns +AWARD_RATE = 5 +TOKEN_ID = 910001 +REWARD_CHAR_GUID = 2506 +--- On Achivement complete the system will reward the player with tokens based on the AWARD_RATE +-- set above +-- Default is 5 Achievement Points = 1 Token +-- +-- IE) +-- 10 Achievement Points = 2 Tokens +-- 50 Achievement Points = 10 Tokens +-- +-- @param event : number +-- @param player : Player +-- @param achievement : Achievement +-- @returns boolean +achievementComplete = function(____, event, player, achievement) + local id = achievement:GetId() + local query = WorldDBQuery("SELECT Points from achievements where ID=" .. tostring(id)) + local points = query:GetUInt32(0) + if points ~= nil then + local tokens = math.ceil(points / AWARD_RATE) + SendMail( + "Your achievement token reward!", + "You earned it now spend it!", + player:GetGUIDLow(), + REWARD_CHAR_GUID, + 41, + 0, + 0, + 0, + TOKEN_ID, + tokens + ) + end + return true +end +RegisterPlayerEvent( + 45, + function(...) return achievementComplete(_G, ...) end +) diff --git a/dist/module/gameplay/worgoblin/worgoblin.lua b/dist/module/gameplay/worgoblin/worgoblin.lua new file mode 100644 index 0000000..0a3b721 --- /dev/null +++ b/dist/module/gameplay/worgoblin/worgoblin.lua @@ -0,0 +1,33 @@ +local ____exports = {} +local ____money = require("shared.money") +local ToCopper = ____money.ToCopper +RegisterPlayerEvent( + 30, + function(event, player) + if player:GetRace() == 12 then + player:LearnSpell(20577) + player:LearnSpell(33697) + player:SetLevel(20) + player:Teleport( + 0, + -10728.057617, + -1131.12085, + 27.594067, + 1.180833 + ) + player:ModifyMoney(ToCopper(nil, 100)) + end + if player:GetRace() == 9 then + player:SetLevel(20) + player:ModifyMoney(ToCopper(nil, 100)) + player:Teleport( + 1, + -1049.596, + -3645.963, + 23.878, + 4.468 + ) + end + end +) +return ____exports diff --git a/dist/module/shared/account.lua b/dist/module/shared/account.lua new file mode 100644 index 0000000..1b33bb1 --- /dev/null +++ b/dist/module/shared/account.lua @@ -0,0 +1,29 @@ +local ____lualib = require("lualib_bundle") +local __TS__Class = ____lualib.__TS__Class +local ____exports = {} +____exports.AccountInfo = __TS__Class() +local AccountInfo = ____exports.AccountInfo +AccountInfo.name = "AccountInfo" +function AccountInfo.prototype.____constructor(self, accountId) + self.accountId = accountId +end +function AccountInfo.prototype.GetAccountMoney(self) + local result = CharDBQuery("SELECT SUM(Money) as AccountMoney from acore_characters.characters WHERE account = " .. tostring(self.accountId)) + local row = result:GetRow() + return row.AccountMoney +end +function AccountInfo.prototype.GetCharacters(self) + local result = CharDBQuery("SELECT guid, name from characters WHERE account = " .. tostring(self.accountId)) + local characters = {} + do + local i = 0 + while i < result:GetRowCount() do + local row = result:GetRow() + characters[#characters + 1] = {guid = row.guid, name = row.name} + result:NextRow() + i = i + 1 + end + end + return characters +end +return ____exports diff --git a/dist/module/shared/money.lua b/dist/module/shared/money.lua new file mode 100644 index 0000000..88641fc --- /dev/null +++ b/dist/module/shared/money.lua @@ -0,0 +1,33 @@ +local ____lualib = require("lualib_bundle") +local __TS__New = ____lualib.__TS__New +local ____exports = {} +local ____account = require("shared.account") +local AccountInfo = ____account.AccountInfo +____exports.GOLD_TO_COPPER = 10000 +--- Converts a copper cost to gold +-- +-- @param cost Cost of item in copper +-- @returns number +function ____exports.ToGold(self, cost) + return math.floor(cost / ____exports.GOLD_TO_COPPER) +end +--- Converts a gold cost to copper +-- +-- @param gold Cost of item in gold +-- @returns number +function ____exports.ToCopper(self, gold) + return gold * ____exports.GOLD_TO_COPPER +end +--- Gets a scaling tax for players to help with balancing the economy for guild features. +-- +-- @param player Player +-- @param tax amount of tax against player to levy number (0-100) +-- @returns number result in copper +function ____exports.GetPlayerTax(self, player, tax) + local account = __TS__New( + AccountInfo, + player:GetAccountId() + ) + return tax / 100 * account:GetAccountMoney() +end +return ____exports diff --git a/dist/module/shared/stats.lua b/dist/module/shared/stats.lua new file mode 100644 index 0000000..1e28fa1 --- /dev/null +++ b/dist/module/shared/stats.lua @@ -0,0 +1,129 @@ +local ____lualib = require("lualib_bundle") +local __TS__Class = ____lualib.__TS__Class +local Map = ____lualib.Map +local __TS__New = ____lualib.__TS__New +local __TS__Iterator = ____lualib.__TS__Iterator +local __TS__ClassExtends = ____lualib.__TS__ClassExtends +local ____exports = {} +--- Config +local PLAYER_TYPE = "player" +____exports.StatEvents = {TOKEN_CREATED = "token_created", TICKETS_AWARDED = "darkmoon_tickets_awarded"} +--- Adds stats to database based on type of stat. +____exports.Stats = __TS__Class() +local Stats = ____exports.Stats +Stats.name = "Stats" +function Stats.prototype.____constructor(self, entity) + self.stats = __TS__New(Map) + self.entity = entity + self:load() +end +function Stats.GetStatsByType(self, ____type, name) + local result = CharDBQuery(((("SELECT id, name, value, updated FROM " .. ____type) .. "_stats WHERE name = '") .. name) .. "'") + local stats = __TS__New(Map) + if not result then + return stats + end + do + local i = 0 + while i < result:GetRowCount() do + local row = result:GetRow() + stats:set(row.id, row.value) + result:NextRow() + i = i + 1 + end + end + return stats +end +function Stats.prototype.load(self) + local result = CharDBQuery((("SELECT id, name, value, updated FROM " .. self.entity.type) .. "_stats WHERE id = ") .. tostring(self.entity.id)) + if not result then + return false + end + do + local i = 0 + while i < result:GetRowCount() do + local row = result:GetRow() + local stat = { + name = row.name, + type = self.entity.type, + value = row.value, + updated = row.updated, + loaded = true + } + self.stats:set(stat.name, stat) + result:NextRow() + i = i + 1 + end + end + return true +end +function Stats.prototype.save(self) + for ____, stat in __TS__Iterator(self.stats:values()) do + if not stat.loaded then + CharDBExecute(((((((((("INSERT INTO " .. self.entity.type) .. "_stats (id, name, value, updated) VALUES (") .. tostring(self.entity.id)) .. ", '") .. stat.name) .. "', ") .. tostring(stat.value)) .. ", ") .. tostring(stat.updated)) .. ")") + PrintDebug((((((("Inserted " .. stat.name) .. " for ") .. self.entity.type) .. " ") .. tostring(self.entity.id)) .. " with value ") .. tostring(stat.value)) + else + CharDBExecute(((((((((("UPDATE " .. self.entity.type) .. "_stats SET value = ") .. tostring(stat.value)) .. ", updated = ") .. tostring(stat.updated)) .. " WHERE id = ") .. tostring(self.entity.id)) .. " AND name = '") .. stat.name) .. "'") + PrintDebug((((((("Updated " .. stat.name) .. " for ") .. self.entity.type) .. " ") .. tostring(self.entity.id)) .. " to ") .. tostring(stat.value)) + end + end +end +function Stats.prototype.getStat(self, name) + return self.stats:get(name) +end +function Stats.prototype.setStat(self, name, value) + local stat = self.stats:get(name) + if stat then + stat.value = value + stat.updated = GetGameTime(nil) + else + self.stats:set( + name, + { + name = name, + type = PLAYER_TYPE, + value = value, + updated = GetGameTime(nil), + loaded = false + } + ) + end +end +function Stats.prototype.increment(self, name, amount) + if amount == nil then + amount = 1 + end + local stat = self.stats:get(name) + if stat then + stat.value = stat.value + amount + stat.updated = GetGameTime(nil) + else + self.stats:set( + name, + { + name = name, + type = PLAYER_TYPE, + value = 0, + updated = GetGameTime(nil), + loaded = false + } + ) + end +end +--- Custom player stats that will be +____exports.PlayerStats = __TS__Class() +local PlayerStats = ____exports.PlayerStats +PlayerStats.name = "PlayerStats" +__TS__ClassExtends(PlayerStats, ____exports.Stats) +function PlayerStats.prototype.____constructor(self, player) + PlayerStats.____super.prototype.____constructor( + self, + { + id = player:GetGUID(), + type = PLAYER_TYPE + } + ) + self.playerStats = {} + self.player = player +end +return ____exports diff --git a/dist/module/shared/triggers.lua b/dist/module/shared/triggers.lua new file mode 100644 index 0000000..5f4d24f --- /dev/null +++ b/dist/module/shared/triggers.lua @@ -0,0 +1,23 @@ +local ____exports = {} +--- Sets a player trigger boolean that can be retieved later as needed +-- +-- @param charTrigger TriggerInput +function ____exports.SetTrigger(self, charTrigger) + local sql = ("INSERT INTO player_trigger (triggerName, characterGuid, isSet) " .. ((((("VALUES (\"" .. charTrigger.triggerName) .. "\", ") .. tostring(charTrigger.characterGuid)) .. ", ") .. tostring(charTrigger.isSet)) .. ")") .. "ON DUPLICATE KEY UPDATE isSet=" .. tostring(charTrigger.isSet) + CharDBExecute(sql) +end +--- Will return the value of the trigger if it exists, otherwise it will return false +-- +-- @param charGuid number +-- @param triggerName string +-- @returns boolean +function ____exports.GetTrigger(self, charGuid, triggerName) + local sql = (("SELECT isSet from player_trigger WHERE triggerName=\"" .. triggerName) .. "\" and characterGuid=") .. tostring(charGuid) + local result = CharDBQuery(sql) + if result and result:GetRowCount() > 0 then + return result:GetBool(0) + else + return false + end +end +return ____exports diff --git a/dist/module/shared/ui-utils.lua b/dist/module/shared/ui-utils.lua new file mode 100644 index 0000000..818a914 --- /dev/null +++ b/dist/module/shared/ui-utils.lua @@ -0,0 +1,19 @@ +local ____exports = {} +function ____exports.colors(self, name) + local colors = { + GREY = "|cff999999", + RED = "|cffff0000", + WHITE = "|cffFFFFFF", + GREEN = "|cff1eff00", + PURPLE = "|cff9F3FFF", + BLUE = "|cff0070dd", + ORANGE = "|cffFF8400" + } + local keyName = string.upper(name) + if colors[keyName] then + return colors[keyName] + else + return colors.WHITE + end +end +return ____exports diff --git a/dist/module/special/gambler/gambler.client.lua b/dist/module/special/gambler/gambler.client.lua new file mode 100644 index 0000000..9543318 --- /dev/null +++ b/dist/module/special/gambler/gambler.client.lua @@ -0,0 +1,194 @@ +--- + +local AIO = AIO or require("AIO") +if not AIO.AddAddon() then + --- Configuration options + local LOW_BET_SIZE_GOLD = 20 + local HIGH_BET_SIZE_GOLD = 100 + local gamblerHandlers = AIO.AddHandlers("GamblerMain", {}) + local classImages = { + "Interface/Gambler/druid", + "Interface/Gambler/deathknight", + "Interface/Gambler/hunter", + "Interface/Gambler/mage", + "Interface/Gambler/paladin", + "Interface/Gambler/priest", + "Interface/Gambler/rogue", + "Interface/Gambler/shaman", + "Interface/Gambler/warlock", + "Interface/Gambler/warrior" + } + local slotSpin = {} + local multiplier = 1 + local function getRandomClassImage(self) + local spinIndex = math.floor(math.random() * #classImages) + slotSpin[#slotSpin + 1] = spinIndex + return classImages[spinIndex + 1] + end + local function resetSpin(self) + slotSpin = {} + end + local function determineWin(self) + local win = 0 + local gold = 0 + local tokens = 0 + if slotSpin[1] == 1 and slotSpin[2] == 1 and slotSpin[3] == 1 then + if multiplier == 3 then + tokens = 100 + end + gold = multiplier * 5000 + win = 2 + end + if slotSpin[1] == slotSpin[2] and slotSpin[2] == slotSpin[3] then + if multiplier == 3 then + tokens = 50 + end + gold = multiplier * 1000 + win = 1 + end + if slotSpin[1] == slotSpin[2] and slotSpin[3] == 1 or slotSpin[1] == slotSpin[3] and slotSpin[2] == 1 or slotSpin[2] == slotSpin[3] and slotSpin[1] == 1 or slotSpin[1] == 1 and slotSpin[2] == 1 or slotSpin[1] == 1 and slotSpin[3] == 1 or slotSpin[2] == 1 and slotSpin[3] == 1 then + if multiplier == 3 then + tokens = 20 + end + gold = multiplier * 500 + win = 1 + end + if slotSpin[1] == slotSpin[2] and win == 0 then + gold = multiplier * 100 + win = 1 + if slotSpin[2] == 1 then + if multiplier == 3 then + tokens = 3 + end + gold = multiplier * 250 + win = 1 + end + end + if (slotSpin[1] == 1 or slotSpin[2] == 1 or slotSpin[3] == 1) and win == 0 then + if multiplier == 3 then + tokens = 0 + gold = 200 + else + tokens = 0 + gold = 40 + end + win = 1 + end + if win > 0 then + PlaySoundFile("Sound\\Interface\\LootCoinLarge.wav", "Master") + AIO.Handle("GamblerMain", "AwardSlotWin", gold, tokens) + end + return win + end + local function SpinSlots(self, SlotFrame, Slot) + local timer = 1 + local counter = 1 + PlaySoundFile("Sound\\Doodad\\GnomeMachine02StandLoop.wav", "Master") + SlotFrame:SetScript( + "OnUpdate", + function(frame, elapsed) + timer = timer + elapsed + if timer > 0.2 then + counter = counter + 1 + resetSpin(_G) + timer = 0 + Slot[1]:SetTexture(getRandomClassImage(_G)) + Slot[2]:SetTexture(getRandomClassImage(_G)) + Slot[3]:SetTexture(getRandomClassImage(_G)) + if counter > 22 then + frame:SetScript("OnUpdate", nil) + determineWin(_G) + end + end + end + ) + end + local function ShowSlots(self, player) + local GamblerMainFrame = CreateFrame("Frame", "GamblerMainFrame", UIParent, "UIPanelDialogTemplate") + GamblerMainFrame:SetSize(512, 324) + GamblerMainFrame:SetMovable(false) + GamblerMainFrame:SetPoint("CENTER") + GamblerMainFrame:EnableMouse(true) + GamblerMainFrame:EnableKeyboard(true) + GamblerMainFrame:Hide() + local Title = GamblerMainFrame:CreateFontString("TitleFrame", "OVERLAY", "GameFontHighlight") + Title:SetPoint("TOPLEFT", 15, -10) + Title:SetText("Heros Slots") + Title:SetFont("Fonts\\FRIZQT__.TTF", 10) + local Slots = CreateFrame("Frame", "SlotsFrame", GamblerMainFrame) + Slots:SetSize(420, 160) + Slots:SetPoint("CENTER", 0, 25) + Slots:SetFrameLevel(1) + Slots:SetBackdrop({ + bgFile = "Interface/DialogFrame/UI-DialogBox-Background", + edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", + tile = true, + tileSize = 32, + edgeSize = 32, + insets = {left = 11, right = 12, top = 12, bottom = 11} + }) + local Slot1 = Slots:CreateTexture("Slot1Texture", nil, Slots) + Slot1:SetSize(128, 128) + Slot1:SetAlpha(0.85) + Slot1:SetPoint("TOPLEFT", 13, -16) + Slot1:SetTexture(getRandomClassImage(_G)) + local Slot1Point, Slot1Region, Slot1RelPoint, x1offset, y1offset = Slot1:GetPoint() + local Slot2 = Slots:CreateTexture("Slot2Texture", nil, Slots) + Slot2:SetSize(128, 128) + Slot2:SetAlpha(0.85) + Slot2:SetPoint( + "TOPLEFT", + Slot1Region, + Slot1RelPoint, + x1offset + 128 + 5, + y1offset + ) + Slot2:SetTexture(getRandomClassImage(_G)) + local Slot2Point, Slot2Region, Slot2RelPoint, x2offset, y2offset = Slot2:GetPoint() + local Slot3 = Slots:CreateTexture("Slot3Texture", nil, Slots) + Slot3:SetSize(128, 128) + Slot3:SetAlpha(0.85) + Slot3:SetPoint( + "TOPLEFT", + Slot2Region, + Slot2RelPoint, + x2offset + 128 + 5, + y2offset + ) + Slot3:SetTexture(getRandomClassImage(_G)) + local SpinButton = CreateFrame("Button", "SpinButtonLow", GamblerMainFrame, "UIPanelButtonTemplate") + SpinButton:SetSize(128, 32) + SpinButton:SetPoint("CENTER", -80, -80) + SpinButton:SetText(("Bet " .. tostring(LOW_BET_SIZE_GOLD)) .. "g Spin") + SpinButton:SetFrameLevel(2) + SpinButton:SetScript( + "OnClick", + function(frame, mouse, button) + resetSpin(_G) + multiplier = 1 + AIO.Handle("GamblerMain", "PayForSpin", LOW_BET_SIZE_GOLD * 10000) + end + ) + local SpinButtonHigh = CreateFrame("Button", "SpinButtonHigh", GamblerMainFrame, "UIPanelButtonTemplate") + SpinButtonHigh:SetSize(128, 32) + SpinButtonHigh:SetPoint("CENTER", 80, -80) + SpinButtonHigh:SetText(("Bet " .. tostring(HIGH_BET_SIZE_GOLD)) .. "g Spin") + SpinButtonHigh:SetFrameLevel(2) + SpinButtonHigh:SetScript( + "OnClick", + function(frame, mouse, button) + resetSpin(_G) + multiplier = 3 + AIO.Handle("GamblerMain", "PayForSpin", HIGH_BET_SIZE_GOLD * 10000) + end + ) + gamblerHandlers.StartSpin = function(____, player) + SpinSlots(_G, Slots, {Slot1, Slot2, Slot3}) + end + GamblerMainFrame:Show() + return GamblerMainFrame + end + gamblerHandlers.ShowFrame = function(____, player) + ShowSlots(_G, player) + end +end diff --git a/dist/module/special/gambler/gambler.server.lua b/dist/module/special/gambler/gambler.server.lua new file mode 100644 index 0000000..28458c4 --- /dev/null +++ b/dist/module/special/gambler/gambler.server.lua @@ -0,0 +1,70 @@ +--- + +local AIO = AIO or require("AIO") +--- Game Object that will start the slot machine up +SLOT_GAME_OBJECT = 750001 +--- Token Id of the currency you want to aware the players. +TOKEB_ID = 910001 +ShowGambler = function(____, event, player, command) + if command == "gamble" then + AIO.Handle(player, "GamblerMain", "ShowFrame") + return false + end + return true +end +--- +-- @noSelf +function PayForSpin(player, cost) + local money = player:GetCoinage() + if money >= cost then + player:ModifyMoney(cost * -1) + AIO.Handle(player, "GamblerMain", "StartSpin") + else + player:SendNotification("You don't have enough money to spin the slots!") + player:PlayDirectSound(8959, player) + end +end +function AwardSlotWin(player, gold, tokens) + player:ModifyMoney(gold * 10000) + if tokens > 0 then + player:AddItem(TOKEB_ID, tokens) + end + if tokens > 75 then + player:SendChatMessageToPlayer( + 1, + 0, + ((("|cff1eff00I HIT THE JACKPOT! I won " .. tostring(gold)) .. " gold and ") .. tostring(tokens)) .. " tokens!", + player + ) + else + if tokens > 0 then + player:SendChatMessageToPlayer( + 1, + 0, + ((("|cff1eff00I won " .. tostring(gold)) .. " gold and ") .. tostring(tokens)) .. " tokens!", + player + ) + else + player:SendChatMessageToPlayer( + 1, + 0, + ("|cff1eff00I won " .. tostring(gold)) .. " gold", + player + ) + end + end +end +SendSlotStart = function(____, event, gameobject, player) + AIO.Handle(player, "GamblerMain", "ShowFrame") + return true +end +gamblerHandlers = AIO.AddHandlers("GamblerMain", {PayForSpin = PayForSpin, AwardSlotWin = AwardSlotWin}) +RegisterPlayerEvent( + 42, + function(...) return ShowGambler(_G, ...) end +) +RegisterGameObjectEvent( + SLOT_GAME_OBJECT, + 14, + function(...) return SendSlotStart(_G, ...) end +)