From 7b85e50bcc6052a6e6b59302e855cc8ad9683528 Mon Sep 17 00:00:00 2001 From: Anna Date: Sat, 27 Jul 2024 19:02:14 -0400 Subject: [PATCH] feat: continue adding evaluators This method of determing evaluation is very flawed. --- Configuration.cs | 1 + Evaluator.cs | 372 +++++++++++++++++++++++++++++++++++++++++++++++ Plugin.cs | 309 ++++----------------------------------- PluginUi.cs | 21 +++ 4 files changed, 420 insertions(+), 283 deletions(-) create mode 100644 Evaluator.cs diff --git a/Configuration.cs b/Configuration.cs index 7b8aa0d..d1035dc 100644 --- a/Configuration.cs +++ b/Configuration.cs @@ -27,6 +27,7 @@ public class Configuration : IPluginConfiguration { public bool ClearResultsOnInactive = true; public float ClearDelaySeconds = 10; public bool UseEvaluatorNpc; + public Guid EvaluatorId = Guid.Empty; } public enum MeterMode { diff --git a/Evaluator.cs b/Evaluator.cs new file mode 100644 index 0000000..0952e32 --- /dev/null +++ b/Evaluator.cs @@ -0,0 +1,372 @@ +using System.Text; +using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Game.Text.SeStringHandling.Payloads; + +namespace PartyDamage; +public class Evaluator { + public required Guid Id { get; init; } + public required string Name { get; init; } + public required uint BattleTalkImage { get; init; } + public required Dictionary Lines { get; init; } + public bool IsMammet { get; init; } + + public SeString? GetLineFor(Evaluation evaluation) { + if (!this.Lines.TryGetValue(evaluation, out var lines)) { + return null; + } + + var line = Random.Shared.GetItems(lines, 1)[0]; + if (!this.IsMammet) { + return line; + } + + foreach (var payload in line.Payloads) { + if (payload is TextPayload text) { + var newText = new StringBuilder(); + var upper = true; + foreach (var ch in text.Text!) { + newText.Append(upper ? char.ToUpperInvariant(ch) : char.ToLowerInvariant(ch)); + upper = !upper; + } + + text.Text = newText.ToString(); + } + } + + return line; + } + + public static readonly Evaluator[] Evaluators = [ + new Evaluator { + Id = new Guid("ebbccc44-13b5-4843-a635-3b693fe47840"), + Name = "Parser Mammet", + BattleTalkImage = 73160, + Lines = new Dictionary { + [Evaluation.Best] = [ + "Parse result: greatly exceeds expectations!", + "Parse result: excellent!", + "Parse result: fantastic!", + "Parse result: extraordinary!", + ], + [Evaluation.Good] = [ + "Parse result: good.", + "Parse result: above expectations.", + "Parse result: great.", + "Parse result: more than adequate.", + ], + [Evaluation.Fair] = [ + "Parse result: meets expectations.", + "Parse result: adequate.", + "Parse result: satisfactory.", + "Parse result: baseline.", + ], + [Evaluation.Poor] = [ + "Parse result: below expectations...", + "Parse result: poor...", + "Parse result: perfunctory performance...", + "Parse result: inadequate...", + ], + [Evaluation.Awful] = [ + "Parse result: ★※☆ extremely ★※☆ poor...", + "Parse result: failure...", + "Parse result: far below expectations...", + "Parse result: ★※☆ terrible...", + ], + }, + IsMammet = true, + }, + new Evaluator { + Id = new Guid("5053c386-192a-416f-b025-223af8d592bf"), + Name = "G'raha Tia", + BattleTalkImage = 73012, + Lines = new Dictionary { + + }, + }, + + ]; +} + +public enum Evaluation { + Best, + Good, + Fair, + Poor, + Awful, +} + +// 001 Venat +// 002 Zenos +// 003 Evil? Zenos +// 004 Fandaniel +// 005 ? some garlean +// 006 ? +// 007 Estinien +// 008 Alphinaud +// 009 radiant host dude +// 010 Forchenault +// 011 Alisaie +// 012 G'raha Tia +// 013 Thancred +// 014 oh god I should know his name +// 015 one of the padjali, the boy +// 016 Emmanelaine or however you spell it +// 017 ? +// 018 Lucia +// 019 Pipin? +// 020 Lyse +// 021 Magnai for sure +// 022 Sadu +// 023 Cirina +// 024 Thancred again +// 025 Y'shtola +// 026 Urianger +// 027 Nero with helmet on +// 028 different alphinaud's dad +// 029 Kan-E-Senna +// 030 Aymeric +// 031 ? +// 032 Hien +// 033 ? (monster) +// 034 Alphinaud again +// 035 Estinien casual +// 036 Alisaie cold attire +// 037 some kobold +// 038 bearded roe +// 039 ? +// 040 ardbert with ascian mask? +// 041 ardbert but creepy smile +// 042 ? +// 043 oh god some fviera +// 044 another fviera +// 045 yet another fviera +// 046 ? soranus +// 047 gaius? +// 048 imperial buckethead +// 049 imperial helmet +// 050 ? soranus +// 051 imperial helmet but less aggro +// 052 Lyna +// 053 Alphinaud in a red shawl +// 054 mustachioed-man with horn helmet +// 055 different horn helmet +// 056 Alisaie in a red a shawl +// 057 horn helmet +// 058 horn helmet +// 059 fu manchu man +// 060 Minfilia (Ryne) +// 061 Alisaie cold attire +// 062 Alphi cold attire +// 063 Ranjit? +// 064 Ryne +// 065 Female Jester red +// 066 Female Jester blue +// 067 a dwarf +// 068 Fandaniel hood covering eyes +// 069 Merlwyb +// 070 Vrtra boy avatar +// 071 Krile +// 072 Tataru +// 073 Hydaelyn? +// 074 Faurchenault +// 075 Vrtra +// 076 some boss +// 077 Zero +// 078 Vrtra man avatar +// 079 Zenos Helmet? +// 080 Lyse in red dress +// 081 Yugiri +// 082 Zenos? helmet revealing eyes +// 083 Sadu +// 084 some blue au ra male +// 085 Y'shtola +// 086 garlean guy +// 087 garlean pot helmet +// 088 garlean bucket helmet +// 089 garlean pot helmet +// 090 purple haired chin strap guy +// 091 garlean bucket helmet +// 092 evil oni? +// 093 Asahi +// 094 Lakshmi +// 095 cripple man +// 096 criminal woman +// 097 ? +// 098 some machine? +// 099 some guy with radiation hair +// 100 Krile but happy +// 101 lalafell in horn helmet +// 102 some ala mhigan resistance guy +// 103 criminal lady again +// 104 Lyse in red jacket +// 105 green Kojin main guy +// 106 Yotsuyu +// 107 magnai +// 108 Gosetsu +// 109 old guy +// 110 imperial bucket head +// 111 some guy with a scar maybe ala mhigan resistance +// 112 Thancred with blindfold? +// 113 face mask ala mhigan resistance +// 114 imperial pot helmet +// 115 lupin guy +// 116 another lupin +// 117 imperial pot helmet but roe +// 118 straw hat +// 119 some boy +// 120 Raubahn +// 121 Sultana? +// 122 elezen man +// 123 angry bird thing +// 124 Haurchefant +// 125 Tataru +// 126 no idea elezen +// 127 eyepatch elezen +// 128 Alphinaud old outfit +// 129 Yugiri with dagger +// 130 Raubahn maybe with two arms? +// 131 some uldahn lalafell +// 132 Ilberd +// 133 a crystal brave +// 134 diff crystal brave +// 135 woman crystal brave +// 136 Estinien full armour +// 137 some dude in chain mail elezen face plate +// 138 someone other person in same outfit not elezen maybe hyur +// 139 Hilda +// 140 elezen guy +// 141 ishgardian soldier face plate chain mail +// 142 a vanu vanu or gundu or whatever +// 143 goblin brayflox +// 144 the machine boss from brayflox hard +// 145 imperial in cool helmet (not gaius?) +// 146 red dragoon but doesn't look like estinien +// 147 some child +// 148 some old elezen +// 149 emmanelaine's brother +// 150 old elezen woman +// 151 someone in a hat +// 152 other person in a hat +// 153 Raubahn in big helmet +// 154 Ardbert? +// 155 old outfit Urianger no mask +// 156 Yda +// 157 imperial pot helmet long hair +// 158 ??? +// 159 ??? +// 160 mammet with green face +// 161 Hancock +// 162 pink haired fem elezen +// 163 not sure dragoon +// 164 Papalymo +// 165 old Thancred +// 166 some elezen girl +// 167 Yugiri in full face mask +// 168 roe in big plate armour +// 169 child f (doman?) +// 170 another child m +// 171 m elezen caster in witch's hat +// 172 another child m/f +// 173 another child m +// 174 Thancred ascian mask +// 175 full armour person +// 176 red imperial buckethead +// 177 Minfilia (original) +// 178 Urianger (old outfit with mask thing) +// 179 imperial pot helmet +// 180 imperial pot helmet +// 181 biggs or wedge (the lala) +// 182 biggs or wedge (the roe) +// 183 imperial buckethead +// 184 Cid (old outfit) +// 185 imperial pot helmet +// 186 imperial pot helmet (roe) +// 187 Y'shtola with normal sight and aetherometer or whatever +// 188 crazy hair girl +// 189 an elezen with a beard whoa +// 190 some kind of monster? maybe old mamool ja +// 191 Haurchefant in chain mail +// 192 Haurchefant in chain mail +// 193 elezen with a soul patch +// 194 young elezen (emman?) +// 195 elezen with awful facial hair +// 196 roe with straw hat (not the ronin kind) +// 197 generic man +// 198 generic anime man +// 199 Ranjit +// 200 Amalj'aa +// 201 shirtless roe man +// 202 different shirtless roe man +// 203 mutton chops guy +// 204 elezen with a sick red beard whoa +// 205 imperial pot helmet roe beard +// 206 creepy mask miqo +// 207 sylph purple +// 208 sylph green +// 209 weird monster guy +// 210 Erenville +// 211 Wuk Lamat (with hat) +// 212 giant Toucan +// 213 Arkasodara +// 214 some guy +// 215 imperial pot helmet +// 216 gridanian guy? +// 217 lady with cap +// 218 man with cap +// 219 roe with hat +// 220 lalafell with pot helm +// 221 miqo with pot helm +// 222 dude with mask +// 223 girl with pot helm +// 224 lala with pot helm +// 225 guy with cool hair +// 226 dude with pot helm +// 227 lala pot helm +// 228 hyur pot helm +// 229 pot helm +// 230 roe with bandana mask +// 231 yet another pot helm +// 232 poooot helm +// 233 thief rogue? +// 234 full face mask ascian with red floaty mask and hood +// 235 POT. HELM. +// 236 ph +// 237 roe man +// 238 sailor roe man +// 239 maelstrom roe lady +// 240 Mamool Ja +// 241 pot helm +// 242 creepy mask guy +// 243 wood wailer creepy mask +// 244 ix...al? +// 245 cfm +// 246 cfm ww +// 247 elezen with face paint +// 248 Moogle +// 249 lala with tiara and mustache +// 250 boy +// 251 hooded m roe +// 252 hyur m +// 253 hyur m +// 254 Papa...lymo? +// 255 dude +// 256 Emet Selch elpis version +// 257 Krile +// 258 Gulool Ja Ja with cover for dead head +// 259 some mamool ja +// 260 Bakool Ja Ja mystic +// 261 Bakool Ja Ja both heads +// 262 a mamool ja +// 263 another mamool ja +// 264 another mamool ja +// 265 Wuk Lamat without hat +// 266 Koana +// 267 old Gulool Ja Ja with both heads alive +// 268 head of resolve +// 269 head of reason +// 270 Sphene +// 271 evil Otis in machine form +// 272 good Otis in machine form +// 273 Sphene final boss form +// 274 looks like Zero kind of +// "73" + str(number) for index \ No newline at end of file diff --git a/Plugin.cs b/Plugin.cs index 9e6a669..aadaa74 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.Globalization; +using System.Text; using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; using Dalamud.Game.Gui.ContextMenu; @@ -161,291 +162,33 @@ public class Plugin : IDalamudPlugin { this.DelayWatch.Restart(); } - if (this.Config.UseEvaluatorNpc && this.Client.Data != null) { + if ( + this.Config.UseEvaluatorNpc + && this.Client.Data != null + && Evaluator.Evaluators.FirstOrDefault(e => e.Id == this.Config.EvaluatorId) is { } evaluator + ) { var combatants = this.Client.Data.Combatants.Values.ToList(); - combatants.Sort((a, b) => b.EncDps.CompareTo(a.EncDps)); - var rank = combatants.FindIndex(combatant => combatant.Name == "YOU"); - // 001 Venat - // 002 Zenos - // 003 Evil? Zenos - // 004 Fandaniel - // 005 ? some garlean - // 006 ? - // 007 Estinien - // 008 Alphinaud - // 009 radiant host dude - // 010 Forchenault - // 011 Alisaie - // 012 G'raha Tia - // 013 Thancred - // 014 oh god I should know his name - // 015 one of the padjali, the boy - // 016 Emmanelaine or however you spell it - // 017 ? - // 018 Lucia - // 019 Pipin? - // 020 Lyse - // 021 Magnai for sure - // 022 Sadu - // 023 Cirina - // 024 Thancred again - // 025 Y'shtola - // 026 Urianger - // 027 Nero with helmet on - // 028 different alphinaud's dad - // 029 Kan-E-Senna - // 030 Aymeric - // 031 ? - // 032 oh god I should know his name... stormblood main boy - // 033 ? (monster) - // 034 Alphinaud again - // 035 Estinien casual - // 036 Alisaie cold attire - // 037 some kobold - // 038 bearded roe - // 039 ? - // 040 ardbert with ascian mask? - // 041 ardbert but creepy smile - // 042 ? - // 043 oh god some fviera - // 044 another fviera - // 045 yet another fviera - // 046 ? soranus - // 047 gaius? - // 048 imperial buckethead - // 049 imperial helmet - // 050 ? soranus - // 051 imperial helmet but less aggro - // 052 Lyna - // 053 Alphinaud in a red shawl - // 054 mustachioed-man with horn helmet - // 055 different horn helmet - // 056 Alisaie in a red a shawl - // 057 horn helmet - // 058 horn helmet - // 059 fu manchu man - // 060 Minfilia (Ryne) - // 061 Alisaie cold attire - // 062 Alphi cold attire - // 063 Ranjit? - // 064 Ryne - // 065 Female Jester red - // 066 Female Jester blue - // 067 a dwarf - // 068 Fandaniel hood covering eyes - // 069 Merlwyb - // 070 Vrtra boy avatar - // 071 Krile - // 072 Tataru - // 073 Hydaelyn? - // 074 Faurchenault - // 075 Vrtra - // 076 some boss - // 077 Zero - // 078 Vrtra man avatar - // 079 Zenos Helmet? - // 080 Lyse in red dress - // 081 Yugiri - // 082 Zenos? helmet revealing eyes - // 083 Sadu - // 084 some blue au ra male - // 085 Y'shtola - // 086 garlean guy - // 087 garlean pot helmet - // 088 garlean bucket helmet - // 089 garlean pot helmet - // 090 purple haired chin strap guy - // 091 garlean bucket helmet - // 092 evil oni? - // 093 Asahi - // 094 Lakshmi - // 095 cripple man - // 096 criminal woman - // 097 ? - // 098 some machine? - // 099 some guy with radiation hair - // 100 Krile but happy - // 101 lalafell in horn helmet - // 102 some ala mhigan resistance guy - // 103 criminal lady again - // 104 Lyse in red jacket - // 105 green Kojin main guy - // 106 Yotsuyu - // 107 magnai - // 108 Gosetsu - // 109 old guy - // 110 imperial bucket head - // 111 some guy with a scar maybe ala mhigan resistance - // 112 Thancred with blindfold? - // 113 face mask ala mhigan resistance - // 114 imperial pot helmet - // 115 lupin guy - // 116 another lupin - // 117 imperial pot helmet but roe - // 118 straw hat - // 119 some boy - // 120 Raubahn - // 121 Sultana? - // 122 elezen man - // 123 angry bird thing - // 124 Haurchefant - // 125 Tataru - // 126 no idea elezen - // 127 eyepatch elezen - // 128 Alphinaud old outfit - // 129 Yugiri with dagger - // 130 Raubahn maybe with two arms? - // 131 some uldahn lalafell - // 132 Ilberd - // 133 a crystal brave - // 134 diff crystal brave - // 135 woman crystal brave - // 136 Estinien full armour - // 137 some dude in chain mail elezen face plate - // 138 someone other person in same outfit not elezen maybe hyur - // 139 Hilda - // 140 elezen guy - // 141 ishgardian soldier face plate chain mail - // 142 a vanu vanu or gundu or whatever - // 143 goblin brayflox - // 144 the machine boss from brayflox hard - // 145 imperial in cool helmet (not gaius?) - // 146 red dragoon but doesn't look like estinien - // 147 some child - // 148 some old elezen - // 149 emmanelaine's brother - // 150 old elezen woman - // 151 someone in a hat - // 152 other person in a hat - // 153 Raubahn in big helmet - // 154 Ardbert? - // 155 old outfit Urianger no mask - // 156 Yda - // 157 imperial pot helmet long hair - // 158 ??? - // 159 ??? - // 160 mammet with green face - // 161 Hancock - // 162 pink haired fem elezen - // 163 not sure dragoon - // 164 Papalymo - // 165 old Thancred - // 166 some elezen girl - // 167 Yugiri in full face mask - // 168 roe in big plate armour - // 169 child f (doman?) - // 170 another child m - // 171 m elezen caster in witch's hat - // 172 another child m/f - // 173 another child m - // 174 Thancred ascian mask - // 175 full armour person - // 176 red imperial buckethead - // 177 Minfilia (original) - // 178 Urianger (old outfit with mask thing) - // 179 imperial pot helmet - // 180 imperial pot helmet - // 181 biggs or wedge (the lala) - // 182 biggs or wedge (the roe) - // 183 imperial buckethead - // 184 Cid (old outfit) - // 185 imperial pot helmet - // 186 imperial pot helmet (roe) - // 187 Y'shtola with normal sight and aetherometer or whatever - // 188 crazy hair girl - // 189 an elezen with a beard whoa - // 190 some kind of monster? maybe old mamool ja - // 191 Haurchefant in chain mail - // 192 Haurchefant in chain mail - // 193 elezen with a soul patch - // 194 young elezen (emman?) - // 195 elezen with awful facial hair - // 196 roe with straw hat (not the ronin kind) - // 197 generic man - // 198 generic anime man - // 199 Ranjit - // 200 Amalj'aa - // 201 shirtless roe man - // 202 different shirtless roe man - // 203 mutton chops guy - // 204 elezen with a sick red beard whoa - // 205 imperial pot helmet roe beard - // 206 creepy mask miqo - // 207 sylph purple - // 208 sylph green - // 209 weird monster guy - // 210 Erenville - // 211 Wuk Lamat (with hat) - // 212 giant Toucan - // 213 Arkasodara - // 214 some guy - // 215 imperial pot helmet - // 216 gridanian guy? - // 217 lady with cap - // 218 man with cap - // 219 roe with hat - // 220 lalafell with pot helm - // 221 miqo with pot helm - // 222 dude with mask - // 223 girl with pot helm - // 224 lala with pot helm - // 225 guy with cool hair - // 226 dude with pot helm - // 227 lala pot helm - // 228 hyur pot helm - // 229 pot helm - // 230 roe with bandana mask - // 231 yet another pot helm - // 232 poooot helm - // 233 thief rogue? - // 234 full face mask ascian with red floaty mask and hood - // 235 POT. HELM. - // 236 ph - // 237 roe man - // 238 sailor roe man - // 239 maelstrom roe lady - // 240 Mamool Ja - // 241 pot helm - // 242 creepy mask guy - // 243 wood wailer creepy mask - // 244 ix...al? - // 245 cfm - // 246 cfm ww - // 247 elezen with face paint - // 248 Moogle - // 249 lala with tiara and mustache - // 250 boy - // 251 hooded m roe - // 252 hyur m - // 253 hyur m - // 254 Papa...lymo? - // 255 dude - // 256 Emet Selch elpis version - // 257 Krile - // 258 Gulool Ja Ja with cover for dead head - // 259 some mamool ja - // 260 Bakool Ja Ja mystic - // 261 Bakool Ja Ja both heads - // 262 a mamool ja - // 263 another mamool ja - // 264 another mamool ja - // 265 Wuk Lamat without hat - // 266 Koana - // 267 old Gulool Ja Ja with both heads alive - // 268 head of resolve - // 269 head of reason - // 270 Sphene - // 271 evil Otis in machine form - // 272 good Otis in machine form - // 273 Sphene final boss form - // 274 looks like Zero kind of - // "73" + str(number) for index - var msg = rank switch { - < 0 => null, - 1 => "Well done! I never doubted for a second that you'd do so well.", - _ => "Keep trying, friend! You'll get there in the end.", + combatants.Sort((a, b) => a.EncDps.CompareTo(b.EncDps)); + var rank = (float) (combatants.FindIndex(combatant => combatant.Name == "YOU") + 1) / combatants.Count; + var evaluation = rank switch { + >= .85f => Evaluation.Best, + >= .65f => Evaluation.Good, + >= .45f => Evaluation.Fair, + >= .25f => Evaluation.Poor, + _ => Evaluation.Awful, }; - UIModule.Instance()->ShowBattleTalkImage("G'raha Tia", msg, 5f, 73012, 0); + var msg = evaluator.GetLineFor(evaluation); + if (msg != null) { + var bytes = msg.EncodeWithNullTerminator(); + UIModule.Instance()->ShowBattleTalkImage( + Encoding.UTF8.GetBytes(evaluator.Name), + bytes, + 5f, + evaluator.BattleTalkImage, + 0 + ); + } + } } diff --git a/PluginUi.cs b/PluginUi.cs index 28d278f..a0daa8b 100644 --- a/PluginUi.cs +++ b/PluginUi.cs @@ -92,6 +92,27 @@ public class PluginUi : IDisposable { } anyChanged |= ImGui.Checkbox("Show an NPC text bubble rating your performance after an encounter", ref this.Plugin.Config.UseEvaluatorNpc); + using (ImGuiHelper.DisabledUnless(this.Plugin.Config.UseEvaluatorNpc)) { + var current = Evaluator.Evaluators.FirstOrDefault(e => e.Id == this.Plugin.Config.EvaluatorId); + var preview = current == null + ? "None" + : current.Name; + if (ImGui.BeginCombo("Evaluator", preview)) { + using var endCombo = new OnDispose(ImGui.EndCombo); + + if (ImGui.Selectable("None", this.Plugin.Config.EvaluatorId == Guid.Empty)) { + anyChanged = true; + this.Plugin.Config.EvaluatorId = Guid.Empty; + } + + foreach (var evaluator in Evaluator.Evaluators) { + if (ImGui.Selectable(evaluator.Name, this.Plugin.Config.EvaluatorId == evaluator.Id)) { + anyChanged = true; + this.Plugin.Config.EvaluatorId = evaluator.Id; + } + } + } + } if (anyChanged) { this.Plugin.SaveConfig();