Files
Bubberstation/code/modules/mafia/abilities/abilities.dm
T
John Willard 2b844dab93 Mafia notes are no longer automatically written for you & new UI (#74819)
## About The Pull Request

Notes in Mafia are no longer written for you, you instead write it
yourself and save.
Also adds a button to automatically say out your notes for other
players.

Hides the judgment buttons when it's not time to judge
Makes the UI autoupdate and makes use of ui_data / ui_static_data

Video of it in action: https://www.youtube.com/watch?v=NDUSuIUqQv8

## Why It's Good For The Game

A downside to notes currently is that it's very easy to confirm yourself
as a role against players who don't code-dive to know exactly how notes
should be formatted for any role, this makes it easier, as everyone will
type out their own notes, and can send it directly to chat when needed.

## Changelog

🆑
balance: [Mafia] Notes are no longer written out for you.
qol: [Mafia] You can now send your notes to chat whenever.
qol: [Mafia] Roundend has changed. Solos will win over others in a 1v1,
but a HoP can keep a round going in case they can solo lynch.
/🆑
2023-04-25 08:43:36 -07:00

126 lines
4.7 KiB
Plaintext

/datum/mafia_ability
var/name = "Mafia Ability"
var/ability_action = "brutally murder"
///The priority level this action must be sent at. Setting this to null will prevent it from being triggered automatically.
///(COMSIG_MAFIA_NIGHT_PRE_ACTION_PHASE|COMSIG_MAFIA_NIGHT_ACTION_PHASE|COMSIG_MAFIA_NIGHT_KILL_PHASE)
var/action_priority = COMSIG_MAFIA_NIGHT_ACTION_PHASE
///When the ability can be used: (MAFIA_PHASE_DAY | MAFIA_PHASE_VOTING | MAFIA_PHASE_NIGHT)
var/valid_use_period = MAFIA_PHASE_NIGHT
///Whether this ability can be used on yourself. Selections: (CAN_USE_ON_OTHERS | CAN_USE_ON_SELF | CAN_USE_ON_DEAD)
var/use_flags = CAN_USE_ON_OTHERS
///Boolean on whether the ability was selected to be used during the proper period.
var/using_ability = FALSE
///The mafia role that holds this ability.
var/datum/mafia_role/host_role
///The mafia role this ability is targeting, if necessary.
var/datum/mafia_role/target_role
/datum/mafia_ability/New(datum/mafia_controller/game, datum/mafia_role/host_role)
. = ..()
src.host_role = host_role
if(action_priority)
RegisterSignal(game, action_priority, PROC_REF(perform_action_target))
RegisterSignal(game, COMSIG_MAFIA_NIGHT_END, PROC_REF(clean_action_refs))
/datum/mafia_ability/Destroy(force, ...)
host_role = null
target_role = null
return ..()
/**
* Called when refs need to be cleared, when the target is no longer set.
*/
/datum/mafia_ability/proc/clean_action_refs(datum/mafia_controller/game)
SIGNAL_HANDLER
SHOULD_CALL_PARENT(TRUE)
target_role = null
using_ability = initial(using_ability)
/**
* Used to check if this ability can be used on a potential target.
* Args:
* game - The Mafia controller that holds reference to the game.
* potential_target - The player we are attempting to validate the action on.
* silent - Whether to give feedback to the player about why the action cannot be used.
*/
/datum/mafia_ability/proc/validate_action_target(datum/mafia_controller/game, datum/mafia_role/potential_target, silent = FALSE)
SHOULD_CALL_PARENT(TRUE)
if(game.phase != valid_use_period)
return FALSE
if(host_role.role_flags & ROLE_ROLEBLOCKED)
to_chat(host_role.body, span_warning("You were roleblocked!"))
return FALSE
if(potential_target)
if(!(use_flags & CAN_USE_ON_DEAD) && (potential_target.game_status == MAFIA_DEAD))
if(!silent)
to_chat(host_role.body, span_notice("This can only be used on dead players."))
return FALSE
if(!(use_flags & CAN_USE_ON_SELF) && (potential_target == host_role))
if(!silent)
to_chat(host_role.body, span_notice("This can only be used on others."))
return FALSE
if(!(use_flags & CAN_USE_ON_OTHERS) && (potential_target != host_role))
if(!silent)
to_chat(host_role.body, span_notice("This can only be used on yourself."))
return FALSE
return TRUE
/**
* Called when using the ability.
* Will first check if you are using the ability, then whether you can use it.
* Finally it will check if you are interrupted, then will pass that you've performed it.
* Args:
* game - The Mafia controller that holds reference to the game.
* day_target - Set when using actions during the day, this is the person that is the target during this phase.
*/
/datum/mafia_ability/proc/perform_action_target(datum/mafia_controller/game, datum/mafia_role/day_target)
SHOULD_CALL_PARENT(TRUE)
if(!using_ability)
return FALSE
if(host_role.game_status == MAFIA_DEAD)
return FALSE
if(!validate_action_target(game, target_role))
return FALSE
if(target_role)
if(SEND_SIGNAL(target_role, COMSIG_MAFIA_ON_VISIT, game, host_role) & MAFIA_VISIT_INTERRUPTED) //visited a warden. something that prevents you by visiting that person
to_chat(host_role.body, span_danger("Your [name] was interrupted!"))
return FALSE
return TRUE
/**
* ##set_target
*
* Used for Night abilities ONLY
* Sets the ability's target, which will cause the action to be performed on them at the end of the night.
* Subtypes can override this for things like self-abilities (such as shooting visitors).
*/
/datum/mafia_ability/proc/set_target(datum/mafia_controller/game, datum/mafia_role/new_target)
if(!validate_action_target(game, new_target))
return FALSE
var/feedback_text = "You will %WILL_PERFORM% [ability_action]%SELF%"
if(use_flags & CAN_USE_ON_SELF)
feedback_text = replacetext(feedback_text, "%SELF%", ".")
else
feedback_text = replacetext(feedback_text, "%SELF%", " [new_target.body].")
if(target_role == new_target)
using_ability = FALSE
target_role = null
feedback_text = replacetext(feedback_text, "%WILL_PERFORM%", "not")
else
using_ability = TRUE
target_role = new_target
feedback_text = replacetext(feedback_text, "%WILL_PERFORM%", "now")
to_chat(host_role.body, span_notice(feedback_text))
return TRUE