-
Notifications
You must be signed in to change notification settings - Fork 0
/
Essentials.cs
1965 lines (1919 loc) · 112 KB
/
Essentials.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using System.Linq;
using System.Collections.Generic;
using HarmonyLib;
using System.IO;
using UnityEngine;
using TMPro;
using static Enums;
using Steamworks.Data;
using Steamworks;
using System.Threading.Tasks;
using System;
using System.Text;
/*
FULL LIST OF ATO CLASSES->METHODS THAT ARE PATCHED:
*/
namespace Obeliskial_Essentials
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
[BepInProcess("AcrossTheObelisk.exe")]
public class Essentials : BaseUnityPlugin
{
internal const int ModDate = 20240516;
private readonly Harmony harmony = new(PluginInfo.PLUGIN_GUID);
internal static ManualLogSource Log;
public static ConfigEntry<bool> medsExportJSON { get; private set; }
public static ConfigEntry<bool> medsExportSprites { get; private set; }
public static ConfigEntry<bool> medsShowAtStart { get; private set; }
public static ConfigEntry<bool> medsConsistency { get; private set; }
public static ConfigEntry<bool> medsSkipLogos { get; private set; }
internal static Dictionary<string, string> medsNodeEvent = new();
internal static Dictionary<string, int> medsNodeEventPercent = new();
internal static Dictionary<string, int> medsNodeEventPriority = new();
internal static Dictionary<string, EventReplyDataText> medsEventReplyDataText = new();
internal static Dictionary<string, Node> medsNodeSource = new();
public static List<string> medsAllThePetsCards = new();
public static List<string> medsDropOnlyItems = new();
public static Dictionary<Enums.CardType, List<string>> medsBasicCardListByType = new();
public static Dictionary<Enums.CardClass, List<string>> medsBasicCardListByClass = new();
public static List<string> medsBasicCardListNotUpgraded = new();
public static Dictionary<Enums.CardClass, List<string>> medsBasicCardListNotUpgradedByClass = new();
public static Dictionary<string, List<string>> medsBasicCardListByClassType = new();
public static Dictionary<Enums.CardType, List<string>> medsBasicCardItemByType = new();
public static Dictionary<string, string> medsCustomCardDescriptions = new();
public static RewardsManager RewardsManagerInstance;
internal static string medsVersionText = "";
public static readonly string[] vanillaSubclasses = { "mercenary", "sentinel", "berserker", "warden", "ranger", "assassin", "archer", "minstrel", "elementalist", "pyromancer", "loremaster", "warlock", "cleric", "priest", "voodoowitch", "prophet", "bandit", "fallen", "paladin", "queen" };
public static Dictionary<string, string> medsTexts = new();
private static List<string> medsExportedSpritePaths = new();
internal static int medsForceWeekly = 0;
public static Dictionary<int, Mod> medsMods = new();
internal static Dictionary<string, List<string>> medsModAuthors = new();
public static Dictionary<string, string> medsLoadedDependencies = new();
public static string medsCloneTwo = "";
public static string medsCloneThree = "";
public static string medsCloneFour = "";
public static Dictionary<string, List<string>> medsBaseCardsListSearch = new();
public static List<string> medsF2UIOpen = new();
public static List<string> medsCheckSummary = new();
private void Awake()
{
Log = Logger;
LogInfo($"{PluginInfo.PLUGIN_GUID} {PluginInfo.PLUGIN_VERSION} has loaded!");
medsExportJSON = Config.Bind(new ConfigDefinition("Debug", "Export Vanilla Content"), false, new ConfigDescription("Export AtO class data to JSON files that are compatible with Obeliskial Content."));
medsExportSprites = Config.Bind(new ConfigDefinition("Debug", "Export Sprites"), true, new ConfigDescription("Export sprites when exporting JSON files."));
medsShowAtStart = Config.Bind(new ConfigDefinition("Debug", "Show At Start"), true, new ConfigDescription("Show the mod version window when the game loads."));
medsConsistency = Config.Bind(new ConfigDefinition("Should Be Vanilla", "Disable Paradox Integration"), true, new ConfigDescription("Disable Paradox integration and telemetry (does not include launcher)."));
medsSkipLogos = Config.Bind(new ConfigDefinition("Should Be Vanilla", "Skip Logos"), true, new ConfigDescription("Skip logos on startup."));
UniverseLib.Universe.Init(1f, ObeliskialUI.InitUI, LogHandler, new()
{
Disable_EventSystem_Override = false, // or null
Force_Unlock_Mouse = true, // or null
Unhollowed_Modules_Folder = null
});
UniverseLib.Universe.Init(1f, DevTools.Init, LogHandler, new()
{
Disable_EventSystem_Override = false, // or null
Force_Unlock_Mouse = true, // or null
Unhollowed_Modules_Folder = null
});
UniverseLib.Universe.Init(1f, ProfileEditor.Init, LogHandler, new()
{
Disable_EventSystem_Override = false, // or null
Force_Unlock_Mouse = true, // or null
Unhollowed_Modules_Folder = null
});
RegisterMod(_name: PluginInfo.PLUGIN_NAME, _author: "stiffmeds", _description: "Essential reference classes and methods for Across the Obelisk modding.", _version: PluginInfo.PLUGIN_VERSION, _date: ModDate, _link: @"https://across-the-obelisk.thunderstore.io/package/meds/Obeliskial_Essentials/", _priority: int.MaxValue, _type: new string[1] { "Core" });
//AddModVersionText(PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION, ModDate.ToString());
harmony.PatchAll();
}
internal static void LogDebug(string msg)
{
Log.LogDebug(msg);
}
internal static void LogInfo(string msg)
{
Log.LogInfo(msg);
}
internal static void LogWarning(string msg)
{
Log.LogWarning(msg);
}
internal static void LogError(string msg)
{
Log.LogError(msg);
}
void LogHandler(string message, UnityEngine.LogType type)
{
string log = message?.ToString() ?? "";
switch (type)
{
case UnityEngine.LogType.Assert:
case UnityEngine.LogType.Log:
LogInfo(log);
break;
case UnityEngine.LogType.Warning:
LogWarning(log);
break;
case UnityEngine.LogType.Error:
case UnityEngine.LogType.Exception:
LogError(log);
break;
}
}
public static void ExportSprite(Sprite spriteToExport, string spriteType, string subType = "", string subType2 = "", bool fullTextureExport = false)
{
if (spriteToExport.textureRect.width == 0 || spriteToExport.textureRect.height == 0) { return; }
LogDebug("Exporting sprite: " + spriteToExport.name);
string filePath = Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "sprite", spriteType);
if (!subType.IsNullOrWhiteSpace())
{
filePath = Path.Combine(filePath, subType);
if (!subType2.IsNullOrWhiteSpace())
filePath = Path.Combine(filePath, subType2);
}
Texture2D finalImage;
Texture2D readableText;
FolderCreate(filePath);
filePath = Path.Combine(filePath, (fullTextureExport ? spriteToExport.texture.name : spriteToExport.name) + ".png");
if (medsExportedSpritePaths.Contains(filePath))
return;
RenderTexture renderTex = RenderTexture.GetTemporary((int)spriteToExport.texture.width, (int)spriteToExport.texture.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear);
// we flip it when doing the Graphics.Blit because the sprites are packed (which... flips them? idk?)
Graphics.Blit(spriteToExport.texture, renderTex, new Vector2(1, -1), new Vector2(0, 1));
RenderTexture previous = RenderTexture.active;
RenderTexture.active = renderTex;
readableText = fullTextureExport ? new((int)spriteToExport.texture.width, (int)spriteToExport.texture.height) : new((int)spriteToExport.textureRect.width, (int)spriteToExport.textureRect.height);
readableText.ReadPixels(fullTextureExport ? new Rect(0, 0, spriteToExport.texture.width, spriteToExport.texture.height) : new Rect(spriteToExport.textureRect.x, spriteToExport.textureRect.y, spriteToExport.textureRect.width, spriteToExport.textureRect.height), 0, 0);
readableText.Apply();
RenderTexture.active = previous;
RenderTexture.ReleaseTemporary(renderTex);
// flip it back
finalImage = fullTextureExport ? new((int)spriteToExport.texture.width, (int)spriteToExport.texture.height) : new((int)spriteToExport.textureRect.width, (int)spriteToExport.textureRect.height);
for (int i = 0; i < readableText.width; i++)
for (int j = 0; j < readableText.height; j++)
finalImage.SetPixel(i, readableText.height - j - 1, readableText.GetPixel(i, j));
finalImage.Apply();
File.WriteAllBytes(filePath, ImageConversion.EncodeToPNG(finalImage));
medsExportedSpritePaths.Add(filePath);
}
public static void FolderCreate(string folderPath)
{
DirectoryInfo medsDI = new(folderPath);
if (!medsDI.Exists)
medsDI.Create();
}
public static void AddModVersionText(string sModName, string sModVersion, string sModDate)
{
string newText = sModName + " v" + sModVersion + (sModDate.IsNullOrWhiteSpace() ? "" : (" (" + sModDate + ")"));
if (medsVersionText.IsNullOrWhiteSpace())
medsVersionText = newText;
else if (!medsVersionText.Contains(newText))
medsVersionText += "\n" + newText;
}
public static void RegisterMod(string _name, string _author = "", string _description = "", string _version = "1.0.0", int _date = 19920101, string _link = "", string[] _dependencies = null, string _contentFolder = "", int _priority = 100, string[] _type = null, string _comment = "", bool _enabled = true)
{
Mod _mod = new(_name, _author, _description, _version, _date, _link, _dependencies, _contentFolder, _priority, _type, _comment, _enabled);
RegisterMod(_mod);
}
public static void RegisterMod(Mod _mod)
{
if (medsModAuthors.ContainsKey(_mod.Author.ToLower()))
{
if (medsModAuthors[_mod.Author.ToLower()].Contains(_mod.Name.ToLower()))
{
LogError("Attempting to register duplicate mod: " + _mod.Author + " - " + _mod.Name);
}
else
{
medsModAuthors[_mod.Author.ToLower()].Add(_mod.Name.ToLower());
medsMods[medsMods.Count] = _mod;
}
}
else
{
medsModAuthors[_mod.Author.ToLower()] = new() { _mod.Name.ToLower() };
medsMods[medsMods.Count] = _mod;
}
if (_mod.Enabled)
{
if (_mod.ContentFolder.IsNullOrWhiteSpace()) // no custom content to load
medsLoadedDependencies[_mod.Author.ToLower().Replace(" ", "_") + "-" + _mod.Name.ToLower().Replace(" ", "_")] = _mod.Version.ToLower();
string newText = _mod.Name + " v" + _mod.Version + (_mod.Date == 19920101 ? "" : " (" + _mod.Date.ToString() + ")");
if (medsVersionText.IsNullOrWhiteSpace())
medsVersionText = newText;
else if (!medsVersionText.Contains(newText))
medsVersionText += "\n" + newText;
}
}
public static string TextChargesLeft(int currentCharges, int chargesTotal)
{
int cCharges = currentCharges;
int cTotal = chargesTotal;
return "<br><color=#FFF>" + cCharges.ToString() + "/" + cTotal.ToString() + "</color>";
}
public static void ExtractData<T>(T[] data)
{
//string combined = "{";
//int h = 1; // counts hundreds for combined files
for (int a = 1; a <= data.Length; a++)
{
string type = "";
string id = "";
string text = "";
string textFULL = "";
bool pretty = true;
if (data[a - 1].GetType() == typeof(SubClassData))
{
type = "subclass";
SubClassData d = (SubClassData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(TraitData))
{
type = "trait";
TraitData d = (TraitData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(CardData))
{
type = "card";
CardData d = (CardData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(PerkData))
{
type = "perk";
PerkData d = (PerkData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(AuraCurseData))
{
type = "auraCurse";
AuraCurseData d = (AuraCurseData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(NPCData))
{
type = "npc";
NPCData d = (NPCData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(NodeData))
{
type = "node";
NodeData d = (NodeData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
textFULL = JsonUtility.ToJson(DataTextConvert.ToFULLText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(LootData))
{
type = "loot";
LootData d = (LootData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(PerkNodeData))
{
type = "perkNode";
PerkNodeData d = (PerkNodeData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(ChallengeData))
{
type = "challengeData";
ChallengeData d = (ChallengeData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(ChallengeTrait))
{
type = "challengeTrait";
ChallengeTrait d = (ChallengeTrait)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(CombatData))
{
type = "combatData";
CombatData d = (CombatData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(EventData))
{
type = "event";
EventData d = (EventData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(EventReplyDataText))
{
type = "eventReply";
EventReplyDataText d = (EventReplyDataText)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(d, pretty);
}
else if (data[a - 1].GetType() == typeof(EventRequirementData))
{
type = "eventRequirement";
EventRequirementData d = (EventRequirementData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(ZoneData))
{
type = "zone";
ZoneData d = (ZoneData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(KeyNotesData))
{
type = "keynote";
KeyNotesData d = (KeyNotesData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(PackData))
{
type = "pack";
PackData d = (PackData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(CardPlayerPackData))
{
type = "cardPlayerPack";
CardPlayerPackData d = (CardPlayerPackData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(CardPlayerPairsPackData))
{
type = "pairsPack";
CardPlayerPairsPackData d = (CardPlayerPairsPackData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(ItemData))
{
type = "item";
ItemData d = (ItemData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(CardbackData))
{
type = "cardback";
CardbackData d = (CardbackData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(SkinData))
{
type = "skin";
SkinData d = (SkinData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(CorruptionPackData))
{
type = "corruptionPack";
CorruptionPackData d = (CorruptionPackData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(CinematicData))
{
type = "cinematic";
CinematicData d = (CinematicData)(object)data[a - 1];
id = DataTextConvert.ToString(d);
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else if (data[a - 1].GetType() == typeof(TierRewardData))
{
type = "tierReward";
TierRewardData d = (TierRewardData)(object)data[a - 1];
id = d.TierNum.ToString();
text = JsonUtility.ToJson(DataTextConvert.ToText(d), pretty);
}
else
{
Log.LogError("Unknown type while extracting data: " + data[a - 1].GetType());
return;
}
//text = text.Replace(@""":false,", @""":0,").Replace(@""":false}", @""":0}").Replace(@""":true,", @""":1,").Replace(@""":true}", @""":1}");
if (a == 1)
{
FolderCreate(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", type));
File.WriteAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "!combined", type + ".json"), "[{\n");
if (textFULL != "")
{
FolderCreate(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", type + "_FULL"));
File.WriteAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "!combined", type + "_FULL.json"), "[{\n");
}
}
WriteToJSON(type, text, id);
if (textFULL != "")
WriteToJSON(type + "_FULL", textFULL, id);
if (a == data.Length)
{
// WriteToJSON(type, combined.Remove(combined.Length - 1) + "}", a, h);
File.AppendAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "!combined", type + ".json"), "\"" + id + "\": " + text + "}]");
if (textFULL != "")
File.AppendAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "!combined", type + "_FULL.json"), "\"" + id + "\": " + textFULL + "]");
Log.LogInfo("exported " + a + " " + type + " values!");
}
else
{
File.AppendAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "!combined", type + ".json"), "\"" + id + "\": " + text + ",");
if (textFULL != "")
File.AppendAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "!combined", type + "_FULL.json"), "\"" + id + "\": " + textFULL + ",");
}
}
}
public static void WriteToJSON(string exportType, string exportText, string exportID)
{
FolderCreate(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", exportType));
File.WriteAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", exportType, exportID + ".json"), exportText);
}
public static bool IsHost()
{
if ((GameManager.Instance.IsMultiplayer() && NetworkManager.Instance.IsMaster()) || !GameManager.Instance.IsMultiplayer())
return true;
return false;
}
public static int TeamHeroToInt(Hero[] medsTeam)
{
int team = 0;
for (int index = 0; index < 4; ++index)
team += (Array.IndexOf(vanillaSubclasses, medsTeam[index].SubclassName) + 1) * (int)Math.Pow(100, index);
LogDebug("TeamHeroToInt: " + team);
return team;
}
public static string TeamIntToString(int team)
{
int[] iTeam = new int[4];
string[] sTeam = new string[4];
iTeam[3] = team / 1000000;
iTeam[2] = (team % 1000000) / 10000;
iTeam[1] = (team % 10000) / 100;
iTeam[0] = (team % 100);
for (int a = 0; a < 4; a++)
{
if (iTeam[a] < 1 || iTeam[a] > vanillaSubclasses.Length)
sTeam[a] = "UNKNOWN";
else
sTeam[a] = vanillaSubclasses[iTeam[a] - 1];
}
LogDebug("TeamIntToString: " + string.Join(", ", sTeam));
return string.Join(", ", sTeam);
}
public static async Task SetScoreLeaderboard(int score, bool singleplayer = true, string mode = "RankingAct4")
{
int gameId32 = Functions.StringToAsciiInt32(AtOManager.Instance.GetGameId());
int details = Convert.ToInt32(gameId32 + score * 101);
int seed = AtOManager.Instance.GetGameId().GetDeterministicHashCode();
int team = TeamHeroToInt(AtOManager.Instance.GetTeam());
int nodes = 0; // #TODO: nodelist
string[] gameVersion = GameManager.Instance.gameVersion.Split(".");
int vanillaVersion = int.Parse(gameVersion[0]) * 10000 + int.Parse(gameVersion[1]) * 100 + int.Parse(gameVersion[2]);
int obeliskialVersion = ModDate;
Leaderboard? leaderboardAsync = await SteamUserStats.FindLeaderboardAsync(mode + (singleplayer ? "" : "Coop"));
if (leaderboardAsync.HasValue)
{
LeaderboardUpdate? nullable = await leaderboardAsync.Value.SubmitScoreAsync(score, new int[7]
{
gameId32,
details,
vanillaVersion,
obeliskialVersion,
seed,
team,
nodes
});
}
else
Debug.Log((object)"Couldn't Get Leaderboard!");
}
public static void OptimalPathSeed()
{
List<string[]> nodeList = new();
// Senenthia: 2 events, 4 corruptors
nodeList.Add(new string[4] { "Betty", "sen_6", "e_sen6_b", "Senenthia" });
nodeList.Add(new string[4] { "combat", "sen_9", "", "Senenthia" });
nodeList.Add(new string[4] { "combat", "secta_2", "", "Senenthia" });
nodeList.Add(new string[4] { "combat", "sen_19", "", "Senenthia" });
nodeList.Add(new string[4] { "Soldier Trainer", "sen_37", "e_sen37_a", "Senenthia" });
nodeList.Add(new string[4] { "combat", "sen_28", "", "Senenthia" });
// Aquarfall: 7 corruptors
nodeList.Add(new string[4] { "combat", "aqua_4", "", "Aquarfall" });
nodeList.Add(new string[4] { "combat", "aqua_12", "", "Aquarfall" });
nodeList.Add(new string[4] { "combat", "aqua_10", "", "Aquarfall" });
nodeList.Add(new string[4] { "combat", "aqua_15", "", "Aquarfall" });
nodeList.Add(new string[4] { "combat", "spider_3", "", "Aquarfall" });
nodeList.Add(new string[4] { "combat", "spider_4", "", "Aquarfall" });
nodeList.Add(new string[4] { "combat", "aqua_33", "", "Aquarfall" });
// Faeborg: 2 events, 6 corruptors
/*nodeList.Add(new string[4] { "Monster Trainer", "faen_7", "", "Faeborg" });
nodeList.Add(new string[4] { "combat", "faen_8", "", "Faeborg" });
nodeList.Add(new string[4] { "combat", "faen_14", "", "Faeborg" });
nodeList.Add(new string[4] { "combat", "faen_24", "", "Faeborg" });
nodeList.Add(new string[4] { "Binks", "faen_40", "e_faen40_a", "Faeborg" });
nodeList.Add(new string[4] { "Charls", "faen_40", "e_faen40_b", "Faeborg" });
nodeList.Add(new string[4] { "combat", "sewers_2", "", "Faeborg" });
nodeList.Add(new string[4] { "combat", "sewers_12", "", "Faeborg" });
nodeList.Add(new string[4] { "combat", "faen_37", "", "Faeborg" }); */
// Velkarath: 6 corruptors
nodeList.Add(new string[4] { "combat", "velka_2", "", "Velkarath" });
nodeList.Add(new string[4] { "combat", "velka_5", "", "Velkarath" });
nodeList.Add(new string[4] { "combat", "velka_13", "", "Velkarath" });
nodeList.Add(new string[4] { "combat", "forge_1", "", "Velkarath" }); // using upper path because it's more consistent
nodeList.Add(new string[4] { "combat", "velka_28", "", "Velkarath" });
nodeList.Add(new string[4] { "combat", "velka_31", "", "Velkarath" });
// Voidlow: 1 event, 5 corruptors
nodeList.Add(new string[4] { "combat", "voidlow_2", "", "Voidlow" });
nodeList.Add(new string[4] { "combat", "voidlow_9", "", "Voidlow" });
nodeList.Add(new string[4] { "combat", "voidlow_10", "", "Voidlow" });
nodeList.Add(new string[4] { "Chromatic Slime", "voidlow_27", "e_voidlow27_a", "Voidlow" });
nodeList.Add(new string[4] { "combat", "voidlow_19", "", "Voidlow" });
nodeList.Add(new string[4] { "combat", "voidlow_22", "", "Voidlow" });
// Voidhigh: 2 corruptors
nodeList.Add(new string[4] { "combat", "voidhigh_2", "", "Voidhigh" });
nodeList.Add(new string[4] { "combat", "voidhigh_10", "", "Voidhigh" });
for (int a = 1325259; a <= 9999999; a++)
{
string seed = a.ToString();
CheckSeed(seed, nodeList);
}
/*for (int a = 0; a <= 9; a++)
{
for (int b = 0; b <= 9; b++)
{
for (int c = 0; c <= 9; c++)
{
for (int d = 0; d <= 9; d++)
{
for (int e = 0; e <= 9; e++)
{
for (int f = 0; f <= 9; f++)
{
for (int g = 0; g <= 9; g++)
{
string seed = a.ToString() + b.ToString() + c.ToString() + d.ToString() + e.ToString() + f.ToString() + g.ToString();
CheckSeed(seed, nodeList);
}
}
}
}
}
}
}*/
}
public static void CheckSeed(string seed, List<string[]> nodeList)
{
int medsCommon = 0;
int medsUncommon = 0;
int medsRare = 0;
int medsEpic = 0;
int medsEvents = 0;
Dictionary<string, int> zoneEventCount = new();
Dictionary<string, int> zoneCommonCount = new();
Dictionary<string, int> zoneUncommonCount = new();
Dictionary<string, int> zoneRareCount = new();
Dictionary<string, int> zoneEpicCount = new();
zoneEventCount["Senenthia"] = 0;
zoneEventCount["Aquarfall"] = 0;
zoneEventCount["Faeborg"] = 0;
zoneEventCount["Velkarath"] = 0;
zoneEventCount["Voidlow"] = 0;
zoneEventCount["Voidhigh"] = 0;
zoneCommonCount["Senenthia"] = 0;
zoneCommonCount["Aquarfall"] = 0;
zoneCommonCount["Faeborg"] = 0;
zoneCommonCount["Velkarath"] = 0;
zoneCommonCount["Voidlow"] = 0;
zoneCommonCount["Voidhigh"] = 0;
zoneUncommonCount["Senenthia"] = 0;
zoneUncommonCount["Aquarfall"] = 0;
zoneUncommonCount["Faeborg"] = 0;
zoneUncommonCount["Velkarath"] = 0;
zoneUncommonCount["Voidlow"] = 0;
zoneUncommonCount["Voidhigh"] = 0;
zoneRareCount["Senenthia"] = 0;
zoneRareCount["Aquarfall"] = 0;
zoneRareCount["Faeborg"] = 0;
zoneRareCount["Velkarath"] = 0;
zoneRareCount["Voidlow"] = 0;
zoneRareCount["Voidhigh"] = 0;
zoneEpicCount["Senenthia"] = 0;
zoneEpicCount["Aquarfall"] = 0;
zoneEpicCount["Faeborg"] = 0;
zoneEpicCount["Velkarath"] = 0;
zoneEpicCount["Voidlow"] = 0;
zoneEpicCount["Voidhigh"] = 0;
foreach (string[] nodeData in nodeList)
{
NodeData _node = Globals.Instance.GetNodeData(nodeData[1]);
// Log.LogInfo("DHS: " + (_node.NodeId + seed + nameof(AtOManager.Instance.AssignSingleGameNode)));
UnityEngine.Random.InitState((_node.NodeId + seed + nameof(AtOManager.Instance.AssignSingleGameNode)).GetDeterministicHashCode());
// Log.LogInfo("DHC: " + (_node.NodeId + seed + nameof(AtOManager.Instance.AssignSingleGameNode)).GetDeterministicHashCode());
if (UnityEngine.Random.Range(0, 100) < _node.ExistsPercent)
{
bool flag1 = true;
bool flag2 = true;
if (_node.NodeEvent != null && _node.NodeEvent.Length != 0 && _node.NodeCombat != null && _node.NodeCombat.Length != 0)
{
if (UnityEngine.Random.Range(0, 100) < _node.CombatPercent)
flag1 = false;
else
flag2 = false;
}
if (flag1 && _node.NodeEvent != null && _node.NodeEvent.Length != 0) // event!
{
string str = "";
Dictionary<string, int> source = new Dictionary<string, int>();
for (int index = 0; index < _node.NodeEvent.Length; ++index)
{
int num = 10000;
if (index < _node.NodeEventPriority.Length)
num = _node.NodeEventPriority[index];
source.Add(_node.NodeEvent[index].EventId, num);
}
if (source.Count > 0)
{
Dictionary<string, int> dictionary1 = source.OrderBy<KeyValuePair<string, int>, int>((Func<KeyValuePair<string, int>, int>)(x => x.Value)).ToDictionary<KeyValuePair<string, int>, string, int>((Func<KeyValuePair<string, int>, string>)(x => x.Key), (Func<KeyValuePair<string, int>, int>)(x => x.Value));
int num1 = 1;
int num2 = dictionary1.ElementAt<KeyValuePair<string, int>>(0).Value;
while (num1 < dictionary1.Count && dictionary1.ElementAt<KeyValuePair<string, int>>(num1).Value == num2)
++num1;
if (num1 == 1)
{
str = dictionary1.ElementAt<KeyValuePair<string, int>>(0).Key;
}
else
{
if (_node.NodeEventPercent != null && _node.NodeEvent.Length == _node.NodeEventPercent.Length)
{
Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
int index1 = 0;
for (int index2 = 0; index2 < num1; ++index2)
{
int index3 = 0;
while (index2 < _node.NodeEvent.Length)
{
if (_node.NodeEvent[index3].EventId == dictionary1.ElementAt<KeyValuePair<string, int>>(index1).Key)
{
dictionary2.Add(_node.NodeEvent[index3].EventId, _node.NodeEventPercent[index3]);
++index1;
break;
}
++index3;
}
}
int num3 = UnityEngine.Random.Range(0, 100);
int num4 = 0;
foreach (KeyValuePair<string, int> keyValuePair in dictionary2)
{
num4 += keyValuePair.Value;
if (num3 < num4)
{
str = keyValuePair.Key;
break;
}
}
}
if (str == "")
{
int index = UnityEngine.Random.Range(0, num1);
str = dictionary1.ElementAt<KeyValuePair<string, int>>(index).Key;
}
}
if (str == nodeData[2])
{
// this is the event we want!
medsEvents++;
zoneEventCount[nodeData[3]]++;
}
}
}
else if (nodeData[0] == "combat" && flag2 && _node.NodeCombat != null && _node.NodeCombat.Length != 0) // combat!
{
string combatID = _node.NodeCombat[0].CombatId;
string str = _node.NodeId + seed;
int deterministicHashCode = str.GetDeterministicHashCode();
UnityEngine.Random.InitState(deterministicHashCode);
List<string> stringList = new List<string>();
for (int index = 0; index < Globals.Instance.CardListByType[Enums.CardType.Corruption].Count; ++index)
{
CardData cardData = Globals.Instance.GetCardData(Globals.Instance.CardListByType[Enums.CardType.Corruption][index], false);
if ((UnityEngine.Object)cardData != (UnityEngine.Object)null && !cardData.OnlyInWeekly)
stringList.Add(Globals.Instance.CardListByType[Enums.CardType.Corruption][index]);
}
bool flag3 = false;
int medsRandomCorruptionIndex;
string medsCorruptionIdCard = "";
CardData medsCDataCorruption = null;
while (!flag3)
{
int index1 = UnityEngine.Random.Range(0, stringList.Count);
medsRandomCorruptionIndex = index1;
medsCorruptionIdCard = stringList[index1];
if (!(medsCorruptionIdCard == "resurrection") && !(medsCorruptionIdCard == "resurrectiona") && !(medsCorruptionIdCard == "resurrectionb") && !(medsCorruptionIdCard == "resurrectionrare"))
{
for (int index2 = 0; index2 < deterministicHashCode % 10; ++index2)
UnityEngine.Random.Range(0, 100);
medsCDataCorruption = Globals.Instance.GetCardData(medsCorruptionIdCard, false);
if (!((UnityEngine.Object)medsCDataCorruption == (UnityEngine.Object)null) && (!medsCDataCorruption.OnlyInWeekly))
flag3 = true;
}
}
if ((UnityEngine.Object)medsCDataCorruption == (UnityEngine.Object)null)
medsCDataCorruption = Globals.Instance.GetCardData(medsCorruptionIdCard, false);
if (medsCDataCorruption.CardRarity == CardRarity.Common)
{
zoneCommonCount[nodeData[3]]++;
medsCommon++;
}
else if (medsCDataCorruption.CardRarity == CardRarity.Uncommon)
{
zoneUncommonCount[nodeData[3]]++;
medsUncommon++;
}
else if (medsCDataCorruption.CardRarity == CardRarity.Rare)
{
zoneRareCount[nodeData[3]]++;
medsRare++;
}
else if (medsCDataCorruption.CardRarity == CardRarity.Epic)
{
zoneEpicCount[nodeData[3]]++;
medsEpic++;
}
}
}
}
/*string z = "Senenthia";
Log.LogInfo("SEED " + seed + ": SENEN " + zoneEventCount[z] + "/2 events, " + (zoneCommonCount[z] + zoneUncommonCount[z] + zoneRareCount[z] + zoneEpicCount[z]).ToString() + "/4 combats (" + zoneEpicCount[z] + "E " + zoneRareCount[z] + "R " + zoneUncommonCount[z] + "U " + zoneCommonCount[z] + "C)");
z = "Aquarfall";
Log.LogInfo("SEED " + seed + ": AQUAR " + (zoneCommonCount[z] + zoneUncommonCount[z] + zoneRareCount[z] + zoneEpicCount[z]).ToString() + "/7 combats (" + zoneEpicCount[z] + "E " + zoneRareCount[z] + "R " + zoneUncommonCount[z] + "U " + zoneCommonCount[z] + "C)");
// z = "Faeborg";
// Log.LogInfo("SEED " + seed + ": FAEBO " + zoneEventCount[z] + "/2 events, " + (zoneCommonCount[z] + zoneUncommonCount[z] + zoneRareCount[z] + zoneEpicCount[z]).ToString() + "/6 combats (" + zoneEpicCount[z] + "E " + zoneRareCount[z] + "R " + zoneUncommonCount[z] + "U " + zoneCommonCount[z] + "C)");
z = "Velkarath";
Log.LogInfo("SEED " + seed + ": VELKA " + (zoneCommonCount[z] + zoneUncommonCount[z] + zoneRareCount[z] + zoneEpicCount[z]).ToString() + "/6 combats (" + zoneEpicCount[z] + "E " + zoneRareCount[z] + "R " + zoneUncommonCount[z] + "U " + zoneCommonCount[z] + "C)");
z = "Voidlow";
Log.LogInfo("SEED " + seed + ": VOIDL " + zoneEventCount[z] + "/1 events, " + (zoneCommonCount[z] + zoneUncommonCount[z] + zoneRareCount[z] + zoneEpicCount[z]).ToString() + "/5 combats (" + zoneEpicCount[z] + "E " + zoneRareCount[z] + "R " + zoneUncommonCount[z] + "U " + zoneCommonCount[z] + "C)");
z = "Voidhigh";
Log.LogInfo("SEED " + seed + ": VOIDH " + (zoneCommonCount[z] + zoneUncommonCount[z] + zoneRareCount[z] + zoneEpicCount[z]).ToString() + "/2 combats (" + zoneEpicCount[z] + "E " + zoneRareCount[z] + "R " + zoneUncommonCount[z] + "U " + zoneCommonCount[z] + "C)");*/
Log.LogInfo("SEED " + seed + ": TOTAL " + medsEvents + "/3 events, " + (medsCommon + medsUncommon + medsRare + medsEpic).ToString() + "/24 combats (" + medsEpic + "E " + medsRare + "R " + medsUncommon + "U " + medsCommon + "C)");
}
public static void SetTeamExperience(int xp)
{
Hero[] medsTeamAtO = Traverse.Create(AtOManager.Instance).Field("teamAtO").GetValue<Hero[]>();
for (int index = 0; index < medsTeamAtO.Length; ++index)
medsTeamAtO[index].Experience = xp;
Traverse.Create(AtOManager.Instance).Field("teamAtO").SetValue(medsTeamAtO);
}
public async static void CheckLeaderboards(string leaderboardType)
{
Leaderboard? leaderboard = new Leaderboard?();
leaderboard = await SteamUserStats.FindLeaderboardAsync(leaderboardType);
if (!leaderboard.HasValue)
{
Debug.Log((object)"Couldn't Get Leaderboard!");
}
else
{
LeaderboardEntry[] scoreboardGlobal = await leaderboard.Value.GetScoresAsync(450);
Leaderboard leaderboard1 = leaderboard.Value;
// LeaderboardEntry[] scoreboardFriends = await leaderboard1.GetScoresFromFriendsAsync();
leaderboard1 = leaderboard.Value;
LeaderboardEntry[] scoreboardSingle = await leaderboard1.GetScoresAroundUserAsync(0, 0);
string theList = "ID\tScore\tDetails\t2\t3\t4\t5\t6\t7\t8\t9\t10";
for (int a = 0; a < scoreboardGlobal.Length; a++)
theList += "\n" + (SteamManager.Instance.shameList.Contains(scoreboardGlobal[a].User.Id.ToString()) ? "SHAME:" : "") + scoreboardGlobal[a].User.Id.ToString() + "\t" + scoreboardGlobal[a].Score + "\t" + string.Join("\t", scoreboardGlobal[a].Details);
File.WriteAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "scoreboardGlobal.json"), theList);
theList = "";
for (int a = 0; a < scoreboardSingle.Length; a++)
theList += "\n" + scoreboardSingle[a].User.Id.ToString() + "\t" + scoreboardSingle[a].Score + "\t" + string.Join("\t", scoreboardSingle[a].Details);
File.WriteAllText(Path.Combine(Paths.ConfigPath, "Obeliskial_exported", "scoreboardSingle.json"), theList);
}
}
public static System.Collections.IEnumerator FullCardSpriteOutputCo(bool toToKFolder = false, UniverseLib.UI.Models.ButtonRef _btn = null)
{
string origText = "";
if (_btn != null)
{
_btn.ButtonText.alignment = TextAnchor.MiddleLeft;
origText = _btn.ButtonText.text;
}
//SceneStatic.LoadByName("TomeofKnowledge");
//yield return Globals.Instance.WaitForSeconds(5f);
SnapshotCamera snapshotCamera = SnapshotCamera.MakeSnapshotCamera(0);
CardScreenManager.Instance.ShowCardScreen(true);
// for each card in cards
Dictionary<string, CardData> allCards = Traverse.Create(Globals.Instance).Field("_CardsSource").GetValue<Dictionary<string, CardData>>();
LogInfo("i herd u liek memory leaks ;)");
int a = 1;
foreach (KeyValuePair<string, CardData> kvp in allCards)
{
if (a == 100)
Globals.Instance.StartCoroutine(DevTools.medsButtonTextRevert(DevTools.btnProfileEditor, "i herd u liek memory leaks ;)"));
LogInfo("EXTRACTING CARD IMAGE:" + kvp.Key);
if (_btn != null)
_btn.ButtonText.text = "Creating image " + a.ToString() + @"/" + allCards.Count() + ": " + kvp.Key;
CardScreenManager.Instance.SetCardData(kvp.Value);
GameObject cardGO = Traverse.Create(CardScreenManager.Instance).Field("cardGO").GetValue<GameObject>();
if ((UnityEngine.Object)cardGO != (UnityEngine.Object)null)
{
cardGO.transform.Find("BorderCard").gameObject.SetActive(false);
cardGO.transform.Find("Lock").gameObject.SetActive(false);
Texture2D snapshot = snapshotCamera.TakeObjectSnapshot(cardGO, UnityEngine.Color.clear, new Vector3(0, 0.008f, 1), Quaternion.Euler(new Vector3(0f, 0f, 0f)), new Vector3(0.78f, 0.78f, 0.78f), 297, 450);
string path = toToKFolder ? Path.Combine(Paths.GameRootPath, "Tome of Knowledge", "card_images") : Path.Combine(Paths.GameRootPath, "Card Images", DataTextConvert.ToString(kvp.Value.CardClass));
SnapshotCamera.SavePNG(snapshot, kvp.Key, Directory.CreateDirectory(path).FullName);
/*if (kvp.Value.CardType == CardType.Corruption)
SnapshotCamera.SavePNG(snapshot, kvp.Key, Directory.CreateDirectory(Path.Combine(Application.dataPath, "../Card Images", DataTextConvert.ToString(kvp.Value.CardType))).FullName);*/
UnityEngine.Object.Destroy(snapshot);
UnityEngine.Object.Destroy(cardGO);
}
a++;
yield return Globals.Instance.WaitForSeconds(0.01f);
}
if (_btn != null)
{
_btn.ButtonText.alignment = TextAnchor.MiddleCenter;
_btn.ButtonText.text = origText;
Globals.Instance.StartCoroutine(DevTools.medsButtonTextRevert(_btn));
}
Application.OpenURL(@"file://" + Path.Combine(Paths.GameRootPath, toToKFolder ? "Tome of Knowledge" : "Card Images"));
yield return null;
}
public static void TomeOfKnowledgeExport(bool exportImages = true, UniverseLib.UI.Models.ButtonRef _btn = null)
{
List<string> doneList = new();
foreach(string id in Globals.Instance.Cards.Keys)
{
CardData card = Globals.Instance.GetCardData(id, false);
if (card != null)
{
CardData relatedCard = Globals.Instance.GetCardData(card.RelatedCard, false);
if (relatedCard != null && (card.CardClass == CardClass.Monster || (card.CardClass == CardClass.Item && relatedCard.CardClass == CardClass.Special) || (card.CardClass == CardClass.Special && relatedCard.CardClass == CardClass.Special && relatedCard.CardType != CardType.Enchantment)) && !doneList.Contains(relatedCard.Id))
doneList.Add(relatedCard.Id);
CardData relatedCard2 = Globals.Instance.GetCardData(card.RelatedCard2, false);
if (relatedCard2 != null && (card.CardClass == CardClass.Monster || (card.CardClass == CardClass.Item && relatedCard2.CardClass == CardClass.Special) || (card.CardClass == CardClass.Special && relatedCard2.CardClass == CardClass.Special && relatedCard2.CardType != CardType.Enchantment)) && !doneList.Contains(relatedCard2.Id))
doneList.Add(relatedCard2.Id);
CardData relatedCard3 = Globals.Instance.GetCardData(card.RelatedCard3, false);
if (relatedCard3 != null && (card.CardClass == CardClass.Monster || (card.CardClass == CardClass.Item && relatedCard3.CardClass == CardClass.Special) || (card.CardClass == CardClass.Special && relatedCard3.CardClass == CardClass.Special && relatedCard3.CardType != CardType.Enchantment)) && !doneList.Contains(relatedCard3.Id))
doneList.Add(relatedCard3.Id);
}
}
Dictionary<string, List<string>> cardIDs = new();
Dictionary<string, List<string>> relatedIDs = new();
// force order
cardIDs["Armageddon (Corruptor)"] = new();
cardIDs["Barrier"] = new();
cardIDs["Bonk Hammer (Item)"] = new();
cardIDs["Camouflage"] = new();
cardIDs["Charge Battery"] = new();
cardIDs["Death's Toll (Monster)"] = new();
cardIDs["Fire Blast"] = new();
cardIDs["Flash"] = new();
cardIDs["Foresight"] = new();
cardIDs["Frost Bolt"] = new();
cardIDs["Harley (Item)"] = new();
cardIDs["Heal"] = new();
cardIDs["Heal"] = new();
cardIDs["Holy Smite"] = new();
cardIDs["Intercept"] = new();
cardIDs["Mana Gem"] = new();
cardIDs["Poison Dart"] = new();
cardIDs["Quick Shot"] = new();
cardIDs["Rampage"] = new();
cardIDs["Sharpen"] = new();
cardIDs["Skillful"] = new();
cardIDs["Sneak Peek"] = new();
cardIDs["The Yogrinch (Corruptor)"] = new();
cardIDs["Thunderclap"] = new();
cardIDs["Toxic Blob (Item)"] = new();
cardIDs["Zap"] = new();
foreach (string id in Globals.Instance.Cards.Keys)
{
if (doneList.Contains(id))
continue;
CardData card = Globals.Instance.GetCardData(id, false);
if (card != null)
{
string cardname = card.CardName;
if (card.CardType == CardType.Corruption)
cardname += " (Corruptor)";
else if (card.CardClass == CardClass.Monster)
cardname += " (Monster)";
else if (card.CardClass == CardClass.Special && !card.Starter && card.CardType != CardType.Enchantment)
cardname += " (Special)";
else if (card.CardClass == CardClass.Item)
cardname += " (Item)";
if (!cardIDs.ContainsKey(cardname))
cardIDs[cardname] = new();
List<string> newRelated = new();
cardIDs[cardname].Add(card.Id);
foreach (string relatedID in GetRelatedCardIDs(card))
newRelated.Add(relatedID);
// blue upgrade
CardData upgrade1 = Globals.Instance.GetCardData(card.UpgradesTo1, false);
if (upgrade1 != null && !cardIDs[cardname].Contains(upgrade1.Id))
{
cardIDs[cardname].Add(upgrade1.Id);
doneList.Add(upgrade1.Id);
foreach (string relatedID in GetRelatedCardIDs(upgrade1))
newRelated.Add(relatedID);
}
// yellow upgrade
CardData upgrade2 = Globals.Instance.GetCardData(card.UpgradesTo2, false);
if (upgrade2 != null && !cardIDs[cardname].Contains(upgrade2.Id))
{
cardIDs[cardname].Add(upgrade2.Id);
doneList.Add(upgrade2.Id);
foreach (string relatedID in GetRelatedCardIDs(upgrade2))
newRelated.Add(relatedID);
}
// purple upgrade
if (card.UpgradesToRare != null)
{
cardIDs[cardname].Add(card.UpgradesToRare.Id);
doneList.Add(card.UpgradesToRare.Id);
foreach (string relatedID in GetRelatedCardIDs(card.UpgradesToRare))
newRelated.Add(relatedID);
}
cardIDs[cardname] = cardIDs[cardname].Distinct().ToList();
if (newRelated.Count > 0)
{
if (!relatedIDs.ContainsKey(cardname))
relatedIDs[cardname] = newRelated;
else
relatedIDs[cardname].AddRange(newRelated);
relatedIDs[cardname] = relatedIDs[cardname].Distinct().ToList();
}