From eae94f1506c1fa3ad8515dcf68a3ccbcda2828da Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 24 Aug 2023 02:00:20 +0200 Subject: [PATCH] [MIRROR] Roundend reporting now has a section for achievements earned during the round [MDB IGNORE] (#23283) * Roundend reporting now has a section for achievements earned during the round (#77861) ## About The Pull Request The roundend report now has a section dedicated to achievements earned. It will report the ckey/identity of the player, the earned achievement, and where it was earned. ![image](https://github.com/tgstation/tgstation/assets/28870487/aa522eea-0334-4986-8177-557708e5d610) ## Why It's Good For The Game Adds some more fun stuff to the roundend report, and contributes to the recent uptick in achievement-related PRs. ## Changelog :cl: Rhials add: The roundend report will now read out any achievements ("cheevos" as you may know them) earned by players over the course of the round. /:cl: * Roundend reporting now has a section for achievements earned during the round --------- Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> --- code/__HELPERS/roundend.dm | 26 ++++++++++++++++++++++++++ code/datums/achievements/_awards.dm | 13 +++++++++++++ 2 files changed, 39 insertions(+) diff --git a/code/__HELPERS/roundend.dm b/code/__HELPERS/roundend.dm index 9e14c1c1212..681f525bd5e 100644 --- a/code/__HELPERS/roundend.dm +++ b/code/__HELPERS/roundend.dm @@ -4,6 +4,8 @@ #define PERSONAL_LAST_ROUND "personal last round" #define SERVER_LAST_ROUND "server last round" +GLOBAL_LIST_INIT(achievements_unlocked, list()) + /datum/controller/subsystem/ticker/proc/gather_roundend_feedback() gather_antag_data() record_nuke_disk_location() @@ -322,6 +324,8 @@ parts += goal_report() //Economy & Money parts += market_report() + //Player Achievements + parts += cheevo_report() list_clear_nulls(parts) @@ -809,3 +813,25 @@ return qdel(query_update_everything_ranks) qdel(query_check_everything_ranks) + +/datum/controller/subsystem/ticker/proc/cheevo_report() + var/list/parts = list() + if(length(GLOB.achievements_unlocked)) + parts += "Achievement Get!
" + parts += "Total Achievements Earned: [length(GLOB.achievements_unlocked)]!
" + parts += "" + return "
" + +///A datum containing the info necessary for an achievement readout, reported and added to the global list in /datum/award/achievement/on_unlock(mob/user) +/datum/achievement_report + ///The winner of this achievement. + var/winner + ///The achievement that was won. + var/cheevo + ///The ckey of our winner + var/winner_key + ///The name of the area we earned this cheevo in + var/award_location diff --git a/code/datums/achievements/_awards.dm b/code/datums/achievements/_awards.dm index 6c207a120a4..2c9f0908d4c 100644 --- a/code/datums/achievements/_awards.dm +++ b/code/datums/achievements/_awards.dm @@ -89,6 +89,19 @@ to_chat(user, span_greenannounce("Achievement unlocked: [name]!")) user.client.give_award(/datum/award/score/achievements_score, user, 1) + var/datum/achievement_report/new_report = new /datum/achievement_report() + + new_report.winner = "[(user.real_name == user.name) ? user.real_name : "[user.real_name], as [user.name]"]" + new_report.cheevo = name + if(user.ckey) + new_report.winner_key = user.ckey + else + stack_trace("[name] achievement earned by [user], who did not have a ckey.") + + new_report.award_location = "[get_area_name(user)]" + + GLOB.achievements_unlocked += new_report + ///Scores are for leaderboarded things, such as killcount of a specific boss /datum/award/score desc = "you did it sooo many times."