Randomize decoy usernames and which rapports carry coded messages

Decoy names in /var/home and verifyCodes.txt were a hardcoded 4-name
list (Luke, Charles, William, Peter), so a real player registering
under one of those names would collide with it. Now each session
picks 6 decoys from a pool of 10, excluding any name already taken by
a real player, and stores the pick as a session setting.

Likewise the 3 "special report" rapports that get coded messages were
always Doyle, Vega and Lennox. Each session now randomly assigns 3 of
the 20 rapports to that role, and the win screen / mainframe-help
message reference whichever agents were actually picked instead of
the hardcoded names.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Frank
2026-08-22 17:09:52 +02:00
co-authored by Claude Sonnet 5
parent 02780d8f04
commit 6b1436dfe7
6 changed files with 155 additions and 30 deletions
+54 -17
View File
@@ -959,11 +959,52 @@ class GameResponseService
$this->entityManager->persist($everyoneVerifiedSetting);
$this->entityManager->flush();
$message = "Mainframe Help Modus: Agents Doyle, Vega and Lennox rapports have been updated with coded messages.";
$agentNames = $this->getSpecialReportAgentNames($session);
$message = "Mainframe Help Modus: Agents " . $this->formatNameList($agentNames) . " rapports have been updated with coded messages.";
$this->eventDispatcher->dispatch(new PushMercureMessageEvent($session, [0, $message], 'help_modus_activated'));
}
}
private function getDecoyUsernames(Session $session): array
{
$setting = $this->sessionSettingRepository->getSetting($session, SessionSettingType::DECOY_USERNAMES);
$decoded = json_decode($setting?->getValue() ?? '[]', true);
return is_array($decoded) ? $decoded : [];
}
private function getSpecialReportAssignments(Session $session): array
{
$setting = $this->sessionSettingRepository->getSetting($session, SessionSettingType::SPECIAL_REPORT_ASSIGNMENTS);
$decoded = json_decode($setting?->getValue() ?? '[]', true);
return is_array($decoded) ? $decoded : [];
}
public function getSpecialReportAgentNames(Session $session): array
{
return array_column($this->getSpecialReportAssignments($session), 'agent');
}
public function getSpecialReportAgentsText(Session $session): string
{
return $this->formatNameList($this->getSpecialReportAgentNames($session));
}
private function formatNameList(array $names): string
{
if (count($names) === 0) {
return '';
}
if (count($names) === 1) {
return $names[0];
}
$last = array_pop($names);
return implode(', ', $names) . ' and ' . $last;
}
private function goToNewDir(string $pwd, string $newPwd, Player $player) : string|bool
{
$allPossiblePaths = $this->getAllPossiblePaths($player);
@@ -1080,7 +1121,7 @@ class GameResponseService
$paths[] = '/var/home';
$playerNames = ['root', 'Luke', 'Charles', 'William', 'Peter'];
$playerNames = array_merge(['root'], $this->getDecoyUsernames($player->getSession()));
$players = $player->getSession()->getPlayers();
@@ -1490,20 +1531,16 @@ class GameResponseService
return ['Error reading file'];
}
$specialFiles = [
'/var/rapports/083_25-39.txt' => [
'setting' => SessionSettingType::SPECIAL_REPORT_CODE_DOYLE,
'digit' => 1
],
'/var/rapports/019_31-11.txt' => [
'setting' => SessionSettingType::SPECIAL_REPORT_CODE_VEGA,
'digit' => 2
],
'/var/rapports/011_130-62.txt' => [
'setting' => SessionSettingType::SPECIAL_REPORT_CODE_LENNOX,
'digit' => 3
],
];
$specialFiles = [];
foreach ($this->getSpecialReportAssignments($player->getSession()) as $assignment) {
$settingType = SessionSettingType::tryFrom('SpecialReportCode' . $assignment['digit']);
if ($settingType) {
$specialFiles[$assignment['file']] = [
'setting' => $settingType,
'digit' => $assignment['digit'],
];
}
}
if (isset($specialFiles[$file])) {
$everyoneVerifiedSetting = $this->sessionSettingRepository->getSetting($player->getSession(), SessionSettingType::EVERYONE_VERIFIED);
@@ -1571,7 +1608,7 @@ class GameResponseService
$codes = json_decode($setting->getValue() ?? '[]', true) ?? [];
$playerNames = ['Luke', 'Charles', 'William', 'Peter'];
$playerNames = $this->getDecoyUsernames($player->getSession());
foreach ($player->getSession()->getPlayers() as $p) {
$playerNames[] = $p->getUser()->getUsername();
}