mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 11:34: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:
@@ -56,9 +56,6 @@
|
||||
|
||||
var/global/obj/screen/click_catcher/void
|
||||
|
||||
var/karma_spent = 0
|
||||
var/karma_tab = 0
|
||||
|
||||
control_freak = CONTROL_FREAK_ALL | CONTROL_FREAK_SKIN | CONTROL_FREAK_MACROS
|
||||
|
||||
var/ip_intel = "Disabled"
|
||||
@@ -120,6 +117,9 @@
|
||||
/// List of the clients CUIs
|
||||
var/list/datum/custom_user_item/cui_entries = list()
|
||||
|
||||
/// The client's karma holder
|
||||
var/datum/karma_holder/karmaholder
|
||||
|
||||
/client/vv_edit_var(var_name, var_value)
|
||||
switch(var_name)
|
||||
// I know we will never be in a world where admins are editing client vars to let people bypass TOS
|
||||
@@ -129,4 +129,7 @@
|
||||
// Dont fuck with this
|
||||
if("cui_entries")
|
||||
return FALSE
|
||||
// or this
|
||||
if("karmaholder")
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
@@ -125,58 +125,6 @@
|
||||
if(GLOB.configuration.logging.href_logging)
|
||||
log_href("[src] (usr:[usr]\[[COORD(usr)]\]) : [hsrc ? "[hsrc] " : ""][href]")
|
||||
|
||||
if(href_list["karmashop"])
|
||||
if(!GLOB.configuration.general.enable_karma)
|
||||
to_chat(src, "Karma is disabled on this server.")
|
||||
return
|
||||
|
||||
switch(href_list["karmashop"])
|
||||
if("tab")
|
||||
karma_tab = text2num(href_list["tab"])
|
||||
karmashopmenu()
|
||||
return
|
||||
if("shop")
|
||||
if(href_list["KarmaBuy"])
|
||||
var/karma=verify_karma()
|
||||
if(isnull(karma)) //Doesn't display anything if karma database is down.
|
||||
return
|
||||
switch(href_list["KarmaBuy"])
|
||||
if("1")
|
||||
karma_purchase(karma,5,"job","Barber")
|
||||
if("2")
|
||||
karma_purchase(karma,5,"job","Brig Physician")
|
||||
if("3")
|
||||
karma_purchase(karma,30,"job","Nanotrasen Representative")
|
||||
if("4")
|
||||
karma_purchase(karma,30,"job","Blueshield")
|
||||
return
|
||||
if(href_list["KarmaBuy2"])
|
||||
var/karma=verify_karma()
|
||||
if(isnull(karma)) //Doesn't display anything if karma database is down.
|
||||
return
|
||||
switch(href_list["KarmaBuy2"])
|
||||
if("1")
|
||||
karma_purchase(karma,15,"species","Machine People","Machine")
|
||||
if("2")
|
||||
karma_purchase(karma,30,"species","Kidan")
|
||||
if("3")
|
||||
karma_purchase(karma,30,"species","Grey")
|
||||
if("4")
|
||||
karma_purchase(karma,45,"species","Vox")
|
||||
if("5")
|
||||
karma_purchase(karma,45,"species","Slime People")
|
||||
if("6")
|
||||
karma_purchase(karma,45,"species","Plasmaman")
|
||||
if("7")
|
||||
karma_purchase(karma,30,"species","Drask")
|
||||
return
|
||||
if(href_list["KarmaRefund"])
|
||||
var/type = href_list["KarmaRefundType"]
|
||||
var/job = href_list["KarmaRefund"]
|
||||
var/cost = href_list["KarmaRefundCost"]
|
||||
karmarefund(type,job,cost)
|
||||
return
|
||||
|
||||
switch(href_list["_src_"])
|
||||
if("holder") hsrc = holder
|
||||
if("usr") hsrc = mob
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/datum/client_login_processor/karma_numbers
|
||||
priority = 42
|
||||
|
||||
/datum/client_login_processor/karma_numbers/get_query(client/C)
|
||||
var/datum/db_query/query = SSdbcore.NewQuery("SELECT karma, karmaspent FROM karmatotals WHERE byondkey=:ckey", list(
|
||||
"ckey" = C.ckey
|
||||
))
|
||||
return query
|
||||
|
||||
/datum/client_login_processor/karma_numbers/process_result(datum/db_query/Q, client/C)
|
||||
C.karmaholder = new()
|
||||
while(Q.NextRow())
|
||||
C.karmaholder.karma_earned = Q.item[1]
|
||||
C.karmaholder.karma_spent = Q.item[2]
|
||||
@@ -0,0 +1,20 @@
|
||||
/datum/client_login_processor/karma_unlocks
|
||||
priority = 43
|
||||
|
||||
/datum/client_login_processor/karma_unlocks/get_query(client/C)
|
||||
var/datum/db_query/query = SSdbcore.NewQuery("SELECT job, species FROM whitelist WHERE ckey=:ckey", list(
|
||||
"ckey" = C.ckey
|
||||
))
|
||||
return query
|
||||
|
||||
/datum/client_login_processor/karma_unlocks/process_result(datum/db_query/Q, client/C)
|
||||
while(Q.NextRow())
|
||||
// Lets split stuff apart
|
||||
C.karmaholder.unlocked_jobs = splittext(Q.item[1], ",")
|
||||
C.karmaholder.unlocked_species = splittext(Q.item[2], ",") // these should really be JSON
|
||||
|
||||
for(var/i in 1 to length(C.karmaholder.unlocked_jobs))
|
||||
C.karmaholder.unlocked_jobs[i] = trim(C.karmaholder.unlocked_jobs[i]) // Trim whitespace
|
||||
|
||||
for(var/i in 1 to length(C.karmaholder.unlocked_species))
|
||||
C.karmaholder.unlocked_species[i] = trim(C.karmaholder.unlocked_species[i]) // Trim whitespace
|
||||
@@ -220,7 +220,7 @@
|
||||
var/prev_species = active_character.species
|
||||
|
||||
for(var/_species in GLOB.whitelisted_species)
|
||||
if(is_alien_whitelisted(user, _species))
|
||||
if(can_use_species(user, _species))
|
||||
new_species += _species
|
||||
|
||||
active_character.species = input("Please select a species", "Character Generation", null) in sortTim(new_species, /proc/cmp_text_asc)
|
||||
|
||||
Reference in New Issue
Block a user