From 26f274e27320455fc8cebfc8f085a37c5172e42d Mon Sep 17 00:00:00 2001 From: Logan Davidson Date: Wed, 4 Oct 2023 13:07:32 +0100 Subject: [PATCH] Use Prettier for code formatting (#291) * Apply Prettier to JS, TS, JSON and HTML files * Add Prettier (extension) as VS code recommendation --- backend/.vscode/launch.json | 32 +- backend/Dockerrun.aws.json | 10 +- backend/rorapp/presets/senator.json | 480 +++++------ backend/rorapp/presets/statesman.json | 402 ++++----- backend/rorapp/templates/index.html | 8 +- frontend/classes/Collection.ts | 8 +- frontend/classes/Faction.ts | 10 +- frontend/classes/Game.ts | 2 +- frontend/classes/Player.ts | 2 +- frontend/classes/Senator.ts | 35 +- frontend/components/Breadcrumb.tsx | 66 +- frontend/components/ElapsedTime.tsx | 38 +- frontend/components/ExternalLink.tsx | 30 +- frontend/components/FactionIcon.tsx | 25 +- frontend/components/FactionLink.tsx | 21 +- frontend/components/FactionList.tsx | 25 +- frontend/components/FactionListItem.tsx | 92 +- frontend/components/Footer.tsx | 9 +- frontend/components/GamePage.tsx | 731 +++++++++++----- frontend/components/KeyValueList.tsx | 12 +- frontend/components/MetaSection.tsx | 96 ++- frontend/components/PageError.tsx | 19 +- frontend/components/PageWrapper.tsx | 21 +- frontend/components/ProgressSection.tsx | 77 +- frontend/components/SenatorLink.tsx | 17 +- frontend/components/SenatorList.tsx | 307 +++++-- frontend/components/SenatorListItem.tsx | 95 ++- frontend/components/SenatorPortrait.tsx | 121 ++- frontend/components/TermLink.tsx | 54 +- frontend/components/TitleIcon.tsx | 20 +- frontend/components/TopBar.tsx | 88 +- .../components/actionDialogs/ActionDialog.tsx | 17 +- .../ActionDialog_FaceMortality.tsx | 62 +- .../ActionDialog_SelectFactionLeader.tsx | 87 +- frontend/components/actionLogs/ActionLog.tsx | 7 +- .../actionLogs/ActionLog_FaceMortality.tsx | 91 +- .../actionLogs/ActionLog_NewTurn.tsx | 13 +- .../ActionLog_SelectFactionLeader.tsx | 37 +- .../ActionLog_TemporaryRomeConsul.tsx | 41 +- .../detailSections/DetailSection.tsx | 56 +- .../detailSections/DetailSection_Faction.tsx | 24 +- .../detailSections/DetailSection_Senator.tsx | 365 +++++--- frontend/components/modals/ModalContainer.tsx | 64 +- frontend/components/modals/ModalTitle.tsx | 19 +- frontend/components/modals/SignOutModal.tsx | 73 +- frontend/components/terms/Term_Hrao.tsx | 23 +- frontend/components/terms/Term_RomeConsul.tsx | 15 +- frontend/contexts/AuthContext.tsx | 74 +- frontend/contexts/GameContext.tsx | 104 ++- frontend/contexts/ModalContext.tsx | 25 +- frontend/contexts/RootContext.tsx | 28 +- frontend/data/skills.json | 2 +- frontend/functions/cookies.ts | 45 +- frontend/functions/date.ts | 18 +- frontend/functions/request.ts | 61 +- frontend/functions/romanNumerals.ts | 30 +- frontend/functions/serialize.ts | 32 +- frontend/functions/tokens.ts | 24 +- frontend/hooks/useCookies.ts | 30 +- frontend/hooks/useFocusTrap.ts | 45 +- frontend/next.config.js | 2 +- frontend/pages/404.tsx | 8 +- frontend/pages/_app.tsx | 71 +- frontend/pages/_document.tsx | 2 +- frontend/pages/account.tsx | 41 +- frontend/pages/games/[id]/edit.tsx | 177 ++-- frontend/pages/games/[id]/index.tsx | 797 ++++++++++++------ frontend/pages/games/[id]/play.tsx | 35 +- frontend/pages/games/index.tsx | 251 ++++-- frontend/pages/games/new.tsx | 121 ++- frontend/pages/index.tsx | 199 +++-- frontend/pages/sign-in.tsx | 120 +-- frontend/themes/frameTheme.ts | 28 +- frontend/themes/mainTheme.ts | 58 +- frontend/themes/rootTheme.ts | 68 +- frontend/types/actions.ts | 8 +- frontend/types/selectedDetail.ts | 2 +- roronline.code-workspace | 6 + 78 files changed, 4142 insertions(+), 2317 deletions(-) diff --git a/backend/.vscode/launch.json b/backend/.vscode/launch.json index 972f5721..eef617a2 100644 --- a/backend/.vscode/launch.json +++ b/backend/.vscode/launch.json @@ -1,19 +1,17 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python: Django", - "type": "python", - "request": "launch", - "program": "${workspaceFolder}\\manage.py", - "args": [ - "runserver" - ], - "django": true, - "justMyCode": true - } - ] + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}\\manage.py", + "args": ["runserver"], + "django": true, + "justMyCode": true + } + ] } diff --git a/backend/Dockerrun.aws.json b/backend/Dockerrun.aws.json index b49fb0a7..aff40fc8 100644 --- a/backend/Dockerrun.aws.json +++ b/backend/Dockerrun.aws.json @@ -1,7 +1,7 @@ { - "AWSEBDockerrunVersion": "3", - "Authentication": { - "bucket": "api-roronline-com-docker-creds", - "key": "docker_config" - } + "AWSEBDockerrunVersion": "3", + "Authentication": { + "bucket": "api-roronline-com-docker-creds", + "key": "docker_config" + } } diff --git a/backend/rorapp/presets/senator.json b/backend/rorapp/presets/senator.json index 1931692b..aff4cf18 100644 --- a/backend/rorapp/presets/senator.json +++ b/backend/rorapp/presets/senator.json @@ -1,242 +1,242 @@ { - "Cornelius" : { - "code": 1, - "scenario": 1, - "military": 4, - "oratory": 3, - "loyalty": 9, - "influence": 5 - }, - "Fabius" : { - "code": 2, - "scenario": 1, - "military": 4, - "oratory": 2, - "loyalty": 9, - "influence": 5 - }, - "Valerius" : { - "code": 3, - "scenario": 1, - "military": 1, - "oratory": 2, - "loyalty": 10, - "influence": 5 - }, - "Julius" : { - "code": 4, - "scenario": 1, - "military": 4, - "oratory": 3, - "loyalty": 9, - "influence": 4 - }, - "Claudius" : { - "code": 5, - "scenario": 1, - "military": 2, - "oratory": 3, - "loyalty": 7, - "influence": 4 - }, - "Manlius" : { - "code": 6, - "scenario": 1, - "military": 3, - "oratory": 2, - "loyalty": 7, - "influence": 4 - }, - "Fulvius" : { - "code": 7, - "scenario": 1, - "military": 2, - "oratory": 2, - "loyalty": 8, - "influence": 4 - }, - "Furius" : { - "code": 8, - "scenario": 1, - "military": 3, - "oratory": 3, - "loyalty": 8, - "influence": 3 - }, - "Aurelius" : { - "code": 9, - "scenario": 1, - "military": 2, - "oratory": 3, - "loyalty": 7, - "influence": 3 - }, - "Junius" : { - "code": 10, - "scenario": 1, - "military": 1, - "oratory": 2, - "loyalty": 8, - "influence": 3 - }, - "Papirius" : { - "code": 11, - "scenario": 1, - "military": 1, - "oratory": 2, - "loyalty": 6, - "influence": 3 - }, - "Acilius" : { - "code": 12, - "scenario": 1, - "military": 2, - "oratory": 2, - "loyalty": 7, - "influence": 3 - }, - "Flaminius" : { - "code": 13, - "scenario": 1, - "military": 4, - "oratory": 2, - "loyalty": 6, - "influence": 3 - }, - "Aelius" : { - "code": 14, - "scenario": 1, - "military": 3, - "oratory": 4, - "loyalty": 7, - "influence": 2 - }, - "Sulpicius" : { - "code": 15, - "scenario": 1, - "military": 3, - "oratory": 2, - "loyalty": 8, - "influence": 2 - }, - "Calpurnius" : { - "code": 16, - "scenario": 1, - "military": 1, - "oratory": 2, - "loyalty": 9, - "influence": 2 - }, - "Plautius" : { - "code": 17, - "scenario": 1, - "military": 2, - "oratory": 1, - "loyalty": 6, - "influence": 2 - }, - "Quinctius" : { - "code": 18, - "scenario": 1, - "military": 3, - "oratory": 2, - "loyalty": 6, - "influence": 1 - }, - "Aemilius" : { - "code": 19, - "scenario": 1, - "military": 4, - "oratory": 2, - "loyalty": 8, - "influence": 1 - }, - "Terentius" : { - "code": 20, - "scenario": 1, - "military": 2, - "oratory": 1, - "loyalty": 6, - "influence": 1 - }, - "Servilius" : { - "code": 21, - "scenario": 2, - "military": 3, - "oratory": 4, - "loyalty": 9, - "influence": 4 - }, - "Porcius" : { - "code": 22, - "scenario": 2, - "military": 2, - "oratory": 4, - "loyalty": 10, - "influence": 1 - }, - "Popillius" : { - "code": 23, - "scenario": 2, - "military": 1, - "oratory": 3, - "loyalty": 7, - "influence": 3 - }, - "Cassius" : { - "code": 24, - "scenario": 2, - "military": 3, - "oratory": 3, - "loyalty": 9, - "influence": 3 - }, - "Sempronius" : { - "code": 25, - "scenario": 2, - "military": 1, - "oratory": 3, - "loyalty": 6, - "influence": 3 - }, - "Octavius" : { - "code": 26, - "scenario": 3, - "military": 2, - "oratory": 3, - "loyalty": 9, - "influence": 4 - }, - "Marius" : { - "code": 27, - "scenario": 3, - "military": 4, - "oratory": 2, - "loyalty": 9, - "influence": 4 - }, - "Tullius" : { - "code": 28, - "scenario": 3, - "military": 2, - "oratory": 3, - "loyalty": 7, - "influence": 3 - }, - "Licinius" : { - "code": 29, - "scenario": 3, - "military": 3, - "oratory": 2, - "loyalty": 9, - "influence": 3 - }, - "Pompeius" : { - "code": 30, - "scenario": 3, - "military": 2, - "oratory": 2, - "loyalty": 7, - "influence": 2 - } + "Cornelius": { + "code": 1, + "scenario": 1, + "military": 4, + "oratory": 3, + "loyalty": 9, + "influence": 5 + }, + "Fabius": { + "code": 2, + "scenario": 1, + "military": 4, + "oratory": 2, + "loyalty": 9, + "influence": 5 + }, + "Valerius": { + "code": 3, + "scenario": 1, + "military": 1, + "oratory": 2, + "loyalty": 10, + "influence": 5 + }, + "Julius": { + "code": 4, + "scenario": 1, + "military": 4, + "oratory": 3, + "loyalty": 9, + "influence": 4 + }, + "Claudius": { + "code": 5, + "scenario": 1, + "military": 2, + "oratory": 3, + "loyalty": 7, + "influence": 4 + }, + "Manlius": { + "code": 6, + "scenario": 1, + "military": 3, + "oratory": 2, + "loyalty": 7, + "influence": 4 + }, + "Fulvius": { + "code": 7, + "scenario": 1, + "military": 2, + "oratory": 2, + "loyalty": 8, + "influence": 4 + }, + "Furius": { + "code": 8, + "scenario": 1, + "military": 3, + "oratory": 3, + "loyalty": 8, + "influence": 3 + }, + "Aurelius": { + "code": 9, + "scenario": 1, + "military": 2, + "oratory": 3, + "loyalty": 7, + "influence": 3 + }, + "Junius": { + "code": 10, + "scenario": 1, + "military": 1, + "oratory": 2, + "loyalty": 8, + "influence": 3 + }, + "Papirius": { + "code": 11, + "scenario": 1, + "military": 1, + "oratory": 2, + "loyalty": 6, + "influence": 3 + }, + "Acilius": { + "code": 12, + "scenario": 1, + "military": 2, + "oratory": 2, + "loyalty": 7, + "influence": 3 + }, + "Flaminius": { + "code": 13, + "scenario": 1, + "military": 4, + "oratory": 2, + "loyalty": 6, + "influence": 3 + }, + "Aelius": { + "code": 14, + "scenario": 1, + "military": 3, + "oratory": 4, + "loyalty": 7, + "influence": 2 + }, + "Sulpicius": { + "code": 15, + "scenario": 1, + "military": 3, + "oratory": 2, + "loyalty": 8, + "influence": 2 + }, + "Calpurnius": { + "code": 16, + "scenario": 1, + "military": 1, + "oratory": 2, + "loyalty": 9, + "influence": 2 + }, + "Plautius": { + "code": 17, + "scenario": 1, + "military": 2, + "oratory": 1, + "loyalty": 6, + "influence": 2 + }, + "Quinctius": { + "code": 18, + "scenario": 1, + "military": 3, + "oratory": 2, + "loyalty": 6, + "influence": 1 + }, + "Aemilius": { + "code": 19, + "scenario": 1, + "military": 4, + "oratory": 2, + "loyalty": 8, + "influence": 1 + }, + "Terentius": { + "code": 20, + "scenario": 1, + "military": 2, + "oratory": 1, + "loyalty": 6, + "influence": 1 + }, + "Servilius": { + "code": 21, + "scenario": 2, + "military": 3, + "oratory": 4, + "loyalty": 9, + "influence": 4 + }, + "Porcius": { + "code": 22, + "scenario": 2, + "military": 2, + "oratory": 4, + "loyalty": 10, + "influence": 1 + }, + "Popillius": { + "code": 23, + "scenario": 2, + "military": 1, + "oratory": 3, + "loyalty": 7, + "influence": 3 + }, + "Cassius": { + "code": 24, + "scenario": 2, + "military": 3, + "oratory": 3, + "loyalty": 9, + "influence": 3 + }, + "Sempronius": { + "code": 25, + "scenario": 2, + "military": 1, + "oratory": 3, + "loyalty": 6, + "influence": 3 + }, + "Octavius": { + "code": 26, + "scenario": 3, + "military": 2, + "oratory": 3, + "loyalty": 9, + "influence": 4 + }, + "Marius": { + "code": 27, + "scenario": 3, + "military": 4, + "oratory": 2, + "loyalty": 9, + "influence": 4 + }, + "Tullius": { + "code": 28, + "scenario": 3, + "military": 2, + "oratory": 3, + "loyalty": 7, + "influence": 3 + }, + "Licinius": { + "code": 29, + "scenario": 3, + "military": 3, + "oratory": 2, + "loyalty": 9, + "influence": 3 + }, + "Pompeius": { + "code": 30, + "scenario": 3, + "military": 2, + "oratory": 2, + "loyalty": 7, + "influence": 2 + } } diff --git a/backend/rorapp/presets/statesman.json b/backend/rorapp/presets/statesman.json index 743e50d0..29dfe7f1 100644 --- a/backend/rorapp/presets/statesman.json +++ b/backend/rorapp/presets/statesman.json @@ -1,203 +1,203 @@ { - "P. Cornelius Scipio Africanus" : { - "code": "1a", - "scenario": 1, - "military": 5, - "oratory": 5, - "base_loyalty": 7, - "modified_loyalty": 0, - "loyalty_modifiers": ["22a"], - "popularity": 0, - "influence": 6 - }, - "Q. Fabius Maximus Verrucosus Cunctator" : { - "code": "2a", - "scenario": 1, - "military": 5, - "oratory": 2, - "base_loyalty": 7, - "popularity": 0, - "influence": 3 - }, - "T. Quinctius Flamininus" : { - "code": "18a", - "scenario": 1, - "military": 5, - "oratory": 4, - "base_loyalty": 7, - "modified_loyalty": 0, - "loyalty_modifiers": ["22a"], - "popularity": 0, - "influence": 4 - }, - "L. Aemilius Paullus Macedonicus" : { - "code": "19a", - "scenario": 1, - "military": 5, - "oratory": 4, - "base_loyalty": 8, - "popularity": 0, - "influence": 4 - }, - "M. Porcius Cato the Elder" : { - "code": "22a", - "scenario": 1, - "military": 1, - "oratory": 6, - "base_loyalty": 10, - "modified_loyalty": 0, - "loyalty_modifiers": ["1a", "1b", "18a"], - "popularity": 0, - "influence": 1 - }, - "P. Cornelius Scipio Aemilianus Africanus" : { - "code": "1b", - "scenario": 2, - "military": 4, - "oratory": 3, - "base_loyalty": 7, - "popularity": 0, - "influence": 5 - }, - "L. Cornelius Sulla" : { - "code": "1c", - "scenario": 2, - "military": 4, - "oratory": 4, - "base_loyalty": 5, - "modified_loyalty": 0, - "loyalty_modifiers": ["27a"], - "popularity": 0, - "influence": 5 - }, - "M. Fulvius Flaccus" : { - "code": "7a", - "scenario": 2, - "military": 2, - "oratory": 5, - "base_loyalty": 6, - "modified_loyalty": 0, - "loyalty_modifiers": ["23a"], - "popularity": 0, - "influence": 5 - }, - "C. Servilius Glaucia" : { - "code": "21a", - "scenario": 2, - "military": 1, - "oratory": 3, - "base_loyalty": 3, - "modified_loyalty": 0, - "loyalty_modifiers": ["1c"], - "popularity": 0, - "influence": 2 - }, - "P. Popillius Laenas" : { - "code": "23a", - "scenario": 2, - "military": 2, - "oratory": 5, - "base_loyalty": 6, - "modified_loyalty": 0, - "loyalty_modifiers": ["7a", "25a", "25b"], - "popularity": 0, - "influence": 4 - }, - "T. Sempronius Gracchus" : { - "code": "25a", - "scenario": 2, - "military": 1, - "oratory": 4, - "base_loyalty": 0, - "modified_loyalty": 6, - "loyalty_modifiers": ["25b"], - "popularity": 2, - "influence": 3 - }, - "C. Sempronius Gracchus" : { - "code": "25b", - "scenario": 2, - "military": 1, - "oratory": 5, - "base_loyalty": 0, - "modified_loyalty": 6, - "loyalty_modifiers": ["25a"], - "popularity": 3, - "influence": 4 - }, - "C. Marius" : { - "code": "27a", - "scenario": 2, - "military": 5, - "oratory": 3, - "base_loyalty": 6, - "modified_loyalty": 0, - "loyalty_modifiers": ["1c"], - "popularity": 0, - "influence": 5 - }, - "C. Julius Caesar" : { - "code": "4a", - "scenario": 3, - "military": 6, - "oratory": 5, - "base_loyalty": 9, - "modified_loyalty": 0, - "loyalty_modifiers": ["22b"], - "popularity": 2, - "influence": 5 - }, - "M. Porcius Cato the Younger" : { - "code": "22b", - "scenario": 3, - "military": 1, - "oratory": 6, - "base_loyalty": 11, - "modified_loyalty": 0, - "loyalty_modifiers": ["4a"], - "popularity": 0, - "influence": 4 - }, - "M. Tullius Cicero" : { - "code": "28a", - "scenario": 3, - "military": 1, - "oratory": 6, - "base_loyalty": 10, - "popularity": 1, - "influence": 3 - }, - "M. Licinius Crassus" : { - "code": "29a", - "scenario": 3, - "military": 2, - "oratory": 2, - "base_loyalty": 4, - "modified_loyalty": 0, - "loyalty_modifiers": ["30a"], - "popularity": 0, - "influence": 5 - }, - "L. Licinius Lucullus" : { - "code": "29b", - "scenario": 3, - "military": 5, - "oratory": 3, - "base_loyalty": 10, - "modified_loyalty": 0, - "loyalty_modifiers": ["30a"], - "popularity": 0, - "influence": 3 - }, - "Cn. Pompeius Magnus" : { - "code": "30a", - "scenario": 3, - "military": "d6+1", - "oratory": 3, - "base_loyalty": 9, - "modified_loyalty": 0, - "loyalty_modifiers": ["29b"], - "popularity": 5, - "influence": 5 - } + "P. Cornelius Scipio Africanus": { + "code": "1a", + "scenario": 1, + "military": 5, + "oratory": 5, + "base_loyalty": 7, + "modified_loyalty": 0, + "loyalty_modifiers": ["22a"], + "popularity": 0, + "influence": 6 + }, + "Q. Fabius Maximus Verrucosus Cunctator": { + "code": "2a", + "scenario": 1, + "military": 5, + "oratory": 2, + "base_loyalty": 7, + "popularity": 0, + "influence": 3 + }, + "T. Quinctius Flamininus": { + "code": "18a", + "scenario": 1, + "military": 5, + "oratory": 4, + "base_loyalty": 7, + "modified_loyalty": 0, + "loyalty_modifiers": ["22a"], + "popularity": 0, + "influence": 4 + }, + "L. Aemilius Paullus Macedonicus": { + "code": "19a", + "scenario": 1, + "military": 5, + "oratory": 4, + "base_loyalty": 8, + "popularity": 0, + "influence": 4 + }, + "M. Porcius Cato the Elder": { + "code": "22a", + "scenario": 1, + "military": 1, + "oratory": 6, + "base_loyalty": 10, + "modified_loyalty": 0, + "loyalty_modifiers": ["1a", "1b", "18a"], + "popularity": 0, + "influence": 1 + }, + "P. Cornelius Scipio Aemilianus Africanus": { + "code": "1b", + "scenario": 2, + "military": 4, + "oratory": 3, + "base_loyalty": 7, + "popularity": 0, + "influence": 5 + }, + "L. Cornelius Sulla": { + "code": "1c", + "scenario": 2, + "military": 4, + "oratory": 4, + "base_loyalty": 5, + "modified_loyalty": 0, + "loyalty_modifiers": ["27a"], + "popularity": 0, + "influence": 5 + }, + "M. Fulvius Flaccus": { + "code": "7a", + "scenario": 2, + "military": 2, + "oratory": 5, + "base_loyalty": 6, + "modified_loyalty": 0, + "loyalty_modifiers": ["23a"], + "popularity": 0, + "influence": 5 + }, + "C. Servilius Glaucia": { + "code": "21a", + "scenario": 2, + "military": 1, + "oratory": 3, + "base_loyalty": 3, + "modified_loyalty": 0, + "loyalty_modifiers": ["1c"], + "popularity": 0, + "influence": 2 + }, + "P. Popillius Laenas": { + "code": "23a", + "scenario": 2, + "military": 2, + "oratory": 5, + "base_loyalty": 6, + "modified_loyalty": 0, + "loyalty_modifiers": ["7a", "25a", "25b"], + "popularity": 0, + "influence": 4 + }, + "T. Sempronius Gracchus": { + "code": "25a", + "scenario": 2, + "military": 1, + "oratory": 4, + "base_loyalty": 0, + "modified_loyalty": 6, + "loyalty_modifiers": ["25b"], + "popularity": 2, + "influence": 3 + }, + "C. Sempronius Gracchus": { + "code": "25b", + "scenario": 2, + "military": 1, + "oratory": 5, + "base_loyalty": 0, + "modified_loyalty": 6, + "loyalty_modifiers": ["25a"], + "popularity": 3, + "influence": 4 + }, + "C. Marius": { + "code": "27a", + "scenario": 2, + "military": 5, + "oratory": 3, + "base_loyalty": 6, + "modified_loyalty": 0, + "loyalty_modifiers": ["1c"], + "popularity": 0, + "influence": 5 + }, + "C. Julius Caesar": { + "code": "4a", + "scenario": 3, + "military": 6, + "oratory": 5, + "base_loyalty": 9, + "modified_loyalty": 0, + "loyalty_modifiers": ["22b"], + "popularity": 2, + "influence": 5 + }, + "M. Porcius Cato the Younger": { + "code": "22b", + "scenario": 3, + "military": 1, + "oratory": 6, + "base_loyalty": 11, + "modified_loyalty": 0, + "loyalty_modifiers": ["4a"], + "popularity": 0, + "influence": 4 + }, + "M. Tullius Cicero": { + "code": "28a", + "scenario": 3, + "military": 1, + "oratory": 6, + "base_loyalty": 10, + "popularity": 1, + "influence": 3 + }, + "M. Licinius Crassus": { + "code": "29a", + "scenario": 3, + "military": 2, + "oratory": 2, + "base_loyalty": 4, + "modified_loyalty": 0, + "loyalty_modifiers": ["30a"], + "popularity": 0, + "influence": 5 + }, + "L. Licinius Lucullus": { + "code": "29b", + "scenario": 3, + "military": 5, + "oratory": 3, + "base_loyalty": 10, + "modified_loyalty": 0, + "loyalty_modifiers": ["30a"], + "popularity": 0, + "influence": 3 + }, + "Cn. Pompeius Magnus": { + "code": "30a", + "scenario": 3, + "military": "d6+1", + "oratory": 3, + "base_loyalty": 9, + "modified_loyalty": 0, + "loyalty_modifiers": ["29b"], + "popularity": 5, + "influence": 5 + } } diff --git a/backend/rorapp/templates/index.html b/backend/rorapp/templates/index.html index 05db729b..43be3cf5 100644 --- a/backend/rorapp/templates/index.html +++ b/backend/rorapp/templates/index.html @@ -1,5 +1,9 @@

Republic of Rome Online Backend

diff --git a/frontend/classes/Collection.ts b/frontend/classes/Collection.ts index 50abf07c..1af14b17 100644 --- a/frontend/classes/Collection.ts +++ b/frontend/classes/Collection.ts @@ -12,8 +12,8 @@ class Collection { this.allIds = [] for (let instance of instances) { - this.byId[instance.id] = instance; - this.allIds.push(instance.id); + this.byId[instance.id] = instance + this.allIds.push(instance.id) } } @@ -29,14 +29,14 @@ class Collection { remove(id: number) { // Perform the mutation delete this.byId[id] - this.allIds = this.allIds.filter(instanceId => instanceId !== id) + this.allIds = this.allIds.filter((instanceId) => instanceId !== id) // Return new collection to force re-render return new Collection(this.asArray) } get asArray(): T[] { - return this.allIds.map(id => this.byId[id]) + return this.allIds.map((id) => this.byId[id]) } } diff --git a/frontend/classes/Faction.ts b/frontend/classes/Faction.ts index ad61b7e2..6bef0d7d 100644 --- a/frontend/classes/Faction.ts +++ b/frontend/classes/Faction.ts @@ -3,10 +3,10 @@ import Colors from "@/data/colors.json" export type FactionPosition = 1 | 2 | 3 | 4 | 5 | 6 interface FactionData { - id: number, - game: number, - position: FactionPosition, - player: number, + id: number + game: number + position: FactionPosition + player: number rank: number | null } @@ -24,7 +24,7 @@ class Faction { this.player = data.player this.rank = data.rank } - + // Get the faction's color hex code getColor = (type: "primary" | "bg" | "bgHover" | "textBg" = "primary") => { return Colors.aligned[type][this.position] diff --git a/frontend/classes/Game.ts b/frontend/classes/Game.ts index c9b3642b..05f6544e 100644 --- a/frontend/classes/Game.ts +++ b/frontend/classes/Game.ts @@ -21,7 +21,7 @@ class Game { constructor(data: GameData) { this.id = data.id this.name = data.name - this.host = deserializeToInstance(User, data.host) // Expects user to be preloaded with game player + this.host = deserializeToInstance(User, data.host) // Expects user to be preloaded with game player this.description = data.description this.creation_date = new Date(data.creation_date) this.start_date = data.start_date ? new Date(data.start_date) : null diff --git a/frontend/classes/Player.ts b/frontend/classes/Player.ts index b5540357..0a01af17 100644 --- a/frontend/classes/Player.ts +++ b/frontend/classes/Player.ts @@ -16,7 +16,7 @@ class Player { constructor(data: PlayerData) { this.id = data.id - this.user = deserializeToInstance(User, data.user) // Expects user to be preloaded with game player + this.user = deserializeToInstance(User, data.user) // Expects user to be preloaded with game player this.game = data.game this.joinDate = new Date(data.join_date) } diff --git a/frontend/classes/Senator.ts b/frontend/classes/Senator.ts index 7a30e945..012435a4 100644 --- a/frontend/classes/Senator.ts +++ b/frontend/classes/Senator.ts @@ -1,21 +1,21 @@ import numberToRoman from "@/functions/romanNumerals" interface SenatorData { - id: number, - name: string, - game: number, - faction: number, - alive: boolean, - code: number, - generation: number, - rank: number | null, - military: number, - oratory: number, - loyalty: number, - influence: number, - popularity: number, - knights: number, - talents: number, + id: number + name: string + game: number + faction: number + alive: boolean + code: number + generation: number + rank: number | null + military: number + oratory: number + loyalty: number + influence: number + popularity: number + knights: number + talents: number votes: number } @@ -59,7 +59,10 @@ class Senator { } get displayName() { - return this.name + (this.generation > 1 ? " " + numberToRoman(this.generation) : "") + return ( + this.name + + (this.generation > 1 ? " " + numberToRoman(this.generation) : "") + ) } } diff --git a/frontend/components/Breadcrumb.tsx b/frontend/components/Breadcrumb.tsx index 861ec584..5c26cbca 100644 --- a/frontend/components/Breadcrumb.tsx +++ b/frontend/components/Breadcrumb.tsx @@ -1,4 +1,4 @@ -import Link from 'next/link' +import Link from "next/link" import MuiLink from "@mui/material/Link" import { useRouter } from "next/router" import styles from "./Breadcrumb.module.css" @@ -10,25 +10,24 @@ export interface CustomItem { text: string } -const Breadcrumb = ({customItems}: {customItems?: CustomItem[]}) => { +const Breadcrumb = ({ customItems }: { customItems?: CustomItem[] }) => { const router = useRouter() - + const path: string = router.pathname - let routes = [''] - if (path != '/') { - routes = path.split('/') + let routes = [""] + if (path != "/") { + routes = path.split("/") } - routes[0] = ('home') - + routes[0] = "home" + return ( - ) + ) } -export default Breadcrumb \ No newline at end of file +export default Breadcrumb diff --git a/frontend/components/ElapsedTime.tsx b/frontend/components/ElapsedTime.tsx index 5121757e..1b6864c9 100644 --- a/frontend/components/ElapsedTime.tsx +++ b/frontend/components/ElapsedTime.tsx @@ -1,36 +1,32 @@ -import { useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react" -const ElapsedTime = ({ resetKey }: {resetKey: number}) => { - const [seconds, setSeconds] = useState(0); - const intervalRef = useRef(null); +const ElapsedTime = ({ resetKey }: { resetKey: number }) => { + const [seconds, setSeconds] = useState(0) + const intervalRef = useRef(null) useEffect(() => { - if (intervalRef.current) { - clearInterval(intervalRef.current); + clearInterval(intervalRef.current) } - - setSeconds(0); - intervalRef.current = setInterval(() => { - setSeconds((prevSeconds) => prevSeconds + 1); - }, 1000); - }, [resetKey]); + setSeconds(0) + intervalRef.current = setInterval(() => { + setSeconds((prevSeconds) => prevSeconds + 1) + }, 1000) + }, [resetKey]) - let formattedTime; + let formattedTime if (seconds === 0) { - formattedTime = "now"; + formattedTime = "now" } else if (seconds < 60) { - formattedTime = `${seconds}s ago`; + formattedTime = `${seconds}s ago` } else if (seconds < 3600) { - formattedTime = `${Math.floor(seconds / 60)}m ago`; + formattedTime = `${Math.floor(seconds / 60)}m ago` } else { - formattedTime = `${Math.floor(seconds / 3600)}h ago`; + formattedTime = `${Math.floor(seconds / 3600)}h ago` } - return ( - {formattedTime} - ) + return {formattedTime} } -export default ElapsedTime; +export default ElapsedTime diff --git a/frontend/components/ExternalLink.tsx b/frontend/components/ExternalLink.tsx index 4fc558df..b82d2494 100644 --- a/frontend/components/ExternalLink.tsx +++ b/frontend/components/ExternalLink.tsx @@ -1,12 +1,12 @@ -import { ReactNode } from "react"; -import Link from "@mui/material/Link"; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faExternalLink } from '@fortawesome/free-solid-svg-icons' +import { ReactNode } from "react" +import Link from "@mui/material/Link" +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" +import { faExternalLink } from "@fortawesome/free-solid-svg-icons" interface LinkProps { - href: string; - children: ReactNode; - attributes?: React.HTMLAttributes; + href: string + children: ReactNode + attributes?: React.HTMLAttributes } /** @@ -14,11 +14,21 @@ interface LinkProps { */ const ExternalLink = (props: LinkProps) => { return ( - + {props.children} - + ) } -export default ExternalLink; +export default ExternalLink diff --git a/frontend/components/FactionIcon.tsx b/frontend/components/FactionIcon.tsx index 066fcad3..f6b24df6 100644 --- a/frontend/components/FactionIcon.tsx +++ b/frontend/components/FactionIcon.tsx @@ -1,5 +1,5 @@ import styles from "./FactionIcon.module.css" -import Faction from '@/classes/Faction' +import Faction from "@/classes/Faction" import SelectedDetail from "@/types/selectedDetail" import { useGameContext } from "@/contexts/GameContext" @@ -14,11 +14,14 @@ const FactionIcon = (props: FactionIconProps) => { const { setSelectedDetail } = useGameContext() const handleClick = () => { - if (props.faction?.id) setSelectedDetail({type: "Faction", id: props.faction.id} as SelectedDetail) + if (props.faction?.id) + setSelectedDetail({ + type: "Faction", + id: props.faction.id, + } as SelectedDetail) } - - if (props.faction && props.faction) { + if (props.faction && props.faction) { const svg = ( { viewBox="0 0 0.9 1" xmlns="http://www.w3.org/2000/svg" > - + ) const svgInsideButton = ( - ) diff --git a/frontend/components/FactionLink.tsx b/frontend/components/FactionLink.tsx index 0eba6b94..0507ecea 100644 --- a/frontend/components/FactionLink.tsx +++ b/frontend/components/FactionLink.tsx @@ -1,9 +1,9 @@ import { Link } from "@mui/material" -import { useGameContext } from '@/contexts/GameContext' +import { useGameContext } from "@/contexts/GameContext" import Faction from "@/classes/Faction" import SelectedDetail from "@/types/selectedDetail" -import FactionIcon from '@/components/FactionIcon' +import FactionIcon from "@/components/FactionIcon" interface FactionLinkProps { faction: Faction @@ -14,12 +14,23 @@ const FactionLink = (props: FactionLinkProps) => { const { setSelectedDetail } = useGameContext() const handleClick = () => { - if (props.faction) setSelectedDetail({type: "Faction", id: props.faction.id} as SelectedDetail) + if (props.faction) + setSelectedDetail({ + type: "Faction", + id: props.faction.id, + } as SelectedDetail) } return ( - - {props.includeIcon && } + + {props.includeIcon && ( + + + + )} {props.faction.getName()} Faction ) diff --git a/frontend/components/FactionList.tsx b/frontend/components/FactionList.tsx index 354c30a6..c17112a9 100644 --- a/frontend/components/FactionList.tsx +++ b/frontend/components/FactionList.tsx @@ -1,21 +1,22 @@ -import { useEffect, useState } from 'react' +import { useEffect, useState } from "react" -import Faction from '@/classes/Faction' -import FactionListItem from '@/components/FactionListItem' -import { useGameContext } from '@/contexts/GameContext' -import styles from './FactionList.module.css' -import Collection from '@/classes/Collection' +import Faction from "@/classes/Faction" +import FactionListItem from "@/components/FactionListItem" +import { useGameContext } from "@/contexts/GameContext" +import styles from "./FactionList.module.css" +import Collection from "@/classes/Collection" // List of factions const FactionList = () => { const { allFactions } = useGameContext() // State for the sorted factions - const [sortedFactions, setSortedFactions] = useState>(new Collection()) + const [sortedFactions, setSortedFactions] = useState>( + new Collection() + ) // Sort the factions useEffect(() => { - // Sort from lowest to highest rank, and non-null ranks before null ranks const factions = allFactions.asArray.sort((a, b) => { if (a.rank === null && b.rank === null) return 0 @@ -31,7 +32,11 @@ const FactionList = () => { const getRow = (faction: Faction) => { return (
-
+
@@ -41,7 +46,7 @@ const FactionList = () => { return (
- {sortedFactions.asArray.map(faction => getRow(faction))} + {sortedFactions.asArray.map((faction) => getRow(faction))}
) diff --git a/frontend/components/FactionListItem.tsx b/frontend/components/FactionListItem.tsx index f6dbff1d..c76c1f17 100644 --- a/frontend/components/FactionListItem.tsx +++ b/frontend/components/FactionListItem.tsx @@ -1,19 +1,18 @@ -import Image from 'next/image' -import Tooltip from '@mui/material/Tooltip' +import Image from "next/image" +import Tooltip from "@mui/material/Tooltip" -import SenatorPortrait from '@/components/SenatorPortrait' -import Collection from '@/classes/Collection' -import Faction from '@/classes/Faction' -import Senator from '@/classes/Senator' -import styles from './FactionListItem.module.css' -import { useGameContext } from '@/contexts/GameContext' -import FactionLink from '@/components/FactionLink' +import SenatorPortrait from "@/components/SenatorPortrait" +import Collection from "@/classes/Collection" +import Faction from "@/classes/Faction" +import Senator from "@/classes/Senator" +import styles from "./FactionListItem.module.css" +import { useGameContext } from "@/contexts/GameContext" +import FactionLink from "@/components/FactionLink" import SenatorsIcon from "@/images/icons/senators.svg" import InfluenceIcon from "@/images/icons/influence.svg" import TalentsIcon from "@/images/icons/talents.svg" import VotesIcon from "@/images/icons/votes.svg" - type Attribute = { name: "senators" | "influence" | "votes" | "talents" value: Number @@ -32,30 +31,60 @@ const FactionListItem = (props: FactionListItemProps) => { // Get faction-specific data const player = allPlayers.byId[props.faction.player] ?? null const senators = new Collection( - allSenators.asArray.filter(s => s.faction === props.faction.id).sort((a, b) => a.name.localeCompare(b.name)) ?? [] + allSenators.asArray + .filter((s) => s.faction === props.faction.id) + .sort((a, b) => a.name.localeCompare(b.name)) ?? [] ) const senatorsCount = senators.allIds.length - const totalInfluence = senators.asArray.reduce((total, senator) => total + senator.influence, 0) - const totalTalents = senators.asArray.reduce((total, senator) => total + senator.talents, 0) - const totalVotes = senators.asArray.reduce((total, senator) => total + senator.votes, 0) + const totalInfluence = senators.asArray.reduce( + (total, senator) => total + senator.influence, + 0 + ) + const totalTalents = senators.asArray.reduce( + (total, senator) => total + senator.talents, + 0 + ) + const totalVotes = senators.asArray.reduce( + (total, senator) => total + senator.votes, + 0 + ) // Attribute data const attributeItems: Attribute[] = [ - { name: 'senators', value: senatorsCount, image: SenatorsIcon }, - { name: 'influence', value: totalInfluence, image: InfluenceIcon, sum: true }, - { name: 'talents', value: totalTalents, image: TalentsIcon, sum: true }, - { name: 'votes', value: totalVotes, image: VotesIcon, sum: true } + { name: "senators", value: senatorsCount, image: SenatorsIcon }, + { + name: "influence", + value: totalInfluence, + image: InfluenceIcon, + sum: true, + }, + { name: "talents", value: totalTalents, image: TalentsIcon, sum: true }, + { name: "votes", value: totalVotes, image: VotesIcon, sum: true }, ] // Get attribute items const getAttributeItem = (item: Attribute) => { const titleCaseName = item.name[0].toUpperCase() + item.name.slice(1) return ( - -
+ +
{item.sum && Σ} - {`${titleCaseName} + {`${titleCaseName}
{item.value.toString()}
@@ -68,18 +97,27 @@ const FactionListItem = (props: FactionListItemProps) => { return (

- of {player.user.username} + + + {" "} + of {player.user.username}

- {attributeItems.map(item => getAttributeItem(item))} + {attributeItems.map((item) => getAttributeItem(item))}
- {senators.asArray.map((senator: Senator) => - - )} + {senators.asArray.map((senator: Senator) => ( + + ))}
) } -export default FactionListItem \ No newline at end of file +export default FactionListItem diff --git a/frontend/components/Footer.tsx b/frontend/components/Footer.tsx index 6ef973fc..2012f0fd 100644 --- a/frontend/components/Footer.tsx +++ b/frontend/components/Footer.tsx @@ -1,11 +1,12 @@ -import styles from './Footer.module.css'; +import styles from "./Footer.module.css" const Footer = () => { return ( -