mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-19 11:08:35 +01:00
* Mafia now starts without admin intervention (#79348) ## About The Pull Request Mafia should now start without the need of admin intervention. I made a unit test that should always have a PDA and a ghost spawning in a game of Mafia and having it run through basic setup to confirm they both successfully sign up and the game starts. I had to change a lot of things in order to get this working, such as giving unique ckeys to mock clients, fixing harddels in Mafia, and plenty of minor fixes. This is the first time any of this code is put in CI, so a lot of uncaught errors are now showing their faces. Because loading maps mid-round runtimes due to smoothing, I have mafia their own unit test-only map that doesn't use smoothing. I also split the mafia ui code into its own file, and moved a single helper that was sitting around in mafia's file into a helpers file. I also added some comments to explain why certain things are the way they are, because I wrote some undocumented code previously and forgot a few things, leading to self-inflicted wasted time. ## Why It's Good For The Game ^ ## Changelog 🆑 fix: Mafia games can now start properly. /🆑 --------- Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com> * Mafia now starts without admin intervention --------- Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>
73 lines
2.5 KiB
Plaintext
73 lines
2.5 KiB
Plaintext
/datum/computer_file/program/mafia
|
|
filename = "mafia"
|
|
filedesc = "Mafia"
|
|
program_icon_state = "mafia"
|
|
extended_desc = "A program that allows you to play the infamous Mafia game, straight from your Modular PC."
|
|
requires_ntnet = FALSE
|
|
size = 6
|
|
tgui_id = "NtosMafiaPanel"
|
|
program_icon = "user-secret"
|
|
alert_able = TRUE
|
|
|
|
/datum/computer_file/program/mafia/on_install(datum/computer_file/source, obj/item/modular_computer/computer_installing)
|
|
. = ..()
|
|
RegisterSignal(SSdcs, COMSIG_MAFIA_GAME_START, PROC_REF(on_game_start))
|
|
|
|
/datum/computer_file/program/mafia/Destroy(force)
|
|
var/datum/mafia_controller/game = GLOB.mafia_game
|
|
if(!game)
|
|
return ..()
|
|
UnregisterSignal(game, COMSIG_MAFIA_GAME_END)
|
|
var/datum/mafia_role/pda_role = game.get_role_player(computer)
|
|
if(!pda_role)
|
|
return ..()
|
|
game.send_message(span_notice("[pda_role.body] has deleted the game from their PDA, and therefore has left the game."))
|
|
pda_role.kill(game)
|
|
return ..()
|
|
|
|
/datum/computer_file/program/mafia/ui_static_data(mob/user)
|
|
var/list/data = list()
|
|
var/datum/mafia_controller/game = GLOB.mafia_game
|
|
if(!game)
|
|
game = create_mafia_game()
|
|
data += game.ui_static_data(computer)
|
|
return data
|
|
|
|
/datum/computer_file/program/mafia/ui_data(mob/user)
|
|
var/list/data = list()
|
|
var/datum/mafia_controller/game = GLOB.mafia_game
|
|
if(!game)
|
|
game = create_mafia_game()
|
|
data += game.ui_data(computer)
|
|
return data
|
|
|
|
/datum/computer_file/program/mafia/ui_assets(mob/user)
|
|
var/list/data = list()
|
|
var/datum/mafia_controller/game = GLOB.mafia_game
|
|
if(!game)
|
|
game = create_mafia_game()
|
|
data += game.ui_assets(user)
|
|
return data
|
|
|
|
/datum/computer_file/program/mafia/ui_act(mob/user, params, datum/tgui/ui, datum/ui_state/state)
|
|
var/datum/mafia_controller/game = GLOB.mafia_game
|
|
if(!game)
|
|
game = create_mafia_game()
|
|
return game.ui_act(user, params, ui, state)
|
|
|
|
///Called when a game of Mafia starts, sets the ui header to the proper one.
|
|
/datum/computer_file/program/mafia/proc/on_game_start(datum/controller/subsystem/processing/dcs/source, datum/mafia_controller/game)
|
|
SIGNAL_HANDLER
|
|
RegisterSignal(game, COMSIG_MAFIA_GAME_END, PROC_REF(on_game_end))
|
|
ui_header = "mafia.gif"
|
|
if(game.get_role_player(computer))
|
|
alert_pending = TRUE
|
|
computer.alert_call(src, "Mafia game started!")
|
|
|
|
///Called when a game of Mafia ends, deletes its ui header.
|
|
/datum/computer_file/program/mafia/proc/on_game_end(datum/mafia_controller/game)
|
|
SIGNAL_HANDLER
|
|
UnregisterSignal(game, COMSIG_MAFIA_GAME_END)
|
|
ui_header = null
|
|
update_static_data_for_all_viewers()
|