Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion src/service/lootDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,36 @@ type AdjustmentResult = {
weights: number[];
};

function getTimeOfDayMultipliers(weights: readonly number[]): number[] {
const now = new Date();
const hour = Number(
now.toLocaleString("de-DE", { timeZone: "Europe/Berlin", hour: "numeric", hour12: false }),
);

const multipliers = new Array(weights.length).fill(1);

// Morgens (6:00 - 12:00): Höhere Wahrscheinlichkeit für Frühstücks-Items
const isMorning = hour >= 6 && hour < 12;
// Abends (18:00 - 24:00): Höhere Wahrscheinlichkeit für Feierabend-Items
const isEvening = hour >= 18 && hour < 24;

if (isMorning) {
multipliers[LootKind.KAFFEEMUEHLE] = 2;
multipliers[LootKind.KRANKSCHREIBUNG] = 2;
multipliers[LootKind.OETTINGER] = 2;
}

if (isEvening) {
multipliers[LootKind.DOENER] = 2;
multipliers[LootKind.AYRAN] = 2;
multipliers[LootKind.SAHNE] = 2;
multipliers[LootKind.TRICHTER] = 2;
multipliers[LootKind.GAULOISES_BLAU] = 2;
}

return multipliers;
}

async function getDropWeightAdjustments(
user: User,
weights: readonly number[],
Expand All @@ -386,9 +416,26 @@ async function getDropWeightAdjustments(
messages.push("Da du privat versichert bist, hast du die doppelte Chance auf eine AU.");
}

const timeMultipliers = getTimeOfDayMultipliers(weights);

const newWeights = [...weights];
newWeights[LootKind.NICHTS] = Math.ceil(weights[LootKind.NICHTS] * wasteFactor) | 0;
newWeights[LootKind.KRANKSCHREIBUNG] = (weights[LootKind.KRANKSCHREIBUNG] * pkvFactor) | 0;
newWeights[LootKind.KRANKSCHREIBUNG] =
(weights[LootKind.KRANKSCHREIBUNG] * pkvFactor * timeMultipliers[LootKind.KRANKSCHREIBUNG]) |
0;

// Tageszeitabhängige Anpassungen
newWeights[LootKind.KAFFEEMUEHLE] =
(weights[LootKind.KAFFEEMUEHLE] * timeMultipliers[LootKind.KAFFEEMUEHLE]) | 0;
newWeights[LootKind.OETTINGER] =
(weights[LootKind.OETTINGER] * timeMultipliers[LootKind.OETTINGER]) | 0;
newWeights[LootKind.DOENER] = (weights[LootKind.DOENER] * timeMultipliers[LootKind.DOENER]) | 0;
newWeights[LootKind.AYRAN] = (weights[LootKind.AYRAN] * timeMultipliers[LootKind.AYRAN]) | 0;
newWeights[LootKind.SAHNE] = (weights[LootKind.SAHNE] * timeMultipliers[LootKind.SAHNE]) | 0;
newWeights[LootKind.TRICHTER] =
(weights[LootKind.TRICHTER] * timeMultipliers[LootKind.TRICHTER]) | 0;
newWeights[LootKind.GAULOISES_BLAU] =
(weights[LootKind.GAULOISES_BLAU] * timeMultipliers[LootKind.GAULOISES_BLAU]) | 0;

return {
messages,
Expand Down
Loading