Skip to content

Commit

Permalink
fix: ensure scenario 28 special rule is applied
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Stevens committed Dec 21, 2023
1 parent fcee835 commit 2a8435f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const securityHeaders = [
const nextConfig = {
reactStrictMode: true,
outputFileTracing: true,
poweredByHeader: false,
typescript: {
ignoreBuildErrors: true,
},
Expand Down
20 changes: 4 additions & 16 deletions src/data/scenarios.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
//special_rules should be treated with some kind of macro that recognises them and applies them when loading
export const SPECIAL_RULES = {
living_corpse_two_levels_extra: {
description:
'All living corpses are two levels higher than the scenario level, up to a max of 7',
affected_deck: 'Living Corpse',
extra_levels: 2,
},
};

export const SCENARIO_DEFINITIONS = [
{
name: '#1 Black Barrow',
Expand Down Expand Up @@ -291,15 +281,13 @@ export const SCENARIO_DEFINITIONS = [
{ name: 'Night Demon' },
{ name: 'Sun Demon' },
],
special_rules: [
id: 28,
specialRules: [
{
description:
'All living corpses are two levels higher than the scenario level, up to a max of 7',
affected_deck: 'Living Corpse',
deck: 'Living Corpse',
extra_levels: 2,
},
],
id: 28,
},
{
name: '#29 Sanctuary of Gloom',
Expand Down Expand Up @@ -922,4 +910,4 @@ export const SCENARIO_DEFINITIONS = [
],
id: 95,
},
] as const;
];
20 changes: 18 additions & 2 deletions src/hooks/useDecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ export interface BossDeck {
cards: (typeof DECK_DEFINITIONS)['Boss']['cards'];
}

const getScenarioLevelForDeck = (
scenario: Scenario,
level: number,
deck: DeckNames,
) => {
if (!scenario.specialRules?.length) return level;
const matchingSpecialRule = scenario.specialRules.find(
(rule) => rule.deck === deck,
);
if (!matchingSpecialRule) return level;
return Math.min(7, matchingSpecialRule.extra_levels + level);
};

export const useDecks = (
scenario: Scenario | undefined,
level: number,
Expand All @@ -58,8 +71,11 @@ export const useDecks = (
const deckName = scenarioDeck.name as Exclude<DeckNames, 'Boss'>;
const deckClass = DECKS[deckName]?.class;
const deck = DECK_DEFINITIONS[deckClass];

const stats = getMonsterStats(deckName as ScenarioMonsterNames, level);
const adjustedLevel = getScenarioLevelForDeck(scenario, level, deckName);
const stats = getMonsterStats(
deckName as ScenarioMonsterNames,
adjustedLevel,
);

return {
name: deckName,
Expand Down

0 comments on commit 2a8435f

Please sign in to comment.