-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Patreon Rank system, bump Schema (#2587)
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
Showing
8 changed files
with
868 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters