toast. And DiscoFox™️

This commit is contained in:
Letter N
2021-02-08 18:46:05 +08:00
parent 50d66bb93c
commit f87aa0ac5b
118 changed files with 3889 additions and 1382 deletions
+190 -176
View File
@@ -1,21 +1,21 @@
/**
* The mafia controller handles the mafia minigame in progress.
* It is first created when the first ghost signs up to play.
*/
* The mafia controller handles the mafia minigame in progress.
* It is first created when the first ghost signs up to play.
*/
/datum/mafia_controller
///list of observers that should get game updates.
var/list/spectators = list()
///all roles in the game, dead or alive. check their game status if you only want living or dead.
var/list/all_roles = list()
///exists to speed up role retrieval, it's a dict. player_role_lookup[player ckey] will give you the role they play
///exists to speed up role retrieval, it's a dict. `player_role_lookup[player ckey]` will give you the role they play
var/list/player_role_lookup = list()
///what part of the game you're playing in. day phases, night phases, judgement phases, etc.
var/phase = MAFIA_PHASE_SETUP
///how long the game has gone on for, changes with every sunrise. day one, night one, day two, etc.
var/turn = 0
///for debugging and testing a full game, or adminbuse. If this is not null, it will use this as a setup. clears when game is over
///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
var/list/custom_setup = list()
///first day has no voting, and thus is shorter
var/first_day_phase_period = 20 SECONDS
@@ -82,20 +82,20 @@
qdel(map_deleter)
/**
* 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:
* * Picks map, and loads it
* * Grabs landmarks if it is the first time it's loading
* * Sets up the role list
* * Puts players in each role randomly
* Arguments:
* * setup_list: list of all the datum setups (fancy list of roles) that would work for the game
* * ready_players: list of filtered, sane players (so not playing or disconnected) for the game to put into roles
*/
/datum/mafia_controller/proc/prepare_game(setup_list, ready_players)
* 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:
* * Picks map, and loads it
* * Grabs landmarks if it is the first time it's loading
* * Sets up the role list
* * Puts players in each role randomly
* Arguments:
* * setup_list: list of all the datum setups (fancy list of roles) that would work for the game
* * ready_players: list of filtered, sane players (so not playing or disconnected) for the game to put into roles
*/
/datum/mafia_controller/proc/prepare_game(setup_list,ready_players)
var/list/possible_maps = subtypesof(/datum/map_template/mafia)
var/turf/spawn_area = get_turf(locate(/obj/effect/landmark/mafia_game_area) in GLOB.landmarks_list)
@@ -166,23 +166,23 @@
to_chat(M, "[link] MAFIA: [msg] [team_suffix]")
/**
* 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:
* * Creates bodies for all of the roles with the first proc
* * Starts the first day manually (so no timer) with the second proc
*/
* 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:
* * Creates bodies for all of the roles with the first proc
* * Starts the first day manually (so no timer) with the second proc
*/
/datum/mafia_controller/proc/start_game()
create_bodies()
start_day()
/**
* How every day starts.
*
* What players do in this phase:
* * If day one, just a small starting period to see who is in the game and check role, leading to the night phase.
* * Otherwise, it's a longer period used to discuss events that happened during the night, leading to the voting phase.
*/
* How every day starts.
*
* What players do in this phase:
* * If day one, just a small starting period to see who is in the game and check role, leading to the night phase.
* * Otherwise, it's a longer period used to discuss events that happened during the night, leading to the voting phase.
*/
/datum/mafia_controller/proc/start_day()
turn += 1
phase = MAFIA_PHASE_DAY
@@ -198,12 +198,12 @@
SStgui.update_uis(src)
/**
* Players have finished the discussion period, and now must put up someone to the chopping block.
*
* What players do in this phase:
* * Vote on which player to put up for lynching, leading to the judgement phase.
* * If no votes are case, the judgement phase is skipped, leading to the night phase.
*/
* Players have finished the discussion period, and now must put up someone to the chopping block.
*
* What players do in this phase:
* * Vote on which player to put up for lynching, leading to the judgement phase.
* * If no votes are case, the judgement phase is skipped, leading to the night phase.
*/
/datum/mafia_controller/proc/start_voting_phase()
phase = MAFIA_PHASE_VOTING
next_phase_timer = addtimer(CALLBACK(src, .proc/check_trial, TRUE),voting_phase_period,TIMER_STOPPABLE) //be verbose!
@@ -211,21 +211,21 @@
SStgui.update_uis(src)
/**
* 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:
* * Vote innocent or guilty, if they are not on trial.
* * Defend themselves and wait for judgement, if they are.
* * Leads to the lynch phase.
* Arguments:
* * verbose: boolean, announces whether there were votes or not. after judgement it goes back here with no voting period to end the day.
*/
* 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:
* * Vote innocent or guilty, if they are not on trial.
* * Defend themselves and wait for judgement, if they are.
* * Leads to the lynch phase.
* Arguments:
* * verbose: boolean, announces whether there were votes or not. after judgement it goes back here with no voting period to end the day.
*/
/datum/mafia_controller/proc/check_trial(verbose = TRUE)
var/datum/mafia_role/loser = get_vote_winner("Day")//, majority_of_town = TRUE)
// var/loser_votes = get_vote_count(loser,"Day")
var/loser_votes = get_vote_count(loser,"Day")
if(loser)
// if(loser_votes > 12)
// loser.body.client?.give_award(/datum/award/achievement/mafia/universally_hated, loser.body)
if(loser_votes > 12)
award_role(/datum/award/achievement/mafia/universally_hated, loser)
send_message("<b>[loser.body.real_name] wins the day vote, Listen to their defense and vote \"INNOCENT\" or \"GUILTY\"!</b>")
//refresh the lists
judgement_abstain_votes = list()
@@ -248,12 +248,12 @@
SStgui.update_uis(src)
/**
* 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:
* * r/watchpeopledie
* * If the accused is killed, their true role is revealed to the rest of the players.
*/
* 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:
* * r/watchpeopledie
* * If the accused is killed, their true role is revealed to the rest of the players.
*/
/datum/mafia_controller/proc/lynch()
for(var/i in judgement_innocent_votes)
var/datum/mafia_role/role = i
@@ -276,25 +276,25 @@
next_phase_timer = addtimer(CALLBACK(src, .proc/check_trial, FALSE),judgement_lynch_period,TIMER_STOPPABLE)// small pause to see the guy dead, no verbosity since we already did this
/**
* 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:
* * role: mafia role that is getting sent back to the game.
*/
* 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:
* * role: mafia role that is getting sent back to the game.
*/
/datum/mafia_controller/proc/send_home(datum/mafia_role/role)
role.body.forceMove(get_turf(role.assigned_landmark))
/**
* Checks to see if a faction (or solo antagonist) has won.
*
* Calculates in this order:
* * counts up town, mafia, and solo
* * solos can count as town members for the purposes of mafia winning
* * sends the amount of living people to the solo antagonists, and see if they won OR block the victory of the teams
* * checks if solos won from above, then if town, then if mafia
* * starts the end of the game if a faction won
* * returns TRUE if someone won the game, halting other procs from continuing in the case of a victory
*/
* Checks to see if a faction (or solo antagonist) has won.
*
* Calculates in this order:
* * counts up town, mafia, and solo
* * solos can count as town members for the purposes of mafia winning
* * sends the amount of living people to the solo antagonists, and see if they won OR block the victory of the teams
* * checks if solos won from above, then if town, then if mafia
* * starts the end of the game if a faction won
* * returns TRUE if someone won the game, halting other procs from continuing in the case of a victory
*/
/datum/mafia_controller/proc/check_victory()
//needed for achievements
var/list/total_town = list()
@@ -336,8 +336,7 @@
var/solo_end = FALSE
for(var/datum/mafia_role/winner in total_victors)
send_message("<span class='big comradio'>!! [uppertext(winner.name)] VICTORY !!</span>")
// var/client/winner_client = GLOB.directory[winner.player_key]
// winner_client?.give_award(winner.winner_award, winner.body)
award_role(winner.winner_award, winner)
solo_end = TRUE
if(solo_end)
start_the_end()
@@ -345,28 +344,39 @@
if(blocked_victory)
return FALSE
if(alive_mafia == 0)
// for(var/datum/mafia_role/townie in total_town)
// var/client/townie_client = GLOB.directory[townie.player_key]
// townie_client?.give_award(townie.winner_award, townie.body)
for(var/datum/mafia_role/townie in total_town)
award_role(townie.winner_award, townie)
start_the_end("<span class='big green'>!! TOWN VICTORY !!</span>")
return TRUE
else if(alive_mafia >= alive_town) //guess could change if town nightkill is added
start_the_end("<span class='big red'>!! MAFIA VICTORY !!</span>")
// for(var/datum/mafia_role/changeling in total_mafia)
// var/client/changeling_client = GLOB.directory[changeling.player_key]
// changeling_client?.give_award(changeling.winner_award, changeling.body)
for(var/datum/mafia_role/changeling in total_mafia)
award_role(changeling.winner_award, changeling)
return TRUE
/**
* 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.
*
* What players do in this phase:
* * See everyone's role postgame
* * See who won the game
* Arguments:
* * message: string, if non-null it sends it to all players. used to announce team victories while solos are handled in check victory
*/
* Lets the game award roles with all their checks and sanity, prevents achievements given out for debug games
*
* Arguments:
* * award: path of the award
* * role: mafia_role datum to reward.
*/
/datum/mafia_controller/proc/award_role(award, datum/mafia_role/rewarded)
if(custom_setup.len)
return
var/client/role_client = GLOB.directory[rewarded.player_key]
role_client?.give_award(award, rewarded.body)
/**
* 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.
*
* What players do in this phase:
* * See everyone's role postgame
* * See who won the game
* Arguments:
* * message: string, if non-null it sends it to all players. used to announce team victories while solos are handled in check victory
*/
/datum/mafia_controller/proc/start_the_end(message)
SEND_SIGNAL(src,COMSIG_MAFIA_GAME_END)
if(message)
@@ -377,8 +387,8 @@
next_phase_timer = addtimer(CALLBACK(src,.proc/end_game),victory_lap_period,TIMER_STOPPABLE)
/**
* Cleans up the game, resetting variables back to the beginning and removing the map with the generator.
*/
* Cleans up the game, resetting variables back to the beginning and removing the map with the generator.
*/
/datum/mafia_controller/proc/end_game()
map_deleter.generate() //remove the map, it will be loaded at the start of the next one
QDEL_LIST(all_roles)
@@ -392,17 +402,17 @@
phase = MAFIA_PHASE_SETUP
/**
* After the voting and judgement phases, the game goes to night shutting the windows and beginning night with a proc.
*/
* After the voting and judgement phases, the game goes to night shutting the windows and beginning night with a proc.
*/
/datum/mafia_controller/proc/lockdown()
toggle_night_curtains(close=TRUE)
start_night()
/**
* Shuts poddoors attached to mafia.
* Arguments:
* * close: boolean, the state you want the curtains in.
*/
* Shuts poddoors attached to mafia.
* Arguments:
* * close: boolean, the state you want the curtains in.
*/
/datum/mafia_controller/proc/toggle_night_curtains(close)
for(var/obj/machinery/door/poddoor/D in GLOB.machines) //I really dislike pathing of these
if(D.id != "mafia") //so as to not trigger shutters on station, lol
@@ -413,12 +423,12 @@
INVOKE_ASYNC(D, /obj/machinery/door/poddoor.proc/open)
/**
* 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:
* * Mafia are told to begin voting on who to kill
* * Powers that are picked during the day announce themselves right now
*/
* 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:
* * Mafia are told to begin voting on who to kill
* * Powers that are picked during the day announce themselves right now
*/
/datum/mafia_controller/proc/start_night()
phase = MAFIA_PHASE_NIGHT
send_message("<b>Night [turn] started! Lockdown will end in 45 seconds.</b>")
@@ -427,16 +437,16 @@
SStgui.update_uis(src)
/**
* 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:
* * Start of resolve (NIGHT_START) is for activating night abilities that MUST go first
* * Action phase (NIGHT_ACTION_PHASE) is for non-lethal day abilities
* * Mafia then tallies votes and kills the highest voted person (note: one random voter visits that person for the purposes of roleblocking)
* * Killing phase (NIGHT_KILL_PHASE) is for lethal night abilities
* * End of resolve (NIGHT_END) is for cleaning up abilities that went off and i guess doing some that must go last
* * Finally opens the curtains and calls the start of day phase, completing the cycle until check victory returns TRUE
*/
* 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:
* * Start of resolve (NIGHT_START) is for activating night abilities that MUST go first
* * Action phase (NIGHT_ACTION_PHASE) is for non-lethal day abilities
* * Mafia then tallies votes and kills the highest voted person (note: one random voter visits that person for the purposes of roleblocking)
* * Killing phase (NIGHT_KILL_PHASE) is for lethal night abilities
* * End of resolve (NIGHT_END) is for cleaning up abilities that went off and i guess doing some that must go last
* * Finally opens the curtains and calls the start of day phase, completing the cycle until check victory returns TRUE
*/
/datum/mafia_controller/proc/resolve_night()
SEND_SIGNAL(src,COMSIG_MAFIA_NIGHT_START)
SEND_SIGNAL(src,COMSIG_MAFIA_NIGHT_ACTION_PHASE)
@@ -457,15 +467,15 @@
SStgui.update_uis(src)
/**
* 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:
* * voter: the mafia role that is trying to vote for...
* * target: the mafia role that is getting voted for
* * vote_type: type of vote submitted (is this the day vote? is this the mafia night vote?)
* * teams: see mafia team defines for what to put in, makes the messages only send to a specific team (so mafia night votes only sending messages to mafia at night)
*/
* 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:
* * voter: the mafia role that is trying to vote for...
* * target: the mafia role that is getting voted for
* * vote_type: type of vote submitted (is this the day vote? is this the mafia night vote?)
* * teams: see mafia team defines for what to put in, makes the messages only send to a specific team (so mafia night votes only sending messages to mafia at night)
*/
/datum/mafia_controller/proc/vote_for(datum/mafia_role/voter,datum/mafia_role/target,vote_type, teams)
if(!votes[vote_type])
votes[vote_type] = list()
@@ -485,8 +495,8 @@
old.body.update_icon()
/**
* Clears out the votes of a certain type (day votes, mafia kill votes) while leaving others untouched
*/
* Clears out the votes of a certain type (day votes, mafia kill votes) while leaving others untouched
*/
/datum/mafia_controller/proc/reset_votes(vote_type)
var/list/bodies_to_update = list()
for(var/vote in votes[vote_type])
@@ -497,11 +507,11 @@
M.update_icon()
/**
* Returns how many people voted for the role, in whatever vote (day vote, night kill vote)
* Arguments:
* * role: the mafia role the proc tries to get the amount of votes for
* * vote_type: the vote type (getting how many day votes were for the role, or mafia night votes for the role)
*/
* Returns how many people voted for the role, in whatever vote (day vote, night kill vote)
* Arguments:
* * role: the mafia role the proc tries to get the amount of votes for
* * vote_type: the vote type (getting how many day votes were for the role, or mafia night votes for the role)
*/
/datum/mafia_controller/proc/get_vote_count(role,vote_type)
. = 0
for(var/v in votes[vote_type])
@@ -510,11 +520,11 @@
. += votee.vote_power
/**
* Returns whichever role got the most votes, in whatever vote (day vote, night kill vote)
* returns null if no votes
* Arguments:
* * vote_type: the vote type (getting the role that got the most day votes, or the role that got the most mafia votes)
*/
* Returns whichever role got the most votes, in whatever vote (day vote, night kill vote)
* returns null if no votes
* Arguments:
* * vote_type: the vote type (getting the role that got the most day votes, or the role that got the most mafia votes)
*/
/datum/mafia_controller/proc/get_vote_winner(vote_type)
var/list/tally = list()
for(var/votee in votes[vote_type])
@@ -526,21 +536,23 @@
return length(tally) ? tally[1] : null
/**
* Returns a random person who voted for whatever vote (day vote, night kill vote)
* Arguments:
* * vote_type: vote type (getting a random day voter, or mafia night voter)
*/
* Returns a random person who voted for whatever vote (day vote, night kill vote)
* Arguments:
* * vote_type: vote type (getting a random day voter, or mafia night voter)
*/
/datum/mafia_controller/proc/get_random_voter(vote_type)
if(length(votes[vote_type]))
return pick(votes[vote_type])
/**
* Adds mutable appearances to people who get publicly voted on (so not night votes) showing how many people are picking them
* Arguments:
* * source: the body of the role getting the overlays
* * overlay_list: signal var passing the overlay list of the mob
*/
* Adds mutable appearances to people who get publicly voted on (so not night votes) showing how many people are picking them
* Arguments:
* * source: the body of the role getting the overlays
* * overlay_list: signal var passing the overlay list of the mob
*/
/datum/mafia_controller/proc/display_votes(atom/source, list/overlay_list)
SIGNAL_HANDLER
if(phase != MAFIA_PHASE_VOTING)
return
var/v = get_vote_count(player_role_lookup[source],"Day")
@@ -548,14 +560,14 @@
overlay_list += MA
/**
* 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:
* * Toggles godmode so the mafia players cannot kill themselves
* * Adds signals for voting overlays, see display_votes proc
* * gives mafia panel
* * sends the greeting text (goals, role name, etc)
*/
* 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:
* * Toggles godmode so the mafia players cannot kill themselves
* * Adds signals for voting overlays, see display_votes proc
* * gives mafia panel
* * sends the greeting text (goals, role name, etc)
*/
/datum/mafia_controller/proc/create_bodies()
for(var/datum/mafia_role/role in all_roles)
var/mob/living/carbon/human/H = new(get_turf(role.assigned_landmark))
@@ -716,13 +728,14 @@
if(GLOB.mafia_signup[C.ckey])
GLOB.mafia_signup -= C.ckey
to_chat(usr, "<span class='notice'>You unregister from Mafia.</span>")
return
return TRUE
else
GLOB.mafia_signup[C.ckey] = C
to_chat(usr, "<span class='notice'>You sign up for Mafia.</span>")
if(phase == MAFIA_PHASE_SETUP)
check_signups()
try_autostart()
return TRUE
if("mf_spectate")
if(C.ckey in spectators)
to_chat(usr, "<span class='notice'>You will no longer get messages from the game.</span>")
@@ -730,6 +743,7 @@
else
to_chat(usr, "<span class='notice'>You will now get messages from the game.</span>")
spectators += C.ckey
return TRUE
if(user_role.game_status == MAFIA_DEAD)
return
//User actions (just living)
@@ -800,13 +814,13 @@
. += L[key]
/**
* Returns a semirandom setup, with...
* Town, Two invest roles, one protect role, sometimes a misc role, and the rest assistants for town.
* Mafia, 2 normal mafia and one special.
* Neutral, two disruption roles, sometimes one is a killing.
*
* See _defines.dm in the mafia folder for a rundown on what these groups of roles include.
*/
* Returns a semirandom setup, with...
* Town, Two invest roles, one protect role, sometimes a misc role, and the rest assistants for town.
* Mafia, 2 normal mafia and one special.
* Neutral, two disruption roles, sometimes one is a killing.
*
* See _defines.dm in the mafia folder for a rundown on what these groups of roles include.
*/
/datum/mafia_controller/proc/generate_random_setup()
var/invests_left = 2
var/protects_left = 1
@@ -845,8 +859,8 @@
return random_setup
/**
* 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
*/
* 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
*/
/datum/mafia_controller/proc/add_setup_role(setup_list, wanted_role_type)
var/list/role_type_paths = list()
for(var/path in typesof(/datum/mafia_role))
@@ -868,17 +882,17 @@
setup_list[mafia_path] = 1
/**
* 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 required_player(max_player) 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.
*/
* 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.
*/
/datum/mafia_controller/proc/basic_setup()
var/req_players
var/list/setup = custom_setup
if(!setup.len)
req_players = required_player //max_player
req_players = max_player //MAFIA_MAX_PLAYER_COUNT
else
req_players = assoc_value_sum(setup)
@@ -918,10 +932,10 @@
start_game()
/**
* 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)
*/
* 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)
*/
/datum/mafia_controller/proc/try_autostart()
if(phase != MAFIA_PHASE_SETUP) // || !(GLOB.ghost_role_flags & GHOSTROLE_MINIGAME))
return
@@ -929,10 +943,10 @@
basic_setup()
/**
* 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.
*/
* 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.
*/
/datum/mafia_controller/proc/check_signups()
for(var/bad_key in GLOB.mafia_bad_signup)
if(GLOB.directory[bad_key])//they have reconnected if we can search their key and get a client
@@ -962,8 +976,8 @@
parent.ui_interact(owner)
/**
* Creates the global datum for playing mafia games, destroys the last if that's required and returns the new.
*/
* Creates the global datum for playing mafia games, destroys the last if that's required and returns the new.
*/
/proc/create_mafia_game()
if(GLOB.mafia_game)
QDEL_NULL(GLOB.mafia_game)
+61 -20
View File
@@ -19,7 +19,7 @@
var/list/actions = list()
var/list/targeted_actions = list()
//what the role gets when it wins a game
// var/winner_award = /datum/award/achievement/mafia/assistant
var/winner_award = /datum/award/achievement/mafia/assistant
//so mafia have to also kill them to have a majority
var/solo_counts_as_town = FALSE //(don't set this for town)
@@ -124,7 +124,7 @@
desc = "You can investigate a single person each night to learn their team."
revealed_outfit = /datum/outfit/mafia/detective
role_type = TOWN_INVEST
// winner_award = /datum/award/achievement/mafia/detective
winner_award = /datum/award/achievement/mafia/detective
hud_icon = "huddetective"
revealed_icon = "detective"
@@ -151,6 +151,8 @@
current_investigation = target
/datum/mafia_role/detective/proc/investigate(datum/mafia_controller/game)
SIGNAL_HANDLER
var/datum/mafia_role/target = current_investigation
if(target)
if(target.detect_immune)
@@ -178,7 +180,7 @@
desc = "You can visit someone ONCE PER GAME to reveal their true role in the morning!"
revealed_outfit = /datum/outfit/mafia/psychologist
role_type = TOWN_INVEST
// winner_award = /datum/award/achievement/mafia/psychologist
winner_award = /datum/award/achievement/mafia/psychologist
hud_icon = "hudpsychologist"
revealed_icon = "psychologist"
@@ -202,6 +204,8 @@
current_target = target
/datum/mafia_role/psychologist/proc/therapy_reveal(datum/mafia_controller/game)
SIGNAL_HANDLER
if(SEND_SIGNAL(src,COMSIG_MAFIA_CAN_PERFORM_ACTION,game,"reveal",current_target) & MAFIA_PREVENT_ACTION || game_status != MAFIA_ALIVE) //Got lynched or roleblocked by a lawyer.
current_target = null
if(current_target)
@@ -218,7 +222,7 @@
role_type = TOWN_INVEST
hud_icon = "hudchaplain"
revealed_icon = "chaplain"
// winner_award = /datum/award/achievement/mafia/chaplain
winner_award = /datum/award/achievement/mafia/chaplain
targeted_actions = list("Pray")
var/current_target
@@ -238,6 +242,8 @@
current_target = target
/datum/mafia_role/chaplain/proc/commune(datum/mafia_controller/game)
SIGNAL_HANDLER
var/datum/mafia_role/target = current_target
if(target)
to_chat(body,"<span class='warning'>You invoke spirit of [target.body.real_name] and learn their role was <b>[target.name]<b>.</span>")
@@ -251,7 +257,7 @@
role_type = TOWN_PROTECT
hud_icon = "hudmedicaldoctor"
revealed_icon = "medicaldoctor"
// winner_award = /datum/award/achievement/mafia/md
winner_award = /datum/award/achievement/mafia/md
targeted_actions = list("Protect")
var/datum/mafia_role/current_protected
@@ -277,16 +283,22 @@
current_protected = target
/datum/mafia_role/md/proc/protect(datum/mafia_controller/game)
SIGNAL_HANDLER
if(current_protected)
RegisterSignal(current_protected,COMSIG_MAFIA_ON_KILL,.proc/prevent_kill)
add_note("N[game.turn] - Protected [current_protected.body.real_name]")
/datum/mafia_role/md/proc/prevent_kill(datum/source)
SIGNAL_HANDLER
to_chat(body,"<span class='warning'>The person you protected tonight was attacked!</span>")
to_chat(current_protected.body,"<span class='userdanger'>You were attacked last night, but someone nursed you back to life!</span>")
return MAFIA_PREVENT_KILL
/datum/mafia_role/md/proc/end_protection(datum/mafia_controller/game)
SIGNAL_HANDLER
if(current_protected)
UnregisterSignal(current_protected,COMSIG_MAFIA_ON_KILL)
current_protected = null
@@ -298,7 +310,7 @@
role_type = TOWN_PROTECT
hud_icon = "hudlawyer"
revealed_icon = "lawyer"
// winner_award = /datum/award/achievement/mafia/lawyer
winner_award = /datum/award/achievement/mafia/lawyer
targeted_actions = list("Advise")
var/datum/mafia_role/current_target
@@ -310,6 +322,8 @@
RegisterSignal(game,COMSIG_MAFIA_NIGHT_END,.proc/release)
/datum/mafia_role/lawyer/proc/roleblock_text(datum/mafia_controller/game)
SIGNAL_HANDLER
if(SEND_SIGNAL(src,COMSIG_MAFIA_CAN_PERFORM_ACTION,game,"roleblock",current_target) & MAFIA_PREVENT_ACTION || game_status != MAFIA_ALIVE) //Got lynched or roleblocked by another lawyer.
current_target = null
if(current_target)
@@ -335,16 +349,22 @@
to_chat(body,"<span class='warning'>You will block [target.body.real_name] tonight.</span>")
/datum/mafia_role/lawyer/proc/try_to_roleblock(datum/mafia_controller/game)
SIGNAL_HANDLER
if(current_target)
RegisterSignal(current_target,COMSIG_MAFIA_CAN_PERFORM_ACTION, .proc/prevent_action)
/datum/mafia_role/lawyer/proc/release(datum/mafia_controller/game)
SIGNAL_HANDLER
. = ..()
if(current_target)
UnregisterSignal(current_target, COMSIG_MAFIA_CAN_PERFORM_ACTION)
current_target = null
/datum/mafia_role/lawyer/proc/prevent_action(datum/source)
SIGNAL_HANDLER
if(game_status == MAFIA_ALIVE) //in case we got killed while imprisoning sk - bad luck edge
return MAFIA_PREVENT_ACTION
@@ -355,7 +375,7 @@
role_type = TOWN_MISC
hud_icon = "hudheadofpersonnel"
revealed_icon = "headofpersonnel"
// winner_award = /datum/award/achievement/mafia/hop
winner_award = /datum/award/achievement/mafia/hop
targeted_actions = list("Reveal")
@@ -378,7 +398,7 @@
role_type = MAFIA_REGULAR
hud_icon = "hudchangeling"
revealed_icon = "changeling"
// winner_award = /datum/award/achievement/mafia/changeling
winner_award = /datum/award/achievement/mafia/changeling
revealed_outfit = /datum/outfit/mafia/changeling
special_theme = "syndicate"
@@ -389,6 +409,8 @@
RegisterSignal(game,COMSIG_MAFIA_SUNDOWN,.proc/mafia_text)
/datum/mafia_role/mafia/proc/mafia_text(datum/mafia_controller/source)
SIGNAL_HANDLER
to_chat(body,"<b>Vote for who to kill tonight. The killer will be chosen randomly from voters.</b>")
//better detective for mafia
@@ -398,7 +420,7 @@
role_type = MAFIA_SPECIAL
hud_icon = "hudthoughtfeeder"
revealed_icon = "thoughtfeeder"
// winner_award = /datum/award/achievement/mafia/thoughtfeeder
winner_award = /datum/award/achievement/mafia/thoughtfeeder
targeted_actions = list("Learn Role")
var/datum/mafia_role/current_investigation
@@ -418,6 +440,8 @@
current_investigation = target
/datum/mafia_role/mafia/thoughtfeeder/proc/investigate(datum/mafia_controller/game)
SIGNAL_HANDLER
var/datum/mafia_role/target = current_investigation
current_investigation = null
if(SEND_SIGNAL(src,COMSIG_MAFIA_CAN_PERFORM_ACTION,game,"thoughtfeed",target) & MAFIA_PREVENT_ACTION)
@@ -441,7 +465,7 @@
win_condition = "kill everyone."
team = MAFIA_TEAM_SOLO
role_type = NEUTRAL_KILL
// winner_award = /datum/award/achievement/mafia/traitor
winner_award = /datum/award/achievement/mafia/traitor
targeted_actions = list("Night Kill")
revealed_outfit = /datum/outfit/mafia/traitor
@@ -464,6 +488,8 @@
return TRUE //while alive, town AND mafia cannot win (though since mafia know who is who it's pretty easy to win from that point)
/datum/mafia_role/traitor/proc/nightkill_immunity(datum/source,datum/mafia_controller/game,lynch)
SIGNAL_HANDLER
if(game.phase == MAFIA_PHASE_NIGHT && !lynch)
to_chat(body,"<span class='userdanger'>You were attacked, but they'll have to try harder than that to put you down.</span>")
return MAFIA_PREVENT_KILL
@@ -481,6 +507,8 @@
to_chat(body,"<span class='warning'>You will attempt to kill [target.body.real_name] tonight.</span>")
/datum/mafia_role/traitor/proc/try_to_kill(datum/mafia_controller/source)
SIGNAL_HANDLER
var/datum/mafia_role/target = current_victim
current_victim = null
if(SEND_SIGNAL(src,COMSIG_MAFIA_CAN_PERFORM_ACTION,source,"traitor kill",target) & MAFIA_PREVENT_ACTION)
@@ -500,7 +528,7 @@
special_theme = "neutral"
hud_icon = "hudnightmare"
revealed_icon = "nightmare"
// winner_award = /datum/award/achievement/mafia/nightmare
winner_award = /datum/award/achievement/mafia/nightmare
targeted_actions = list("Flicker", "Hunt")
var/list/flickering = list()
@@ -543,6 +571,8 @@
to_chat(body,"<span class='danger'>You will hunt everyone in a flickering room down tonight.</span>")
/datum/mafia_role/nightmare/proc/flicker_or_hunt(datum/mafia_controller/source)
SIGNAL_HANDLER
if(game_status != MAFIA_ALIVE || !flicker_target)
return
if(SEND_SIGNAL(src,COMSIG_MAFIA_CAN_PERFORM_ACTION,source,"nightmare actions",flicker_target) & MAFIA_PREVENT_ACTION)
@@ -576,7 +606,7 @@
special_theme = "neutral"
hud_icon = "hudfugitive"
revealed_icon = "fugitive"
// winner_award = /datum/award/achievement/mafia/fugitive
winner_award = /datum/award/achievement/mafia/fugitive
actions = list("Self Preservation")
var/charges = 2
@@ -604,11 +634,15 @@
protection_status = !protection_status
/datum/mafia_role/fugitive/proc/night_start(datum/mafia_controller/game)
SIGNAL_HANDLER
if(protection_status == FUGITIVE_WILL_PRESERVE)
to_chat(body,"<span class='danger'>Your preparations are complete. Nothing could kill you tonight!</span>")
RegisterSignal(src,COMSIG_MAFIA_ON_KILL,.proc/prevent_death)
/datum/mafia_role/fugitive/proc/night_end(datum/mafia_controller/game)
SIGNAL_HANDLER
if(protection_status == FUGITIVE_WILL_PRESERVE)
charges--
UnregisterSignal(src,COMSIG_MAFIA_ON_KILL)
@@ -616,13 +650,16 @@
protection_status = FUGITIVE_NOT_PRESERVING
/datum/mafia_role/fugitive/proc/prevent_death(datum/mafia_controller/game)
SIGNAL_HANDLER
to_chat(body,"<span class='userdanger'>You were attacked! Luckily, you were ready for this!</span>")
return MAFIA_PREVENT_KILL
/datum/mafia_role/fugitive/proc/survived(datum/mafia_controller/game)
SIGNAL_HANDLER
if(game_status == MAFIA_ALIVE)
// var/client/winner_client = GLOB.directory[player_key]
// winner_client?.give_award(winner_award, body)
game.award_role(winner_award, src)
game.send_message("<span class='big comradio'>!! FUGITIVE VICTORY !!</span>")
#undef FUGITIVE_NOT_PRESERVING
@@ -640,7 +677,7 @@
hud_icon = "hudobsessed"
revealed_icon = "obsessed"
// winner_award = /datum/award/achievement/mafia/obsessed
winner_award = /datum/award/achievement/mafia/obsessed
revealed_outfit = /datum/outfit/mafia/obsessed // /mafia <- outfit must be readded (just make a new mafia outfits file for all of these)
solo_counts_as_town = TRUE //after winning or whatever, can side with whoever. they've already done their objective!
@@ -652,6 +689,8 @@
RegisterSignal(game,COMSIG_MAFIA_SUNDOWN,.proc/find_obsession)
/datum/mafia_role/obsessed/proc/find_obsession(datum/mafia_controller/game)
SIGNAL_HANDLER
var/list/all_roles_shuffle = shuffle(game.all_roles)
for(var/role in all_roles_shuffle)
var/datum/mafia_role/possible = role
@@ -667,13 +706,14 @@
UnregisterSignal(game,COMSIG_MAFIA_SUNDOWN)
/datum/mafia_role/obsessed/proc/check_victory(datum/source,datum/mafia_controller/game,lynch)
SIGNAL_HANDLER
UnregisterSignal(source,COMSIG_MAFIA_ON_KILL)
if(game_status == MAFIA_DEAD)
return
if(lynch)
game.send_message("<span class='big comradio'>!! OBSESSED VICTORY !!</span>")
// var/client/winner_client = GLOB.directory[player_key]
// winner_client?.give_award(winner_award, body)
game.award_role(winner_award, src)
reveal_role(game, FALSE)
else
to_chat(body, "<span class='userdanger'>You have failed your objective to lynch [obsession.body]!</span>")
@@ -689,17 +729,18 @@
special_theme = "neutral"
hud_icon = "hudclown"
revealed_icon = "clown"
// winner_award = /datum/award/achievement/mafia/clown
winner_award = /datum/award/achievement/mafia/clown
/datum/mafia_role/clown/New(datum/mafia_controller/game)
. = ..()
RegisterSignal(src,COMSIG_MAFIA_ON_KILL,.proc/prank)
/datum/mafia_role/clown/proc/prank(datum/source,datum/mafia_controller/game,lynch)
SIGNAL_HANDLER
if(lynch)
var/datum/mafia_role/victim = pick(game.judgement_guilty_votes + game.judgement_abstain_votes)
game.send_message("<span class='big clown'>[body.real_name] WAS A CLOWN! HONK! They take down [victim.body.real_name] with their last prank.</span>")
game.send_message("<span class='big clown'>!! CLOWN VICTORY !!</span>")
// var/client/winner_client = GLOB.directory[player_key]
// winner_client?.give_award(winner_award, body)
game.award_role(winner_award, src)
victim.kill(game,FALSE)