Adds friendly commendations (#51217)

* with message

* remove message, neaten up
This commit is contained in:
Ryll Ryll
2020-05-25 01:49:12 +08:00
committed by GitHub
parent e5e1e831a3
commit 753af7bda5
14 changed files with 180 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
/// Called when the shuttle starts launching back to centcom, polls a few random players who joined the round for commendations
/datum/controller/subsystem/ticker/proc/poll_hearts()
if(!CONFIG_GET(number/commendations))
return
var/number_to_ask = round(LAZYLEN(GLOB.joined_player_list) * CONFIG_GET(number/commendations)) + rand(0,1)
for(var/i in GLOB.joined_player_list)
var/mob/check_mob = get_mob_by_ckey(i)
if(!check_mob || !check_mob.mind || !check_mob.client)
continue
// maybe some other filters like bans or whatever
check_mob.query_heart(1)
number_to_ask--
if(number_to_ask == 0)
break
/// Once the round is actually over, cycle through the commendations in the hearts list and give them the hearted status
/datum/controller/subsystem/ticker/proc/handle_hearts()
for(var/i in hearts)
var/mob/heart_winner = i
if(!heart_winner.mind || !heart_winner.client)
continue
heart_winner.client.prefs.hearted_until = world.realtime + 24 HOURS // make configable
if(!heart_winner.client)
return
heart_winner.client.prefs.hearted = TRUE // so they get it right away
if(!heart_winner.client)
return
heart_winner.client.prefs.save_preferences()
tgalert(heart_winner, "Someone anonymously thanked you for being kind during the last round!", "<3!", "Okay")
/// Ask someone if they'd like to award a commendation for the round, 3 tries to get the name they want before we give up
/mob/proc/query_heart(attempt=1)
if(!mind || !client || attempt > 3)
return
if(attempt == 1 && tgalert(src, "Was there another character you noticed being kind this round that you would like to anonymously thank?", "<3?", "Yes", "No", StealFocus=FALSE, Timeout = 30 SECONDS) != "Yes")
return
var/heart_nominee
switch(attempt)
if(1)
heart_nominee = input(src, "What was their name? Just a first or last name may be enough. (Leave blank to cancel)", "<3?")
if(2)
heart_nominee = input(src, "Try again, what was their name? Just a first or last name may be enough. (Leave blank to cancel)", "<3?")
if(3)
heart_nominee = input(src, "One more try, what was their name? Just a first or last name may be enough. (Leave blank to cancel)", "<3?")
if(isnull(heart_nominee) || heart_nominee == "")
return
var/list/name_checks = get_mob_by_name(heart_nominee)
if(!name_checks || name_checks.len == 0)
query_heart(attempt + 1)
return
name_checks = shuffle(name_checks)
for(var/i in name_checks)
var/mob/heart_contender = i
if(heart_contender == src)
continue
switch(tgalert(src, "Is this the person: [heart_contender.real_name]?", "<3?", "Yes!", "Nope", "Cancel", Timeout = 15 SECONDS))
if("Yes!")
nominate_heart(heart_contender)
return
if("Nope")
continue
if("Cancel")
return
query_heart(attempt + 1)
/// Once we've confirmed who we're commendating, log it and add them to the hearts list
/mob/proc/nominate_heart(mob/heart_recepient)
if(!mind || !client)
return
to_chat(src, "<span class='nicegreen'>Commendation sent!</span>")
message_admins("[key_name(src)] commended [key_name(heart_recepient)] (<a href='?src=[REF(SSticker)];cancel_heart=1;heart_source=[REF(src)];heart_target=[REF(heart_recepient)]'>CANCEL</a>)") // cancel is probably unnecessary without messages
log_admin("[key_name(src)] commended [key_name(heart_recepient)]")
LAZYADD(SSticker.hearts, heart_recepient)
+5
View File
@@ -246,6 +246,11 @@
CHECK_TICK
//check config blah blah
handle_hearts()
CHECK_TICK
//These need update to actually reflect the real antagonists
//Print a list of antagonists to the server log
var/list/total_antagonists = list()
@@ -204,6 +204,9 @@
/datum/config_entry/flag/ooc_during_round
/datum/config_entry/number/commendations
integer = FALSE
/datum/config_entry/flag/emojis
/datum/config_entry/keyed_list/multiplicative_movespeed
+12
View File
@@ -59,6 +59,9 @@ SUBSYSTEM_DEF(ticker)
var/mode_result = "undefined"
var/end_state = "undefined"
/// People who have been commended and will receive a heart
var/list/hearts
/datum/controller/subsystem/ticker/Initialize(timeofday)
load_mode()
@@ -666,3 +669,12 @@ SUBSYSTEM_DEF(ticker)
SEND_SOUND(M.client, end_of_round_sound_ref)
text2file(login_music, "data/last_round_lobby_music.txt")
/datum/controller/subsystem/ticker/Topic(href, list/href_list)
. = ..()
if(href_list["cancel_heart"] && usr.client.holder)
var/mob/heart_sender = locate(href_list["heart_source"])
var/mob/intended_recepient = locate(href_list["heart_target"])
log_admin("[usr.ckey] blocked commendation from [heart_sender] ([heart_sender.ckey]) to [intended_recepient] ([intended_recepient.ckey])")
message_admins("[usr.ckey] blocked commendation from [heart_sender] ([heart_sender.ckey]) to [intended_recepient] ([intended_recepient.ckey])")
hearts[intended_recepient] = null
+1
View File
@@ -183,6 +183,7 @@
body += "<A href='?_src_=holder;[HrefToken()];tdome2=[REF(M)]'>Thunderdome 2</A> | "
body += "<A href='?_src_=holder;[HrefToken()];tdomeadmin=[REF(M)]'>Thunderdome Admin</A> | "
body += "<A href='?_src_=holder;[HrefToken()];tdomeobserve=[REF(M)]'>Thunderdome Observer</A> | "
body += "<A href='?_src_=holder;[HrefToken()];admincommend=[REF(M)]'>Commend Behavior</A> | "
body += "<br>"
body += "</body></html>"
+9
View File
@@ -2251,6 +2251,15 @@
var/datum/poll_question/poll = locate(href_list["submitoptionpoll"]) in GLOB.polls
poll_option_parse_href(href_list, poll, option)
else if(href_list["admincommend"])
if(!SSticker.IsRoundInProgress())
to_chat(usr, "<span class='warning'>The round must be in progress to use this!</span>")
return
var/mob/heart_recepient = locate(href_list["admincommend"])
if(tgalert(usr, "Are you sure you'd like to anonymously commend [heart_recepient.ckey]? NOTE: This is logged, please use this sparingly and only for actual kind behavior, not as a reward for your friends.", "<3?", "Yes", "No") == "No")
return
usr.nominate_heart(heart_recepient)
/datum/admins/proc/HandleCMode()
if(!check_rights(R_ADMIN))
return
+31
View File
@@ -687,3 +687,34 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
return founds
return msg
/proc/get_mob_by_name(msg)
//This is a list of words which are ignored by the parser when comparing message contents for names. MUST BE IN LOWER CASE!
var/list/ignored_words = list("unknown","the","a","an","of","monkey","alien","as", "i")
//explode the input msg into a list
var/list/msglist = splittext(msg, " ")
//who might fit the shoe
var/list/potential_hits = list()
for(var/i in GLOB.mob_list)
var/mob/M = i
var/list/nameWords = list()
if(!M.mind)
continue
for(var/string in splittext(lowertext(M.real_name), " "))
if(!(string in ignored_words))
nameWords += string
for(var/string in splittext(lowertext(M.name), " "))
if(!(string in ignored_words))
nameWords += string
for(var/string in nameWords)
testing("Name word [string]")
if(string in msglist)
potential_hits += M
break
return potential_hits
+11
View File
@@ -967,3 +967,14 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
///Redirect proc that makes it easier to get the status of an achievement. Achievement type is the typepath to the award.
/client/proc/get_award_status(achievement_type, mob/user, value = 1)
return player_details.achievements.get_achievement_status(achievement_type)
///Redirect proc that makes it easier to get the status of an achievement. Achievement type is the typepath to the award.
/client/proc/award_heart(heart_reason)
to_chat(src, "<span class='nicegreen'>Someone awarded you a heart![heart_reason ? " They said: [heart_reason]!" : ""]</span>")
if(!src)
return
prefs.hearted_until = world.realtime + (24 HOURS)
prefs.hearted = TRUE
if(!src)
return
prefs.save_preferences()
+13
View File
@@ -115,6 +115,11 @@ GLOBAL_LIST_EMPTY(preferences_datums)
///This var stores the amount of points the owner will get for making it out alive.
var/hardcore_survival_score = 0
///Someone thought we were nice! We get a little heart in OOC until we join the server past the below time (we can keep it until the end of the round otherwise)
var/hearted
///
var/hearted_until
/datum/preferences/New(client/C)
parent = C
@@ -653,6 +658,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(unlock_content || check_rights_for(user.client, R_ADMIN))
dat += "<b>OOC Color:</b> <span style='border: 1px solid #161616; background-color: [ooccolor ? ooccolor : GLOB.normal_ooc_colour];'>&nbsp;&nbsp;&nbsp;</span> <a href='?_src_=prefs;preference=ooccolor;task=input'>Change</a><br>"
if(hearted_until)
dat += "<a href='?_src_=prefs;preference=clear_heart'>Clear OOC Commend Heart</a><br>"
dat += "</td>"
@@ -1742,6 +1749,12 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if (href_list["tab"])
current_tab = text2num(href_list["tab"])
if("clear_heart")
hearted = FALSE
hearted_until = null
to_chat(user, "<span class='notice'>OOC Commendation Heart disabled</span>")
save_preferences()
ShowChoices(user)
return 1
@@ -203,6 +203,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
// Custom hotkeys
S["key_bindings"] >> key_bindings
// hearted
S["hearted_until"] >> hearted_until
if(hearted_until > world.realtime)
hearted = TRUE
//try to fix any outdated data if necessary
if(needs_update >= 0)
@@ -288,6 +292,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
WRITE_FILE(S["pda_style"], pda_style)
WRITE_FILE(S["pda_color"], pda_color)
WRITE_FILE(S["key_bindings"], key_bindings)
WRITE_FILE(S["hearted_until"], (hearted_until > world.realtime ? hearted_until : null))
return TRUE
/datum/preferences/proc/load_character(slot)
+3
View File
@@ -56,6 +56,9 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
mob.log_talk(raw_msg, LOG_OOC)
var/keyname = key
if(prefs.hearted)
var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/goonchat)
keyname = "[sheet.icon_tag("emoji-heart")][keyname]"
if(prefs.unlock_content)
if(prefs.toggles & MEMBER_PUBLIC)
keyname = "<font color='[prefs.ooccolor ? prefs.ooccolor : GLOB.normal_ooc_colour]'>[icon2html('icons/member_content.dmi', world, "blag")][keyname]</font>"
+1
View File
@@ -368,6 +368,7 @@
launch_status = ENDGAME_LAUNCHED
setTimer(SSshuttle.emergencyEscapeTime * engine_coeff)
priority_announce("The Emergency Shuttle has left the station. Estimate [timeLeft(600)] minutes until the shuttle docks at Central Command.", null, null, "Priority")
SSticker.poll_hearts()
SSmapping.mapvote() //If no map vote has been run yet, start one.
if(SHUTTLE_STRANDED)
+4
View File
@@ -22,6 +22,10 @@ OOC_DURING_ROUND
## Comment this out if you want to disable emojis
EMOJIS
## HEART COMMENDATIONS ###
## Uncomment this if you'd like to enable commendation pollings for this percentage of players near the end of the round (5% default)
## COMMENDATIONS 0.05
## MOB MOVEMENT ###
## We suggest editing these variables ingame to find a good speed for your server.
+1
View File
@@ -131,6 +131,7 @@
#include "code\__HELPERS\game.dm"
#include "code\__HELPERS\global_lists.dm"
#include "code\__HELPERS\heap.dm"
#include "code\__HELPERS\hearted.dm"
#include "code\__HELPERS\icon_smoothing.dm"
#include "code\__HELPERS\icons.dm"
#include "code\__HELPERS\level_traits.dm"