diff --git a/backend/rorapp/functions/face_mortality.py b/backend/rorapp/functions/face_mortality.py index 8a74ce5a..450d79d4 100644 --- a/backend/rorapp/functions/face_mortality.py +++ b/backend/rorapp/functions/face_mortality.py @@ -123,7 +123,7 @@ def face_mortality(game, faction, potential_action, step): } }) - # Create a action_log and action_log relations + # Create an action_log and action_log relations new_action_log_index = ActionLog.objects.filter(step__phase__turn__game=game).order_by('-index')[0].index + 1 action_log = ActionLog( index=new_action_log_index, @@ -161,6 +161,23 @@ def face_mortality(game, faction, potential_action, step): "data": SenatorActionLogSerializer(heir_senator_action_log).data } }) + + # If nobody dies, issue a notification to say so + else: + new_action_log_index = ActionLog.objects.filter(step__phase__turn__game=game).order_by('-index')[0].index + 1 + action_log = ActionLog( + index=new_action_log_index, + step=step, + type="face_mortality" + ) + action_log.save() + messages_to_send.append({ + "operation": "create", + "instance": { + "class": "action_log", + "data": ActionLogSerializer(action_log).data + } + }) # Update senator ranks messages_to_send.extend(rank_senators_and_factions(game.id)) diff --git a/frontend/components/actionLogs/ActionLog_FaceMortality.tsx b/frontend/components/actionLogs/ActionLog_FaceMortality.tsx index dede2473..6a5abc08 100644 --- a/frontend/components/actionLogs/ActionLog_FaceMortality.tsx +++ b/frontend/components/actionLogs/ActionLog_FaceMortality.tsx @@ -20,9 +20,9 @@ const FaceMortalityNotification = ({ notification, senatorDetails } : Notificati // Get notification-specific data const faction: Faction | null = notification.faction ? allFactions.byId[notification.faction] ?? null : null - const senator: Senator | null = notification.data.senator ? allSenators.byId[notification.data.senator] ?? null : null - const heir: Senator | null = notification.data.senator ? allSenators.byId[notification.data.heir_senator] ?? null : null - const majorOfficeName: string = notification.data.major_office + const senator: Senator | null = notification.data?.senator ? allSenators.byId[notification.data.senator] ?? null : null + const heir: Senator | null = notification.data?.senator ? allSenators.byId[notification.data.heir_senator] ?? null : null + const majorOfficeName: string = notification.data?.major_office ?? null const getIcon = () => (
@@ -32,28 +32,28 @@ const FaceMortalityNotification = ({ notification, senatorDetails } : Notificati // Get the text for the notification (tense sensitive) const getText = () => { - if (!faction || !senator) return null + if (!senator) { + return

All senators have survived the Mortality Phase.

+ } return (

{majorOfficeName || heir ? The : null} {majorOfficeName && {majorOfficeName}} {majorOfficeName && heir ? and : null} - {heir && Leader} + {heir && faction && Leader} {majorOfficeName || heir ? , : null} - {!heir && of the } + {!heir && faction && of the } {!senatorDetails && "has"} passed away. {heir && His heir {!senatorDetails && "has"} replaced him as Faction Leader.}

) } - if (!faction || !senator) return null - return ( - - Mortality + + {!senator && "No "}Mortality {getText()} )