From 07319f86a6e9da08f323d179074951880f1064d9 Mon Sep 17 00:00:00 2001 From: Logan Davidson Date: Mon, 8 Jul 2024 21:03:51 +0100 Subject: [PATCH] Disallow land commissioner concession assignment Disallow assignment of the land commissioner concession because it shouldn't be possible unless a land bill is in effect, and there are no land bills in the game yet. --- .../functions/revolution_phase_helper.py | 7 +++- .../actionDialogs/AssignConcessionsDialog.tsx | 35 ++++++++----------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/backend/rorapp/functions/revolution_phase_helper.py b/backend/rorapp/functions/revolution_phase_helper.py index fcc351bd..754db8fa 100644 --- a/backend/rorapp/functions/revolution_phase_helper.py +++ b/backend/rorapp/functions/revolution_phase_helper.py @@ -27,12 +27,17 @@ def generate_assign_concessions_action(faction: Faction) -> List[dict]: else: senators = Senator.objects.filter(faction=faction, alive=True) senator_id_list = [senator.id for senator in senators] + concession_secrets = faction_secrets.filter(type="concession").exclude(name="Land Commissioner") + concession_secret_id_list = [concession.id for concession in concession_secrets] action = Action( step=new_step, faction=faction, type="assign_concessions", required=True, - parameters={"senators": senator_id_list}, + parameters={ + "senators": senator_id_list, + "concession_secrets": concession_secret_id_list, + }, ) action.save() messages_to_send.append( diff --git a/frontend/components/actionDialogs/AssignConcessionsDialog.tsx b/frontend/components/actionDialogs/AssignConcessionsDialog.tsx index 4915d346..78d2a04d 100644 --- a/frontend/components/actionDialogs/AssignConcessionsDialog.tsx +++ b/frontend/components/actionDialogs/AssignConcessionsDialog.tsx @@ -20,6 +20,7 @@ import Senator from "@/classes/Senator" import Secret from "@/classes/Secret" import SenatorSelectInput from "@/components/SenatorSelectInput" import TermLink from "@/components/TermLink" +import { set } from "lodash" interface AssignConcessionsDialogProps { onClose: () => void @@ -54,27 +55,19 @@ const AssignConcessionsDialog = ({ if (requiredAction) setRequiredAction(requiredAction) }, [actions]) - // Set concession secrets - useEffect(() => { - if (game && requiredAction) { - const secrets = allSecrets.asArray.filter( - (secret) => - secret.faction === requiredAction.faction && - secret.type === "concession" - ) - setConcessionSecrets(secrets) - } - }, [game, requiredAction, allSecrets]) - - // Set senators + // Set senators and concession secrets useEffect(() => { if (requiredAction) { const senators = allSenators.asArray.filter((senator) => requiredAction?.parameters["senators"].includes(senator.id) ) setSenators(new Collection(senators)) + const secrets = allSecrets.asArray.filter((secret) => + requiredAction?.parameters["concession_secrets"].includes(secret.id) + ) + setConcessionSecrets(secrets) } - }, [requiredAction, allSenators]) + }, [requiredAction, allSenators, allSecrets]) // Set concession senator map useEffect(() => { @@ -131,8 +124,8 @@ const AssignConcessionsDialog = ({

Each of your Concession Secrets may be revealed to assign the respective Concession to a chosen Senator in your Faction. - Unassigned Concession Secrets will remain hidden in your Faction's - possession. + Unassigned Concession Secrets will remain hidden in your + Faction's possession.

{" "} @@ -167,15 +160,15 @@ const AssignConcessionsDialog = ({ ) : ( <>

- Your has no Concession to - assign at the moment. + Your has no Concession{" "} + to assign at the moment.

- Since your Faction has at least one Secret, other players won't be able to determine - whether you have no Concession Secrets or if you've chosen not - to assign any. + Since your Faction has at least one Secret, other players + won't be able to determine whether you have no Concession + Secrets or if you've chosen not to assign any.