Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow land commissioner concession assignment #496

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/rorapp/functions/revolution_phase_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
35 changes: 14 additions & 21 deletions frontend/components/actionDialogs/AssignConcessionsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Senator>(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(() => {
Expand Down Expand Up @@ -131,8 +124,8 @@ const AssignConcessionsDialog = ({
<p>
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&apos;s
possession.
Unassigned Concession Secrets will remain hidden in your
Faction&apos;s possession.
</p>
<div className="py-2 flex justify-center items-center gap-1 text-purple-600 dark:text-purple-300">
<VisibilityOffIcon fontSize="small" />{" "}
Expand Down Expand Up @@ -167,15 +160,15 @@ const AssignConcessionsDialog = ({
) : (
<>
<p>
Your <TermLink name="Faction" /> has no Concession <TermLink name="Secret" plural /> to
assign at the moment.
Your <TermLink name="Faction" /> has no Concession{" "}
<TermLink name="Secret" plural /> to assign at the moment.
</p>

<p className="text-purple-600 dark:text-purple-300">
<i>
Since your Faction has at least one Secret, other players won&apos;t be able to determine
whether you have no Concession Secrets or if you&apos;ve chosen not
to assign any.
Since your Faction has at least one Secret, other players
won&apos;t be able to determine whether you have no Concession
Secrets or if you&apos;ve chosen not to assign any.
</i>
</p>
</>
Expand Down
Loading