2PlayerGame/detective-game/casegen/evening.js
UndecimoDia 2c887ca451 fixes
2026-08-15 15:37:54 +03:00

34 lines
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// casegen/evening.js — налаштування вечора злочину:
// де хто був насправді (evening) і що каже (claim), брехуни, спільники
const { chance, pick } = require('./rng');
const { unitBuilding } = require('./district');
const N = require('./names');
function setupEvening(ctx) {
const { r, citizens, victim, killer, herring, district, scene, coveredB } = ctx;
for (const c of citizens) {
c.evening = c.workplace && chance(r, 0.2) ? c.workplace
: chance(r, 0.2) ? pick(r, ['bar', 'diner']) : unitBuilding(c.home);
c.liar = chance(r, 0.15);
}
victim.evening = scene.building; victim.liar = false;
killer.evening = scene.building; killer.liar = true;
herring.evening = pick(r, coveredB.filter(b => b !== scene.building && b !== 'station')) || unitBuilding(herring.home);
herring.liar = false;
const otherB = b => pick(r, district.buildings.filter(x => x.id !== b && x.id !== 'station')).id;
for (const c of citizens) c.claim = c.liar ? otherB(c.evening) : c.evening;
killer.claim = pick(r, coveredB.filter(b => b !== scene.building && b !== 'station')) || otherB(scene.building);
// Виправдання роздаємо тут (споживає RNG). А от свідка алібі (`mate`) рахувати
// рано: мутатори після нас іще переносять людей (спільниця йде на місце злочину),
// і вже роздані посилання протухають — див. assignMates() в кінці генерації.
for (const c of citizens) {
if (!c.liar || c === killer) continue;
c.excuse = pick(r, N.EXCUSES);
}
}
module.exports = { setupEvening };