Files
maplecontest/tools/deck/cb/jobs.mjs
2026-06-30 01:53:45 +09:00

119 lines
3.8 KiB
JavaScript

import { method } from '../lib/codeblock.mjs';
export const jobMethods = [
method('BaseClassLabel', `if classId == "warrior" then
return "전사"
elseif classId == "rogue" then
return "Rogue"
elseif classId == "magician" then
return "마법사"
end
return "플레이어"`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'classId' }], 0, 'string'),
method('CurrentClassId', `if self.PlayerJob ~= nil and self.PlayerJob ~= "" then
return self.PlayerJob
end
return self.SelectedClass or ""`, [], 0, 'string'),
method('GetPlayableClasses', `local current = self:CurrentClassId()
if current == nil or current == "" then
return {}
end
if self.ClassLineages ~= nil and self.ClassLineages[current] ~= nil then
return self.ClassLineages[current]
end
return { current }`, [], 0, 'any'),
method('CanUseClassCard', `if cardClass == nil or cardClass == "" then
return false
end
if cardClass == "curse" then
return true
end
local playable = self:GetPlayableClasses()
for i = 1, #playable do
if playable[i] == cardClass then
return true
end
end
return false`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardClass' }], 0, 'boolean'),
method('CanAdvanceJob', `local current = self:CurrentClassId()
if current == nil or current == "" or self.Jobs == nil then
return false
end
local opts = self.Jobs[current]
return opts ~= nil and #opts > 0`, [], 0, 'boolean'),
method('ShowJobChoice', `if self:CanAdvanceJob() ~= true then
self:ContinueAfterBoss()
return
end
self:SetEntityEnabled("/ui/RunUIGroup/CardHand", false)
self:SetEntityEnabled("/ui/RunUIGroup/DeckHud", false)
self:SetEntityEnabled("/ui/SelectUIGroup/JobChoiceHud", true)`),
method('PickJobReward', `self:SetEntityEnabled("/ui/SelectUIGroup/JobChoiceHud", false)
if kind == "relic" then
local bid = self:PickNewRelic()
if bid ~= "" then
self:AddRelic(bid)
local br = self.Relics[bid]
if br ~= nil then
self:Toast("유물 획득: " .. br.name)
end
end
self:ContinueAfterBoss()
else
self:ShowJobSelect()
end`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'kind' }]),
method('ShowJobSelect', `local current = self:CurrentClassId()
local opts = nil
if self.Jobs ~= nil then
opts = self.Jobs[current]
end
if opts == nil then
opts = {}
end
self.JobOpts = opts
for i = 1, 3 do
local base = "/ui/SelectUIGroup/JobSelectHud/Job_slot" .. tostring(i)
local o = opts[i]
if o ~= nil then
self:SetEntityEnabled(base, true)
self:SetText(base .. "/Name", o.name)
self:SetText(base .. "/Desc", o.desc)
local sc = self.Cards[o.starter]
if sc ~= nil then
self:SetText(base .. "/Starter", "대표 카드: " .. sc.name)
end
else
self:SetEntityEnabled(base, false)
end
end
self:SetEntityEnabled("/ui/SelectUIGroup/JobSelectHud", true)`),
method('JobLabel', `if self.PlayerJob ~= "" and self.JobMeta ~= nil and self.JobMeta[self.PlayerJob] ~= nil then
return self.JobMeta[self.PlayerJob].name
end
return self:BaseClassLabel(self.SelectedClass)`, [], 0, 'string'),
method('SetJob', `local current = self:CurrentClassId()
local starter = ""
local tier = 2
local opts = {}
if self.Jobs ~= nil and self.Jobs[current] ~= nil then
opts = self.Jobs[current]
end
for i = 1, #opts do
if opts[i].id == jobId then
starter = opts[i].starter or ""
tier = opts[i].tier or 2
break
end
end
self.PlayerJob = jobId
if starter ~= "" then
table.insert(self.RunDeck, starter)
local sc = self.Cards[starter]
if sc ~= nil then
self:Toast(tostring(tier) .. "차 전직: " .. self:JobLabel() .. "! 신규 카드 - " .. sc.name)
end
end
self:SetText("/ui/RunUIGroup/CombatHud/PlayerPanel/Name", self:JobLabel())
self:SetEntityEnabled("/ui/SelectUIGroup/JobSelectHud", false)
self:ContinueAfterBoss()`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'jobId' }]),
];