64 lines
3.3 KiB
JavaScript
64 lines
3.3 KiB
JavaScript
import { method, RUN_LENGTH, GOLD_PER_WIN, CARD_PRICE, REST_HEAL, RELIC_PRICE, ACT_COUNT, ACT_MAPS, LOBBY_MAP, LOBBY_SPAWN } from '../lib/codeblock.mjs';
|
|
import { CARDS, ENEMIES, CLASSES, JOBS, SOUL_UNLOCKS, CARDFRAMES, RARITIES, MAP_ROWS, MAP_COLS, CHEST_CLOSED_RUID, CHEST_OPEN_RUID, NODEICONS, CHARS, CAM, RELICS, POTIONS, luaSoulShopTable, frameRuid, luaFramesTable, luaNodeIconsTable, luaRelicsTable, luaPotionsTable, luaIntentsArray, luaEnemiesTable, luaStr, luaJobsTable, luaCardsTable, luaDeckTable } from '../lib/data.mjs';
|
|
import { UI_FILE, COMMON_FILE, UI_ROOT, GENERATED_UI_SECTIONS, UI_APPEND_ORDER, DISABLED_STOCK_CONTROLS, TRANSPARENT, DARK, GOLD, ATTACK, DEFEND, SKILL, DAMAGE_DIGIT_RUIDS, DAMAGE_POP_MAX_DIGITS, DAMAGE_POP_DIGIT_W, DAMAGE_POP_DIGIT_H, DAMAGE_POP_DIGIT_SPACING, MAX_MONSTERS, HEAD_OFFSET_Y, HP_BAR_W, WHITE, CARD_NAME_TEXT, CARD_DESC_TEXT, cardFaceLayout, CARD_W, CARD_H, CARD_SPACING, CARD_XS, ALIGN_CENTER, ALIGN_BOTTOM_CENTER, guid, transform, sprite, button, text, scrollLayoutGroup, popupLayerFor, uiOrderFor, displayOrderFor, applySortingOverride, entity, uiPath, sectionRoot, isGeneratedUiEntity, appendUiSection } from '../lib/ui-helpers.mjs';
|
|
|
|
export const rewardMethods = [
|
|
method('CardPool', `local pool = {}
|
|
for id, c in pairs(self.Cards) do
|
|
local pools = self.ClassPools or {}
|
|
local basePool = pools[self.SelectedClass] or pools.rogue or {}
|
|
local jobPool = pools[self.PlayerJob] or {}
|
|
if c.token ~= true and ((basePool[c.class] == true) or (self.PlayerJob ~= "" and jobPool[c.class] == true)) then
|
|
table.insert(pool, id)
|
|
end
|
|
end
|
|
table.sort(pool)
|
|
return pool`, [], 0, 'any'),
|
|
method('OfferReward', `self:SetEntityEnabled("/ui/RunUIGroup/CardHand", false)
|
|
self:SetEntityEnabled("/ui/RunUIGroup/DeckHud", false)
|
|
local pool = self:CardPool()
|
|
local byRarity = {}
|
|
for _, id in ipairs(pool) do
|
|
local r = self.Cards[id].rarity or "normal"
|
|
if byRarity[r] == nil then byRarity[r] = {} end
|
|
table.insert(byRarity[r], id)
|
|
end
|
|
self.RewardChoices = {}
|
|
for i = 1, 3 do
|
|
local roll = math.random(1, 100)
|
|
local want = "normal"
|
|
if roll > 95 then want = "legend" elseif roll > 70 then want = "unique" end
|
|
local bucket = byRarity[want]
|
|
if bucket == nil or #bucket == 0 then bucket = pool end
|
|
self.RewardChoices[i] = bucket[math.random(1, #bucket)]
|
|
self:ApplyRewardVisual(i, self.RewardChoices[i])
|
|
end
|
|
local hud = _EntityService:GetEntityByPath("/ui/RunUIGroup/RewardHud")
|
|
if hud ~= nil then
|
|
hud.Enable = true
|
|
end`),
|
|
method('ApplyRewardVisual', `self:ApplyCardFace("/ui/RunUIGroup/RewardHud/Reward" .. tostring(slot), cardId)`, [
|
|
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' },
|
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' },
|
|
]),
|
|
method('PickReward', `if self.CombatOver ~= true or self.RunActive ~= true then
|
|
return
|
|
end
|
|
if slot ~= 0 and self.RewardChoices ~= nil then
|
|
local id = self.RewardChoices[slot]
|
|
if id ~= nil then
|
|
table.insert(self.RunDeck, id)
|
|
end
|
|
end
|
|
if self.BonusRewardScreens ~= nil and self.BonusRewardScreens > 0 and slot ~= 0 then
|
|
self.BonusRewardScreens = self.BonusRewardScreens - 1
|
|
self:OfferReward()
|
|
return
|
|
end
|
|
local hud = _EntityService:GetEntityByPath("/ui/RunUIGroup/RewardHud")
|
|
if hud ~= nil then
|
|
hud.Enable = false
|
|
end
|
|
self:ShowMap()`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }]),
|
|
];
|