From 3c2b14ecec17327b70ca322be68be5b50b148b92 Mon Sep 17 00:00:00 2001
From: Li
Date: Sat, 7 May 2022 13:24:09 +1200
Subject: [PATCH] Improve code for handling user pronouns,. (remove copy paste
hell)
---
HorseIsleServer/LibHISP/Game/Messages.cs | 4 +-
HorseIsleServer/LibHISP/Game/Meta.cs | 55 ++++---------------
HorseIsleServer/LibHISP/Player/User.cs | 11 ++++
.../LibHISP/Server/GameDataJson.cs | 5 +-
4 files changed, 28 insertions(+), 47 deletions(-)
diff --git a/HorseIsleServer/LibHISP/Game/Messages.cs b/HorseIsleServer/LibHISP/Game/Messages.cs
index 9e823ef..02e7d53 100644
--- a/HorseIsleServer/LibHISP/Game/Messages.cs
+++ b/HorseIsleServer/LibHISP/Game/Messages.cs
@@ -495,8 +495,10 @@ namespace HISP.Game
public static string PronounFemaleShe;
public static string PronounFemaleHer;
- public static string PronounYouYour;
+ public static string PronounNeutralYour;
+ public static string PronounNeutralThey;
+ public static string PronounNeutralTheir;
// Stats Page
public static string StatsBarFormat;
public static string StatsAreaFormat;
diff --git a/HorseIsleServer/LibHISP/Game/Meta.cs b/HorseIsleServer/LibHISP/Game/Meta.cs
index 47f22f9..452c0e8 100644
--- a/HorseIsleServer/LibHISP/Game/Meta.cs
+++ b/HorseIsleServer/LibHISP/Game/Meta.cs
@@ -253,23 +253,10 @@ namespace HISP.Game
private static string buildWornJewelery(User user, bool other)
{
string message = "";
-
- // Insert LGBT Patch here
-
string pronoun = "";
if (other)
- {
- if (user.Gender == "FEMALE")
- {
- pronoun = Messages.PronounFemaleShe;
- }
-
- if (user.Gender == "MALE")
- {
- pronoun = Messages.PronounMaleHe;
- }
- }
+ pronoun = user.GetPronouns(false);
if (!other)
message += Messages.JewelrySelected;
@@ -364,22 +351,12 @@ namespace HISP.Game
if (!other)
message = Messages.CompetitionGearSelected;
- // Insert LGBT Patch Here
-
- string pronoun = Messages.PronounYouYour;
- string pronoun2 = Messages.PronounYouYour;
+ string pronoun = Messages.PronounNeutralYour;
+ string possessivePronoun = Messages.PronounNeutralYour;
if (other)
{
- if (user.Gender == "FEMALE")
- {
- pronoun = Messages.PronounFemaleShe;
- pronoun2 = Messages.PronounFemaleHer;
- }
- else if (user.Gender == "MALE")
- {
- pronoun = Messages.PronounMaleHe;
- pronoun2 = Messages.PronounMaleHis;
- }
+ pronoun = user.GetPronouns(false);
+ possessivePronoun = user.GetPronouns(true);
message = Messages.FormatOtherCompetitionGear(pronoun);
}
@@ -388,22 +365,22 @@ namespace HISP.Game
if (user.EquipedCompetitionGear.Head != null)
{
- message += Messages.FormatCompetitionGearHead(user.EquipedCompetitionGear.Head.Name, pronoun2, user.EquipedCompetitionGear.Head.IconId, other);
+ message += Messages.FormatCompetitionGearHead(user.EquipedCompetitionGear.Head.Name, possessivePronoun, user.EquipedCompetitionGear.Head.IconId, other);
hasMsg = true;
}
if (user.EquipedCompetitionGear.Body != null)
{
- message += Messages.FormatCompetitionGearBody(user.EquipedCompetitionGear.Body.Name, pronoun2, user.EquipedCompetitionGear.Body.IconId, other);
+ message += Messages.FormatCompetitionGearBody(user.EquipedCompetitionGear.Body.Name, possessivePronoun, user.EquipedCompetitionGear.Body.IconId, other);
hasMsg = true;
}
if (user.EquipedCompetitionGear.Legs != null)
{
- message += Messages.FormatCompetitionGearLegs(user.EquipedCompetitionGear.Legs.Name, pronoun2, user.EquipedCompetitionGear.Legs.IconId, other);
+ message += Messages.FormatCompetitionGearLegs(user.EquipedCompetitionGear.Legs.Name, possessivePronoun, user.EquipedCompetitionGear.Legs.IconId, other);
hasMsg = true;
}
if (user.EquipedCompetitionGear.Feet != null)
{
- message += Messages.FormatCompetitionGearFeet(user.EquipedCompetitionGear.Feet.Name, pronoun2, user.EquipedCompetitionGear.Feet.IconId, other);
+ message += Messages.FormatCompetitionGearFeet(user.EquipedCompetitionGear.Feet.Name, possessivePronoun, user.EquipedCompetitionGear.Feet.IconId, other);
hasMsg = true;
}
@@ -1054,20 +1031,8 @@ namespace HISP.Game
}
else
{
- // Insert LGBT Patch here
-
- string pronoun = "";
- if (other)
- {
- if (user.Gender == "FEMALE")
- pronoun = Messages.PronounFemaleHer;
-
- if (user.Gender == "MALE")
- pronoun = Messages.PronounMaleHis;
- }
-
+ string pronoun = user.GetPronouns(true);
message += Messages.FormatOtherHorsesMeta(pronoun);
-
message += buildHorseList(user, false);
message += Messages.FormatAwardHeaderOthers(user.Username);
diff --git a/HorseIsleServer/LibHISP/Player/User.cs b/HorseIsleServer/LibHISP/Player/User.cs
index 74ccb2b..c4547e6 100644
--- a/HorseIsleServer/LibHISP/Player/User.cs
+++ b/HorseIsleServer/LibHISP/Player/User.cs
@@ -582,6 +582,17 @@ namespace HISP.Player
GameServer.Update(LoggedinClient);
+ }
+
+ // Insert LGBT Patch here
+ public string GetPronouns(bool possessive)
+ {
+ if (Gender == "FEMALE")
+ return possessive ? Messages.PronounFemaleHer : Messages.PronounFemaleShe;
+ else if (Gender == "MALE")
+ return possessive ? Messages.PronounMaleHis : Messages.PronounMaleHe;
+ else
+ return possessive ? Messages.PronounNeutralTheir : Messages.PronounNeutralThey;
}
public byte[] GenerateSecCode()
diff --git a/HorseIsleServer/LibHISP/Server/GameDataJson.cs b/HorseIsleServer/LibHISP/Server/GameDataJson.cs
index 04aec38..71c810f 100644
--- a/HorseIsleServer/LibHISP/Server/GameDataJson.cs
+++ b/HorseIsleServer/LibHISP/Server/GameDataJson.cs
@@ -1431,7 +1431,10 @@ namespace HISP.Server
Messages.PronounMaleHe = gameData.messages.meta.stats_page.pronouns.male_he;
Messages.PronounMaleHis = gameData.messages.meta.stats_page.pronouns.male_his;
- Messages.PronounYouYour = gameData.messages.meta.stats_page.pronouns.you_your;
+ Messages.PronounNeutralYour = gameData.messages.meta.stats_page.pronouns.neutral_your;
+
+ Messages.PronounNeutralThey = gameData.messages.meta.stats_page.pronouns.neutral_they;
+ Messages.PronounNeutralTheir = gameData.messages.meta.stats_page.pronouns.neutral_their;
// Stats
Messages.StatsBarFormat = gameData.messages.meta.stats_page.stats_bar_format;