Skip to content

Commit

Permalink
Add config option to completely disable karma
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercat2000 committed Apr 22, 2017
1 parent 531541e commit a7506f0
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 135 deletions.
5 changes: 5 additions & 0 deletions code/controllers/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@

var/shutdown_on_reboot = 0 // Whether to shut down the world instead of rebooting it

var/disable_karma = 0 // Disable all karma functions and unlock karma jobs by default

/datum/configuration/New()
var/list/L = subtypesof(/datum/game_mode)
for(var/T in L)
Expand Down Expand Up @@ -593,6 +595,9 @@
if("shutdown_shell_command")
shutdown_shell_command = value

if("disable_karma")
disable_karma = 1

else
diary << "Unknown setting in configuration: '[name]'"

Expand Down
4 changes: 4 additions & 0 deletions code/game/jobs/whitelist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var/list/whitelist = list()
if(guest_jobbans(rank))
if(!config.usewhitelist)
return 1
if(config.disable_karma)
return 1
if(check_rights(R_ADMIN, 0, M))
return 1
if(!dbcon.IsConnected())
Expand Down Expand Up @@ -62,6 +64,8 @@ var/list/whitelist = list()
/proc/is_alien_whitelisted(mob/M, var/species)
if(!config.usealienwhitelist)
return 1
if(config.disable_karma)
return 1
if(species == "human" || species == "Human")
return 1
if(check_rights(R_ADMIN, 0))
Expand Down
268 changes: 135 additions & 133 deletions code/modules/client/client procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,160 +97,163 @@
if(config && config.log_hrefs && href_logfile)
to_chat(href_logfile, "<small>[time2text(world.timeofday,"hh:mm")] [src] (usr:[usr])</small> || [hsrc ? "[hsrc] " : ""][href]<br>")

switch(href_list["karmashop"])
if("tab")
karma_tab = text2num(href_list["tab"])
karmashopmenu()
if(href_list["karmashop"])
if(config.disable_karma)
return
if("shop")
if(href_list["KarmaBuy"])
var/karma=verify_karma()
switch(href_list["KarmaBuy"])
if("1")
if(karma <5)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Barber?", "Confirmation", "No", "Yes") != "Yes")

switch(href_list["karmashop"])
if("tab")
karma_tab = text2num(href_list["tab"])
karmashopmenu()
return
if("shop")
if(href_list["KarmaBuy"])
var/karma=verify_karma()
switch(href_list["KarmaBuy"])
if("1")
if(karma <5)
to_chat(usr, "You do not have enough karma!")
return
DB_job_unlock("Barber",5)
return
if("2")
if(karma <5)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Brig Physician?", "Confirmation", "No", "Yes") != "Yes")
else
if(alert("Are you sure you want to unlock Barber?", "Confirmation", "No", "Yes") != "Yes")
return
DB_job_unlock("Barber",5)
return
DB_job_unlock("Brig Physician",5)
return
if("3")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Nanotrasen Representative?", "Confirmation", "No", "Yes") != "Yes")
if("2")
if(karma <5)
to_chat(usr, "You do not have enough karma!")
return
DB_job_unlock("Nanotrasen Representative",30)
return
if("5")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Blueshield?", "Confirmation", "No", "Yes") != "Yes")
else
if(alert("Are you sure you want to unlock Brig Physician?", "Confirmation", "No", "Yes") != "Yes")
return
DB_job_unlock("Brig Physician",5)
return
DB_job_unlock("Blueshield",30)
return
if("6")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Mechanic?", "Confirmation", "No", "Yes") != "Yes")
if("3")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
DB_job_unlock("Mechanic",30)
return
if("7")
if(karma <45)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Magistrate?", "Confirmation", "No", "Yes") != "Yes")
else
if(alert("Are you sure you want to unlock Nanotrasen Representative?", "Confirmation", "No", "Yes") != "Yes")
return
DB_job_unlock("Nanotrasen Representative",30)
return
DB_job_unlock("Magistrate",45)
return
if("9")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Security Pod Pilot?", "Confirmation", "No", "Yes") != "Yes")
if("5")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
DB_job_unlock("Security Pod Pilot",30)
return
if(href_list["KarmaBuy2"])
var/karma=verify_karma()
switch(href_list["KarmaBuy2"])
if("1")
if(karma <15)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Machine People?", "Confirmation", "No", "Yes") != "Yes")
else
if(alert("Are you sure you want to unlock Blueshield?", "Confirmation", "No", "Yes") != "Yes")
return
DB_job_unlock("Blueshield",30)
return
DB_species_unlock("Machine",15)
return
if("2")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Kidan?", "Confirmation", "No", "Yes") != "Yes")
if("6")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
DB_species_unlock("Kidan",30)
return
if("3")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Grey?", "Confirmation", "No", "Yes") != "Yes")
else
if(alert("Are you sure you want to unlock Mechanic?", "Confirmation", "No", "Yes") != "Yes")
return
DB_job_unlock("Mechanic",30)
return
DB_species_unlock("Grey",30)
return
if("4")
if(karma <45)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Vox?", "Confirmation", "No", "Yes") != "Yes")
if("7")
if(karma <45)
to_chat(usr, "You do not have enough karma!")
return
DB_species_unlock("Vox",45)
return
if("5")
if(karma <45)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Slime People?", "Confirmation", "No", "Yes") != "Yes")
else
if(alert("Are you sure you want to unlock Magistrate?", "Confirmation", "No", "Yes") != "Yes")
return
DB_job_unlock("Magistrate",45)
return
DB_species_unlock("Slime People",45)
return
if("6")
if(karma <100)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Plasmaman?", "Confirmation", "No", "Yes") != "Yes")
if("9")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
DB_species_unlock("Plasmaman",100)
return
if("7")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Drask?", "Confirmation", "No", "Yes") != "Yes")
else
if(alert("Are you sure you want to unlock Security Pod Pilot?", "Confirmation", "No", "Yes") != "Yes")
return
DB_job_unlock("Security Pod Pilot",30)
return
DB_species_unlock("Drask",30)
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
if(href_list["KarmaBuy2"])
var/karma=verify_karma()
switch(href_list["KarmaBuy2"])
if("1")
if(karma <15)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Machine People?", "Confirmation", "No", "Yes") != "Yes")
return
DB_species_unlock("Machine",15)
return
if("2")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Kidan?", "Confirmation", "No", "Yes") != "Yes")
return
DB_species_unlock("Kidan",30)
return
if("3")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Grey?", "Confirmation", "No", "Yes") != "Yes")
return
DB_species_unlock("Grey",30)
return
if("4")
if(karma <45)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Vox?", "Confirmation", "No", "Yes") != "Yes")
return
DB_species_unlock("Vox",45)
return
if("5")
if(karma <45)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Slime People?", "Confirmation", "No", "Yes") != "Yes")
return
DB_species_unlock("Slime People",45)
return
if("6")
if(karma <100)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Plasmaman?", "Confirmation", "No", "Yes") != "Yes")
return
DB_species_unlock("Plasmaman",100)
return
if("7")
if(karma <30)
to_chat(usr, "You do not have enough karma!")
return
else
if(alert("Are you sure you want to unlock Drask?", "Confirmation", "No", "Yes") != "Yes")
return
DB_species_unlock("Drask",30)
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
if("prefs") return prefs.process_link(usr,href_list)
if("vars") return view_var_Topic(href,href_list,hsrc)

//Polls and shit
if(href_list["showpoll"])

handle_player_polling()
return
if(href_list["createpollwindow"])
Expand All @@ -260,7 +263,6 @@
create_poll_function(href_list)
return
if(href_list["pollid"])

var/pollid = href_list["pollid"]
if(istext(pollid))
pollid = text2num(pollid)
Expand Down Expand Up @@ -443,7 +445,7 @@
winset(src, null, "command=\".configure graphics-hwmode on\"")

log_client_to_db(tdata)

. = ..() //calls mob.Login()

if(ckey in clientmessages)
Expand Down
14 changes: 14 additions & 0 deletions code/modules/karma/karma.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ var/list/karma_spenders = list()
/mob/proc/can_give_karma()
if(!client)
return 0
if(config.disable_karma)
to_chat(src, "<span class='warning'>Karma is disabled.</span>")
return 0
if(!ticker || !player_list.len || (ticker.current_state == GAME_STATE_PREGAME))
to_chat(src, "<span class='warning'>You can't award karma until the game has started.</span>")
return 0
Expand Down Expand Up @@ -118,6 +121,9 @@ var/list/karma_spenders = list()
if(!M)
to_chat(usr, "Please right click a mob to award karma directly, or use the 'Award Karma' verb to select a player from the player listing.")
return
if(config.disable_karma) // this is here because someone thought it was a good idea to add an alert box before checking if they can even give a mob karma
to_chat(usr, "<span class='warning'>Karma is disabled.</span>")
return
if(alert("Give [M.name] good karma?", "Karma", "Yes", "No") != "Yes")
return
if(!can_give_karma_to_mob(M))
Expand Down Expand Up @@ -145,6 +151,10 @@ var/list/karma_spenders = list()
set desc = "Reports how much karma you have accrued."
set category = "OOC"

if(config.disable_karma)
to_chat(src, "<span class='warning'>Karma is disabled.</span>")
return 0

var/currentkarma=verify_karma()
to_chat(usr, {"<br>You have <b>[currentkarma]</b> available."})
return
Expand Down Expand Up @@ -176,6 +186,10 @@ You've gained <b>[totalkarma]</b> total karma in your time here.<br>"}
set desc = "Spend your hard-earned karma here"
set hidden = 1

if(config.disable_karma)
to_chat(src, "<span class='warning'>Karma is disabled.</span>")
return 0

karmashopmenu()
return

Expand Down
Loading

0 comments on commit a7506f0

Please sign in to comment.