Skip to content

Commit

Permalink
fix: typescript compilation errors
Browse files Browse the repository at this point in the history
`yarn build` has been giving a lot of grief about proper types for the
pino logger
  • Loading branch information
alee committed Dec 15, 2023
1 parent 8a41e92 commit 097eb0c
Show file tree
Hide file tree
Showing 22 changed files with 466 additions and 446 deletions.
172 changes: 86 additions & 86 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -406,70 +406,70 @@
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==

"@rollup/rollup-android-arm-eabi@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.8.0.tgz#0e42b155630adaaec0f659f979ece4b7d3391329"
integrity sha512-zdTObFRoNENrdPpnTNnhOljYIcOX7aI7+7wyrSpPFFIOf/nRdedE6IYsjaBE7tjukphh1tMTojgJ7p3lKY8x6Q==

"@rollup/rollup-android-arm64@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.8.0.tgz#6c9fe8f9eb0cd9029be93b822b1a1c2d6b31c275"
integrity sha512-aiItwP48BiGpMFS9Znjo/xCNQVwTQVcRKkFKsO81m8exrGjHkCBDvm9PHay2kpa8RPnZzzKcD1iQ9KaLY4fPQQ==

"@rollup/rollup-darwin-arm64@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.8.0.tgz#7dcb1317a8089762c1f7e437c1e1d695b787b70f"
integrity sha512-zhNIS+L4ZYkYQUjIQUR6Zl0RXhbbA0huvNIWjmPc2SL0cB1h5Djkcy+RZ3/Bwszfb6vgwUvcVJYD6e6Zkpsi8g==

"@rollup/rollup-darwin-x64@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.8.0.tgz#91d7d31d22607c4fcccce9126457d6785c57f7c7"
integrity sha512-A/FAHFRNQYrELrb/JHncRWzTTXB2ticiRFztP4ggIUAfa9Up1qfW8aG2w/mN9jNiZ+HB0t0u0jpJgFXG6BfRTA==

"@rollup/rollup-linux-arm-gnueabihf@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.8.0.tgz#f2015d6e4ff41417f2e2c55b3d9625346e355c57"
integrity sha512-JsidBnh3p2IJJA4/2xOF2puAYqbaczB3elZDT0qHxn362EIoIkq7hrR43Xa8RisgI6/WPfvb2umbGsuvf7E37A==

"@rollup/rollup-linux-arm64-gnu@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.8.0.tgz#95207444b78f235c9de62797ec2a3dcd18daf473"
integrity sha512-hBNCnqw3EVCkaPB0Oqd24bv8SklETptQWcJz06kb9OtiShn9jK1VuTgi7o4zPSt6rNGWQOTDEAccbk0OqJmS+g==

"@rollup/rollup-linux-arm64-musl@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.8.0.tgz#bc994c676fd3aae14aaa905040fdcde461e41ce5"
integrity sha512-Fw9ChYfJPdltvi9ALJ9wzdCdxGw4wtq4t1qY028b2O7GwB5qLNSGtqMsAel1lfWTZvf4b6/+4HKp0GlSYg0ahA==

"@rollup/rollup-linux-riscv64-gnu@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.8.0.tgz#67984f1d1f663610f4e1f6e638a2b07169562448"
integrity sha512-BH5xIh7tOzS9yBi8dFrCTG8Z6iNIGWGltd3IpTSKp6+pNWWO6qy8eKoRxOtwFbMrid5NZaidLYN6rHh9aB8bEw==

"@rollup/rollup-linux-x64-gnu@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.8.0.tgz#48e09a455d543be986003c7c2ea37c16ff4a53d5"
integrity sha512-PmvAj8k6EuWiyLbkNpd6BLv5XeYFpqWuRvRNRl80xVfpGXK/z6KYXmAgbI4ogz7uFiJxCnYcqyvZVD0dgFog7Q==

"@rollup/rollup-linux-x64-musl@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.8.0.tgz#df8d0966b02d1bdc6447b5eb58fa18666da1f3e8"
integrity sha512-mdxnlW2QUzXwY+95TuxZ+CurrhgrPAMveDWI97EQlA9bfhR8tw3Pt7SUlc/eSlCNxlWktpmT//EAA8UfCHOyXg==

"@rollup/rollup-win32-arm64-msvc@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.8.0.tgz#7cce8efc5c9239a1bafe7ac2a52743bc5734471f"
integrity sha512-ge7saUz38aesM4MA7Cad8CHo0Fyd1+qTaqoIo+Jtk+ipBi4ATSrHWov9/S4u5pbEQmLjgUjB7BJt+MiKG2kzmA==

"@rollup/rollup-win32-ia32-msvc@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.8.0.tgz#794ef4058d04f97447e4434c083b1309b2be73c2"
integrity sha512-p9E3PZlzurhlsN5h9g7zIP1DnqKXJe8ZUkFwAazqSvHuWfihlIISPxG9hCHCoA+dOOspL/c7ty1eeEVFTE0UTw==

"@rollup/rollup-win32-x64-msvc@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.8.0.tgz#05057436705f0be9203c30612a48225ec70af741"
integrity sha512-kb4/auKXkYKqlUYTE8s40FcJIj5soOyRLHKd4ugR0dCq0G2EfcF54eYcfQiGkHzjidZ40daB4ulsFdtqNKZtBg==
"@rollup/rollup-android-arm-eabi@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.0.tgz#0437b27edd7095d0b6d5db99d13af8157d7c58b0"
integrity sha512-+1ge/xmaJpm1KVBuIH38Z94zj9fBD+hp+/5WLaHgyY8XLq1ibxk/zj6dTXaqM2cAbYKq8jYlhHd6k05If1W5xA==

"@rollup/rollup-android-arm64@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.0.tgz#d4c14ef9e45d5c46b8d1f611ab8124a611d5be5b"
integrity sha512-im6hUEyQ7ZfoZdNvtwgEJvBWZYauC9KVKq1w58LG2Zfz6zMd8gRrbN+xCVoqA2hv/v6fm9lp5LFGJ3za8EQH3A==

"@rollup/rollup-darwin-arm64@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.0.tgz#6f3fdf5712db6b5e3d8f62a86a09cd659dd871f9"
integrity sha512-u7aTMskN6Dmg1lCT0QJ+tINRt+ntUrvVkhbPfFz4bCwRZvjItx2nJtwJnJRlKMMaQCHRjrNqHRDYvE4mBm3DlQ==

"@rollup/rollup-darwin-x64@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.0.tgz#626d7786fe7c10b2e8533ad981b4a791fd72b9d0"
integrity sha512-8FvEl3w2ExmpcOmX5RJD0yqXcVSOqAJJUJ29Lca29Ik+3zPS1yFimr2fr5JSZ4Z5gt8/d7WqycpgkX9nocijSw==

"@rollup/rollup-linux-arm-gnueabihf@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.0.tgz#57ece7bb1b7659a3ea2ace580a63b8f92b3161f1"
integrity sha512-lHoKYaRwd4gge+IpqJHCY+8Vc3hhdJfU6ukFnnrJasEBUvVlydP8PuwndbWfGkdgSvZhHfSEw6urrlBj0TSSfg==

"@rollup/rollup-linux-arm64-gnu@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.0.tgz#345b276b814a5377344adc5780c4dfb7cd0e8ba9"
integrity sha512-JbEPfhndYeWHfOSeh4DOFvNXrj7ls9S/2omijVsao+LBPTPayT1uKcK3dHW3MwDJ7KO11t9m2cVTqXnTKpeaiw==

"@rollup/rollup-linux-arm64-musl@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.0.tgz#61cc6516e6e92e2205ea1d0ac30326379b0563c8"
integrity sha512-ahqcSXLlcV2XUBM3/f/C6cRoh7NxYA/W7Yzuv4bDU1YscTFw7ay4LmD7l6OS8EMhTNvcrWGkEettL1Bhjf+B+w==

"@rollup/rollup-linux-riscv64-gnu@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.0.tgz#e9add70ddca7bd6f685ec447ae83eb3be552f211"
integrity sha512-uwvOYNtLw8gVtrExKhdFsYHA/kotURUmZYlinH2VcQxNCQJeJXnkmWgw2hI9Xgzhgu7J9QvWiq9TtTVwWMDa+w==

"@rollup/rollup-linux-x64-gnu@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.0.tgz#ece153613f0cf2c864dbfc2076c579da8abd51a9"
integrity sha512-m6pkSwcZZD2LCFHZX/zW2aLIISyzWLU3hrLLzQKMI12+OLEzgruTovAxY5sCZJkipklaZqPy/2bEEBNjp+Y7xg==

"@rollup/rollup-linux-x64-musl@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.0.tgz#2d2dbdf5fbf2c19d1f3d31b8a7850b57f5799037"
integrity sha512-VFAC1RDRSbU3iOF98X42KaVicAfKf0m0OvIu8dbnqhTe26Kh6Ym9JrDulz7Hbk7/9zGc41JkV02g+p3BivOdAg==

"@rollup/rollup-win32-arm64-msvc@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.0.tgz#bf2dbad350376e46cb77fab408bb398ad5f3648d"
integrity sha512-9jPgMvTKXARz4inw6jezMLA2ihDBvgIU9Ml01hjdVpOcMKyxFBJrn83KVQINnbeqDv0+HdO1c09hgZ8N0s820Q==

"@rollup/rollup-win32-ia32-msvc@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.0.tgz#5c26b07f74f4054f3ecf202550100496ed2e73f3"
integrity sha512-WE4pT2kTXQN2bAv40Uog0AsV7/s9nT9HBWXAou8+++MBCnY51QS02KYtm6dQxxosKi1VIz/wZIrTQO5UP2EW+Q==

"@rollup/rollup-win32-x64-msvc@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.0.tgz#4ea610e0c40a07a8afa2977cbf80507f41c2271c"
integrity sha512-aPP5Q5AqNGuT0tnuEkK/g4mnt3ZhheiXrDIiSVIHN9mcN21OyXDVbEMqmXPE7e2OplNLDkcvV+ZoGJa2ZImFgw==

"@rushstack/eslint-patch@^1.2.0":
version "1.6.0"
Expand Down Expand Up @@ -1103,9 +1103,9 @@ camelcase-css@^2.0.1:
integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==

caniuse-lite@^1.0.30001538, caniuse-lite@^1.0.30001565:
version "1.0.30001568"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001568.tgz#53fa9297273c9a977a560663f48cbea1767518b7"
integrity sha512-vSUkH84HontZJ88MiNrOau1EBrCqEQYgkC5gIySiDlpsm8sGVrhU7Kx4V6h0tnqaHzIHZv08HlJIwPbL4XL9+A==
version "1.0.30001570"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001570.tgz#b4e5c1fa786f733ab78fc70f592df6b3f23244ca"
integrity sha512-+3e0ASu4sw1SWaoCtvPeyXp+5PsjigkSt8OXZbF9StH5pQWbxEjLAZE3n8Aup5udop1uRiKA7a4utUk/uoSpUw==

chai@^4.3.10:
version "4.3.10"
Expand Down Expand Up @@ -1479,9 +1479,9 @@ editorconfig@^1.0.3:
semver "^7.5.3"

electron-to-chromium@^1.4.601:
version "1.4.611"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.611.tgz#92d3a8f03110fbf5f99b054da97825f994fa480a"
integrity sha512-ZtRpDxrjHapOwxtv+nuth5ByB8clyn8crVynmRNGO3wG3LOp8RTcyZDqwaI6Ng6y8FCK2hVZmJoqwCskKbNMaw==
version "1.4.612"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.612.tgz#350c6fd4201d677307519b931949fa64dae6a5cc"
integrity sha512-dM8BMtXtlH237ecSMnYdYuCkib2QHq0kpWfUnavjdYsyr/6OsAwg5ZGUfnQ9KD1Ga4QgB2sqXlB2NT8zy2GnVg==

emoji-regex@^8.0.0:
version "8.0.0"
Expand Down Expand Up @@ -3199,23 +3199,23 @@ rollup@^3.27.1:
fsevents "~2.3.2"

rollup@^4.2.0:
version "4.8.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.8.0.tgz#365c34e85f1ed034de974dab934c1663cc69b754"
integrity sha512-NpsklK2fach5CdI+PScmlE5R4Ao/FSWtF7LkoIrHDxPACY/xshNasPsbpG0VVHxUTbf74tJbVT4PrP8JsJ6ZDA==
version "4.9.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.9.0.tgz#94dff4070f106c1be6b2e88401a49b023c87fa88"
integrity sha512-bUHW/9N21z64gw8s6tP4c88P382Bq/L5uZDowHlHx6s/QWpjJXivIAbEw6LZthgSvlEizZBfLC4OAvWe7aoF7A==
optionalDependencies:
"@rollup/rollup-android-arm-eabi" "4.8.0"
"@rollup/rollup-android-arm64" "4.8.0"
"@rollup/rollup-darwin-arm64" "4.8.0"
"@rollup/rollup-darwin-x64" "4.8.0"
"@rollup/rollup-linux-arm-gnueabihf" "4.8.0"
"@rollup/rollup-linux-arm64-gnu" "4.8.0"
"@rollup/rollup-linux-arm64-musl" "4.8.0"
"@rollup/rollup-linux-riscv64-gnu" "4.8.0"
"@rollup/rollup-linux-x64-gnu" "4.8.0"
"@rollup/rollup-linux-x64-musl" "4.8.0"
"@rollup/rollup-win32-arm64-msvc" "4.8.0"
"@rollup/rollup-win32-ia32-msvc" "4.8.0"
"@rollup/rollup-win32-x64-msvc" "4.8.0"
"@rollup/rollup-android-arm-eabi" "4.9.0"
"@rollup/rollup-android-arm64" "4.9.0"
"@rollup/rollup-darwin-arm64" "4.9.0"
"@rollup/rollup-darwin-x64" "4.9.0"
"@rollup/rollup-linux-arm-gnueabihf" "4.9.0"
"@rollup/rollup-linux-arm64-gnu" "4.9.0"
"@rollup/rollup-linux-arm64-musl" "4.9.0"
"@rollup/rollup-linux-riscv64-gnu" "4.9.0"
"@rollup/rollup-linux-x64-gnu" "4.9.0"
"@rollup/rollup-linux-x64-musl" "4.9.0"
"@rollup/rollup-win32-arm64-msvc" "4.9.0"
"@rollup/rollup-win32-ia32-msvc" "4.9.0"
"@rollup/rollup-win32-x64-msvc" "4.9.0"
fsevents "~2.3.2"

rrweb-cssom@^0.6.0:
Expand Down
25 changes: 14 additions & 11 deletions server/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ async function createTournament(

async function setAdminUser(em: EntityManager, username: string): Promise<void> {
const services = getServices(em);
logger.debug("setting admin user: %s", username);
try {
const user = await services.account.setAdminByUsername(username);
logger.info("set user '%s' (id: %s) as admin", user.username, user.id);
logger.info("set user '%s' (id: %d) as admin", user.username, user.id);
} catch (e) {
logger.warn("error attempting to set '%s' as admin", username);
logger.warn("unable to set '%s' as admin", username);
logger.warn(e as Error);
}
}

Expand All @@ -254,7 +254,7 @@ async function anonymizeUsernames(
);
await repo.save(anonUsers);
} catch (e) {
logger.fatal("error anonymizing usernames: %o", e);
logger.fatal(e as Error);
}
}

Expand Down Expand Up @@ -347,7 +347,7 @@ async function createTournamentRoundInvites(
): Promise<number> {
const sp = getServices(em);
const invites = await sp.tournament.createInvites(userIds, tournamentRoundId, hasParticipated);
logger.debug("created tournament round invites for %s", userIds);
logger.debug("created tournament round invites for %s", userIds.toString());
return invites.length;
}

Expand All @@ -364,14 +364,15 @@ async function exportActiveEmails(
enableAmdfFormat: boolean
): Promise<void> {
const sp = getServices(em);
logger.debug("exporting emails after %s", after);
logger.debug("exporting emails after %s", after.toISOString());
const users = await sp.account.getActiveUsers(after);
const emails = users.map(u => formatEmail(u, enableAmdfFormat));
try {
await writeFile("active-emails.csv", emails.join("\n"));
logger.debug("Exported all active users with emails to active-emails.csv");
} catch (err) {
logger.fatal("unable to export active emails: %s", err);
} catch (e) {
logger.fatal("unable to export active emails");
logger.fatal(e as Error);
}
}

Expand All @@ -385,8 +386,9 @@ async function exportTournamentRoundEmails(
try {
await writeFile(outputFile, emails.join("\n"));
logger.debug(`exported round invitation emails to ${outputFile}`);
} catch (err) {
logger.fatal("Unable to export emails", err);
} catch (e) {
logger.fatal("Unable to export emails");
logger.fatal(e as Error);
}
}

Expand All @@ -409,7 +411,8 @@ async function createTournamentTreatment(
);
logger.debug("created tournament treatment: %o", treatment);
} catch (e) {
logger.fatal("Unable to create treatment: %s", e);
logger.fatal("Unable to create treatment");
logger.fatal(e as Error);
}
}

Expand Down
4 changes: 2 additions & 2 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ passport.deserializeUser(function (id: number, done: any) {
.account.findUserById(id)
.then(user => done(null, user))
.catch(e => {
logger.fatal(`Could not find user with ${id}: `, e);
logger.fatal(`Could not find user with ${id}: ${e}`);
done(e, null);
});
});
Expand All @@ -143,7 +143,7 @@ async function createApp() {

logger.info(
"starting (%s) server: [build id: %s, settings.host %s]",
process.env.NODE_ENV,
NODE_ENV,
Constants.BUILD_ID,
settings.host
);
Expand Down
4 changes: 2 additions & 2 deletions server/src/rooms/game/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ export class GameRoom extends Room<GameState> implements Game {
}

async onDispose(): Promise<void> {
logger.info("Disposing of room", this.roomId);
logger.info("Disposing of room %s", this.roomId);
await this.persister.sync();
await this.persister.finalize(this.gameId, true);
logger.info("Disposed of room", this.roomId);
logger.info("Disposed of room %s", this.roomId);
}

set gameId(id: number) {
Expand Down
8 changes: 6 additions & 2 deletions server/src/rooms/game/state/accomplishment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ export class AccomplishmentSet extends Schema implements AccomplishmentSetData<A

discardPurchased(id: number): void {
const discardedAccomplishmentIndex = this.purchased.findIndex(acc => acc.id === id);
logger.info("Discarding purchased accomplishment [%d] from deck {%s}", id, this.purchased);
logger.info(
"Discarding purchased accomplishment [%d] from deck {%s}",
id,
this.purchased.toString()
);
if (discardedAccomplishmentIndex >= 0) {
this.purchased.splice(discardedAccomplishmentIndex, 1);
// make the discarded card available for purchase again
Expand All @@ -206,7 +210,7 @@ export class AccomplishmentSet extends Schema implements AccomplishmentSetData<A

draw(numberOfCards: number): void {
for (let i = 0; i < numberOfCards; i++) {
logger.debug("drawing an accomplishment from deck %s", this.deck);
logger.debug("drawing an accomplishment from deck %s", this.deck.toString());
const accomplishmentId = this.deck.shift();
const newAccomplishment = new Accomplishment(
getAccomplishmentByID(this.role, accomplishmentId!)
Expand Down
2 changes: 1 addition & 1 deletion server/src/rooms/game/state/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class MarsEventVisitor implements AbstractMarsEventVisitor {
downCastEventState(HeroOrPariah, state, eventState => {
if (!eventState.hasVoted(player.role)) {
const choice = _.random(0, 1) ? "hero" : "pariah";
logger.debug("player %s choice %o", player.role, choice);
logger.debug("player %s choice %s", player.role, choice);
return [new VoteHeroOrPariah({ role: player.role, heroOrPariah: choice })];
} else return [];
}) ?? []
Expand Down
2 changes: 1 addition & 1 deletion server/src/rooms/game/state/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class GameState
if (this.hasUser(username)) {
return this.players[this.userRoles[username]];
}
logger.fatal("GameState.getPlayer: Unable to find player with username", username);
logger.fatal("GameState.getPlayer: Unable to find player with username %s", username);
throw new Error(`No player found with ${username}`);
}

Expand Down
17 changes: 10 additions & 7 deletions server/src/rooms/game/state/marsevents/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ export class HeroOrPariah extends BaseEvent {
// _.orderBy => [[ROLE, highest vote], ... [ROLE, lowest vote]]
const winners = _.orderBy(_.toPairs(votes), o => o[1], "desc");
logger.debug("winners: %o", winners);
console.log("winners: ", winners);

if (this.tie(winners)) {
logger.debug("hero or pariah voting tie: %o", this.tie(winners));
const isTie = this.tie(winners);

if (isTie) {
logger.debug(
"2-way tie: %o",
_.filter(winners, o => o[1] == 2)
Expand All @@ -416,8 +416,11 @@ export class HeroOrPariah extends BaseEvent {
"5-way tie: %o",
_.filter(winners, o => o[1] == 1)
);
// pick a winner randomly
this.winner = winners[Math.floor(Math.random() * winners.length)][0] as Role;
} else this.winner = winners[0][0] as Role;
} else {
this.winner = winners[0][0] as Role;
}

// mars log messaging

Expand All @@ -427,7 +430,7 @@ export class HeroOrPariah extends BaseEvent {
const specialty = game.players[this.winner].specialty;
game.players[this.winner].inventory[specialty] += 4;

if (this.tie(winners)) {
if (isTie) {
game.log(
`Because of a voting tie, ${this.winner} is randomly voted a Hero and has gained 4 ${specialty}.`,
this.title
Expand All @@ -449,7 +452,7 @@ export class HeroOrPariah extends BaseEvent {
game.players[this.winner].inventory[resource] = 0;
}

if (this.tie(winners)) {
if (isTie) {
game.log(
`Because of a voting tie, ${this.winner} is randomly voted a Pariah and has lost all
their Influence resources.`,
Expand Down Expand Up @@ -738,6 +741,6 @@ export function downCastEventState<T extends BaseEvent, R>(
if (eventState instanceof classDef) {
return callBack(eventState);
} else {
logger.warn("the expected event state is the wrong type %s", eventState);
logger.warn("expected event state is the wrong type %o", eventState);
}
}
Loading

0 comments on commit 097eb0c

Please sign in to comment.