카드 설명 키워드 하이라이트와 드로우 연동 공용 효과 추가 #83

Merged
maple merged 1 commits from codex/bandit-effect-pack into main 2026-06-19 01:53:04 +09:00
9 changed files with 144 additions and 14 deletions
Showing only changes of commit b2bf1bf4dd - Show all commits

File diff suppressed because one or more lines are too long

View File

@@ -803,8 +803,8 @@
"class": "bandit",
"rarity": "unique",
"desc": "카드를 1장 뽑습니다. 뽑은 카드가 스킬 카드라면, 방어도를 3 얻습니다.",
"block": 3,
"draw": 1,
"drawSkillBlock": 3,
"image": "91a2d1c16cb041549adbf1a0d7b1f37f"
},
"Acrobatics": {

22
docs/draw-skill-block.md Normal file
View File

@@ -0,0 +1,22 @@
# 드로우 연동 효과
드로우 결과를 받아 후속 효과를 처리하는 공용 패턴을 정리합니다.
## 현재 구현
- `draw`: 카드를 뽑음
- `drawUntilHandSize`: 손패가 지정 수치가 될 때까지 뽑음
- `drawSkillBlock`: 이번 카드로 뽑힌 카드 중 스킬 카드마다 방어도를 얻음
## 동작 방식
- 드로우 함수는 이번에 뽑힌 카드 ID 목록을 반환합니다.
- 카드 효과는 그 목록을 보고 조건을 판정합니다.
- 그래서 `EscapePlan` 같은 카드뿐 아니라, 나중에 같은 규칙이 필요한 카드에도 같은 필드를 붙이면 됩니다.
## 예시
- `EscapePlan`
- `draw = 1`
- `drawSkillBlock = 3`

View File

@@ -161,16 +161,19 @@ export function simulateCombat(data, rng, stats) {
let turns = 0;
function draw(n) {
const drawn = [];
for (let k = 0; k < n; k++) {
if (drawPile.length === 0) { drawPile = shuffle(discard, rng); discard = []; }
if (drawPile.length === 0) break;
const card = drawPile.pop();
drawn.push(card);
// 손패 10장 상한 — 초과 드로는 자동 버림 (Lua DrawCards 동기화)
if (hand.length >= 10) {
discard.push(card);
triggerSly(card);
} else hand.push(card);
}
return drawn;
}
function addCardsToHand(id, n) {
for (let k = 0; k < n; k++) {
@@ -318,10 +321,16 @@ export function simulateCombat(data, rng, stats) {
if (c.heal) pHp = Math.min(pHp + c.heal, PLAYER_HP);
if (c.gainEnergy) energy += c.gainEnergy;
queueNextTurnEffects(c);
if (c.draw) draw(c.draw);
let drawnCards = [];
if (c.draw) drawnCards = drawnCards.concat(draw(c.draw));
if (c.drawUntilHandSize) {
const need = c.drawUntilHandSize - Math.max(0, hand.length - 1);
if (need > 0) draw(need);
if (need > 0) drawnCards = drawnCards.concat(draw(need));
}
if (c.drawSkillBlock && c.drawSkillBlock > 0) {
for (const drawnId of drawnCards) {
if (cards[drawnId]?.kind === 'Skill') blockGained += addBlock(c.drawSkillBlock);
}
}
if (c.addShiv && !c.discard && c.discardAll !== true) addCardsToHand('Shiv', c.addShiv);
if (recordStats && stats) stats[id] = bump(stats[id], costSpent, dmg, blockGained);

View File

@@ -720,3 +720,22 @@ test("chooseAction: skillCostReductionThisTurn allows discounted skills", () =>
assert.equal(chooseAction(["Guard"], cards, 1, { skillCostReductionThisTurn: 1 }), 0);
assert.equal(chooseAction(["Guard"], cards, 1, {}), -1);
});
test("simulateCombat: drawSkillBlock grants block for each drawn skill", () => {
const data = {
cards: {
Escape: { name: "EscapePlan", cost: 0, kind: "Skill", draw: 1, drawSkillBlock: 3, innate: true, exhaust: true },
Filler1: { name: "Filler1", cost: 99, kind: "Skill", block: 0 },
Filler2: { name: "Filler2", cost: 99, kind: "Skill", block: 0 },
Filler3: { name: "Filler3", cost: 99, kind: "Skill", block: 0 },
Filler4: { name: "Filler4", cost: 99, kind: "Skill", block: 0 },
Filler5: { name: "Filler5", cost: 99, kind: "Skill", block: 0 },
},
starterDeck: ["Escape", "Filler1", "Filler2", "Filler3", "Filler4", "Filler5"],
monsters: [{ name: "Dummy", maxHp: 9999, intents: [{ kind: "Attack", value: 0 }] }],
};
const stats = {};
const r = simulateCombat(data, () => 0.999999, stats);
assert.equal(r.draw, true);
assert.equal(stats.Escape.block, 3);
});

View File

@@ -415,7 +415,8 @@ if self.PlayerVuln > 0 then self.PlayerVuln = self.PlayerVuln - 1 end
self:RenderHand(false)
self:RenderPiles()
self:EnemyTurn()`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'retainSlot' }]),
method('DrawCards', `local drawnSlots = {}
method('DrawCards', `local drawnSlots = {}
local drawnCards = {}
local drewAny = false
for i = 1, amount do
\tif #self.DrawPile <= 0 then
@@ -425,6 +426,7 @@ for i = 1, amount do
\t\tbreak
\tend
\tlocal cardId = table.remove(self.DrawPile)
\ttable.insert(drawnCards, cardId)
\tif #self.Hand >= 10 then
\t\ttable.insert(self.DiscardPile, cardId)
\t\tself:TriggerSly(cardId)
@@ -444,10 +446,11 @@ if animate == true and #drawnSlots > 0 then
\t\tlocal slot = drawnSlots[i]
\t\tself:AnimateCardFrom(slot, drawStart, Vector2(self:GetHandSlotX(slot), 0), 0.08 + i * 0.045)
\tend
return drawnCards
end`, [
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'amount' },
{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'animate' },
]),
], 0, 'any'),
method('AddCardsToHand', `if self.Hand == nil then
self.Hand = {}
end

View File

@@ -60,7 +60,7 @@ if e ~= nil and e.SpriteGUIRendererComponent ~= nil then
end
self:SetText(base .. "/Cost", string.format("%d", c.cost))
self:SetText(base .. "/Name", c.name)
self:SetText(base .. "/Desc", c.desc)
self:SetText(base .. "/Desc", self:FormatCardDescription(c.desc))
local art = _EntityService:GetEntityByPath(base .. "/Art")
if art ~= nil then
if c.image ~= nil and c.image ~= "" then
@@ -459,8 +459,9 @@ if c.weak ~= nil or c.vuln ~= nil or c.poison ~= nil then
end
end
end
local drawnCards = {}
if c.draw ~= nil then
self:DrawCards(c.draw, true)
drawnCards = self:DrawCards(c.draw, true) or {}
end
if c.drawUntilHandSize ~= nil and c.drawUntilHandSize > 0 then
local currentHand = 0
@@ -472,7 +473,18 @@ if c.drawUntilHandSize ~= nil and c.drawUntilHandSize > 0 then
end
local need = c.drawUntilHandSize - currentHand
if need > 0 then
self:DrawCards(need, true)
local moreDrawnCards = self:DrawCards(need, true) or {}
for i = 1, #moreDrawnCards do
table.insert(drawnCards, moreDrawnCards[i])
end
end
end
if c.drawSkillBlock ~= nil and c.drawSkillBlock > 0 then
for i = 1, #drawnCards do
local drawnCard = self.Cards[drawnCards[i]]
if drawnCard ~= nil and drawnCard.kind == "Skill" then
self:AddCardBlock(c.drawSkillBlock)
end
end
end
if c.addShiv ~= nil and c.discard == nil and c.discardAll ~= true then

View File

@@ -3,6 +3,47 @@ import { CARDS, ENEMIES, CLASSES, JOBS, SOUL_UNLOCKS, CARDFRAMES, RARITIES, MAP_
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

View File

@@ -182,6 +182,7 @@ function luaCardsTable(cards) {
if (c.selfVuln != null) fields.push(`selfVuln = ${c.selfVuln}`);
if (c.draw != null) fields.push(`draw = ${c.draw}`);
if (c.drawUntilHandSize != null) fields.push(`drawUntilHandSize = ${c.drawUntilHandSize}`);
if (c.drawSkillBlock != null) fields.push(`drawSkillBlock = ${c.drawSkillBlock}`);
if (c.heal != null) fields.push(`heal = ${c.heal}`);
if (c.gainEnergy != null) fields.push(`gainEnergy = ${c.gainEnergy}`);
if (c.poison != null) fields.push(`poison = ${c.poison}`);