From 284114251c4fa1e336a34691fa708ffede15934f Mon Sep 17 00:00:00 2001 From: forest2001 Date: Sun, 29 Sep 2024 20:50:48 +0100 Subject: [PATCH 01/22] test --- code/modules/clans/clan_tgui.dm | 96 ++++++ colonialmarines.dme | 1 + tgui/packages/tgui/interfaces/YautjaClans.jsx | 292 ++++++++++++++++++ 3 files changed, 389 insertions(+) create mode 100644 code/modules/clans/clan_tgui.dm create mode 100644 tgui/packages/tgui/interfaces/YautjaClans.jsx diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm new file mode 100644 index 000000000000..406b3b9e6e1d --- /dev/null +++ b/code/modules/clans/clan_tgui.dm @@ -0,0 +1,96 @@ +/datum/yautja_panel + var/viewed_player = list() + var/current_menu = "view_clans" + var/user_rights = 0 + var/target_rights = 0 + var/new_rights = 0 + +/client + var/datum/yautja_panel/yautja_panel + +/client/verb/yautja_panel() + set name = "Yautja Clan Panel" + set category = "OOC.Records" + + if(yautja_panel) + qdel(yautja_panel) + yautja_panel = new + yautja_panel.tgui_interact(mob) + +/datum/yautja_panel/tgui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "YautjaClans", "Yautja Clan Panel") + ui.open() + +/datum/yautja_panel/ui_state(mob/user) + return GLOB.always_state + +/datum/yautja_panel/ui_close(mob/user) + . = ..() + if(user?.client.yautja_panel) + qdel(user.client.yautja_panel) + +/datum/yautja_panel/vv_edit_var(var_name, var_value) + return FALSE + +/datum/yautja_panel/ui_data(mob/user) + var/list/data = list() + + data["current_menu"] = current_menu + + return data + +/datum/yautja_panel/ui_static_data() + var/list/data = list() + data["clans"] = list() + + var/list/datum/view_record/clan_view/clan_list = DB_VIEW(/datum/view_record/clan_view/) + for(var/datum/view_record/clan_view/viewed_clan in clan_list) + data["clans"] += list(populate_clan("[viewed_clan.name]", viewed_clan.clan_id)) + + return data + +/datum/yautja_panel/proc/populate_clan(clan_name, clan_to_format) + var/list/data = list() + + var/datum/entity/clan/formatting_clan + var/list/datum/view_record/clan_playerbase_view/clan_view + + if(clan_to_format) + formatting_clan = GET_CLAN(clan_to_format) + formatting_clan.sync() + clan_view = DB_VIEW(/datum/view_record/clan_playerbase_view, DB_COMP("clan_id", DB_EQUALS, clan_to_format)) + else + clan_view = DB_VIEW(/datum/view_record/clan_playerbase_view, DB_COMP("clan_id", DB_IS, clan_to_format)) + + var/list/formatted_clan = list() + for(var/datum/view_record/clan_playerbase_view/CP in clan_view) + var/yautja = list() + yautja["ckey"] = CP.ckey + yautja["player_id"] = CP.player_id + yautja["rank"] = GLOB.clan_ranks[CP.clan_rank] + yautja["honor_amount"] = (CP.honor? CP.honor : 0) + //yautja["rank_pos"] = rank_to_give + formatted_clan += list(yautja) + + data["label"] = clan_name + data["clan"] = formatted_clan + + return data + +/datum/yautja_panel/ui_act(action, params) + . = ..() + if(.) + return + + switch (action) + if ("set_menu") + current_menu = params["new_menu"] + + if ("main_menu") + current_menu = "main" + + if ("view_clans") + current_menu = "view_clans" + return TRUE diff --git a/colonialmarines.dme b/colonialmarines.dme index 7af974d6c715..b315e0cdcd0e 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -1540,6 +1540,7 @@ #include "code\modules\character_traits\robotic_limbs.dm" #include "code\modules\character_traits\skills.dm" #include "code\modules\clans\clan.dm" +#include "code\modules\clans\clan_tgui.dm" #include "code\modules\clans\client.dm" #include "code\modules\clans\rank.dm" #include "code\modules\clans\ship.dm" diff --git a/tgui/packages/tgui/interfaces/YautjaClans.jsx b/tgui/packages/tgui/interfaces/YautjaClans.jsx new file mode 100644 index 000000000000..17779b590807 --- /dev/null +++ b/tgui/packages/tgui/interfaces/YautjaClans.jsx @@ -0,0 +1,292 @@ +import { useState } from 'react'; + +import { useBackend } from '../backend'; +import { Box, Button, Flex, LabeledList, Section, Tabs } from '../components'; +import { Window } from '../layouts'; + +const PAGES = { + main: () => MainMenu, + view_clans: () => ViewClans, +}; + +export const YautjaClans = (props) => { + const { data } = useBackend(); + const { current_menu } = data; + const PageComponent = PAGES[current_menu](); + + return ( + + + + + + ); +}; + +const MainMenu = (props) => { + const { act } = useBackend(); + + return ( + + Jurisdictional Automated System + + WY-DOS Executive + + Version 5.8.4 + Copyright © 2182, Weyland Yutani Corp. + + + + OR + + + scan an existing report + + + ); +}; + +const ViewClans = (props) => { + const { data, act } = useBackend(); + const { clans } = data; + const [selectedClan, setSelectedClan] = useState(0); + + return ( +
+ + {clans.map((category, i) => ( + setSelectedClan(i)} + > + {category.label} + + ))} + + +
+ {clans[selectedClan].clan.map((yautja, i) => ( +
+ + {yautja.name} + {yautja.rank} + + + {yautja.honor_amount} + + + +
+ ))} +
+
+ ); +}; + +const Charges = (props) => { + const { data, act } = useBackend(); + const { current_charges } = data; + + return ( +
+ + {!!current_charges.length && ( + + + Charge + + + Description + + + Extra + + + )} + {current_charges.map((charge, i) => { + return ( + + + {charge.name} + + + {charge.desc} + + + {charge.special_punishment} + + + + + +
+ ); +}; + +const Evidence = (props) => { + const { data, act } = useBackend(); + const { witnesses, evidence } = data; + + return ( +
+ + {/* Witnesses */} + + {witnesses.map((witness, i) => ( + + + + {witness.name} + + + {witness.notes} + + + + + + + {/* Objects */} + + {evidence.map((evidence, i) => ( + + + + {evidence.name} + + + {evidence.notes} + + + + + + +
+ ); +}; From 6f0a97d063abeb2610071077a73302708e5ee92b Mon Sep 17 00:00:00 2001 From: forest2001 Date: Sun, 29 Sep 2024 20:54:40 +0100 Subject: [PATCH 02/22] clean up x --- tgui/packages/tgui/interfaces/YautjaClans.jsx | 231 +----------------- 1 file changed, 1 insertion(+), 230 deletions(-) diff --git a/tgui/packages/tgui/interfaces/YautjaClans.jsx b/tgui/packages/tgui/interfaces/YautjaClans.jsx index 17779b590807..a36a4f21a792 100644 --- a/tgui/packages/tgui/interfaces/YautjaClans.jsx +++ b/tgui/packages/tgui/interfaces/YautjaClans.jsx @@ -1,11 +1,10 @@ import { useState } from 'react'; import { useBackend } from '../backend'; -import { Box, Button, Flex, LabeledList, Section, Tabs } from '../components'; +import { Button, LabeledList, Section, Tabs } from '../components'; import { Window } from '../layouts'; const PAGES = { - main: () => MainMenu, view_clans: () => ViewClans, }; @@ -23,47 +22,6 @@ export const YautjaClans = (props) => { ); }; -const MainMenu = (props) => { - const { act } = useBackend(); - - return ( - - Jurisdictional Automated System - - WY-DOS Executive - - Version 5.8.4 - Copyright © 2182, Weyland Yutani Corp. - - - - OR - - - scan an existing report - - - ); -}; - const ViewClans = (props) => { const { data, act } = useBackend(); const { clans } = data; @@ -103,190 +61,3 @@ const ViewClans = (props) => { ); }; - -const Charges = (props) => { - const { data, act } = useBackend(); - const { current_charges } = data; - - return ( -
- - {!!current_charges.length && ( - - - Charge - - - Description - - - Extra - - - )} - {current_charges.map((charge, i) => { - return ( - - - {charge.name} - - - {charge.desc} - - - {charge.special_punishment} - - - - - -
- ); -}; - -const Evidence = (props) => { - const { data, act } = useBackend(); - const { witnesses, evidence } = data; - - return ( -
- - {/* Witnesses */} - - {witnesses.map((witness, i) => ( - - - - {witness.name} - - - {witness.notes} - - - - - - - {/* Objects */} - - {evidence.map((evidence, i) => ( - - - - {evidence.name} - - - {evidence.notes} - - - - - - -
- ); -}; From 544c0b842f2e8416a0beb29ae5da29af5f699e71 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Mon, 30 Sep 2024 01:49:54 +0100 Subject: [PATCH 03/22] Working? --- code/__DEFINES/clans.dm | 6 ++- code/datums/entities/clans.dm | 6 ++- code/modules/clans/clan_tgui.dm | 42 ++++++++++++---- code/modules/clans/client.dm | 2 + tgui/packages/tgui/interfaces/YautjaClans.jsx | 49 ++++++++++++------- 5 files changed, 74 insertions(+), 31 deletions(-) diff --git a/code/__DEFINES/clans.dm b/code/__DEFINES/clans.dm index 576bbf6b76d5..d4d6c44dcad1 100644 --- a/code/__DEFINES/clans.dm +++ b/code/__DEFINES/clans.dm @@ -41,8 +41,10 @@ #define CLAN_RANK_BLOODED_INT 3 #define CLAN_RANK_ELITE_INT 4 #define CLAN_RANK_ELDER_INT 5 -#define CLAN_RANK_LEADER_INT 6 -#define CLAN_RANK_ADMIN_INT 7 +#define CLAN_RANK_COUNCIL_INT 6 +#define CLAN_RANK_LEADER_INT 7 +#define CLAN_RANK_ADMIN_INT 8 +#define CLAN_RANK_SUPERADMIN_INT 10 /// Hard limit #define CLAN_LIMIT_NUMBER 1 diff --git a/code/datums/entities/clans.dm b/code/datums/entities/clans.dm index 916afd18c178..0636ea73c75d 100644 --- a/code/datums/entities/clans.dm +++ b/code/datums/entities/clans.dm @@ -5,6 +5,7 @@ var/clan_id var/honor + var/player_name /datum/entity/clan var/name @@ -40,6 +41,7 @@ BSQL_PROTECT_DATUM(/datum/entity/clan) "permissions" = DB_FIELDTYPE_BIGINT, "clan_id" = DB_FIELDTYPE_BIGINT, "honor" = DB_FIELDTYPE_BIGINT, + "player_name" = DB_FIELDTYPE_STRING_MEDIUM ) key_field = "player_id" @@ -76,6 +78,7 @@ BSQL_PROTECT_DATUM(/datum/entity/clan) var/permissions var/clan_name var/honor + var/player_name /datum/entity_view_meta/clan_players_view root_record_type = /datum/entity/clan_player @@ -88,7 +91,8 @@ BSQL_PROTECT_DATUM(/datum/entity/clan) "honor", "clan_player_id" = "id", "clan_name" = "clan.name", - "ckey" = "player.ckey" + "ckey" = "player.ckey", + "player_name", ) order_by = list("clan_rank" = DB_ORDER_BY_DESC) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index 406b3b9e6e1d..60d7ee9742bc 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -1,9 +1,11 @@ /datum/yautja_panel - var/viewed_player = list() + var/client/linked_client var/current_menu = "view_clans" var/user_rights = 0 - var/target_rights = 0 - var/new_rights = 0 + +/datum/yautja_panel/New(client/origin_client) + . = ..() + linked_client = origin_client /client var/datum/yautja_panel/yautja_panel @@ -12,9 +14,12 @@ set name = "Yautja Clan Panel" set category = "OOC.Records" + if(!check_whitelist_status(WHITELIST_PREDATOR)) + return FALSE + if(yautja_panel) qdel(yautja_panel) - yautja_panel = new + yautja_panel = new(src) yautja_panel.tgui_interact(mob) /datum/yautja_panel/tgui_interact(mob/user, datum/tgui/ui) @@ -56,26 +61,43 @@ var/datum/entity/clan/formatting_clan var/list/datum/view_record/clan_playerbase_view/clan_view - + var/clan_desc = "This is a list of players without a clan" if(clan_to_format) formatting_clan = GET_CLAN(clan_to_format) formatting_clan.sync() + clan_desc = html_encode(formatting_clan.description) clan_view = DB_VIEW(/datum/view_record/clan_playerbase_view, DB_COMP("clan_id", DB_EQUALS, clan_to_format)) else - clan_view = DB_VIEW(/datum/view_record/clan_playerbase_view, DB_COMP("clan_id", DB_IS, clan_to_format)) + clan_view = DB_VIEW(/datum/view_record/clan_playerbase_view, DB_COMP("clan_id", DB_IS, null)) - var/list/formatted_clan = list() + var/list/members_list = list() for(var/datum/view_record/clan_playerbase_view/CP in clan_view) + var/rank_to_give = CP.clan_rank + if(CP.permissions & CLAN_PERMISSION_ADMIN_MANAGER) + rank_to_give = 999 + var/yautja = list() yautja["ckey"] = CP.ckey + yautja["label"] = CP.ckey + yautja["name"] = CP.player_name yautja["player_id"] = CP.player_id yautja["rank"] = GLOB.clan_ranks[CP.clan_rank] yautja["honor_amount"] = (CP.honor? CP.honor : 0) - //yautja["rank_pos"] = rank_to_give - formatted_clan += list(yautja) + yautja["rank_pos"] = rank_to_give + + var/datum/entity/player/player = get_player_from_key(CP.ckey) + if(player.check_whitelist_status(WHITELIST_YAUTJA_COUNCIL)) + yautja["label"] = "[CP.ckey] (COUNCILLOR)" + + members_list += list(yautja) data["label"] = clan_name - data["clan"] = formatted_clan + data["desc"] = clan_desc + data["color"] = formatting_clan?.color + data["honor"] = (formatting_clan?.honor? formatting_clan.honor : 0) + data["members"] = members_list + if(clan_to_format) + data["clan_id"] = clan_to_format return data diff --git a/code/modules/clans/client.dm b/code/modules/clans/client.dm index b31a2c06f9c9..f23c81a136c9 100644 --- a/code/modules/clans/client.dm +++ b/code/modules/clans/client.dm @@ -15,6 +15,8 @@ else clan_info.permissions &= ~CLAN_PERMISSION_ADMIN_MANAGER // Only the leader can manage the ancients + clan_info.player_name = prefs.predator_name + clan_info.save() /client/proc/usr_create_new_clan() diff --git a/tgui/packages/tgui/interfaces/YautjaClans.jsx b/tgui/packages/tgui/interfaces/YautjaClans.jsx index a36a4f21a792..eecf9d7af51e 100644 --- a/tgui/packages/tgui/interfaces/YautjaClans.jsx +++ b/tgui/packages/tgui/interfaces/YautjaClans.jsx @@ -1,7 +1,7 @@ import { useState } from 'react'; import { useBackend } from '../backend'; -import { Button, LabeledList, Section, Tabs } from '../components'; +import { Box, Button, LabeledList, Section, Tabs } from '../components'; import { Window } from '../layouts'; const PAGES = { @@ -40,24 +40,37 @@ const ViewClans = (props) => { ))} - -
- {clans[selectedClan].clan.map((yautja, i) => ( -
- - {yautja.name} - {yautja.rank} - - - {yautja.honor_amount} - - - -
- ))} +
+

{clans[selectedClan].label}

+

Total Honor: {clans[selectedClan].honor}

+ + {clans[selectedClan].desc} +
+ {clans[selectedClan].members.map((yautja, i) => ( +
+ + {yautja.name} + {yautja.rank} + None + + {yautja.honor_amount} + + + + + + +
+ ))}
); }; From 60b35a846bb18852809129cc7e1f5a65468664d3 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Mon, 30 Sep 2024 02:03:42 +0100 Subject: [PATCH 04/22] fix --- code/__DEFINES/clans.dm | 5 ++--- code/modules/clans/clan_tgui.dm | 13 ++++++------- tgui/packages/tgui/interfaces/YautjaClans.jsx | 8 ++++---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/code/__DEFINES/clans.dm b/code/__DEFINES/clans.dm index d4d6c44dcad1..9253bd561a9d 100644 --- a/code/__DEFINES/clans.dm +++ b/code/__DEFINES/clans.dm @@ -41,9 +41,8 @@ #define CLAN_RANK_BLOODED_INT 3 #define CLAN_RANK_ELITE_INT 4 #define CLAN_RANK_ELDER_INT 5 -#define CLAN_RANK_COUNCIL_INT 6 -#define CLAN_RANK_LEADER_INT 7 -#define CLAN_RANK_ADMIN_INT 8 +#define CLAN_RANK_LEADER_INT 6 +#define CLAN_RANK_ADMIN_INT 7 #define CLAN_RANK_SUPERADMIN_INT 10 /// Hard limit diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index 60d7ee9742bc..af4d852e9004 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -50,6 +50,7 @@ var/list/data = list() data["clans"] = list() + data["clans"] += list(populate_clan("Clanless", null)) var/list/datum/view_record/clan_view/clan_list = DB_VIEW(/datum/view_record/clan_view/) for(var/datum/view_record/clan_view/viewed_clan in clan_list) data["clans"] += list(populate_clan("[viewed_clan.name]", viewed_clan.clan_id)) @@ -72,22 +73,20 @@ var/list/members_list = list() for(var/datum/view_record/clan_playerbase_view/CP in clan_view) - var/rank_to_give = CP.clan_rank - if(CP.permissions & CLAN_PERMISSION_ADMIN_MANAGER) - rank_to_give = 999 var/yautja = list() yautja["ckey"] = CP.ckey - yautja["label"] = CP.ckey + yautja["player_label"] = CP.ckey yautja["name"] = CP.player_name yautja["player_id"] = CP.player_id yautja["rank"] = GLOB.clan_ranks[CP.clan_rank] yautja["honor_amount"] = (CP.honor? CP.honor : 0) - yautja["rank_pos"] = rank_to_give var/datum/entity/player/player = get_player_from_key(CP.ckey) - if(player.check_whitelist_status(WHITELIST_YAUTJA_COUNCIL)) - yautja["label"] = "[CP.ckey] (COUNCILLOR)" + if(player.check_whitelist_status(WHITELIST_YAUTJA_LEADER)) + yautja["player_label"] = "[CP.ckey] (SENATOR)" + else if(player.check_whitelist_status(WHITELIST_YAUTJA_COUNCIL)) + yautja["player_label"] = "[CP.ckey] (COUNCILLOR)" members_list += list(yautja) diff --git a/tgui/packages/tgui/interfaces/YautjaClans.jsx b/tgui/packages/tgui/interfaces/YautjaClans.jsx index eecf9d7af51e..2fc4d07ca11d 100644 --- a/tgui/packages/tgui/interfaces/YautjaClans.jsx +++ b/tgui/packages/tgui/interfaces/YautjaClans.jsx @@ -48,7 +48,7 @@ const ViewClans = (props) => { {clans[selectedClan].members.map((yautja, i) => ( -
+
{yautja.name} {yautja.rank} @@ -57,13 +57,13 @@ const ViewClans = (props) => { {yautja.honor_amount} - - - - - - + {!user_is_council && ( + <> + + + + )} + {user_is_council && ( + + )} + {user_is_superadmin && ( + + )}
))}
From 3ca8745fc45ce26b8fcff3ad38f1713cd7d31bfc Mon Sep 17 00:00:00 2001 From: forest2001 Date: Sat, 5 Oct 2024 07:13:20 +0100 Subject: [PATCH 14/22] button safeties, non-func move --- code/modules/clans/clan_tgui.dm | 115 ++++++++++++++--- code/modules/clans/client.dm | 4 +- tgui/packages/tgui/interfaces/YautjaClans.jsx | 118 +++++++++++++++--- 3 files changed, 201 insertions(+), 36 deletions(-) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index d36bedb48450..e85e07704d3e 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -1,12 +1,24 @@ /datum/yautja_panel var/client/linked_client var/current_clan_index = 0 + + /// A list of all clan names, in the order they were populated. var/list/clan_name_to_index = list() + /// A list of clan IDs, tied to the order the clan was populated. var/list/clan_index_to_id = list() + + /// The permissions of the panel user. var/user_rights = 0 + /// The ID of the user's clan. var/user_clan_id + + /// The currently selected clan's OD var/current_clan_id + + /// The global data. var/list/global_data + /// Whether an early update of the global data is queued. + var/early_queued = FALSE GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE)) @@ -74,35 +86,92 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if(.) return var/mob/user = ui.user + var/data_reloader = FALSE + + if(action == "change_clan_list") + var/selected_clan = params["selected_clan"] + current_clan_index = GLOB.yautja_clan_data.clan_name_to_index[selected_clan] + current_clan_id = index_to_id(current_clan_index) + return TRUE + + if(!verify_clan_leader(index_to_id(current_clan_index))) + to_chat(user, SPAN_WARNING("You are not authorized to do this.")) + return FALSE + + var/datum/entity/clan_player/target_yautja + var/datum/entity/player/target_player + var/target_ckey + if(params["target_player"]) + target_yautja = GET_CLAN_PLAYER(params["target_player"]) + target_yautja.sync() + + target_player = DB_ENTITY(/datum/entity/player, target_yautja.player_id) + target_player.sync() + target_ckey = target_player.ckey switch (action) - if("change_clan_list") - var/new_clan = params["new_clan"] - current_clan_index = GLOB.yautja_clan_data.clan_name_to_index[new_clan] - current_clan_id = index_to_id(current_clan_index) + + if("clan_name") + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + + if("clan_desc") + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + + if("clan_color") + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) if("change_rank") - if(!verify_clan_leader(index_to_id(current_clan_index))) - to_chat(user, SPAN_WARNING("You are not authorized to do this.")) - return FALSE + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) if("assign_ancillary") - if(!verify_clan_leader(index_to_id(current_clan_index))) + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + + if("kick_from_clan") + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + + if("banish_from_clan") + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + + if("move_to_clan") + if(!verify_council()) to_chat(user, SPAN_WARNING("You are not authorized to do this.")) return FALSE - if("kick_from_clan") - if(!verify_clan_leader(index_to_id(current_clan_index))) + var/new_clan = tgui_input_list(src, "Choose the clan to put them in", "Change player's clan", GLOB.yautja_clan_data.clan_name_to_index) + if(!new_clan) + return FALSE + + target_yautja.clan_id = get_clan_id(new_clan) + + to_chat(src, SPAN_NOTICE("Moved [target_ckey] to [new_clan].")) + message_admins("Yautja Clans: [key_name_admin(src)] has moved [target_ckey] to clan [new_clan] ([target_yautja.clan_id]).") + + if(!(target_yautja.permissions & CLAN_PERMISSION_ADMIN_ANCIENT)) + target_yautja.permissions = GLOB.clan_ranks[CLAN_RANK_BLOODED].permissions + target_yautja.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_BLOODED] + data_reloader = TRUE + + if("delete_player_data") + if(!verify_superadmin()) to_chat(user, SPAN_WARNING("You are not authorized to do this.")) return FALSE + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) - if("banish_from_clan") - if(!verify_clan_leader(index_to_id(current_clan_index))) + if("delete_clan") + if(!verify_superadmin()) to_chat(user, SPAN_WARNING("You are not authorized to do this.")) return FALSE + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + + if(data_reloader) + GLOB.yautja_clan_data.populate_global_clan_data(FALSE) return TRUE +/datum/yautja_panel/proc/get_clan_id(clan_name) + var/index_holder = GLOB.yautja_clan_data.clan_name_to_index[clan_name] + return index_to_id(index_holder) + /datum/yautja_panel/proc/index_to_id(clan_index) var/index_holder = "[clan_index]" return GLOB.yautja_clan_data.clan_index_to_id[index_holder] @@ -110,7 +179,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) /datum/yautja_panel/proc/verify_clan_leader(clan_id) if(user_rights & CLAN_PERMISSION_ADMIN_ANCIENT) return TRUE - if(user_clan_id == clan_id) + if((user_rights & CLAN_PERMISSION_USER_MODIFY) && (user_clan_id == clan_id)) return TRUE return FALSE @@ -124,18 +193,30 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) return TRUE return FALSE -/datum/yautja_panel/proc/populate_global_clan_data(start_timer = FALSE) +/datum/yautja_panel/proc/queue_early_repopulate() + if(early_queued) + return FALSE + + early_queued = TRUE + addtimer(CALLBACK(src, PROC_REF(populate_global_clan_data), FALSE, "early"), 5 MINUTES) + log_debug("Yautja Clan Global Data will early repopulate in 5 minutes.") + return TRUE + +/datum/yautja_panel/proc/populate_global_clan_data(start_timer = FALSE, type = "override") + if(type == "early") + early_queued = FALSE + log_debug("Populating Yautja Clan Global Data.") global_data = populate_clan_data() log_debug("Yautja Clan Global Data has been populated.") if(start_timer) - addtimer(CALLBACK(src, PROC_REF(populate_global_clan_data), TRUE), 30 MINUTES) + addtimer(CALLBACK(src, PROC_REF(populate_global_clan_data), TRUE, "regular"), 30 MINUTES) log_debug("Yautja Clan Global Data will repopulate in 30 minutes.") /datum/yautja_panel/proc/populate_clan_data() clan_name_to_index = list("Clanless" = 0) clan_index_to_id = list("0" = 0) - var/clan_names = list("Clanless") + var/list/clan_names = list("Clanless") var/index = 1 var/list/data = list() data["clans"] = list() @@ -181,6 +262,8 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) yautja["player_label"] = "[CP.ckey] (SENATOR)" else if(player.check_whitelist_status(WHITELIST_YAUTJA_COUNCIL)) yautja["player_label"] = "[CP.ckey] (COUNCILLOR)" + else if(player.check_whitelist_status(WHITELIST_YAUTJA_LEGACY)) + yautja["player_label"] = "[CP.ckey] (LEGACY)" members_list += list(yautja) diff --git a/code/modules/clans/client.dm b/code/modules/clans/client.dm index e13c8ddd9fb4..978f7f58f7eb 100644 --- a/code/modules/clans/client.dm +++ b/code/modules/clans/client.dm @@ -12,8 +12,10 @@ if(check_whitelist_status(WHITELIST_YAUTJA_LEADER)) clan_info.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_ADMIN] clan_info.permissions |= CLAN_PERMISSION_ALL + else if(check_whitelist_status(WHITELIST_YAUTJA_COUNCIL)) + clan_info.permissions |= CLAN_PERMISSION_ADMIN_ANCIENT else - clan_info.permissions &= ~CLAN_PERMISSION_ADMIN_MANAGER // Only the leader can manage the ancients + clan_info.permissions = GLOB.clan_ranks[clan_info.clan_rank].permissions clan_info.player_name = prefs.predator_name diff --git a/tgui/packages/tgui/interfaces/YautjaClans.jsx b/tgui/packages/tgui/interfaces/YautjaClans.jsx index 7c4dfb9238f9..21db6527d7de 100644 --- a/tgui/packages/tgui/interfaces/YautjaClans.jsx +++ b/tgui/packages/tgui/interfaces/YautjaClans.jsx @@ -30,7 +30,9 @@ const ViewClans = (props) => { menuWidth="200px" selected={clans[current_clan_index].label} options={clan_names} - onSelected={(value) => act('change_clan_list', { new_clan: value })} + onSelected={(value) => + act('change_clan_list', { selected_clan: value }) + } />
@@ -38,6 +40,72 @@ const ViewClans = (props) => { {clans[current_clan_index].desc} + {clans[current_clan_index].clan_id && ( + <> + + act('clan_name', { + target_clan: clans[current_clan_index].clan_id, + }) + } + > + Rename Clan + + + act('clan_desc', { + target_clan: clans[current_clan_index].clan_id, + }) + } + > + Change Description + + + act('clan_color', { + target_clan: clans[current_clan_index].clan_id, + }) + } + > + Change Clan Color + + {user_is_superadmin && ( + + act('delete_clan', { + target_clan: clans[current_clan_index].clan_id, + }) + } + > + Delete Clan + + )} + + )}
{clans[current_clan_index].members.map((yautja, i) => (
@@ -46,67 +114,79 @@ const ViewClans = (props) => { {yautja.rank} None - - + {!user_is_council && ( <> - - + )} {user_is_council && ( - + )} {user_is_superadmin && ( - + )}
))} From c1870b93cf0a15eb4b20bc10de283052dcfc5a87 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Sat, 5 Oct 2024 17:04:26 +0100 Subject: [PATCH 15/22] mostly functional --- code/modules/clans/clan_tgui.dm | 156 +++++++++++++++++++++++++++----- 1 file changed, 134 insertions(+), 22 deletions(-) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index e85e07704d3e..a4bc50d107a0 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -68,25 +68,27 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) return FALSE /datum/yautja_panel/ui_data(mob/user) - var/list/data = list() + var/list/data = GLOB.yautja_clan_data.global_data data["current_clan_index"] = current_clan_index - data["user_is_clan_leader"] = verify_clan_leader(current_clan_id) - data["user_is_council"] = verify_council() - data["user_is_superadmin"] = verify_superadmin() return data /datum/yautja_panel/ui_static_data() - return GLOB.yautja_clan_data.global_data + var/list/data = list() + + data["user_is_council"] = verify_council() + data["user_is_superadmin"] = verify_superadmin() + + return data /datum/yautja_panel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) . = ..() if(.) return var/mob/user = ui.user - var/data_reloader = FALSE + var/data_reloader = TRUE if(action == "change_clan_list") var/selected_clan = params["selected_clan"] @@ -94,12 +96,13 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) current_clan_id = index_to_id(current_clan_index) return TRUE - if(!verify_clan_leader(index_to_id(current_clan_index))) + if(!verify_clan_leader(current_clan_id)) to_chat(user, SPAN_WARNING("You are not authorized to do this.")) return FALSE var/datum/entity/clan_player/target_yautja var/datum/entity/player/target_player + var/datum/entity/clan/target_clan var/target_ckey if(params["target_player"]) target_yautja = GET_CLAN_PLAYER(params["target_player"]) @@ -109,47 +112,148 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) target_player.sync() target_ckey = target_player.ckey - switch (action) + if(params["target_clan"]) + target_clan = GET_CLAN(params["target_clan"]) + target_clan.sync() + + switch(action) if("clan_name") - to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + var/input = input(user, "Input the new name", "Set Name", target_clan.name) as text|null + + if(!input || input == target_clan.name) + return + + message_admins("[key_name_admin(user)] has set the name of [target_clan.name] to [input].") + to_chat(user, SPAN_NOTICE("Set the name of [target_clan.name] to [input].")) + target_clan.name = trim(input) if("clan_desc") - to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + var/input = input(user, "Input a new description", "Set Description", target_clan.description) as message|null + + if(!input || input == target_clan.description) + return + + message_admins("[key_name_admin(user)] has set the description of [target_clan.name].") + to_chat(user, SPAN_NOTICE("Set the description of [target_clan.name].")) + target_clan.description = trim(input) + if("clan_color") - to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + data_reloader = FALSE + var/color = input(user, "Input a new color", "Set Color", target_clan.color) as color|null + + if(!color) + return + + target_clan.color = color + message_admins("[key_name_admin(user)] has set the color of [target_clan.name] to [color].") + to_chat(user, SPAN_NOTICE("Set the color of [target_clan.name] to [color].")) if("change_rank") - to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + if((target_yautja.permissions & CLAN_PERMISSION_ADMIN_MANAGER) || linked_client.clan_info.clan_rank <= target_yautja.clan_rank) + to_chat(user, SPAN_WARNING("You can't target this person!")) + return + + var/list/datum/yautja_rank/ranks = GLOB.clan_ranks.Copy() + ranks -= CLAN_RANK_ADMIN // Admin rank should not and cannot be obtained from here + + var/datum/yautja_rank/chosen_rank + if(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY, warn = FALSE)) + var/input = tgui_input_list(user, "Select the rank to change this user to.", "Select Rank", ranks) + + if(!input) + return + + chosen_rank = ranks[input] + + else if(linked_client.has_clan_permission(CLAN_PERMISSION_USER_MODIFY, target_yautja.clan_id)) + for(var/rank in ranks) + if(!linked_client.has_clan_permission(ranks[rank].permission_required, warn = FALSE)) + ranks -= rank + + var/input = tgui_input_list(user, "Select the rank to change this user to.", "Select Rank", ranks) + + if(!input) + return + + chosen_rank = ranks[input] + + if(chosen_rank.limit_type) + var/list/datum/view_record/clan_playerbase_view/CPV = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_AND(DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id), DB_COMP("rank", DB_EQUALS, GLOB.clan_ranks_ordered[input]))) + var/players_in_rank = length(CPV) + + switch(chosen_rank.limit_type) + if(CLAN_LIMIT_NUMBER) + if(players_in_rank >= chosen_rank.limit) + to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_rank.limit] slots)")) + return + if(CLAN_LIMIT_SIZE) + var/list/datum/view_record/clan_playerbase_view/clan_players = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id)) + var/available_slots = ceil(length(clan_players) / chosen_rank.limit) + + if(players_in_rank >= available_slots) + to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_rank.limit] per player in the clan, currently [available_slots])")) + return + else + return // Doesn't have permission to do this + + if(!linked_client.has_clan_permission(chosen_rank.permission_required)) // Double check + return + + target_yautja.clan_rank = GLOB.clan_ranks_ordered[chosen_rank.name] + target_yautja.permissions = chosen_rank.permissions + message_admins("[key_name_admin(user)] has set the rank of [target_ckey] to [chosen_rank.name] for their clan.") + to_chat(user, SPAN_NOTICE("Set [target_ckey]'s rank to [chosen_rank.name]")) if("assign_ancillary") + if((linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + to_chat(user, SPAN_WARNING("You cannot change this player, they are not in your clan!")) + return + data_reloader = FALSE to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) if("kick_from_clan") - to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + if((linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + to_chat(user, SPAN_WARNING("You cannot kick this player, they are not in your clan!")) + return + target_yautja.clan_id = null + target_yautja.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_BLOODED] + + to_chat(user, SPAN_NOTICE("Kicked [target_ckey] from your clan.")) + message_admins("Yautja Clans: [key_name_admin(user)] has kicked [target_ckey] from their clan.") if("banish_from_clan") + if((linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + to_chat(user, SPAN_WARNING("You cannot banish this player, they are not in your clan!")) + return to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + return + /* + target_yautja.clan_id = get_clan_id("The Banished") + target_yautja.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_BLOODED] + + to_chat(user, SPAN_NOTICE("Banished [target_ckey] from your clan.")) + message_admins("Yautja Clans: [key_name_admin(user)] has banished [target_ckey] from their clan.") + */ if("move_to_clan") if(!verify_council()) to_chat(user, SPAN_WARNING("You are not authorized to do this.")) return FALSE - var/new_clan = tgui_input_list(src, "Choose the clan to put them in", "Change player's clan", GLOB.yautja_clan_data.clan_name_to_index) + var/new_clan = tgui_input_list(user, "Choose the clan to put them in", "Change player's clan", GLOB.yautja_clan_data.clan_name_to_index) if(!new_clan) return FALSE target_yautja.clan_id = get_clan_id(new_clan) - to_chat(src, SPAN_NOTICE("Moved [target_ckey] to [new_clan].")) - message_admins("Yautja Clans: [key_name_admin(src)] has moved [target_ckey] to clan [new_clan] ([target_yautja.clan_id]).") + to_chat(user, SPAN_NOTICE("Moved [target_ckey] to [new_clan].")) + message_admins("Yautja Clans: [key_name_admin(user)] has moved [target_ckey] to clan [new_clan] ([target_yautja.clan_id]).") if(!(target_yautja.permissions & CLAN_PERMISSION_ADMIN_ANCIENT)) target_yautja.permissions = GLOB.clan_ranks[CLAN_RANK_BLOODED].permissions target_yautja.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_BLOODED] - data_reloader = TRUE if("delete_player_data") if(!verify_superadmin()) @@ -164,7 +268,15 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) if(data_reloader) - GLOB.yautja_clan_data.populate_global_clan_data(FALSE) + GLOB.yautja_clan_data.queue_early_repopulate() + + + if(target_clan) + target_clan.save() + target_clan.sync() + if(target_yautja) + target_yautja.save() + target_yautja.sync() return TRUE @@ -199,19 +311,19 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) early_queued = TRUE addtimer(CALLBACK(src, PROC_REF(populate_global_clan_data), FALSE, "early"), 5 MINUTES) - log_debug("Yautja Clan Global Data will early repopulate in 5 minutes.") + message_admins("Yautja Clans: Global Data will early repopulate in 5 minutes.") return TRUE /datum/yautja_panel/proc/populate_global_clan_data(start_timer = FALSE, type = "override") if(type == "early") early_queued = FALSE - log_debug("Populating Yautja Clan Global Data.") + message_admins("Yautja Clans: Populating Global Data.") global_data = populate_clan_data() - log_debug("Yautja Clan Global Data has been populated.") + message_admins("Yautja Clans: Global Data has been populated.") if(start_timer) addtimer(CALLBACK(src, PROC_REF(populate_global_clan_data), TRUE, "regular"), 30 MINUTES) - log_debug("Yautja Clan Global Data will repopulate in 30 minutes.") + message_admins("Yautja Clans: Clan Global Data will repopulate in 30 minutes.") /datum/yautja_panel/proc/populate_clan_data() clan_name_to_index = list("Clanless" = 0) From 889fbe1773221cb19cd5eb75ac3cc7ba14ac247e Mon Sep 17 00:00:00 2001 From: forest2001 Date: Sat, 5 Oct 2024 17:39:26 +0100 Subject: [PATCH 16/22] fix --- code/modules/clans/clan_tgui.dm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index a4bc50d107a0..922e60626500 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -73,11 +73,6 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) data["current_clan_index"] = current_clan_index data["user_is_clan_leader"] = verify_clan_leader(current_clan_id) - return data - -/datum/yautja_panel/ui_static_data() - var/list/data = list() - data["user_is_council"] = verify_council() data["user_is_superadmin"] = verify_superadmin() @@ -151,6 +146,9 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) to_chat(user, SPAN_NOTICE("Set the color of [target_clan.name] to [color].")) if("change_rank") + if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + to_chat(user, SPAN_WARNING("You cannot change this player, they are not in your clan!")) + return if((target_yautja.permissions & CLAN_PERMISSION_ADMIN_MANAGER) || linked_client.clan_info.clan_rank <= target_yautja.clan_rank) to_chat(user, SPAN_WARNING("You can't target this person!")) return @@ -207,14 +205,14 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) to_chat(user, SPAN_NOTICE("Set [target_ckey]'s rank to [chosen_rank.name]")) if("assign_ancillary") - if((linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) to_chat(user, SPAN_WARNING("You cannot change this player, they are not in your clan!")) return data_reloader = FALSE to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) if("kick_from_clan") - if((linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) to_chat(user, SPAN_WARNING("You cannot kick this player, they are not in your clan!")) return target_yautja.clan_id = null @@ -224,7 +222,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) message_admins("Yautja Clans: [key_name_admin(user)] has kicked [target_ckey] from their clan.") if("banish_from_clan") - if((linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) to_chat(user, SPAN_WARNING("You cannot banish this player, they are not in your clan!")) return to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) @@ -324,6 +322,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if(start_timer) addtimer(CALLBACK(src, PROC_REF(populate_global_clan_data), TRUE, "regular"), 30 MINUTES) message_admins("Yautja Clans: Clan Global Data will repopulate in 30 minutes.") + return "Populated" /datum/yautja_panel/proc/populate_clan_data() clan_name_to_index = list("Clanless" = 0) From 7c004ba1aaa16042f4c508eb5a464d23fd9a7763 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Tue, 8 Oct 2024 09:08:03 +0100 Subject: [PATCH 17/22] Ancillaries --- code/__DEFINES/clans.dm | 9 ++ code/_globalvars/lists/clans.dm | 10 +++ code/datums/entities/clans.dm | 5 ++ code/modules/clans/clan_tgui.dm | 84 +++++++++++++++++-- code/modules/clans/client.dm | 46 +++++++++- code/modules/clans/rank.dm | 40 +++++++++ nano/templates/clan_menu.tmpl | 2 + tgui/packages/tgui/interfaces/YautjaClans.jsx | 19 +++-- 8 files changed, 195 insertions(+), 20 deletions(-) diff --git a/code/__DEFINES/clans.dm b/code/__DEFINES/clans.dm index 9253bd561a9d..312c6ac5b37a 100644 --- a/code/__DEFINES/clans.dm +++ b/code/__DEFINES/clans.dm @@ -92,3 +92,12 @@ ) #define CLAN_SHIP_PUBLIC -1 + +#define CLAN_ANCILLARY_NONE "None" +#define CLAN_ANCILLARY_ENFORCER "Enforcer" +#define CLAN_ANCILLARY_HOUND_MASTER "Hound Master" +#define CLAN_ANCILLARY_TASK_MASTER "Task Master" +#define CLAN_ANCILLARY_ADJUTANT "Adjutant" +#define CLAN_ANCILLARY_SHAMAN "Shaman" +#define CLAN_ANCILLARY_HIGH_ENFORCER "High Enforcer" +#define CLAN_ANCILLARY_HIGH_SHAMAN "High Shaman" diff --git a/code/_globalvars/lists/clans.dm b/code/_globalvars/lists/clans.dm index f04915a37435..fbccd76e7865 100644 --- a/code/_globalvars/lists/clans.dm +++ b/code/_globalvars/lists/clans.dm @@ -17,3 +17,13 @@ GLOBAL_LIST_INIT(clan_ranks_ordered, list( CLAN_RANK_LEADER = CLAN_RANK_LEADER_INT, CLAN_RANK_ADMIN = CLAN_RANK_ADMIN_INT )) + +GLOBAL_LIST_INIT_TYPED(clan_ancillaries, /datum/yautja_ancillary, list( + CLAN_ANCILLARY_ENFORCER = new /datum/yautja_ancillary/enforcer(), + CLAN_ANCILLARY_ADJUTANT = new /datum/yautja_ancillary/adjutant(), + CLAN_ANCILLARY_HOUND_MASTER = new /datum/yautja_ancillary/hound_master(), + CLAN_ANCILLARY_TASK_MASTER = new /datum/yautja_ancillary/task_master(), + CLAN_ANCILLARY_SHAMAN = new /datum/yautja_ancillary/shaman(), + CLAN_ANCILLARY_HIGH_ENFORCER = new /datum/yautja_ancillary/high_enforcer(), + CLAN_ANCILLARY_HIGH_SHAMAN = new /datum/yautja_ancillary/high_shaman() +)) diff --git a/code/datums/entities/clans.dm b/code/datums/entities/clans.dm index e5676ba1b1d5..076a24fd371a 100644 --- a/code/datums/entities/clans.dm +++ b/code/datums/entities/clans.dm @@ -6,6 +6,7 @@ var/honor var/player_name + var/clan_ancillary /datum/entity/clan var/name @@ -42,12 +43,14 @@ BSQL_PROTECT_DATUM(/datum/entity/clan) "clan_id" = DB_FIELDTYPE_BIGINT, "honor" = DB_FIELDTYPE_BIGINT, "player_name" = DB_FIELDTYPE_STRING_MEDIUM, + "clan_ancillary" = DB_FIELDTYPE_STRING_MEDIUM, ) key_field = "player_id" /datum/entity_meta/clan_player/on_insert(datum/entity/clan_player/player) player.honor = 0 player.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_UNBLOODED] + player.clan_ancillary = CLAN_ANCILLARY_NONE player.permissions = GLOB.clan_ranks[CLAN_RANK_UNBLOODED].permissions player.save() @@ -79,6 +82,7 @@ BSQL_PROTECT_DATUM(/datum/entity/clan) var/clan_name var/honor var/player_name + var/clan_ancillary /datum/entity_view_meta/clan_players_view root_record_type = /datum/entity/clan_player @@ -93,6 +97,7 @@ BSQL_PROTECT_DATUM(/datum/entity/clan) "clan_name" = "clan.name", "ckey" = "player.ckey", "player_name", + "clan_ancillary", ) order_by = list("clan_rank" = DB_ORDER_BY_DESC) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index 922e60626500..683728813b82 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -11,6 +11,8 @@ var/user_rights = 0 /// The ID of the user's clan. var/user_clan_id + /// The rank held within the user's clan. + var/user_clan_rank /// The currently selected clan's OD var/current_clan_id @@ -28,6 +30,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) linked_client = origin_client user_rights = linked_client.clan_info.permissions user_clan_id = linked_client.clan_info.clan_id + user_clan_rank = linked_client.clan_info.clan_rank if(init_global) addtimer(CALLBACK(src, PROC_REF(populate_global_clan_data), TRUE), 30 SECONDS) @@ -72,6 +75,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) data["current_clan_index"] = current_clan_index data["user_is_clan_leader"] = verify_clan_leader(current_clan_id) + data["user_is_clan_elder"] = verify_clan_elder(current_clan_id) data["user_is_council"] = verify_council() data["user_is_superadmin"] = verify_superadmin() @@ -132,6 +136,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) message_admins("[key_name_admin(user)] has set the description of [target_clan.name].") to_chat(user, SPAN_NOTICE("Set the description of [target_clan.name].")) target_clan.description = trim(input) + data_reloader = FALSE if("clan_color") @@ -208,8 +213,60 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) to_chat(user, SPAN_WARNING("You cannot change this player, they are not in your clan!")) return - data_reloader = FALSE - to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + + var/list/datum/yautja_ancillary/ancillaries = GLOB.clan_ancillaries.Copy() + var/datum/yautja_ancillary/chosen_ancillary + if(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY, warn = FALSE)) + var/input = tgui_input_list(user, "Select the ancillary to change this user to.", "Select Ancillary", ancillaries) + + if(!input) + return + + chosen_ancillary = ancillaries[input] + + else if(linked_client.has_clan_position(CLAN_RANK_ELDER, target_yautja.clan_id)) + for(var/ancillary in ancillaries) + if(!linked_client.has_clan_position(ancillaries[ancillary].granter_title_required, warn = FALSE)) + ancillaries -= ancillary + if(!target_yautja.can_be_ancillary(ancillaries[ancillary].target_rank_required, current_clan_id)) + ancillaries -= ancillary + + if(!ancillaries.len) + to_chat(user, SPAN_WARNING("No possible ancillaries to grant!")) + return + + var/input = tgui_input_list(user, "Select the ancillary to change this user to.", "Select Ancillary", ancillaries) + + if(!input) + return + + chosen_ancillary = ancillaries[input] + + if(chosen_ancillary.limit_type) + var/list/datum/view_record/clan_playerbase_view/CPV = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_AND(DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id), DB_COMP("rank", DB_EQUALS, GLOB.clan_ranks_ordered[input]))) + var/players_in_rank = length(CPV) + + switch(chosen_ancillary.limit_type) + if(CLAN_LIMIT_NUMBER) + if(players_in_rank >= chosen_ancillary.limit) + to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_ancillary.limit] slots)")) + return + if(CLAN_LIMIT_SIZE) + var/list/datum/view_record/clan_playerbase_view/clan_players = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id)) + var/available_slots = ceil(length(clan_players) / chosen_ancillary.limit) + + if(players_in_rank >= available_slots) + to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_ancillary.limit] per player in the clan, currently [available_slots])")) + return + else + return // Doesn't have permission to do this + + if(!linked_client.has_clan_position(chosen_ancillary.granter_title_required, target_yautja.clan_id)) // Double check + return + + target_yautja.clan_ancillary = chosen_ancillary.name + message_admins("[key_name_admin(user)] has set the ancillary title of [target_ckey] to [chosen_ancillary.name] for their clan.") + to_chat(user, SPAN_NOTICE("Set [target_ckey]'s ancillary title to [chosen_ancillary.name]")) if("kick_from_clan") if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) @@ -225,15 +282,15 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) to_chat(user, SPAN_WARNING("You cannot banish this player, they are not in your clan!")) return - to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) - return - /* + var/reason = tgui_input_text(user, "Why do you wish to Banish this Yautja?", "Reason") + if(!reason) + return + target_yautja.clan_id = get_clan_id("The Banished") target_yautja.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_BLOODED] - to_chat(user, SPAN_NOTICE("Banished [target_ckey] from your clan.")) - message_admins("Yautja Clans: [key_name_admin(user)] has banished [target_ckey] from their clan.") - */ + to_chat(user, SPAN_NOTICE("You have banished [target_ckey] from your clan.")) + message_admins("Yautja Clans: [key_name_admin(user)] has banished [target_ckey] from their clan for '[reason]'.") if("move_to_clan") if(!verify_council()) @@ -267,7 +324,8 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if(data_reloader) GLOB.yautja_clan_data.queue_early_repopulate() - + else + to_chat(user, SPAN_WARNING("The UI data will not be reloaded for this change, updates happen automatically every 30 minutes.")) if(target_clan) target_clan.save() @@ -293,6 +351,13 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) return TRUE return FALSE +/datum/yautja_panel/proc/verify_clan_elder(clan_id) + if(verify_clan_leader(clan_id)) + return TRUE + if(user_clan_rank >= CLAN_RANK_ELDER_INT) + return TRUE + return FALSE + /datum/yautja_panel/proc/verify_council() if(user_rights & CLAN_PERMISSION_ADMIN_ANCIENT) return TRUE @@ -367,6 +432,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) yautja["name"] = (CP.player_name? CP.player_name : "No Data") yautja["player_id"] = CP.player_id yautja["rank"] = GLOB.clan_ranks[CP.clan_rank] + yautja["ancillary"] = (CP.clan_ancillary? CP.clan_ancillary : "None") var/datum/entity/player/player = get_player_from_key(CP.ckey) if(player.check_whitelist_status(WHITELIST_YAUTJA_LEADER)) diff --git a/code/modules/clans/client.dm b/code/modules/clans/client.dm index 978f7f58f7eb..1dc8f0c13192 100644 --- a/code/modules/clans/client.dm +++ b/code/modules/clans/client.dm @@ -162,6 +162,7 @@ player_id = CP.player_id, name = CP.ckey, rank = GLOB.clan_ranks[CP.clan_rank], // rank_to_give not used here, because we need to get their visual rank, not their position + ancillary = CP.clan_ancillary, rank_pos = rank_to_give, honor = (CP.honor? CP.honor : 0) ) @@ -177,16 +178,33 @@ ui.set_auto_update(FALSE) ui.open() -/client/proc/has_clan_permission(permission_flag, clan_id, warn) +/client/proc/is_yautja_ancient(query_permissions) + if(query_permissions) + if(query_permissions & CLAN_PERMISSION_ADMIN_ANCIENT) + return TRUE + return FALSE + if(clan_info?.permissions & CLAN_PERMISSION_ADMIN_ANCIENT) + return TRUE + return FALSE + +/client/proc/is_authorized_clan_member(clan_id, warn) if(!clan_info) - if(warn) to_chat(src, "You do not have a yautja whitelist!") + if(warn) + to_chat(src, "You do not have a yautja whitelist!") return FALSE if(clan_id) + if(is_yautja_ancient()) + return TRUE if(clan_id != clan_info.clan_id) - if(warn) to_chat(src, "You do not have permission to perform actions on this clan!") + if(warn) + to_chat(src, "You do not have permission to perform actions on this clan!") return FALSE + return TRUE +/client/proc/has_clan_permission(permission_flag, clan_id, warn) + if(!is_authorized_clan_member(clan_id, warn)) + return FALSE if(!(clan_info.permissions & permission_flag)) if(warn) to_chat(src, "You do not have the necessary permissions to perform this action!") @@ -194,6 +212,28 @@ return TRUE +/client/proc/has_clan_position(needed_position, clan_id, warn) + if(!is_authorized_clan_member(clan_id, warn)) + return FALSE + + if(is_yautja_ancient() || (clan_info.clan_rank >= CLAN_RANK_LEADER_INT)) + return TRUE + if(clan_info.clan_ancillary != needed_position) + if(warn) + to_chat(src, "You do not have the necessary permissions to perform this action!") + return FALSE + + return TRUE + +/datum/entity/clan_player/proc/can_be_ancillary(required_rank, needed_clan_id) + if(needed_clan_id != clan_id) + return FALSE + + var/needed_num = GLOB.clan_ranks_ordered[required_rank] + if(clan_rank < needed_num) + return FALSE + return TRUE + /client/proc/add_honor(number) if(!clan_info) return FALSE diff --git a/code/modules/clans/rank.dm b/code/modules/clans/rank.dm index a6b78a0d95e9..58c99004d947 100644 --- a/code/modules/clans/rank.dm +++ b/code/modules/clans/rank.dm @@ -42,3 +42,43 @@ permission_required = CLAN_PERMISSION_ADMIN_MANAGER permissions = CLAN_PERMISSION_ADMIN_ANCIENT + + + +/datum/yautja_ancillary + var/name + + var/limit_type = CLAN_LIMIT_SIZE + var/limit = 5 + + var/granter_title_required = CLAN_RANK_LEADER + var/target_rank_required = CLAN_RANK_ELITE + +/datum/yautja_ancillary/high_enforcer + name = CLAN_ANCILLARY_HIGH_ENFORCER + target_rank_required = CLAN_RANK_ELDER + limit_type = CLAN_LIMIT_NUMBER + limit = 1 + +/datum/yautja_ancillary/enforcer + name = CLAN_ANCILLARY_ENFORCER + granter_title_required = CLAN_ANCILLARY_HIGH_ENFORCER + +/datum/yautja_ancillary/high_shaman + name = CLAN_ANCILLARY_HIGH_SHAMAN + target_rank_required = CLAN_RANK_ELDER + limit_type = CLAN_LIMIT_NUMBER + limit = 1 + +/datum/yautja_ancillary/shaman + name = CLAN_ANCILLARY_SHAMAN + granter_title_required = CLAN_ANCILLARY_HIGH_SHAMAN + +/datum/yautja_ancillary/adjutant + name = CLAN_ANCILLARY_ADJUTANT + +/datum/yautja_ancillary/hound_master + name = CLAN_ANCILLARY_HOUND_MASTER + +/datum/yautja_ancillary/task_master + name = CLAN_ANCILLARY_TASK_MASTER diff --git a/nano/templates/clan_menu.tmpl b/nano/templates/clan_menu.tmpl index cd987e9079f6..09161f56e16b 100644 --- a/nano/templates/clan_menu.tmpl +++ b/nano/templates/clan_menu.tmpl @@ -108,6 +108,7 @@ Name Rank + Ancillary {{if data.player_modify_ranks}} {{/if}} @@ -124,6 +125,7 @@ {{:keys.name}} {{:keys.rank}} + {{:keys.ancillary}} {{if data.player_rank_pos > keys.rank_pos}} {{if data.player_modify_ranks}}
{{:helper.link('Set Rank', '', { 'clan_target_href' : keys.player_id, 'clan_action': 'modifyrank' })}}
diff --git a/tgui/packages/tgui/interfaces/YautjaClans.jsx b/tgui/packages/tgui/interfaces/YautjaClans.jsx index 21db6527d7de..e4faaf82f341 100644 --- a/tgui/packages/tgui/interfaces/YautjaClans.jsx +++ b/tgui/packages/tgui/interfaces/YautjaClans.jsx @@ -19,6 +19,7 @@ const ViewClans = (props) => { clan_names, current_clan_index, user_is_clan_leader, + user_is_clan_elder, user_is_council, user_is_superadmin, } = data; @@ -112,18 +113,20 @@ const ViewClans = (props) => { {yautja.name} {yautja.rank} - None + + {yautja.ancillary} + - act('change_rank', { target_player: yautja.player_id }) + act('assign_ancillary', { target_player: yautja.player_id }) } > - Change Rank + Assign Ancillary { width="23vw" disabled={!user_is_clan_leader} onClick={() => - act('assign_ancillary', { target_player: yautja.player_id }) + act('change_rank', { target_player: yautja.player_id }) } > - Assign Ancillary + Change Rank {!user_is_council && ( <> @@ -162,7 +165,7 @@ const ViewClans = (props) => { )} - {user_is_council && ( + {!!user_is_council && ( { Change Clan )} - {user_is_superadmin && ( + {!!user_is_superadmin && ( Date: Tue, 8 Oct 2024 10:10:48 +0100 Subject: [PATCH 18/22] t --- code/_globalvars/lists/clans.dm | 3 +- code/modules/clans/clan_tgui.dm | 140 ++++++++++-------- code/modules/clans/rank.dm | 5 + tgui/packages/tgui/interfaces/YautjaClans.jsx | 2 +- 4 files changed, 84 insertions(+), 66 deletions(-) diff --git a/code/_globalvars/lists/clans.dm b/code/_globalvars/lists/clans.dm index fbccd76e7865..8fe4fe3e23b1 100644 --- a/code/_globalvars/lists/clans.dm +++ b/code/_globalvars/lists/clans.dm @@ -25,5 +25,6 @@ GLOBAL_LIST_INIT_TYPED(clan_ancillaries, /datum/yautja_ancillary, list( CLAN_ANCILLARY_TASK_MASTER = new /datum/yautja_ancillary/task_master(), CLAN_ANCILLARY_SHAMAN = new /datum/yautja_ancillary/shaman(), CLAN_ANCILLARY_HIGH_ENFORCER = new /datum/yautja_ancillary/high_enforcer(), - CLAN_ANCILLARY_HIGH_SHAMAN = new /datum/yautja_ancillary/high_shaman() + CLAN_ANCILLARY_HIGH_SHAMAN = new /datum/yautja_ancillary/high_shaman(), + CLAN_ANCILLARY_NONE = new /datum/yautja_ancillary/clear() )) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index 683728813b82..eac3717ee0e0 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -95,7 +95,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) current_clan_id = index_to_id(current_clan_index) return TRUE - if(!verify_clan_leader(current_clan_id)) + if(!verify_clan_elder(current_clan_id)) to_chat(user, SPAN_WARNING("You are not authorized to do this.")) return FALSE @@ -111,11 +111,80 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) target_player.sync() target_ckey = target_player.ckey + if(!verify_superadmin() && (target_ckey == user.ckey)) + to_chat(user, SPAN_WARNING("You cannot edit yourself!")) + return FALSE + if(params["target_clan"]) target_clan = GET_CLAN(params["target_clan"]) target_clan.sync() + if(action == "assign_ancillary") + if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY))) + if(!(target_yautja.clan_id == current_clan_id)) + to_chat(user, SPAN_WARNING("You cannot assign an ancillary title to this player, they are not in your clan!")) + return + + var/list/datum/yautja_ancillary/ancillaries = GLOB.clan_ancillaries.Copy() + + var/datum/yautja_ancillary/chosen_ancillary + if(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY, warn = FALSE)) + var/input = tgui_input_list(user, "Select the ancillary to change this user to.", "Select Ancillary", ancillaries) + + if(!input) + return + + chosen_ancillary = ancillaries[input] + + else if(linked_client.has_clan_position(CLAN_RANK_ELDER, target_yautja.clan_id)) + for(var/ancillary in ancillaries) + if(!linked_client.has_clan_position(ancillaries[ancillary].granter_title_required, warn = FALSE)) + ancillaries -= ancillary + if(!target_yautja.can_be_ancillary(ancillaries[ancillary].target_rank_required, current_clan_id)) + ancillaries -= ancillary + + if(!ancillaries.len) + to_chat(user, SPAN_WARNING("No possible ancillaries to grant!")) + return + + var/input = tgui_input_list(user, "Select the ancillary to change this user to.", "Select Ancillary", ancillaries) + + if(!input) + return + + if(chosen_ancillary.limit_type) + var/list/datum/view_record/clan_playerbase_view/CPV = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_AND(DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id), DB_COMP("rank", DB_EQUALS, GLOB.clan_ranks_ordered[input]))) + var/players_in_rank = length(CPV) + + switch(chosen_ancillary.limit_type) + if(CLAN_LIMIT_NUMBER) + if(players_in_rank >= chosen_ancillary.limit) + to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_ancillary.limit] slots)")) + return + if(CLAN_LIMIT_SIZE) + var/list/datum/view_record/clan_playerbase_view/clan_players = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id)) + var/available_slots = ceil(length(clan_players) / chosen_ancillary.limit) + + if(players_in_rank >= available_slots) + to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_ancillary.limit] per player in the clan, currently [available_slots])")) + return + else + chosen_ancillary = input + else + return // Doesn't have permission to do this + + if(!linked_client.has_clan_position(chosen_ancillary.granter_title_required, target_yautja.clan_id)) // Double check + return + + target_yautja.clan_ancillary = chosen_ancillary.name + message_admins("[key_name_admin(user)] has set the ancillary title of [target_ckey] to [chosen_ancillary.name] for their clan.") + to_chat(user, SPAN_NOTICE("Set [target_ckey]'s ancillary title to [chosen_ancillary.name]")) + + if(!verify_clan_leader(current_clan_id)) + to_chat(user, SPAN_WARNING("You are not authorized to do this.")) + return FALSE + switch(action) if("clan_name") var/input = input(user, "Input the new name", "Set Name", target_clan.name) as text|null @@ -151,8 +220,8 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) to_chat(user, SPAN_NOTICE("Set the color of [target_clan.name] to [color].")) if("change_rank") - if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) - to_chat(user, SPAN_WARNING("You cannot change this player, they are not in your clan!")) + if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == current_clan_id)) + to_chat(user, SPAN_WARNING("You cannot change the rank of this player, they are not in your clan!")) return if((target_yautja.permissions & CLAN_PERMISSION_ADMIN_MANAGER) || linked_client.clan_info.clan_rank <= target_yautja.clan_rank) to_chat(user, SPAN_WARNING("You can't target this person!")) @@ -209,67 +278,8 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) message_admins("[key_name_admin(user)] has set the rank of [target_ckey] to [chosen_rank.name] for their clan.") to_chat(user, SPAN_NOTICE("Set [target_ckey]'s rank to [chosen_rank.name]")) - if("assign_ancillary") - if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) - to_chat(user, SPAN_WARNING("You cannot change this player, they are not in your clan!")) - return - - var/list/datum/yautja_ancillary/ancillaries = GLOB.clan_ancillaries.Copy() - var/datum/yautja_ancillary/chosen_ancillary - if(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY, warn = FALSE)) - var/input = tgui_input_list(user, "Select the ancillary to change this user to.", "Select Ancillary", ancillaries) - - if(!input) - return - - chosen_ancillary = ancillaries[input] - - else if(linked_client.has_clan_position(CLAN_RANK_ELDER, target_yautja.clan_id)) - for(var/ancillary in ancillaries) - if(!linked_client.has_clan_position(ancillaries[ancillary].granter_title_required, warn = FALSE)) - ancillaries -= ancillary - if(!target_yautja.can_be_ancillary(ancillaries[ancillary].target_rank_required, current_clan_id)) - ancillaries -= ancillary - - if(!ancillaries.len) - to_chat(user, SPAN_WARNING("No possible ancillaries to grant!")) - return - - var/input = tgui_input_list(user, "Select the ancillary to change this user to.", "Select Ancillary", ancillaries) - - if(!input) - return - - chosen_ancillary = ancillaries[input] - - if(chosen_ancillary.limit_type) - var/list/datum/view_record/clan_playerbase_view/CPV = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_AND(DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id), DB_COMP("rank", DB_EQUALS, GLOB.clan_ranks_ordered[input]))) - var/players_in_rank = length(CPV) - - switch(chosen_ancillary.limit_type) - if(CLAN_LIMIT_NUMBER) - if(players_in_rank >= chosen_ancillary.limit) - to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_ancillary.limit] slots)")) - return - if(CLAN_LIMIT_SIZE) - var/list/datum/view_record/clan_playerbase_view/clan_players = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id)) - var/available_slots = ceil(length(clan_players) / chosen_ancillary.limit) - - if(players_in_rank >= available_slots) - to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_ancillary.limit] per player in the clan, currently [available_slots])")) - return - else - return // Doesn't have permission to do this - - if(!linked_client.has_clan_position(chosen_ancillary.granter_title_required, target_yautja.clan_id)) // Double check - return - - target_yautja.clan_ancillary = chosen_ancillary.name - message_admins("[key_name_admin(user)] has set the ancillary title of [target_ckey] to [chosen_ancillary.name] for their clan.") - to_chat(user, SPAN_NOTICE("Set [target_ckey]'s ancillary title to [chosen_ancillary.name]")) - if("kick_from_clan") - if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == current_clan_id)) to_chat(user, SPAN_WARNING("You cannot kick this player, they are not in your clan!")) return target_yautja.clan_id = null @@ -279,7 +289,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) message_admins("Yautja Clans: [key_name_admin(user)] has kicked [target_ckey] from their clan.") if("banish_from_clan") - if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == user_clan_id)) + if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == current_clan_id)) to_chat(user, SPAN_WARNING("You cannot banish this player, they are not in your clan!")) return var/reason = tgui_input_text(user, "Why do you wish to Banish this Yautja?", "Reason") @@ -309,6 +319,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if(!(target_yautja.permissions & CLAN_PERMISSION_ADMIN_ANCIENT)) target_yautja.permissions = GLOB.clan_ranks[CLAN_RANK_BLOODED].permissions target_yautja.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_BLOODED] + target_yautja.clan_ancillary = "None" if("delete_player_data") if(!verify_superadmin()) @@ -433,6 +444,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) yautja["player_id"] = CP.player_id yautja["rank"] = GLOB.clan_ranks[CP.clan_rank] yautja["ancillary"] = (CP.clan_ancillary? CP.clan_ancillary : "None") + yautja["clan_id"] = (CP.clan_id) var/datum/entity/player/player = get_player_from_key(CP.ckey) if(player.check_whitelist_status(WHITELIST_YAUTJA_LEADER)) diff --git a/code/modules/clans/rank.dm b/code/modules/clans/rank.dm index 58c99004d947..dd0352a1733d 100644 --- a/code/modules/clans/rank.dm +++ b/code/modules/clans/rank.dm @@ -82,3 +82,8 @@ /datum/yautja_ancillary/task_master name = CLAN_ANCILLARY_TASK_MASTER + +/datum/yautja_ancillary/clear + name = CLAN_ANCILLARY_NONE + limit = null + limit_type = null diff --git a/tgui/packages/tgui/interfaces/YautjaClans.jsx b/tgui/packages/tgui/interfaces/YautjaClans.jsx index e4faaf82f341..e9dd3621c24c 100644 --- a/tgui/packages/tgui/interfaces/YautjaClans.jsx +++ b/tgui/packages/tgui/interfaces/YautjaClans.jsx @@ -88,7 +88,7 @@ const ViewClans = (props) => { > Change Clan Color - {user_is_superadmin && ( + {!!user_is_superadmin && ( Date: Tue, 8 Oct 2024 12:16:38 +0100 Subject: [PATCH 19/22] x --- code/modules/clans/clan_tgui.dm | 33 ++++++++++++++++++++++++++------- code/modules/clans/client.dm | 27 +++++++++++++++++---------- code/modules/clans/rank.dm | 10 ++++++---- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index eac3717ee0e0..640f54fb82b3 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -107,6 +107,8 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) target_yautja = GET_CLAN_PLAYER(params["target_player"]) target_yautja.sync() + log_debug("Yautja Clans: Selected Player Clan ID: [target_yautja.clan_id]") + target_player = DB_ENTITY(/datum/entity/player, target_yautja.player_id) target_player.sync() target_ckey = target_player.ckey @@ -120,10 +122,13 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) target_clan = GET_CLAN(params["target_clan"]) target_clan.sync() + // ------------- CLAN ELDER+ ONLY ACTION ------------- \\ + if(action == "assign_ancillary") if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY))) if(!(target_yautja.clan_id == current_clan_id)) to_chat(user, SPAN_WARNING("You cannot assign an ancillary title to this player, they are not in your clan!")) + log_debug("Target Clan: [target_yautja.clan_id], Needed Clan: [current_clan_id]") return var/list/datum/yautja_ancillary/ancillaries = GLOB.clan_ancillaries.Copy() @@ -133,16 +138,17 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) var/input = tgui_input_list(user, "Select the ancillary to change this user to.", "Select Ancillary", ancillaries) if(!input) + log_debug("Yautja Clans: Input Check failed.") return chosen_ancillary = ancillaries[input] - else if(linked_client.has_clan_position(CLAN_RANK_ELDER, target_yautja.clan_id)) + else if(linked_client.has_clan_position(CLAN_RANK_ELDER_INT, current_clan_id, TRUE)) for(var/ancillary in ancillaries) if(!linked_client.has_clan_position(ancillaries[ancillary].granter_title_required, warn = FALSE)) ancillaries -= ancillary - if(!target_yautja.can_be_ancillary(ancillaries[ancillary].target_rank_required, current_clan_id)) - ancillaries -= ancillary + //if(!target_yautja.can_be_ancillary(ancillaries[ancillary].target_rank_required, current_clan_id)) + // ancillaries -= ancillary if(!ancillaries.len) to_chat(user, SPAN_WARNING("No possible ancillaries to grant!")) @@ -151,8 +157,11 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) var/input = tgui_input_list(user, "Select the ancillary to change this user to.", "Select Ancillary", ancillaries) if(!input) + log_debug("Yautja Clans: Input Check failed.") return + chosen_ancillary = ancillaries[input] + if(chosen_ancillary.limit_type) var/list/datum/view_record/clan_playerbase_view/CPV = DB_VIEW(/datum/view_record/clan_playerbase_view/, DB_AND(DB_COMP("clan_id", DB_EQUALS, target_yautja.clan_id), DB_COMP("rank", DB_EQUALS, GLOB.clan_ranks_ordered[input]))) var/players_in_rank = length(CPV) @@ -169,18 +178,21 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if(players_in_rank >= available_slots) to_chat(user, SPAN_DANGER("This slot is full! (Maximum of [chosen_ancillary.limit] per player in the clan, currently [available_slots])")) return - else - chosen_ancillary = input else + log_debug("Yautja Clans: X Check failed.") return // Doesn't have permission to do this if(!linked_client.has_clan_position(chosen_ancillary.granter_title_required, target_yautja.clan_id)) // Double check + log_debug("Yautja Clans: Double Check failed.") return target_yautja.clan_ancillary = chosen_ancillary.name message_admins("[key_name_admin(user)] has set the ancillary title of [target_ckey] to [chosen_ancillary.name] for their clan.") to_chat(user, SPAN_NOTICE("Set [target_ckey]'s ancillary title to [chosen_ancillary.name]")) + + // ------------- CLAN LEADER ONLY ACTIONS ------------- \\ + if(!verify_clan_leader(current_clan_id)) to_chat(user, SPAN_WARNING("You are not authorized to do this.")) return FALSE @@ -222,13 +234,18 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if("change_rank") if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == current_clan_id)) to_chat(user, SPAN_WARNING("You cannot change the rank of this player, they are not in your clan!")) + log_debug("Target Clan: [target_yautja.clan_id], Needed Clan: [current_clan_id]") return - if((target_yautja.permissions & CLAN_PERMISSION_ADMIN_MANAGER) || linked_client.clan_info.clan_rank <= target_yautja.clan_rank) + if(!verify_superadmin() && ((target_yautja.permissions & CLAN_PERMISSION_ADMIN_MANAGER) || (linked_client.clan_info.clan_rank <= target_yautja.clan_rank))) to_chat(user, SPAN_WARNING("You can't target this person!")) return + if(!target_yautja.clan_id) + to_chat(src, SPAN_WARNING("This player doesn't belong to a clan!")) + return var/list/datum/yautja_rank/ranks = GLOB.clan_ranks.Copy() - ranks -= CLAN_RANK_ADMIN // Admin rank should not and cannot be obtained from here + if(!verify_superadmin()) + ranks -= CLAN_RANK_ADMIN // Admin rank should not and cannot be obtained from here var/datum/yautja_rank/chosen_rank if(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY, warn = FALSE)) @@ -281,6 +298,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if("kick_from_clan") if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == current_clan_id)) to_chat(user, SPAN_WARNING("You cannot kick this player, they are not in your clan!")) + log_debug("Target Clan: [target_yautja.clan_id], Needed Clan: [current_clan_id]") return target_yautja.clan_id = null target_yautja.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_BLOODED] @@ -291,6 +309,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) if("banish_from_clan") if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY)) && !(target_yautja.clan_id == current_clan_id)) to_chat(user, SPAN_WARNING("You cannot banish this player, they are not in your clan!")) + log_debug("Target Clan: [target_yautja.clan_id], Needed Clan: [current_clan_id]") return var/reason = tgui_input_text(user, "Why do you wish to Banish this Yautja?", "Reason") if(!reason) diff --git a/code/modules/clans/client.dm b/code/modules/clans/client.dm index 1dc8f0c13192..fca00d3876bf 100644 --- a/code/modules/clans/client.dm +++ b/code/modules/clans/client.dm @@ -190,7 +190,7 @@ /client/proc/is_authorized_clan_member(clan_id, warn) if(!clan_info) if(warn) - to_chat(src, "You do not have a yautja whitelist!") + to_chat(src, SPAN_WARNING("You do not have a yautja whitelist!")) return FALSE if(clan_id) @@ -198,7 +198,7 @@ return TRUE if(clan_id != clan_info.clan_id) if(warn) - to_chat(src, "You do not have permission to perform actions on this clan!") + to_chat(src, SPAN_WARNING("You do not have permission to perform actions on this clan!")) return FALSE return TRUE @@ -207,7 +207,8 @@ return FALSE if(!(clan_info.permissions & permission_flag)) - if(warn) to_chat(src, "You do not have the necessary permissions to perform this action!") + if(warn) + to_chat(src, SPAN_WARNING("You do not have the necessary permissions to perform this action!")) return FALSE return TRUE @@ -218,19 +219,25 @@ if(is_yautja_ancient() || (clan_info.clan_rank >= CLAN_RANK_LEADER_INT)) return TRUE - if(clan_info.clan_ancillary != needed_position) - if(warn) - to_chat(src, "You do not have the necessary permissions to perform this action!") - return FALSE - return TRUE + if(clan_info.clan_ancillary == needed_position) + return TRUE + if(clan_info.clan_rank >= needed_position) + return TRUE + + if(warn) + log_debug("Needed Position: [needed_position], Needed Clan ID: [clan_id]") + log_debug("Clan Rank: [clan_info.clan_rank], Ancillary: [clan_info.clan_ancillary? clan_info.clan_ancillary : "N/A"]") + to_chat(src, SPAN_WARNING("You do not have the necessary position to perform this action!")) + return FALSE /datum/entity/clan_player/proc/can_be_ancillary(required_rank, needed_clan_id) if(needed_clan_id != clan_id) + log_debug("Needed clan match fail.") return FALSE - var/needed_num = GLOB.clan_ranks_ordered[required_rank] - if(clan_rank < needed_num) + if(clan_rank < required_rank) + log_debug("Clan rank match fail.") return FALSE return TRUE diff --git a/code/modules/clans/rank.dm b/code/modules/clans/rank.dm index dd0352a1733d..2fd6d517ee00 100644 --- a/code/modules/clans/rank.dm +++ b/code/modules/clans/rank.dm @@ -51,12 +51,14 @@ var/limit_type = CLAN_LIMIT_SIZE var/limit = 5 - var/granter_title_required = CLAN_RANK_LEADER - var/target_rank_required = CLAN_RANK_ELITE + /// The rank INTEGER or Ancillary TEXT needed to grant. + var/granter_title_required = CLAN_RANK_LEADER_INT + /// The target rank INTEGER needed for the ancillary. + var/target_rank_required = CLAN_RANK_ELITE_INT /datum/yautja_ancillary/high_enforcer name = CLAN_ANCILLARY_HIGH_ENFORCER - target_rank_required = CLAN_RANK_ELDER + target_rank_required = CLAN_RANK_ELDER_INT limit_type = CLAN_LIMIT_NUMBER limit = 1 @@ -66,7 +68,7 @@ /datum/yautja_ancillary/high_shaman name = CLAN_ANCILLARY_HIGH_SHAMAN - target_rank_required = CLAN_RANK_ELDER + target_rank_required = CLAN_RANK_ELDER_INT limit_type = CLAN_LIMIT_NUMBER limit = 1 From c88fc27d891977eb1ea6d066abbd9ffaace778ea Mon Sep 17 00:00:00 2001 From: forest2001 Date: Tue, 8 Oct 2024 15:40:16 +0100 Subject: [PATCH 20/22] disable anc --- code/modules/clans/clan_tgui.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index 640f54fb82b3..c7d69f4a20a3 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -125,6 +125,9 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) // ------------- CLAN ELDER+ ONLY ACTION ------------- \\ if(action == "assign_ancillary") + to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) + return FALSE + /* if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY))) if(!(target_yautja.clan_id == current_clan_id)) to_chat(user, SPAN_WARNING("You cannot assign an ancillary title to this player, they are not in your clan!")) @@ -189,7 +192,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) target_yautja.clan_ancillary = chosen_ancillary.name message_admins("[key_name_admin(user)] has set the ancillary title of [target_ckey] to [chosen_ancillary.name] for their clan.") to_chat(user, SPAN_NOTICE("Set [target_ckey]'s ancillary title to [chosen_ancillary.name]")) - + */ // ------------- CLAN LEADER ONLY ACTIONS ------------- \\ From cd3b853b09c569450e48a3d1d4a9c974fc1fda66 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Sat, 12 Oct 2024 14:35:16 +0100 Subject: [PATCH 21/22] permission fix test --- code/modules/clans/client.dm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/modules/clans/client.dm b/code/modules/clans/client.dm index fca00d3876bf..2b8ef6d4fe4d 100644 --- a/code/modules/clans/client.dm +++ b/code/modules/clans/client.dm @@ -15,7 +15,17 @@ else if(check_whitelist_status(WHITELIST_YAUTJA_COUNCIL)) clan_info.permissions |= CLAN_PERMISSION_ADMIN_ANCIENT else - clan_info.permissions = GLOB.clan_ranks[clan_info.clan_rank].permissions + var/datum/yautja_rank/permission_rank = GLOB.clan_ranks[clan_info.clan_rank] + if(!istype(permission_rank)) + log_debug("Yautja Clans: Permission change attempt, got rank '[permission_rank]' for '[ckey]' instead of datum.") + permission_rank = GLOB.clan_ranks[permission_rank] + if(!istype(permission_rank)) + log_debug("Yautja Clans: Permission change attempt, got rank '[permission_rank]' for '[ckey]' instead of datum, twice.") + clan_info.permissions = CLAN_PERMISSION_USER_VIEW + else + clan_info.permissions = permission_rank.permissions + else + clan_info.permissions = permission_rank.permissions clan_info.player_name = prefs.predator_name From 283986572c92faad164a3e52309c5fb0e03da189 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Tue, 15 Oct 2024 20:03:38 +0100 Subject: [PATCH 22/22] Revert "disable anc" This reverts commit c88fc27d891977eb1ea6d066abbd9ffaace778ea. --- code/modules/clans/clan_tgui.dm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/modules/clans/clan_tgui.dm b/code/modules/clans/clan_tgui.dm index c7d69f4a20a3..640f54fb82b3 100644 --- a/code/modules/clans/clan_tgui.dm +++ b/code/modules/clans/clan_tgui.dm @@ -125,9 +125,6 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) // ------------- CLAN ELDER+ ONLY ACTION ------------- \\ if(action == "assign_ancillary") - to_chat(user, SPAN_WARNING("This command ([action]) is not yet functional.")) - return FALSE - /* if(!(linked_client.has_clan_permission(CLAN_PERMISSION_ADMIN_MODIFY))) if(!(target_yautja.clan_id == current_clan_id)) to_chat(user, SPAN_WARNING("You cannot assign an ancillary title to this player, they are not in your clan!")) @@ -192,7 +189,7 @@ GLOBAL_DATUM_INIT(yautja_clan_data, /datum/yautja_panel, new(init_global = TRUE) target_yautja.clan_ancillary = chosen_ancillary.name message_admins("[key_name_admin(user)] has set the ancillary title of [target_ckey] to [chosen_ancillary.name] for their clan.") to_chat(user, SPAN_NOTICE("Set [target_ckey]'s ancillary title to [chosen_ancillary.name]")) - */ + // ------------- CLAN LEADER ONLY ACTIONS ------------- \\