Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kjirou committed Sep 22, 2024
1 parent 2ef6c1a commit 7a3349c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/lesson-mutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
24 changes: 24 additions & 0 deletions src/lesson-mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ export type EffectWithoutCondition = Readonly<
* - 原文の構文は、「{modifierKind}減少{value}」
* - 「スタイリッシュモード」は、「やる気減少1」
* - 現状はスキルカードには存在しない効果
* - 減少する値が不足している場合は、0になるまで減少する
* - 本家仕様は未調査
*/
kind: "drainModifier";
modifierKind: "motivation";
Expand Down

0 comments on commit 7a3349c

Please sign in to comment.