363 lines
13 KiB
JavaScript
363 lines
13 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 tooltipMethods = [
|
|
method('FormatCardDescription', `if desc == nil or desc == "" then
|
|
return ""
|
|
end
|
|
local function replacePlain(text, needle, replacement)
|
|
local out = ""
|
|
local pos = 1
|
|
while true do
|
|
local s, e = string.find(text, needle, pos, true)
|
|
if s == nil then
|
|
out = out .. string.sub(text, pos)
|
|
break
|
|
end
|
|
out = out .. string.sub(text, pos, s - 1) .. replacement
|
|
pos = e + 1
|
|
end
|
|
return out
|
|
end
|
|
local terms = {
|
|
"교활",
|
|
"보존",
|
|
"민첩",
|
|
"가시",
|
|
"소멸",
|
|
"선천성",
|
|
"취약",
|
|
"약화",
|
|
"독",
|
|
"광역",
|
|
"관통",
|
|
"방어도",
|
|
"힘",
|
|
"스킬",
|
|
"공격",
|
|
"파워",
|
|
}
|
|
local out = desc
|
|
for i = 1, #terms do
|
|
local term = terms[i]
|
|
out = replacePlain(out, term, "<color=#70D6FF>" .. term .. "</color>")
|
|
end
|
|
return out`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'desc' }], 0, 'string'),
|
|
method('BuildCardKeywordTooltip', `if c == nil then
|
|
return ""
|
|
end
|
|
local lines = {}
|
|
local function add(name, desc)
|
|
for i = 1, #lines do
|
|
if string.find(lines[i], name .. ":", 1, true) == 1 then
|
|
return
|
|
end
|
|
end
|
|
table.insert(lines, name .. ": " .. desc)
|
|
end
|
|
local cardDesc = c.desc or ""
|
|
if c.sly == true or string.find(cardDesc, "교활", 1, true) ~= nil then
|
|
add("교활", "버려지면 비용 없이 사용됩니다.")
|
|
end
|
|
if c.retain == true or string.find(cardDesc, "보존", 1, true) ~= nil then
|
|
add("보존", "턴 종료 시 버려지지 않고 손에 남습니다.")
|
|
end
|
|
if c.dex ~= nil and c.dex > 0 or string.find(cardDesc, "민첩", 1, true) ~= nil then
|
|
add("민첩", "카드로 얻는 방어도가 증가합니다.")
|
|
end
|
|
if c.thorns ~= nil and c.thorns > 0 or string.find(cardDesc, "가시", 1, true) ~= nil then
|
|
add("가시", "피해를 받으면 공격자에게 반사 피해를 줍니다.")
|
|
end
|
|
if c.exhaust == true or string.find(cardDesc, "소멸.", 1, true) ~= nil then
|
|
add("소멸", "사용 후 소멸 덱으로 이동해 이번 전투 동안 다시 나오지 않습니다.")
|
|
end
|
|
if string.find(cardDesc, "선천성", 1, true) ~= nil then
|
|
add("선천성", "전투 시작 시 손패에 들어옵니다.")
|
|
end
|
|
if c.vuln ~= nil and c.vuln > 0 then
|
|
add("취약", "받는 공격 피해가 50% 증가합니다.")
|
|
end
|
|
if c.weak ~= nil and c.weak > 0 then
|
|
add("약화", "주는 공격 피해가 25% 감소합니다.")
|
|
end
|
|
if c.poison ~= nil and c.poison > 0 then
|
|
add("중독", "턴 시작 시 체력을 잃고 수치가 1 감소합니다.")
|
|
end
|
|
if c.pierce == true then
|
|
add("관통", "방어도를 무시하고 피해를 줍니다.")
|
|
end
|
|
if c.aoe == true then
|
|
add("전체", "모든 적에게 적용됩니다.")
|
|
end
|
|
if c.kind == "Power" then
|
|
add("파워", "사용하면 전투 동안 지속 효과로 남습니다.")
|
|
end
|
|
if c.unplayable == true then
|
|
add("저주", "사용할 수 없고 손패를 방해합니다.")
|
|
end
|
|
local out = ""
|
|
for i = 1, #lines do
|
|
if i > 1 then out = out .. "\\n" end
|
|
out = out .. lines[i]
|
|
end
|
|
return out`, [{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'c' }], 0, 'string'),
|
|
method('GetHoveredCardId', `if path == nil or path == "" then
|
|
return nil
|
|
end
|
|
if string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
|
|
if self.Hand == nil then
|
|
return nil
|
|
end
|
|
local slot = tonumber(string.match(path, "Card(%d+)")) or 0
|
|
return self.Hand[slot]
|
|
end
|
|
if string.find(path, "/ui/RunUIGroup/RewardHud/Reward", 1, true) == 1 then
|
|
if self.RewardCards == nil then
|
|
return nil
|
|
end
|
|
local slot = tonumber(string.match(path, "Reward(%d+)")) or 0
|
|
return self.RewardCards[slot]
|
|
end
|
|
if string.find(path, "/ui/RunUIGroup/ShopHud/Card", 1, true) == 1 then
|
|
if self.ShopCards == nil then
|
|
return nil
|
|
end
|
|
local slot = tonumber(string.match(path, "Card(%d+)")) or 0
|
|
return self.ShopCards[slot]
|
|
end
|
|
if string.find(path, "/ui/DeckUIGroup/DeckInspectHud/Grid/Card", 1, true) == 1 then
|
|
local pile = nil
|
|
if self.DeckInspectKind == "discard" then
|
|
pile = self.DiscardPile
|
|
elseif self.DeckInspectKind == "exhaust" then
|
|
pile = self.ExhaustPile
|
|
else
|
|
pile = self.DrawPile
|
|
end
|
|
if pile == nil then
|
|
return nil
|
|
end
|
|
local slot = tonumber(string.match(path, "Card(%d+)")) or 0
|
|
return pile[slot]
|
|
end
|
|
if string.find(path, "/ui/DeckUIGroup/DeckAllHud/Grid/Card", 1, true) == 1 then
|
|
local pile = self.RunDeck
|
|
if self.ClassDeckMode == true then
|
|
pile = self.ClassDeckCards
|
|
elseif self.CodexMode == true then
|
|
pile = self.CodexCards
|
|
end
|
|
if pile == nil then
|
|
return nil
|
|
end
|
|
local slot = tonumber(string.match(path, "Card(%d+)")) or 0
|
|
return pile[slot]
|
|
end
|
|
return nil`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }], 0, 'string'),
|
|
method('GetGridCardPathAtPoint', `if gridPath == nil or gridPath == "" or touchPoint == nil then
|
|
return nil
|
|
end
|
|
local prefix = nil
|
|
local maxSlots = 0
|
|
if gridPath == "/ui/DeckUIGroup/DeckAllHud/Grid" then
|
|
prefix = "/ui/DeckUIGroup/DeckAllHud/Grid/Card"
|
|
maxSlots = 120
|
|
elseif gridPath == "/ui/DeckUIGroup/DeckInspectHud/Grid" then
|
|
prefix = "/ui/DeckUIGroup/DeckInspectHud/Grid/Card"
|
|
maxSlots = 60
|
|
else
|
|
return nil
|
|
end
|
|
local uiPos = _UILogic:ScreenToUIPosition(touchPoint)
|
|
local bestPath = nil
|
|
local bestDist = 999999
|
|
for i = 1, maxSlots do
|
|
local path = prefix .. tostring(i)
|
|
local cardEntity = _EntityService:GetEntityByPath(path)
|
|
if cardEntity ~= nil and cardEntity.Enable == true and cardEntity.UITransformComponent ~= nil then
|
|
local pos = self:GetUiPathPosition(path)
|
|
local dx = uiPos.x - pos.x
|
|
local dy = uiPos.y - pos.y
|
|
if math.abs(dx) <= 90 and math.abs(dy) <= 125 then
|
|
local dist = dx * dx + dy * dy
|
|
if bestPath == nil or dist < bestDist then
|
|
bestPath = path
|
|
bestDist = dist
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return bestPath`, [
|
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'gridPath' },
|
|
{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'touchPoint' },
|
|
], 0, 'string'),
|
|
method('GetUiPathPosition', `if path == nil or path == "" then
|
|
return Vector2(0, 0)
|
|
end
|
|
local sumX = 0
|
|
local sumY = 0
|
|
local cur = path
|
|
while cur ~= nil and cur ~= "" do
|
|
local e = _EntityService:GetEntityByPath(cur)
|
|
if e ~= nil and e.UITransformComponent ~= nil then
|
|
local pos = e.UITransformComponent.anchoredPosition
|
|
if pos ~= nil then
|
|
sumX = sumX + (pos.x or 0)
|
|
sumY = sumY + (pos.y or 0)
|
|
end
|
|
end
|
|
local slash = string.match(cur, "^.*()/")
|
|
if slash == nil or slash <= 1 then
|
|
break
|
|
end
|
|
cur = string.sub(cur, 1, slash - 1)
|
|
if cur == "/ui" then
|
|
break
|
|
end
|
|
end
|
|
return Vector2(sumX, sumY)`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }], 0, 'any'),
|
|
method('GetTooltipAnchorForPath', `local pos = self:GetUiPathPosition(path)
|
|
local x = pos.x
|
|
local y = pos.y
|
|
local sideOffset = 230
|
|
local verticalOffset = 0
|
|
if string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
|
|
verticalOffset = 90
|
|
elseif string.find(path, "/ui/RunUIGroup/RewardHud/Reward", 1, true) == 1 then
|
|
verticalOffset = 30
|
|
elseif string.find(path, "/ui/RunUIGroup/ShopHud/Card", 1, true) == 1 then
|
|
verticalOffset = 20
|
|
else
|
|
verticalOffset = 0
|
|
end
|
|
local tipX = x + sideOffset
|
|
if x > 180 then
|
|
tipX = x - sideOffset
|
|
end
|
|
if tipX > 760 then
|
|
tipX = x - sideOffset
|
|
end
|
|
if tipX < -760 then
|
|
tipX = x + sideOffset
|
|
end
|
|
local tipY = y + verticalOffset
|
|
if tipY > 430 then
|
|
tipY = 430
|
|
end
|
|
if tipY < -430 then
|
|
tipY = -430
|
|
end
|
|
return Vector2(tipX, tipY)`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }], 0, 'any'),
|
|
method('HoverCardByPath', `if path == nil or path == "" then
|
|
return
|
|
end
|
|
if self.DragSlot ~= nil and self.DragSlot > 0 and string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
|
|
return
|
|
end
|
|
local cardId = self:GetHoveredCardId(path)
|
|
if cardId == nil or self.Cards == nil then
|
|
self:HideTooltip()
|
|
return
|
|
end
|
|
local c = self.Cards[cardId]
|
|
if c == nil then
|
|
self:HideTooltip()
|
|
return
|
|
end
|
|
local tip = self:BuildCardKeywordTooltip(c)
|
|
if tip == nil or tip == "" then
|
|
self:HideTooltip()
|
|
return
|
|
end
|
|
local e = _EntityService:GetEntityByPath(path)
|
|
if e ~= nil and e.UITransformComponent ~= nil then
|
|
if string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
|
|
e.UITransformComponent.UIScale = Vector3(1.3, 1.3, 1)
|
|
end
|
|
end
|
|
local anchor = self:GetTooltipAnchorForPath(path)
|
|
self:ShowTooltipAt("키워드", tip, anchor.x, anchor.y)`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }]),
|
|
method('HoverGridCard', `if gridPath == nil or touchPoint == nil then
|
|
return
|
|
end
|
|
local path = self:GetGridCardPathAtPoint(gridPath, touchPoint)
|
|
local lastPath = self.GridHoverPath
|
|
if lastPath == path then
|
|
return
|
|
end
|
|
if lastPath ~= nil and lastPath ~= "" then
|
|
self:UnhoverCardByPath(lastPath)
|
|
end
|
|
self.GridHoverPath = path or ""
|
|
if path ~= nil and path ~= "" then
|
|
self:HoverCardByPath(path)
|
|
end`, [
|
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'gridPath' },
|
|
{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'touchPoint' },
|
|
]),
|
|
method('UnhoverGridCard', `local path = self.GridHoverPath
|
|
self.GridHoverPath = ""
|
|
if path ~= nil and path ~= "" then
|
|
self:UnhoverCardByPath(path)
|
|
else
|
|
self:HideTooltip()
|
|
end`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'gridPath' }]),
|
|
method('UnhoverCardByPath', `if path ~= nil and string.find(path, "/ui/RunUIGroup/CardHand/Card", 1, true) == 1 then
|
|
local e = _EntityService:GetEntityByPath(path)
|
|
if e ~= nil and e.UITransformComponent ~= nil then
|
|
e.UITransformComponent.UIScale = Vector3(1, 1, 1)
|
|
end
|
|
end
|
|
self:HideTooltip()`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }]),
|
|
method('HoverCard', `if self.DragSlot ~= nil and self.DragSlot > 0 then
|
|
return
|
|
end
|
|
if self.Hand == nil then
|
|
return
|
|
end
|
|
local cardId = self.Hand[slot]
|
|
if cardId == nil then
|
|
return
|
|
end
|
|
local e = _EntityService:GetEntityByPath("/ui/RunUIGroup/CardHand/Card" .. tostring(slot))
|
|
if e ~= nil and e.UITransformComponent ~= nil then
|
|
e.UITransformComponent.UIScale = Vector3(1.3, 1.3, 1)
|
|
end
|
|
local c = self.Cards[cardId]
|
|
if c ~= nil then
|
|
local tip = self:BuildCardKeywordTooltip(c)
|
|
if tip ~= "" then
|
|
local anchor = self:GetTooltipAnchorForPath("/ui/RunUIGroup/CardHand/Card" .. tostring(slot))
|
|
self:ShowTooltipAt("키워드", tip, anchor.x, anchor.y)
|
|
else
|
|
self:HideTooltip()
|
|
end
|
|
end`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }]),
|
|
method('UnhoverCard', `local e = _EntityService:GetEntityByPath("/ui/RunUIGroup/CardHand/Card" .. tostring(slot))
|
|
if e ~= nil and e.UITransformComponent ~= nil then
|
|
e.UITransformComponent.UIScale = Vector3(1, 1, 1)
|
|
end
|
|
self:HideTooltip()`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }]),
|
|
method('ShowTooltip', `self:ShowTooltipAt(name, desc, x, 400)`, [
|
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'name' },
|
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'desc' },
|
|
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'x' },
|
|
]),
|
|
method('ShowTooltipAt', `self:SetText("/ui/ToolTipGroup/TooltipBox/Name", name)
|
|
self:SetText("/ui/ToolTipGroup/TooltipBox/Desc", desc)
|
|
local e = _EntityService:GetEntityByPath("/ui/ToolTipGroup/TooltipBox")
|
|
if e ~= nil then
|
|
if e.UITransformComponent ~= nil then
|
|
e.UITransformComponent.anchoredPosition = Vector2(x, y)
|
|
end
|
|
e.Enable = true
|
|
end`, [
|
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'name' },
|
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'desc' },
|
|
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'x' },
|
|
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'y' },
|
|
]),
|
|
method('HideTooltip', `self:SetEntityEnabled("/ui/ToolTipGroup/TooltipBox", false)`),
|
|
];
|