diff --git a/tools/deck/gen-slaydeck.mjs b/tools/deck/gen-slaydeck.mjs index 22e1994..77e92d6 100644 --- a/tools/deck/gen-slaydeck.mjs +++ b/tools/deck/gen-slaydeck.mjs @@ -73,6 +73,9 @@ function luaCardsTable(cards) { function luaDeckTable(deck) { return `self.DrawPile = { ${deck.map(luaStr).join(', ')} }`; } +function luaSlotGroup(arr) { + return '{ ' + arr.map((s) => `{ x = ${s.x}, y = ${s.y} }`).join(', ') + ' }'; +} const UI_FILE = 'ui/DefaultGroup.ui'; const COMMON_FILE = 'Global/common.gamelogic'; @@ -308,8 +311,10 @@ function entity({ id, path, modelId, entryId, componentNames, components, displa } function upsertUi() { - if (SLOTS.length < MAX_MONSTERS) { - throw new Error(`[gen-slaydeck] monster-slots.json 항목(${SLOTS.length}) < MAX_MONSTERS(${MAX_MONSTERS})`); + for (const g of ['combat', 'elite', 'boss']) { + if (!Array.isArray(SLOTS[g]) || SLOTS[g].length < 1) { + throw new Error(`[gen-slaydeck] monster-slots.json 의 "${g}" 그룹 좌표가 없습니다`); + } } const ui = JSON.parse(readFileSync(UI_FILE, 'utf8')); const E = ui.ContentProto.Entities; @@ -1560,6 +1565,7 @@ function writeCodeblocks() { prop('any', 'Registered'), prop('number', 'TargetIndex', '1'), prop('any', 'SlotPos'), + prop('any', 'ActiveSlotPos'), prop('any', 'RunDeck'), prop('number', 'Gold', '0'), prop('number', 'Floor', '0'), @@ -1671,7 +1677,7 @@ self.RelicPool = { ${RELICS.relicPool.map(luaStr).join(', ')} } ${luaEnemiesTable(ENEMIES.enemies)} ${luaMapNodesTable(MAP.nodes)} ${luaStartArray(MAP.start)} -self.SlotPos = { ${SLOTS.map((s) => `{ x = ${s.x}, y = ${s.y} }`).join(', ')} } +self.SlotPos = { combat = ${luaSlotGroup(SLOTS.combat)}, elite = ${luaSlotGroup(SLOTS.elite)}, boss = ${luaSlotGroup(SLOTS.boss)} } self.CurrentNodeId = "" self.CurrentEnemyId = "" self:BindButtons() @@ -2267,7 +2273,7 @@ e.UITransformComponent.RectSize = Vector2(w, 14)`, [ { Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'hp' }, { Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'maxHp' }, ]), - method('PositionMonsterSlot', `local sp = self.SlotPos + method('PositionMonsterSlot', `local sp = self.ActiveSlotPos if sp == nil or sp[slot] == nil then return end