/tg/ Station 13 - Modules - TypesVar Details - Proc Details

mafia_controller

The mafia controller handles the mafia minigame in progress. It is first created when the first ghost signs up to play.

Vars

all_rolesall roles in the game, dead or alive. check their game status if you only want living or dead.
current_maptemplate picked when the game starts. used for the name and desc reading
current_setup_textReadable list of roles in current game, sent to the tgui panel for roles list > list("Psychologist x1", "Clown x2")
custom_setupfor debugging and testing a full game, or adminbuse. If this is not empty, it will use this as a setup. clears when game is over
default_role_listThe 12 roles used in a default game, selected randomly from each list, going in order of position. This is balanced for player amount, regardless of players you'll still be about equal town and evils.
early_startwas our game forced to start early?
judgement_abstain_votesand these (judgement_innocent_votes, judgement_abstain_votes and judgement_guilty_votes) are the judgement phase votes, aka people sorting themselves into guilty and innocent, and "eh, i don't really care" lists. whichever has more inno or guilty wins!
landmarksspawn points for players, each one has a house
living_rolesall living roles in the game, removed on death.
map_deletermap generation tool that deletes the current map after the game finishes
next_phase_timercurrent timer for phase
on_trialcurrent role on trial for the judgement phase, will die if guilty is greater than innocent
phasewhat part of the game you're playing in. day phases, night phases, judgement phases, etc.
player_outfitstarting outfit for all mafia players. it's just a grey jumpsuit.
player_role_lookupexists to speed up role retrieval, it's a dict. player_role_lookup[player ckey/PDA] will give you the role they play
time_speedupHow much faster the game should be, which triggers when half the players are dead.
town_center_landmarktown center for when people get put on trial
turnhow long the game has gone on for, changes with every sunrise. day one, night one, day two, etc.
votesgroup voting on one person, like putting people to trial or choosing who to kill as mafia

Procs

add_setup_roleHelper proc that adds a random role of a type to a setup. if it doesn't exist in the setup, it adds the path to the list and otherwise bumps the path in the list up one. unique roles can only get added once.
award_roleLets the game award roles with all their checks and sanity, prevents achievements given out for debug games
basic_setupCalled when enough players have signed up to fill a setup. DOESN'T NECESSARILY MEAN THE GAME WILL START.
check_signupsFilters inactive player into a different list until they reconnect, and removes players who are no longer ghosts.
check_start_votesChecks if we have enough early start votes to begin the game early.
check_trialPlayers have voted someone up, and now the person must defend themselves while the town votes innocent or guilty.
check_victoryChecks to see if a faction (or solo antagonist) has won.
create_bodiesCalled when the game is setting up, AFTER map is loaded but BEFORE the phase timers start. Creates and places each role's body and gives the correct player key
display_votesAdds mutable appearances to people who get publicly voted on (so not night votes) showing how many people are picking them Arguments:
end_gameCleans up the game, resetting variables back to the beginning and removing the map with the generator.
filter_playersHandles the filtering of disconected signups when picking who gets to be in the round.
forced_setupGenerates a forced role list and runs the game with the current number of signed-up players.
generate_standard_setupReturns a standard setup, with certain important/unique roles guaranteed.
get_random_voterReturns a random person who voted for whatever vote (day vote, night kill vote) Arguments:
get_role_playerFrom a 'user' (Either a mob or ModPC) or TGUI UI, will try to find the Mafia role from 'player_role_lookup'.
get_vote_countReturns how many people voted for the role, in whatever vote (day vote, night kill vote) Arguments:
get_vote_winnerReturns whichever role got the most votes, in whatever vote (day vote, night kill vote) returns null if no votes Arguments:
lockdownAfter the voting and judgement phases, the game goes to night shutting the windows and beginning night with a proc.
lynchPlayers have voted innocent or guilty on the person on trial, and that person is now killed or returned home.
prepare_gameTriggers at beginning of the game when there is a confirmed list of valid, ready players. Creates a 100% ready game that has NOT started (no players in bodies) Followed by start game
reset_votesClears out the votes of a certain type (day votes, mafia kill votes) while leaving others untouched
resolve_nightThe end of the night, and a series of signals for the order of events on a night.
send_homeTeenie helper proc to move players back to their home. Used in the above, but also used in the debug button "send all players home" Arguments:
send_messageSends a global message to all players, or just 'team' if set.
signup_mafiaSigns the player up for Mafia, or removes them from the list if they are already signed up. Args:
start_dayHow every day starts.
start_gameThe game by this point is now all set up, and so we can put people in their bodies and start the first phase.
start_nightThe actual start of night for players. Mostly info is given at the start of the night as the end of the night is when votes and actions are submitted and tried.
start_the_endThe end of the game is in two procs, because we want a bit of time for players to see eachothers roles. Because of how check_victory works, the game is halted in other places by this point. We won't delete ourselves in a certain amount of time in unit tests, as the unit test will handle our deletion instead.
start_voting_phasePlayers have finished the discussion period, and now must put up someone to the chopping block.
toggle_night_curtainsShuts poddoors attached to mafia. Arguments:
try_autostartCalled when someone signs up, and sees if there are enough people in the signup list to begin.
vote_forProc that goes off when players vote for something with their mafia panel.

Var Details

all_roles

all roles in the game, dead or alive. check their game status if you only want living or dead.

current_map

template picked when the game starts. used for the name and desc reading

current_setup_text

Readable list of roles in current game, sent to the tgui panel for roles list > list("Psychologist x1", "Clown x2")

custom_setup

for debugging and testing a full game, or adminbuse. If this is not empty, it will use this as a setup. clears when game is over

default_role_list

The 12 roles used in a default game, selected randomly from each list, going in order of position. This is balanced for player amount, regardless of players you'll still be about equal town and evils.

early_start

was our game forced to start early?

judgement_abstain_votes

and these (judgement_innocent_votes, judgement_abstain_votes and judgement_guilty_votes) are the judgement phase votes, aka people sorting themselves into guilty and innocent, and "eh, i don't really care" lists. whichever has more inno or guilty wins!

landmarks

spawn points for players, each one has a house

living_roles

all living roles in the game, removed on death.

map_deleter

map generation tool that deletes the current map after the game finishes

next_phase_timer

current timer for phase

on_trial

current role on trial for the judgement phase, will die if guilty is greater than innocent

phase

what part of the game you're playing in. day phases, night phases, judgement phases, etc.

player_outfit

starting outfit for all mafia players. it's just a grey jumpsuit.

player_role_lookup

exists to speed up role retrieval, it's a dict. player_role_lookup[player ckey/PDA] will give you the role they play

time_speedup

How much faster the game should be, which triggers when half the players are dead.

town_center_landmark

town center for when people get put on trial

turn

how long the game has gone on for, changes with every sunrise. day one, night one, day two, etc.

votes

group voting on one person, like putting people to trial or choosing who to kill as mafia

Proc Details

add_setup_role

Helper proc that adds a random role of a type to a setup. if it doesn't exist in the setup, it adds the path to the list and otherwise bumps the path in the list up one. unique roles can only get added once.

award_role

Lets the game award roles with all their checks and sanity, prevents achievements given out for debug games

Arguments:

basic_setup

Called when enough players have signed up to fill a setup. DOESN'T NECESSARILY MEAN THE GAME WILL START.

Checks for a custom setup, if so gets the required players from that and if not it sets the player requirement to MAFIA_MAX_PLAYER_COUNT and generates one IF basic setup starts a game. Checks if everyone signed up is an observer, and is still connected. If people aren't, they're removed from the list. If there aren't enough players post sanity, it aborts. otherwise, it selects enough people for the game and starts preparing the game for real.

check_signups

Filters inactive player into a different list until they reconnect, and removes players who are no longer ghosts.

If a disconnected player gets a non-ghost mob and reconnects, they will be first put back into mafia_signup then filtered by that.

check_start_votes

Checks if we have enough early start votes to begin the game early.

Checks if we have the bare minimum of three signups, then checks if the number of early voters is at least half of the total number of active signups.

check_trial

Players have voted someone up, and now the person must defend themselves while the town votes innocent or guilty.

What players do in this phase:

check_victory

Checks to see if a faction (or solo antagonist) has won.

Calculates in this order:

create_bodies

Called when the game is setting up, AFTER map is loaded but BEFORE the phase timers start. Creates and places each role's body and gives the correct player key

Notably:

display_votes

Adds mutable appearances to people who get publicly voted on (so not night votes) showing how many people are picking them Arguments:

end_game

Cleans up the game, resetting variables back to the beginning and removing the map with the generator.

filter_players

Handles the filtering of disconected signups when picking who gets to be in the round.

Filters out the player list, from a given max_players count. If more players are found in the signup list than max_players, those players will be notified that they will not be put into the game.

This should only be run as we are in the process of starting a game.

max_players - The maximum number of keys to put in our return list before we start telling people they're not getting in. filtered_keys_and_pdas - A list of player ckeys and PDAs, to be included in the game.

forced_setup

Generates a forced role list and runs the game with the current number of signed-up players.

Generates a randomized setup, and begins the game with everyone currently signed up.

generate_standard_setup

Returns a standard setup, with certain important/unique roles guaranteed.

please check the variables at the top of the proc to see how much of each role types it picks Args: req_players - The amount of players needed.

get_random_voter

Returns a random person who voted for whatever vote (day vote, night kill vote) Arguments:

get_role_player

From a 'user' (Either a mob or ModPC) or TGUI UI, will try to find the Mafia role from 'player_role_lookup'.

get_vote_count

Returns how many people voted for the role, in whatever vote (day vote, night kill vote) Arguments:

get_vote_winner

Returns whichever role got the most votes, in whatever vote (day vote, night kill vote) returns null if no votes Arguments:

lockdown

After the voting and judgement phases, the game goes to night shutting the windows and beginning night with a proc.

lynch

Players have voted innocent or guilty on the person on trial, and that person is now killed or returned home.

What players do in this phase:

prepare_game

Triggers at beginning of the game when there is a confirmed list of valid, ready players. Creates a 100% ready game that has NOT started (no players in bodies) Followed by start game

Does the following:

reset_votes

Clears out the votes of a certain type (day votes, mafia kill votes) while leaving others untouched

resolve_night

The end of the night, and a series of signals for the order of events on a night.

Order of events, and what they mean:

send_home

Teenie helper proc to move players back to their home. Used in the above, but also used in the debug button "send all players home" Arguments:

send_message

Sends a global message to all players, or just 'team' if set.

signup_mafia

Signs the player up for Mafia, or removes them from the list if they are already signed up. Args:

start_day

How every day starts.

What players do in this phase:

start_game

The game by this point is now all set up, and so we can put people in their bodies and start the first phase.

Does the following:

start_night

The actual start of night for players. Mostly info is given at the start of the night as the end of the night is when votes and actions are submitted and tried.

What players do in this phase:

start_the_end

The end of the game is in two procs, because we want a bit of time for players to see eachothers roles. Because of how check_victory works, the game is halted in other places by this point. We won't delete ourselves in a certain amount of time in unit tests, as the unit test will handle our deletion instead.

What players do in this phase:

start_voting_phase

Players have finished the discussion period, and now must put up someone to the chopping block.

What players do in this phase:

toggle_night_curtains

Shuts poddoors attached to mafia. Arguments:

try_autostart

Called when someone signs up, and sees if there are enough people in the signup list to begin.

Only checks if everyone is actually valid to start (still connected and an observer) if there are enough players (basic_setup)

vote_for

Proc that goes off when players vote for something with their mafia panel.

If teams, it hides the tally overlay and only sends the vote messages to the team that is voting Arguments: