Skip to content

Commit

Permalink
Add: Patreon Rank system, bump Schema (#2587)
Browse files Browse the repository at this point in the history
Adopted from Monkestation/Monkestation2.0
_patreon.dm originally by dwasint
Updated by wraith-54321, dwasint, Absolucy
patreon_data.dm originally by dwasint
Updated by dwasint, wraith-54321, Absolucy

Bumps Schema to 6.1
Adds current lc13_schema.sql, generated using:
Win64 DBeaver 24.2.2 DROP statements, Additional Comments,
Structure Only

Adds "Change Patreon Rank" admin verb
Usage:
First dialog, input ckey (case sensitive)
Second dialog, select new rank
  • Loading branch information
Cupax3 authored Dec 19, 2024
1 parent 8b073c8 commit a317120
Show file tree
Hide file tree
Showing 8 changed files with 868 additions and 2 deletions.
716 changes: 716 additions & 0 deletions SQL/lc13_schema.sql

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* make sure you add an update to the schema_version stable in the db changelog
*/
#define DB_MAJOR_VERSION 5
#define DB_MAJOR_VERSION 6

/**
* DB minor schema version
Expand All @@ -20,7 +20,7 @@
*
* make sure you add an update to the schema_version stable in the db changelog
*/
#define DB_MINOR_VERSION 12
#define DB_MINOR_VERSION 1


//! ## Timing subsystem
Expand Down
17 changes: 17 additions & 0 deletions code/__DEFINES/~lobotomy_defines/_patreon.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#define NO_RANK "None"
#define UNSUBBED "UNSUBBED"
#define AGENT_RANK "AGENT"
#define SENIOR_AGENT_RANK "SENIORAGENT"
#define CAPTAIN_RANK "CAPTAIN"

// im lazy -Cupa
GLOBAL_LIST_INIT(patreon_ranks, list(
"None",
"UNSUBBED",
"AGENT",
"SENIORAGENT",
"CAPTAIN"))

#define ACCESS_AGENT_RANK 1
#define ACCESS_SENIOR_AGENT_RANK 2
#define ACCESS_CAPTAIN_RANK 3
72 changes: 72 additions & 0 deletions code/datums/patreon_data.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/client
var/datum/patreon_data/patreon

/datum/patreon_data
///the client that owns this data
var/client/owner
///the stored patreon client key for the information
var/client_key
///the stored patreon rank collected from the server
var/owned_rank = NO_RANK
///access rank in numbers
var/access_rank = 0

/datum/patreon_data/New(client/created_client)
. = ..()
if(!created_client)
return

if(!SSdbcore.IsConnected())
owned_rank = NO_RANK ///this is a testing variable
return

owner = created_client

fetch_key(owner.ckey)
fetch_rank(owner.ckey)

assign_access_rank()


/datum/patreon_data/proc/fetch_key(ckey)
var/datum/db_query/query_get_key = SSdbcore.NewQuery("SELECT patreon_key FROM [format_table_name("patreon_ranks")] WHERE ckey = :ckey",
list("ckey" = ckey))
if(query_get_key.warn_execute())
if(query_get_key.NextRow())
client_key = query_get_key.item[1]
qdel(query_get_key)

/datum/patreon_data/proc/fetch_rank(ckey)
var/datum/db_query/query_get_rank = SSdbcore.NewQuery("SELECT patreon_rank FROM [format_table_name("patreon_ranks")] WHERE ckey = :ckey",
list("ckey" = ckey))
if(query_get_rank.warn_execute())
if(query_get_rank.NextRow())
if(query_get_rank.item[1])
owned_rank = query_get_rank.item[1]
if(owned_rank == "UNSUBBED2")
owned_rank = NO_RANK
else
owned_rank = NO_RANK
qdel(query_get_rank)


/datum/patreon_data/proc/assign_access_rank()
switch(owned_rank)
if(AGENT_RANK)
access_rank = ACCESS_AGENT_RANK
if(SENIOR_AGENT_RANK)
access_rank = ACCESS_SENIOR_AGENT_RANK
if(CAPTAIN_RANK)
access_rank = ACCESS_CAPTAIN_RANK

/datum/patreon_data/proc/has_access(rank)
if(!access_rank)
assign_access_rank()
if(rank <= access_rank)
return TRUE
return FALSE

/datum/patreon_data/proc/is_donator()
if((owned_rank == NO_RANK) || !owned_rank || (owned_rank == UNSUBBED))
return FALSE
return TRUE
1 change: 1 addition & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ GLOBAL_PROTECT(admin_verbs_admin)
/client/proc/toggleadminhelpsound,
/client/proc/respawn_character,
/datum/admins/proc/open_borgopanel,
/client/proc/change_patreon_rank,
//LC13 Testing
/client/proc/SpawnAbno,
/client/proc/ClearAbno,
Expand Down
55 changes: 55 additions & 0 deletions code/modules/admin/verbs/patreon_ranks.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/client/proc/change_patreon_rank()
set category = "Admin"
set name = "Change Patreon Rank"
set desc = "Change the Patreon Rank of a ckey"

if(!check_rights(R_ADMIN))
return

if(!SSdbcore.IsConnected())
return

var/change_ckey = input(usr, "Which CKEY to change", "CKEY?", null) as null|text

if(isnull(change_ckey) || length(change_ckey) <= 0)
return

var/change_rank = input(usr, "Please select the rank to change to", "Rank?", null) as null|anything in GLOB.patreon_ranks

if(isnull(change_rank))
return

var/datum/db_query/query_has_patreon_rank = SSdbcore.NewQuery(
"SELECT 1 FROM [format_table_name("patreon_ranks")] WHERE ckey = :change_ckey",
list("change_ckey" = change_ckey)
)

if(!query_has_patreon_rank.warn_execute())
qdel(query_has_patreon_rank)
return
if(!query_has_patreon_rank.NextRow())
// No entry found, inserting
QDEL_NULL(query_has_patreon_rank)
var/datum/db_query/query_add_rank = SSdbcore.NewQuery({"
INSERT INTO [format_table_name("patreon_ranks")] (ckey, patreon_key, patreon_rank)
VALUES (:change_ckey, 'DUMMYKEY', :change_rank)
"}, list("change_ckey" = change_ckey, "change_rank" = change_rank))

if(!query_add_rank.warn_execute())
qdel(query_add_rank)
return
qdel(query_add_rank)
else
qdel(query_has_patreon_rank)
// Entry found, updating
var/datum/db_query/query_change_rank = SSdbcore.NewQuery(
"UPDATE [format_table_name("patreon_ranks")] SET patreon_rank = :change_rank WHERE ckey = :change_ckey",
list("change_rank" = change_rank, "change_ckey" = change_ckey)
)

if(!query_change_rank.warn_execute())
qdel(query_change_rank)
return
qdel(query_change_rank)

message_admins("Patreon rank of ckey [change_ckey] changed to [change_rank]")
2 changes: 2 additions & 0 deletions code/modules/mob/login.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
SEND_SIGNAL(src, COMSIG_MOB_CLIENT_LOGIN, client)
client.init_verbs()

client.patreon = new(client)

return TRUE


Expand Down
3 changes: 3 additions & 0 deletions lobotomy-corp13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
#include "code\__DEFINES\dcs\signals.dm"
#include "code\__DEFINES\dcs\signals_fish.dm"
#include "code\__DEFINES\research\anomalies.dm"
#include "code\__DEFINES\~lobotomy_defines\_patreon.dm"
#include "code\__DEFINES\~lobotomy_defines\adventure.dm"
#include "code\__DEFINES\~lobotomy_defines\is_helpers.dm"
#include "code\__DEFINES\~lobotomy_defines\weapon.dm"
Expand Down Expand Up @@ -416,6 +417,7 @@
#include "code\datums\mutable_appearance.dm"
#include "code\datums\numbered_display.dm"
#include "code\datums\outfit.dm"
#include "code\datums\patreon_data.dm"
#include "code\datums\position_point_vector.dm"
#include "code\datums\profiling.dm"
#include "code\datums\progressbar.dm"
Expand Down Expand Up @@ -1626,6 +1628,7 @@
#include "code\modules\admin\verbs\one_click_antag.dm"
#include "code\modules\admin\verbs\onlyone.dm"
#include "code\modules\admin\verbs\panicbunker.dm"
#include "code\modules\admin\verbs\patreon_ranks.dm"
#include "code\modules\admin\verbs\playsound.dm"
#include "code\modules\admin\verbs\possess.dm"
#include "code\modules\admin\verbs\pray.dm"
Expand Down

0 comments on commit a317120

Please sign in to comment.