mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-13 16:13:19 +01:00
Karma refactor (#17070)
* Karma refactor * This too * Fixes recursion * Fixes bugs * Fixes bad usr * Update code/modules/karma/karma_holder.dm Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com> * Logic tweak Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>
This commit is contained in:
@@ -33,7 +33,7 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ##
|
||||
if(!M || !rank)
|
||||
return 0
|
||||
|
||||
if(GLOB.configuration.jobs.guest_job_ban && guest_jobbans(rank))
|
||||
if(GLOB.configuration.jobs.guest_job_ban && check_job_karma(rank))
|
||||
if(IsGuestKey(M.key))
|
||||
return "Guest Job-ban"
|
||||
|
||||
@@ -46,7 +46,7 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ##
|
||||
if(!ckey || !rank)
|
||||
return null
|
||||
|
||||
if(GLOB.configuration.jobs.guest_job_ban && guest_jobbans(rank))
|
||||
if(GLOB.configuration.jobs.guest_job_ban && check_job_karma(rank))
|
||||
if(IsGuestKey(ckey))
|
||||
return "Guest Job-ban"
|
||||
|
||||
|
||||
@@ -3522,51 +3522,22 @@
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
var/target_ckey = href_list["viewkarma"]
|
||||
|
||||
var/total_karma = 0
|
||||
var/spent_karma = 0
|
||||
var/unlocked_jobs = ""
|
||||
var/unlocked_species = ""
|
||||
// Get their totals
|
||||
var/datum/db_query/query_get_totals = SSdbcore.NewQuery("SELECT karma, karmaspent FROM karmatotals WHERE byondkey=:ckey", list(
|
||||
"ckey" = target_ckey
|
||||
))
|
||||
if(!query_get_totals.warn_execute())
|
||||
qdel(query_get_totals)
|
||||
var/client/C = GLOB.directory[href_list["viewkarma"]]
|
||||
if(!C)
|
||||
return
|
||||
// Even if there aint a row, we can still assume the defaults of 0 above
|
||||
if(query_get_totals.NextRow())
|
||||
total_karma = query_get_totals.item[1]
|
||||
spent_karma = query_get_totals.item[2]
|
||||
|
||||
qdel(query_get_totals)
|
||||
|
||||
// Now get their unlocks
|
||||
var/datum/db_query/query_get_unlocks = SSdbcore.NewQuery("SELECT job, species FROM whitelist WHERE ckey=:ckey", list(
|
||||
"ckey" = target_ckey
|
||||
))
|
||||
if(!query_get_unlocks.warn_execute())
|
||||
qdel(query_get_unlocks)
|
||||
return
|
||||
if(query_get_unlocks.NextRow())
|
||||
unlocked_jobs = query_get_unlocks.item[1]
|
||||
unlocked_species = query_get_unlocks.item[2]
|
||||
|
||||
qdel(query_get_unlocks)
|
||||
|
||||
// Pack it into a dat
|
||||
var/dat = {"
|
||||
<ul>
|
||||
<li>Total Karma: [total_karma]</li>
|
||||
<li>Spent Karma: [spent_karma]</li>
|
||||
<li>Available Karma: [total_karma - spent_karma]</li>
|
||||
<li>Unlocked Jobs: [unlocked_jobs]</li>
|
||||
<li>Unlocked Species: [unlocked_species]</li>
|
||||
<li>Total Karma: [C.karmaholder.karma_earned]</li>
|
||||
<li>Spent Karma: [C.karmaholder.karma_spent]</li>
|
||||
<li>Available Karma: [C.karmaholder.karma_earned - C.karmaholder.karma_spent]</li>
|
||||
<li>Unlocked Jobs: [C.karmaholder.unlocked_jobs.Join(", ")]</li>
|
||||
<li>Unlocked Species: [C.karmaholder.unlocked_species.Join(", ")]</li>
|
||||
</ul>
|
||||
"}
|
||||
|
||||
var/datum/browser/popup = new(usr, "view_karma", "Karma stats for [target_ckey]", 600, 300)
|
||||
var/datum/browser/popup = new(usr, "view_karma", "Karma stats for [C.ckey]", 600, 300)
|
||||
popup.set_content(dat)
|
||||
popup.open(FALSE)
|
||||
else if(href_list["who_advanced"])
|
||||
|
||||
Reference in New Issue
Block a user