Skip to content

Commit 7e061ca

Browse files
committed
refactor: Generics for Guild commands
1 parent a10f64f commit 7e061ca

5 files changed

Lines changed: 75 additions & 85 deletions

File tree

Commands/Commands_Char.lua

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -211,49 +211,34 @@ CHAR_genericCommands = {
211211
[GENERICS_command] = ".teleport group ",
212212
[GENERICS_message] = "logCHAR_teleportGroup"
213213
},
214+
[CHAR_createGuildCommand] = {
215+
[GENERICS_isParametersNeeded] = true,
216+
[GENERICS_command] = ".guild create ",
217+
[GENERICS_message] = "logCHAR_createGuild"
218+
},
219+
[CHAR_deleteGuildCommand] = {
220+
[GENERICS_isParametersNeeded] = true,
221+
[GENERICS_command] = ".guild delete ",
222+
[GENERICS_message] = "logCHAR_deleteGuild"
223+
},
224+
[CHAR_inviteGuildCommand] = {
225+
[GENERICS_isParametersNeeded] = true,
226+
[GENERICS_command] = ".guild invite ",
227+
[GENERICS_message] = "logCHAR_inviteGuild"
228+
},
229+
[CHAR_uninviteGuildCommand] = {
230+
[GENERICS_isParametersNeeded] = true,
231+
[GENERICS_command] = ".guild uninvite ",
232+
[GENERICS_message] = "logCHAR_uninviteGuild"
233+
},
234+
[CHAR_rankGuildCommand] = {
235+
[GENERICS_isParametersNeeded] = true,
236+
[GENERICS_command] = ".guild rank ",
237+
[GENERICS_message] = "logCHAR_rankGuild"
238+
},
214239
}
215240
-- Delete
216241

217-
function CreateGuildButton()
218-
local cname = ma_charactertarget:GetText()
219-
local npccname = ma_npccharactertarget:GetText()
220-
MangAdmin:ChatMsg(".guild create "..cname)
221-
MangAdmin:LogAction("Created Guild: "..cname..".")
222-
223-
end
224-
225-
function GuildInviteButton()
226-
local cname = ma_charactertarget:GetText()
227-
local npccname = ma_npccharactertarget:GetText()
228-
MangAdmin:ChatMsg(".guild invite "..cname)
229-
MangAdmin:LogAction("Guild invitation: "..cname..".")
230-
231-
end
232-
233-
function GuildRankButton()
234-
local cname = ma_charactertarget:GetText()
235-
local npccname = ma_npccharactertarget:GetText()
236-
MangAdmin:ChatMsg(".guild rank "..cname)
237-
MangAdmin:LogAction("Guild rank change: "..cname..".")
238-
239-
end
240-
241-
function GuildDeleteButton()
242-
local cname = ma_charactertarget:GetText()
243-
local npccname = ma_npccharactertarget:GetText()
244-
MangAdmin:ChatMsg(".guild delete "..cname)
245-
MangAdmin:LogAction("Deleted guild: "..cname..".")
246-
247-
end
248-
249-
function GuildUninviteButton()
250-
local cname = ma_charactertarget:GetText()
251-
local npccname = ma_npccharactertarget:GetText()
252-
MangAdmin:ChatMsg(".guild uninvite "..cname)
253-
MangAdmin:LogAction("Removed from guild: "..cname..".")
254-
255-
end
256-
257242
--
258243

259244
function InitModelFrame()

Commands/declarations/command_keys.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ CHAR_freezeCommand = "freeze"
8383
CHAR_unfreezeCommand = "unfreeze"
8484
CHAR_possessCommand = "possess"
8585
CHAR_unpossessCommand = "unpossess"
86-
8786
CHAR_repairItemsCommand = "repairItems"
8887
CHAR_banCommand = "ban"
8988
CHAR_unbanCommand = "unban"
@@ -94,4 +93,9 @@ CHAR_summonCommand = "summon"
9493
CHAR_groupSummonCommand = "groupSummon"
9594
CHAR_teleportNameCommand = "teleportName"
9695
CHAR_teleportGroupCommand = "teleportGroup"
96+
CHAR_createGuildCommand = "createGuild"
97+
CHAR_deleteGuildCommand = "deleteGuild"
98+
CHAR_inviteGuildCommand = "inviteGuild"
99+
CHAR_uninviteGuildCommand = "uninviteGuild"
100+
CHAR_rankGuildCommand = "rankGuild"
97101

Frames/MangFrames_SectionChar.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -834,11 +834,11 @@ function MangAdmin:CreateCharSection()
834834
})
835835

836836
FrameLib:BuildButton({
837-
name = "ma_createguildbutton",
837+
name = "CHAR_createGuildButton",
838838
group = "char",
839839
parent = ma_midframe,
840840
texture = {
841-
name = "ma_createguildbutton_texture",
841+
name = "CHAR_createGuildButton_texture",
842842
color = { color.btn.r, color.btn.g, color.btn.b, transparency.btn }
843843
},
844844
size = {
@@ -850,7 +850,7 @@ function MangAdmin:CreateCharSection()
850850
offX = 548, --charColSix
851851
offY = -52 --charRowTwo
852852
},
853-
text = Locale["ma_createguildbutton"]
853+
text = Locale["labelCHAR_createGuildButton"]
854854
})
855855

856856
FrameLib:BuildButton({
@@ -894,11 +894,11 @@ function MangAdmin:CreateCharSection()
894894
})
895895

896896
FrameLib:BuildButton({
897-
name = "ma_guildinvitebutton",
897+
name = "CHAR_inviteGuildButton",
898898
group = "char",
899899
parent = ma_midframe,
900900
texture = {
901-
name = "ma_guildinvitebutton_texture",
901+
name = "CHAR_inviteGuildButton_texture",
902902
color = { color.btn.r, color.btn.g, color.btn.b, transparency.btn }
903903
},
904904
size = {
@@ -910,7 +910,7 @@ function MangAdmin:CreateCharSection()
910910
offX = 548, --charColSix
911911
offY = -74 --charRowThree
912912
},
913-
text = Locale["ma_guildinvitebutton"]
913+
text = Locale["labelCHAR_inviteGuildButton"]
914914
})
915915

916916
FrameLib:BuildButton({
@@ -954,11 +954,11 @@ function MangAdmin:CreateCharSection()
954954
})
955955

956956
FrameLib:BuildButton({
957-
name = "ma_guildrankbutton",
957+
name = "CHAR_rankGuildButton",
958958
group = "char",
959959
parent = ma_midframe,
960960
texture = {
961-
name = "ma_guildrankbutton_texture",
961+
name = "CHAR_rankGuildButton_texture",
962962
color = { color.btn.r, color.btn.g, color.btn.b, transparency.btn }
963963
},
964964
size = {
@@ -970,7 +970,7 @@ function MangAdmin:CreateCharSection()
970970
offX = 548, --charColSix
971971
offY = -95 --charRowFour
972972
},
973-
text = Locale["ma_guildrankbutton"]
973+
text = Locale["labelCHAR_rankGuildButton"]
974974
})
975975

976976
FrameLib:BuildButton({
@@ -1014,11 +1014,11 @@ function MangAdmin:CreateCharSection()
10141014
})
10151015

10161016
FrameLib:BuildButton({
1017-
name = "ma_guilddeletebutton",
1017+
name = "CHAR_deleteGuildButton",
10181018
group = "char",
10191019
parent = ma_midframe,
10201020
texture = {
1021-
name = "ma_guilddeletebutton_texture",
1021+
name = "CHAR_deleteGuildButton_texture",
10221022
color = { color.btn.r, color.btn.g, color.btn.b, transparency.btn }
10231023
},
10241024
size = {
@@ -1030,15 +1030,15 @@ function MangAdmin:CreateCharSection()
10301030
offX = 467, --charColFive
10311031
offY = -117 --charRowFive
10321032
},
1033-
text = Locale["ma_guilddeletebutton"]
1033+
text = Locale["labelCHAR_deleteGuildButton"]
10341034
})
10351035

10361036
FrameLib:BuildButton({
1037-
name = "ma_guilduninvitebutton",
1037+
name = "CHAR_uninviteGuildButton",
10381038
group = "char",
10391039
parent = ma_midframe,
10401040
texture = {
1041-
name = "ma_guilduninvitebutton_texture",
1041+
name = "CHAR_uninviteGuildButton_texture",
10421042
color = { color.btn.r, color.btn.g, color.btn.b, transparency.btn }
10431043
},
10441044
size = {
@@ -1050,7 +1050,7 @@ function MangAdmin:CreateCharSection()
10501050
offX = 548, --charColSix
10511051
offY = -117 --charRowFive
10521052
},
1053-
text = Locale["ma_guilduninvitebutton"]
1053+
text = Locale["labelCHAR_uninviteGuildButton"]
10541054
})
10551055

10561056
FrameLib:BuildButton({

FunctionInit.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -802,10 +802,10 @@ function InitControls()
802802
end
803803
)
804804
MangAdmin:PrepareScript(
805-
ma_createguildbutton,
806-
Locale["tt_createguildbutton"],
805+
CHAR_createGuildButton,
806+
Locale["ttCHAR_createGuild"],
807807
function()
808-
CreateGuildButton()
808+
genericCaller(CHAR_KEY, CHAR_createGuildCommand)
809809
end
810810
)
811811
MangAdmin:PrepareScript(
@@ -823,10 +823,10 @@ function InitControls()
823823
end
824824
)
825825
MangAdmin:PrepareScript(
826-
ma_guildinvitebutton,
827-
Locale["tt_guildinvitebutton"],
826+
CHAR_inviteGuildButton,
827+
Locale["ttCHAR_inviteGuild"],
828828
function()
829-
GuildInviteButton()
829+
genericCaller(CHAR_KEY, CHAR_inviteGuildCommand)
830830
end
831831
)
832832
MangAdmin:PrepareScript(
@@ -844,10 +844,10 @@ function InitControls()
844844
end
845845
)
846846
MangAdmin:PrepareScript(
847-
ma_guildrankbutton,
848-
Locale["tt_guildrankbutton"],
847+
CHAR_rankGuildButton,
848+
Locale["ttCHAR_rankGuild"],
849849
function()
850-
GuildRankButton()
850+
genericCaller(CHAR_KEY, CHAR_rankGuildCommand)
851851
end
852852
)
853853
MangAdmin:PrepareScript(
@@ -865,17 +865,17 @@ function InitControls()
865865
end
866866
)
867867
MangAdmin:PrepareScript(
868-
ma_guilddeletebutton,
869-
Locale["tt_guilddeletebutton"],
868+
CHAR_deleteGuildButton,
869+
Locale["ttCHAR_deleteGuild"],
870870
function()
871-
GuildDeleteButton()
871+
genericCaller(CHAR_KEY, CHAR_deleteGuildCommand)
872872
end
873873
)
874874
MangAdmin:PrepareScript(
875-
ma_guilduninvitebutton,
876-
Locale["tt_guilduninvitebutton"],
875+
CHAR_uninviteGuildButton,
876+
Locale["ttCHAR_uninviteGuild"],
877877
function()
878-
GuildUninviteButton()
878+
genericCaller(CHAR_KEY, CHAR_uninviteGuildCommand)
879879
end
880880
)
881881
MangAdmin:PrepareScript(

Locales/enUS.lua

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ function Return_enUS()
312312
["ttCHAR_groupSummon"] = "Teleports the specified character and his/her group to your location [[Parameters: $charactername]]",
313313
["ttCHAR_teleportName"] = "Teleports the specified character to the specified location [[Parameters: $charactername $telename]]",
314314
["ttCHAR_teleportGroup"] = "Teleports the **selected** character and his/her group to the specified location [[Parameters: $telename]]",
315+
["ttCHAR_createGuild"] = "Creates a guild named with the specified name with the specified leader. Guild name must in quotes. [[Parameters: $GuildLeaderName $GuildName]]",
316+
["ttCHAR_deleteGuild"] = "Deletes the specifies guild. Guild name must in quotes. [[Parameters: $GuildName]]",
317+
["ttCHAR_inviteGuild"] = "Adds the specified character to the specified guild. Guild name must in quotes. [[Parameters: $charactername $guildname]]",
318+
["ttCHAR_uninviteGuild"] = "Kicks the specified character from his/her guild [[Parameters: $charactername]]",
319+
["ttCHAR_rankGuild"] = "Sets to the specified character the specified guild rank [[Parameters: $charactername #ranknumber]]",
315320

316321
--[[CHAR-Control-Labels]]
317322
["labelCHAR_killButton"] = "Kill",
@@ -348,6 +353,11 @@ function Return_enUS()
348353
["labelCHAR_groupSummonButton"] = "GroupSumm",
349354
["labelCHAR_teleportNameButton"] = "TeleName",
350355
["labelCHAR_teleportGroupButton"] = "TeleGroup",
356+
["labelCHAR_createGuildButton"] = "G Create",
357+
["labelCHAR_deleteGuildButton"] = "G Delete",
358+
["labelCHAR_inviteGuildButton"] = "G Invite",
359+
["labelCHAR_uninviteGuildButton"] = "G UnInv",
360+
["labelCHAR_rankGuildButton"] = "G Rank",
351361

352362
--[[CHAR-Commands Output]]
353363
["logCHAR_kill"] = "_T_ has been killed",
@@ -384,6 +394,11 @@ function Return_enUS()
384394
["logCHAR_groupSummon"] = "Teleported _V1_ and his/her group to you",
385395
["logCHAR_teleportName"] = "Teleported _V1_ to _V2_",
386396
["logCHAR_teleportGroup"] = "Teleported _T_ and his/her group to _V1_",
397+
["logCHAR_createGuild"] = "Created a guild named _V2_ lead by _V1_",
398+
["logCHAR_deleteGuild"] = "Deleted the guild _V1_",
399+
["logCHAR_inviteGuild"] = "Added _V1_ to the guild _V2_",
400+
["logCHAR_uninviteGuild"] = "Kicked _V1_ from his/her guild",
401+
["logCHAR_rankGuild"] = "Set rank _V2_ to _V1_",
387402

388403
["tt_RotateLeft"] = "Rotate left.",
389404
["tt_RotateRight"] = "Rotate right.",
@@ -394,12 +409,7 @@ function Return_enUS()
394409
["tt_resetbutton"] = "Reset the selected attribute",
395410
["tt_modelzoominbutton"] = "Zoom in the selected model",
396411
["tt_modelzoomoutbutton"] = "Zoom out the selected model",
397-
["tt_createguildbutton"] = "Parameters= $GuildLeaderName $GuildName [[Creates a guild named $GuildName, with $GuildLeaderName as leader]]",
398-
["tt_guildinvitebutton"] = "Parameters= $charactername $guildname [[Adds $charactername to the guild $guildname]]",
399-
["tt_guildrankbutton"] = "Parameters= $charactername #ranknumber [[Sets the character specified to the rank specified in his/her guild]]",
400412

401-
["tt_guilddeletebutton"] = "Parameter= $guildname [[Deletes the specified Guild]]",
402-
["tt_guilduninvitebutton"] = "Parameter= $charactername [[Kicks the specified character out of his/her guild]]",
403413
["tt_mutebutton"] = "Parameters= $charactername #minutes [[Disables chat for $charactername's entire account for #minutes]]",
404414
["tt_charaurabutton"] = "Parameters = #AuraID [[Enter the AuraID of the aura you want to apply]]",
405415
["tt_charunaurabutton"] = "Parameters = #AuraID [[Enter the AuraID of the aura you want to remove]]",
@@ -425,15 +435,6 @@ function Return_enUS()
425435
["ma_Learn"] = "Learn",
426436
["ma_Modify"] = "Modify",
427437
["ma_Reset"] = "Reset",
428-
429-
["ma_createguildbutton"] = "G Create",
430-
["ma_guildinvitebutton"] = "G Invite",
431-
432-
["ma_guildrankbutton"] = "G Rank",
433-
434-
["ma_guilddeletebutton"] = "G Delete",
435-
["ma_guilduninvitebutton"] = "G UnInv",
436-
437438
["ma_mutebutton"] = "Mute",
438439
["ma_Aura"] = "Aura",
439440
["ma_UnAura"] = "UnAura",

0 commit comments

Comments
 (0)