Implement dex and thorns effects
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -516,7 +516,7 @@
|
||||
"class": "bandit",
|
||||
"rarity": "normal",
|
||||
"desc": "이번 턴 동안 민첩을 2 얻습니다.",
|
||||
"draw": 1
|
||||
"dex": 2
|
||||
},
|
||||
"Deflect": {
|
||||
"name": "튕겨내기",
|
||||
@@ -887,8 +887,7 @@
|
||||
"class": "bandit",
|
||||
"rarity": "unique",
|
||||
"desc": "민첩을 2 얻습니다.",
|
||||
"powerEffect": "blockPerTurn",
|
||||
"value": 2
|
||||
"dex": 2
|
||||
},
|
||||
"Outbreak": {
|
||||
"name": "발병",
|
||||
@@ -1192,8 +1191,8 @@
|
||||
"class": "bandit",
|
||||
"rarity": "legend",
|
||||
"desc": "교활. 민첩을 1 얻습니다. 가시를 4 얻습니다.",
|
||||
"powerEffect": "blockPerTurn",
|
||||
"value": 2,
|
||||
"dex": 1,
|
||||
"thorns": 4,
|
||||
"sly": true
|
||||
},
|
||||
"Suppress": {
|
||||
|
||||
@@ -111,7 +111,7 @@ export function simulateCombat(data, rng, stats) {
|
||||
const exhaust = [];
|
||||
let hand = [];
|
||||
let pHp = PLAYER_HP, pBlock = 0;
|
||||
let pStr = 0, pWeak = 0, pVuln = 0;
|
||||
let pStr = 0, pDex = 0, pThorns = 0, pWeak = 0, pVuln = 0;
|
||||
const powers = [];
|
||||
const mob = monsters.map((m) => ({
|
||||
name: m.name, hp: m.maxHp, maxHp: m.maxHp, block: 0, str: 0, weak: 0, vuln: 0, poison: 0,
|
||||
@@ -135,6 +135,7 @@ export function simulateCombat(data, rng, stats) {
|
||||
function resolveCardEffects(id, c, costSpent, recordStats = true) {
|
||||
const alive = aliveList();
|
||||
let dmg = 0;
|
||||
let blockGained = 0;
|
||||
if (c.kind === 'Attack') {
|
||||
if (alive.length && c.damage) {
|
||||
const target = chooseTarget(alive, calcAttack(c.damage || 0, pStr, pWeak, 0));
|
||||
@@ -163,11 +164,11 @@ export function simulateCombat(data, rng, stats) {
|
||||
if (target.hp <= 0) target.alive = false;
|
||||
}
|
||||
}
|
||||
if (c.block) pBlock += c.block;
|
||||
if (c.block) { blockGained = Math.max(0, c.block + pDex); pBlock += blockGained; }
|
||||
} else if (c.kind === 'Power') {
|
||||
if (c.powerEffect && recordStats) powers.push(id);
|
||||
} else {
|
||||
pBlock += c.block || 0;
|
||||
if (c.block) { blockGained = Math.max(0, c.block + pDex); pBlock += blockGained; }
|
||||
if ((c.weak || c.vuln || c.poison) && alive.length) {
|
||||
const target = chooseTarget(alive, 0);
|
||||
if (c.weak) target.weak += c.weak;
|
||||
@@ -176,10 +177,12 @@ export function simulateCombat(data, rng, stats) {
|
||||
}
|
||||
}
|
||||
if (c.strength) pStr += c.strength;
|
||||
if (c.dex) pDex += c.dex;
|
||||
if (c.thorns) pThorns += c.thorns;
|
||||
if (c.selfVuln) pVuln += c.selfVuln;
|
||||
if (c.heal) pHp = Math.min(pHp + c.heal, PLAYER_HP);
|
||||
if (c.draw) draw(c.draw);
|
||||
if (recordStats && stats) stats[id] = bump(stats[id], costSpent, dmg, c.block || 0);
|
||||
if (recordStats && stats) stats[id] = bump(stats[id], costSpent, dmg, blockGained);
|
||||
}
|
||||
function triggerSly(id) {
|
||||
const c = cards[id];
|
||||
@@ -257,7 +260,12 @@ export function simulateCombat(data, rng, stats) {
|
||||
if (it) {
|
||||
if (it.kind === 'Attack') {
|
||||
const atk = calcAttack(it.value, m.str, m.weak, pVuln);
|
||||
const beforeHp = pHp;
|
||||
const r = applyDamage(pHp, pBlock, atk); pHp = r.hp; pBlock = r.block;
|
||||
if (beforeHp > pHp && pThorns > 0) {
|
||||
m.hp -= pThorns;
|
||||
if (m.hp <= 0) m.alive = false;
|
||||
}
|
||||
} else if (it.kind === 'Defend') { m.block += it.value; }
|
||||
else if (it.kind === 'Debuff') {
|
||||
if (it.effect === 'weak') pWeak += it.value;
|
||||
|
||||
@@ -418,3 +418,32 @@ test("simulateCombat: exhaust cards do not return through discard reshuffle", ()
|
||||
assert.equal(r.win, false);
|
||||
assert.equal(r.draw, true);
|
||||
});
|
||||
|
||||
test("simulateCombat: dex increases block gained from cards", () => {
|
||||
const data = {
|
||||
cards: {
|
||||
Footwork: { name: "Footwork", cost: 1, kind: "Power", dex: 2 },
|
||||
Defend: { name: "Defend", cost: 1, kind: "Skill", block: 5 },
|
||||
},
|
||||
starterDeck: ["Footwork", "Defend"],
|
||||
monsters: [{ name: "Dummy", maxHp: 99, intents: [{ kind: "Attack", value: 6 }] }],
|
||||
};
|
||||
const r = simulateCombat(data, () => 0.999999);
|
||||
assert.equal(r.win, false);
|
||||
assert.equal(r.draw, true);
|
||||
assert.equal(r.playerHpRemaining, 80);
|
||||
});
|
||||
|
||||
test("simulateCombat: thorns reflects unblocked attack damage", () => {
|
||||
const data = {
|
||||
cards: {
|
||||
Spikes: { name: "Spikes", cost: 1, kind: "Power", thorns: 4 },
|
||||
},
|
||||
starterDeck: ["Spikes"],
|
||||
monsters: [{ name: "Dummy", maxHp: 4, intents: [{ kind: "Attack", value: 1 }] }],
|
||||
};
|
||||
const r = simulateCombat(data, () => 0.999999);
|
||||
assert.equal(r.win, true);
|
||||
assert.equal(r.turns, 1);
|
||||
assert.equal(r.playerHpRemaining, 79);
|
||||
});
|
||||
|
||||
@@ -156,6 +156,8 @@ function luaCardsTable(cards) {
|
||||
if (c.damage != null) fields.push(`damage = ${c.damage}`);
|
||||
if (c.block != null) fields.push(`block = ${c.block}`);
|
||||
if (c.strength != null) fields.push(`strength = ${c.strength}`);
|
||||
if (c.dex != null) fields.push(`dex = ${c.dex}`);
|
||||
if (c.thorns != null) fields.push(`thorns = ${c.thorns}`);
|
||||
if (c.weak != null) fields.push(`weak = ${c.weak}`);
|
||||
if (c.vuln != null) fields.push(`vuln = ${c.vuln}`);
|
||||
if (c.powerEffect != null) fields.push(`powerEffect = ${luaStr(c.powerEffect)}`);
|
||||
@@ -2952,6 +2954,8 @@ function writeCodeblocks() {
|
||||
prop('number', 'PlayerHp', '0'),
|
||||
prop('number', 'PlayerMaxHp', '80'),
|
||||
prop('number', 'PlayerBlock', '0'),
|
||||
prop('number', 'PlayerDex', '0'),
|
||||
prop('number', 'PlayerThorns', '0'),
|
||||
prop('boolean', 'CombatOver', 'false'),
|
||||
prop('any', 'Monsters'),
|
||||
prop('any', 'Registered'),
|
||||
@@ -3500,6 +3504,8 @@ self.MaxEnergy = 3
|
||||
self.Turn = 0
|
||||
self.PlayerBlock = 0
|
||||
self.PlayerStr = 0
|
||||
self.PlayerDex = 0
|
||||
self.PlayerThorns = 0
|
||||
self.PlayerWeak = 0
|
||||
self.PlayerVuln = 0
|
||||
self.PlayerPowers = {}
|
||||
@@ -4373,6 +4379,15 @@ end, 1 / 60)`, [
|
||||
{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'toPos' },
|
||||
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'duration' },
|
||||
]),
|
||||
method('AddCardBlock', `local amount = base or 0
|
||||
if amount > 0 and self.PlayerDex ~= nil then
|
||||
amount = amount + self.PlayerDex
|
||||
end
|
||||
if amount < 0 then
|
||||
amount = 0
|
||||
end
|
||||
self.PlayerBlock = self.PlayerBlock + amount
|
||||
return amount`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'base' }], 0, 'number'),
|
||||
method('CalcPlayerAttack', `local base2 = base
|
||||
self.FightAttackCount = self.FightAttackCount + 1
|
||||
if self.FightAttackCount == 1 and self:HasRelic("akabeko") then
|
||||
@@ -4410,14 +4425,14 @@ if c.kind == "Attack" then
|
||||
end
|
||||
end
|
||||
if c.block ~= nil then
|
||||
self.PlayerBlock = self.PlayerBlock + c.block
|
||||
self:AddCardBlock(c.block)
|
||||
end
|
||||
if free ~= true then
|
||||
self:ApplyRelics("cardPlayed")
|
||||
end
|
||||
elseif c.kind == "Skill" then
|
||||
if c.block ~= nil then
|
||||
self.PlayerBlock = self.PlayerBlock + c.block
|
||||
self:AddCardBlock(c.block)
|
||||
end
|
||||
elseif c.kind == "Power" then
|
||||
if c.powerEffect ~= nil and free ~= true then
|
||||
@@ -4427,6 +4442,12 @@ end
|
||||
if c.strength ~= nil then
|
||||
self.PlayerStr = self.PlayerStr + c.strength
|
||||
end
|
||||
if c.dex ~= nil then
|
||||
self.PlayerDex = self.PlayerDex + c.dex
|
||||
end
|
||||
if c.thorns ~= nil then
|
||||
self.PlayerThorns = self.PlayerThorns + c.thorns
|
||||
end
|
||||
if c.selfVuln ~= nil then
|
||||
self.PlayerVuln = self.PlayerVuln + c.selfVuln
|
||||
end
|
||||
@@ -4828,10 +4849,15 @@ if self.PlayerBlock > 0 then
|
||||
end
|
||||
if dmg > 0 then
|
||||
self.PlayerHp = self.PlayerHp - dmg
|
||||
if self:HasRelic("bronzeScales") and attackerSlot ~= nil and attackerSlot > 0 then
|
||||
local reflect = self.PlayerThorns or 0
|
||||
if self:HasRelic("bronzeScales") then
|
||||
reflect = reflect + 3
|
||||
end
|
||||
if reflect > 0 and attackerSlot ~= nil and attackerSlot > 0 then
|
||||
local am = self.Monsters[attackerSlot]
|
||||
if am ~= nil and am.alive == true then
|
||||
am.hp = am.hp - 3
|
||||
am.hp = am.hp - reflect
|
||||
self:ShowDmgPop(am.slot, reflect)
|
||||
self:MonsterHitMotion(am.slot)
|
||||
if am.hp <= 0 then
|
||||
am.hp = 0
|
||||
@@ -5169,6 +5195,14 @@ self:SetHpBar("/ui/DefaultGroup/CombatHud/PlayerPanel/HpBarFill", self.PlayerHp,
|
||||
self:SetEntityEnabled("/ui/DefaultGroup/CombatHud/PlayerPanel/BlockBadge", self.PlayerBlock > 0)
|
||||
self:SetText("/ui/DefaultGroup/CombatHud/PlayerPanel/BlockBadge/Value", string.format("%d", self.PlayerBlock))
|
||||
local pb = self:BuffsLabel(self.PlayerStr, self.PlayerWeak, self.PlayerVuln, 0)
|
||||
if self.PlayerDex ~= nil and self.PlayerDex > 0 then
|
||||
if pb ~= "" then pb = pb .. " " end
|
||||
pb = pb .. "민첩+" .. tostring(self.PlayerDex)
|
||||
end
|
||||
if self.PlayerThorns ~= nil and self.PlayerThorns > 0 then
|
||||
if pb ~= "" then pb = pb .. " " end
|
||||
pb = pb .. "가시" .. tostring(self.PlayerThorns)
|
||||
end
|
||||
if self.PlayerPowers ~= nil and #self.PlayerPowers > 0 then
|
||||
local names = {}
|
||||
for i = 1, #self.PlayerPowers do
|
||||
@@ -5672,6 +5706,12 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user