From 54709a217b0891cb2000fcd37f4d61c43a9c7935 Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+AnArgonianLizardThatStealsPRs@users.noreply.github.com> Date: Sun, 12 Nov 2023 23:35:22 +0300 Subject: [PATCH] [MIRROR] Mafia panel fixes [MDB IGNORE] (#567) * Mafia panel fixes (#79573) --------- Co-authored-by: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> --- code/__HELPERS/_lists.dm | 2 +- code/modules/mafia/controller.dm | 1 + code/modules/mafia/controller_ui.dm | 3 ++- code/modules/mafia/roles/neutral/neutral_chaos.dm | 14 ++++++++++---- tgui/packages/tgui/interfaces/MafiaPanel.tsx | 6 ++++-- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 4ab974dd4a8..918428daf77 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -900,7 +900,7 @@ ///Gets the total amount of everything in the associative list. /proc/assoc_value_sum(list/input) - var/list/keys = list() + var/keys = 0 for(var/key in input) keys += input[key] return keys diff --git a/code/modules/mafia/controller.dm b/code/modules/mafia/controller.dm index a6e1e3c5f7f..007e0b5e456 100644 --- a/code/modules/mafia/controller.dm +++ b/code/modules/mafia/controller.dm @@ -196,6 +196,7 @@ GLOBAL_LIST_INIT(mafia_role_by_alignment, setup_mafia_role_by_alignment()) for(var/datum/mafia_role/roles as anything in all_roles) var/obj/item/modular_computer/modpc = roles.player_pda if(!modpc) + update_static_data(roles.body) continue modpc.update_static_data_for_all_viewers() diff --git a/code/modules/mafia/controller_ui.dm b/code/modules/mafia/controller_ui.dm index 9caa25d9f74..cc901392d22 100644 --- a/code/modules/mafia/controller_ui.dm +++ b/code/modules/mafia/controller_ui.dm @@ -2,7 +2,7 @@ /datum/mafia_controller/ui_static_data(atom/user) var/list/data = list() - if(usr.client?.holder) + if(usr?.client?.holder) data["admin_controls"] = TRUE //show admin buttons to start/setup/stop data["is_observer"] = isobserver(user) data["all_roles"] = current_setup_text @@ -59,6 +59,7 @@ player_info["possible_actions"] = list() if(user_role) //not observer + player_info["is_you"] = (role.body.real_name == user_role.body.real_name) for(var/datum/mafia_ability/action as anything in user_role.role_unique_actions) if(action.validate_action_target(src, potential_target = role, silent = TRUE)) player_info["possible_actions"] += list(list("name" = action, "ref" = REF(action))) diff --git a/code/modules/mafia/roles/neutral/neutral_chaos.dm b/code/modules/mafia/roles/neutral/neutral_chaos.dm index e4bd5ca0f17..de2c7fc4833 100644 --- a/code/modules/mafia/roles/neutral/neutral_chaos.dm +++ b/code/modules/mafia/roles/neutral/neutral_chaos.dm @@ -1,6 +1,6 @@ /datum/mafia_role/obsessed name = "Obsessed" - desc = "You're completely lost in your own mind. You win by lynching your obsession before you get killed in this mess. Obsession assigned on the first night!" + desc = "Lynch your obsession before you get killed at all costs!" win_condition = "lynch their obsession." revealed_outfit = /datum/outfit/mafia/obsessed team = MAFIA_TEAM_SOLO @@ -15,20 +15,26 @@ /datum/mafia_role/obsessed/New(datum/mafia_controller/game) //note: obsession is always a townie . = ..() + desc = initial(desc) + " Obsessions are assigned on the first night." RegisterSignal(game, COMSIG_MAFIA_SUNDOWN, PROC_REF(find_obsession)) /datum/mafia_role/obsessed/proc/find_obsession(datum/mafia_controller/game) SIGNAL_HANDLER - var/list/all_roles_shuffle = shuffle(game.living_roles) + var/list/all_roles_shuffle = shuffle(game.living_roles) - src for(var/datum/mafia_role/possible as anything in all_roles_shuffle) if(possible.team == MAFIA_TEAM_TOWN) obsession = possible break if(!obsession) obsession = pick(all_roles_shuffle) //okay no town just pick anyone here - //if you still don't have an obsession you're playing a single player game like i can't help your dumb ass - to_chat(body, span_userdanger("Your obsession is [obsession.body.real_name]! Get them lynched to win!")) + desc = initial(desc) + " Target: [obsession.body.real_name]" + var/obj/item/modular_computer/modpc = player_pda + if(modpc) + modpc.update_static_data_for_all_viewers() + else + game.update_static_data(body) + send_message_to_player(span_userdanger("Your obsession is [obsession.body.real_name]! Get them lynched to win!")) RegisterSignal(obsession, COMSIG_MAFIA_ON_KILL, PROC_REF(check_victory)) UnregisterSignal(game, COMSIG_MAFIA_SUNDOWN) diff --git a/tgui/packages/tgui/interfaces/MafiaPanel.tsx b/tgui/packages/tgui/interfaces/MafiaPanel.tsx index 528f6260b8d..ee63d105dd1 100644 --- a/tgui/packages/tgui/interfaces/MafiaPanel.tsx +++ b/tgui/packages/tgui/interfaces/MafiaPanel.tsx @@ -1,4 +1,4 @@ -import { classes } from 'common/react'; +import { BooleanLike, classes } from 'common/react'; import { decodeHtmlEntities } from 'common/string'; import { multiline } from 'common/string'; import { useBackend, useLocalState } from '../backend'; @@ -16,6 +16,7 @@ type RoleInfo = { type PlayerInfo = { name: string; + is_you: BooleanLike; ref: string; alive: string; possible_actions: ActionInfo[]; @@ -431,7 +432,8 @@ const MafiaPlayers = (props, context) => { - {player.name} {!player.alive && '(DEAD)'} + {player.name} + {player.is_you && ' (YOU)'} {!player.alive && '(DEAD)'} {player.votes !== undefined &&