Skip to content

Commit

Permalink
[MIRROR] Updates the Mafia UI [MDB IGNORE] (#25214)
Browse files Browse the repository at this point in the history
* Updates the Mafia UI (#79856)

## About The Pull Request

The player currently on the stand has a yellow color behind their name.
Players who have had their roles revealed now has that stated in the
player list
Votes no longer show up to people who are on trial

![image](https://github.com/tgstation/tgstation/assets/53777086/7b3b6128-4aa0-4a83-b7f6-54c9e9cde4d9)

Minor edit: It no longer says 'ON STAND', it instead has their name in
yellow background

![image](https://github.com/tgstation/tgstation/assets/53777086/d149a881-04ab-4a75-91e1-1e5f53dd1c7f)

## Why It's Good For The Game

Mafia UI's a little better now.

## Changelog

:cl:
qol: Mafia panel no longer shows vote buttons if you're on stand, shows
the roles of revealed players, and list out who is on the stand, if any.
/:cl:

---------

Co-authored-by: Jeremiah <42397676+jlsnow301@ users.noreply.github.com>

* Updates the Mafia UI

---------

Co-authored-by: John Willard <[email protected]>
Co-authored-by: Jeremiah <42397676+jlsnow301@ users.noreply.github.com>
  • Loading branch information
3 people authored and FFMirrorBot committed Nov 23, 2023
1 parent 8cd0026 commit 71ff870
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
7 changes: 7 additions & 0 deletions code/modules/mafia/controller_ui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
if(turn)
data["turn"] = " - Day [turn]"

if(phase == MAFIA_PHASE_JUDGEMENT)
data["person_voted_up_ref"] = REF(on_trial)
if(phase == MAFIA_PHASE_SETUP)
data["lobbydata"] = list()
for(var/key in GLOB.mafia_signup + GLOB.mafia_bad_signup + GLOB.pda_mafia_signup)
Expand All @@ -41,8 +43,10 @@
data["timeleft"] = next_phase_timer ? timeleft(next_phase_timer) : 0

var/datum/mafia_role/user_role = get_role_player(user)

if(user_role)
data["user_notes"] = user_role.written_notes
data["player_voted_up"] = (user_role == on_trial)
var/list/ui_messages = list()
for(var/i = user_role.role_messages.len to 1 step -1)
ui_messages.Add(list(list(
Expand All @@ -56,6 +60,9 @@
player_info["name"] = role.body.real_name
player_info["ref"] = REF(role)
player_info["alive"] = role.game_status == MAFIA_ALIVE
player_info["role_revealed"] = FALSE
if(role.role_flags & ROLE_REVEALED)
player_info["role_revealed"] = role.name
player_info["possible_actions"] = list()

if(user_role) //not observer
Expand Down
32 changes: 22 additions & 10 deletions tgui/packages/tgui/interfaces/MafiaPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type RoleInfo = {

type PlayerInfo = {
name: string;
role_revealed: string;
is_you: BooleanLike;
ref: string;
alive: string;
Expand Down Expand Up @@ -49,11 +50,13 @@ type MafiaData = {
is_observer: boolean;
all_roles: string[];
admin_controls: boolean;
person_voted_up_ref: string;
player_voted_up: BooleanLike;
};

export const MafiaPanelData = (props, context) => {
const { act, data } = useBackend<MafiaData>(context);
const { phase, roleinfo, admin_controls, messages } = data;
const { phase, roleinfo, admin_controls, messages, player_voted_up } = data;
const [mafia_tab, setMafiaMode] = useLocalState(
context,
'mafia_tab',
Expand Down Expand Up @@ -90,7 +93,7 @@ export const MafiaPanelData = (props, context) => {
<Stack.Item>
<MafiaRole />
</Stack.Item>
{phase === 'Judgment' && (
{phase === 'Judgment' && !player_voted_up && (
<Stack.Item>
<MafiaJudgement />
</Stack.Item>
Expand Down Expand Up @@ -401,17 +404,20 @@ const MafiaJudgement = (props, context) => {
const { act, data } = useBackend(context);
return (
<Section title="Judgement">
<Flex justify="space-around">
<Flex>
<Button
icon="smile-beam"
content="INNOCENT!"
content="Innocent"
color="good"
onClick={() => act('vote_innocent')}
/>
<Box>It is now time to vote, vote the accused innocent or guilty!</Box>
<Button icon="angry" color="bad" onClick={() => act('vote_guilty')}>
GUILTY!
</Button>
<Button
icon="angry"
content="Guilty"
color="bad"
onClick={() => act('vote_guilty')}
/>
</Flex>
<Flex justify="center">
<Button icon="meh" color="white" onClick={() => act('vote_abstain')}>
Expand All @@ -424,16 +430,22 @@ const MafiaJudgement = (props, context) => {

const MafiaPlayers = (props, context) => {
const { act, data } = useBackend<MafiaData>(context);
const { players } = data;
const { players = [], person_voted_up_ref } = data;
return (
<Section fill scrollable title="Players">
<Flex direction="column" fill justify="space-around">
{players?.map((player) => (
<Flex.Item className="Section__title candystripe" key={player.ref}>
<Stack align="center">
<Stack.Item grow color={!player.alive && 'red'}>
<Stack.Item
grow
color={!player.alive && 'red'}
backgroundColor={
player.ref === person_voted_up_ref ? 'yellow' : null
}>
{player.name}
{player.is_you && ' (YOU)'} {!player.alive && '(DEAD)'}
{(!!player.is_you && ' (YOU)') ||
(!!player.role_revealed && ' - ' + player.role_revealed)}
</Stack.Item>
<Stack.Item>
{player.votes !== undefined &&
Expand Down

0 comments on commit 71ff870

Please sign in to comment.