From 7a3349c773a9994dcadc3b08dbfacbcfecae6d64 Mon Sep 17 00:00:00 2001 From: kjirou Date: Sun, 22 Sep 2024 18:15:06 +0900 Subject: [PATCH] wip --- src/lesson-mutation.test.ts | 35 +++++++++++++++++++++++++++++++++++ src/lesson-mutation.ts | 24 ++++++++++++++++++++++++ src/types.ts | 2 ++ 3 files changed, 61 insertions(+) diff --git a/src/lesson-mutation.test.ts b/src/lesson-mutation.test.ts index 0154501..63555e5 100644 --- a/src/lesson-mutation.test.ts +++ b/src/lesson-mutation.test.ts @@ -76,6 +76,41 @@ describe("activateEffectIf", () => { }, ], }, + { + name: "drainModifier - motivation - 現在値より減少値が高い時、0になるまで減らす", + args: [ + (() => { + const lesson = createLessonForTest(); + lesson.idol.modifiers = [{ kind: "motivation", amount: 2, id: "m1" }]; + return lesson; + })(), + { kind: "drainModifier", modifierKind: "motivation", value: 5 }, + () => 0, + createIdGenerator(), + ], + expected: [ + { + kind: "modifiers.update", + propertyNameKind: "amount", + id: "m1", + actual: -2, + max: -5, + }, + ], + }, + { + name: "drainModifier - motivation - 現在値が0の時、何もしない", + args: [ + (() => { + const lesson = createLessonForTest(); + return lesson; + })(), + { kind: "drainModifier", modifierKind: "motivation", value: 1 }, + () => 0, + createIdGenerator(), + ], + expected: [], + }, { name: "generateCard - 手札0枚で実行した時、強化されたSSRのスキルカードを追加して、手札はその1枚になる", args: [ diff --git a/src/lesson-mutation.ts b/src/lesson-mutation.ts index 509fad0..084a330 100644 --- a/src/lesson-mutation.ts +++ b/src/lesson-mutation.ts @@ -844,6 +844,30 @@ export const activateEffect = < ]; break; } + case "drainModifier": { + switch (effect.modifierKind) { + case "motivation": { + const motivation = lesson.idol.modifiers.find( + (e) => e.kind === "motivation", + ); + if (motivation) { + diffs.push({ + kind: "modifiers.update", + propertyNameKind: "amount", + id: motivation.id, + actual: Math.max(-effect.value, -motivation.amount) + 0, + max: -effect.value + 0, + }); + } + break; + } + default: { + const unreachable: never = effect; + throw new Error(`Unreachable statement`); + } + } + break; + } case "drawCards": { const { deck, discardPile, drawnCards } = drawCardsFromDeck( lesson.deck, diff --git a/src/types.ts b/src/types.ts index 09498a1..db43a4e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -616,6 +616,8 @@ export type EffectWithoutCondition = Readonly< * - 原文の構文は、「{modifierKind}減少{value}」 * - 「スタイリッシュモード」は、「やる気減少1」 * - 現状はスキルカードには存在しない効果 + * - 減少する値が不足している場合は、0になるまで減少する + * - 本家仕様は未調査 */ kind: "drainModifier"; modifierKind: "motivation";