Add campfireRest function with tests
This commit is contained in:
parent
febb05764b
commit
91d32a71ee
2 changed files with 19 additions and 0 deletions
|
|
@ -23,6 +23,10 @@ export function endCombat(run, combatHp) {
|
|||
return { ...run, hp, combatCount: run.combatCount + 1 };
|
||||
}
|
||||
|
||||
export function campfireRest(run) {
|
||||
return { ...run, hp: Math.min(run.hp + 3, run.maxHp) };
|
||||
}
|
||||
|
||||
export function revealRewards(run) {
|
||||
const count = Math.min(3, run.cardRewardsDeck.length);
|
||||
const revealed = run.cardRewardsDeck.slice(0, count);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { beforeAll, describe, expect, test } from "bun:test";
|
|||
import { getAllCards, initCards } from "./cards.js";
|
||||
import { initEnemies } from "./enemies.js";
|
||||
import {
|
||||
campfireRest,
|
||||
createRunState,
|
||||
endCombat,
|
||||
pickReward,
|
||||
|
|
@ -89,6 +90,20 @@ describe("endCombat", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("campfireRest", () => {
|
||||
test("campfireRest heals 3 HP", () => {
|
||||
const run = { hp: 5, maxHp: 11 };
|
||||
const result = campfireRest(run);
|
||||
expect(result.hp).toBe(8);
|
||||
});
|
||||
|
||||
test("campfireRest does not heal above maxHp", () => {
|
||||
const run = { hp: 10, maxHp: 11 };
|
||||
const result = campfireRest(run);
|
||||
expect(result.hp).toBe(11);
|
||||
});
|
||||
});
|
||||
|
||||
describe("rewards", () => {
|
||||
test("revealRewards removes 3 from rewards deck and returns them", () => {
|
||||
const run = createRunState("ironclad");
|
||||
|
|
|
|||
Loading…
Reference in a new issue