-
Notifications
You must be signed in to change notification settings - Fork 2
/
CircleCalc.cs
1861 lines (1696 loc) · 81.2 KB
/
CircleCalc.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
//HMACSHA1
using System;
using System.Collections;
using GeniePlugin.Interfaces;
using System.Xml;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
namespace Standalone_Circle_Calc
{
public class CircleCalc : IPlugin
{
//Constant variable for the Properties of the plugin
//At the top for easy changes.
string _NAME = "Circle Calculator";
string _VERSION = "4.0.6b";
string _AUTHOR = "VTCifer";
string _DESCRIPTION = "Calculcates the circle requirments for different guilds. It will also sort skills form highest to lowest.";
public IHost _host; //Required for plugin
public System.Windows.Forms.Form _parent; //Required for plugin
bool _reqsLoaded = false;
string _reqsAuthor = "";
string _reqsVer = "0.0";
bool _sortLoaded = false;
string _sortAuthor = "";
string _sortVer = "0.0";
bool _debug = false;
string _pluginPath = "";
//Used in storing of Reqs, Hard, Soft, TopN
class ReqType
{
public string Name; //Display Name/Name of Skill
public string Skillset; //Group the skill belongs to in TopN
public int Circles1to10; //Circles 1-0
public int Circles11to30; //Cirlces 11-30
public int Circles31to70; //Circles 31-70
public int Circles71to100; //Circles 71-100
public int Circles101to150; //Circles101-150
public int Circles151Up; //Circles Higher than 150
}
class SortSkillGroup
{
public string Name;
public ArrayList Skills = new ArrayList();
public SkillSets Skillset;
};
//Stores all the requirements and the Groupings for a guild used in global hashtable GuildReqList
class GuildType
{
public Hashtable Skillsets = new Hashtable(); //filled with Skillset names, key is Skill name
public Hashtable HardReqs = new Hashtable(); //filled with ReqTypes, key is name
public Hashtable SoftReqs = new Hashtable(); //filled with ReqTypes, key is name
public ArrayList TopN = new ArrayList(); //filled with ReqTypes, no key, indexed by number
}
private Hashtable _GuildNameList = new Hashtable(); //filled with guild names, key is shortname
private Hashtable _GuildReqList = new Hashtable(); //filled with guildtypes, key is string
Hashtable _GroupNameList = new Hashtable();
Hashtable _SortGroupList = new Hashtable();
SortSkillGroup _CurrentSortGroup = new SortSkillGroup();
#region Circle Calc Members
/*
private enum Guilds
{
None,
Commoner,
Barbarian,
Bard,
Thief,
Empath,
MoonMage,
Trader,
Paladin,
Ranger,
Cleric,
WarriorMage,
Necromancer
};
private Guilds _guild = Guilds.Commoner; //
private Guilds _calcGuildName = Guilds.Commoner; //Default Guild set to Commonder
*/
private string _calcGuildName = "";
private GuildType _calcGuild = new GuildType();
private Hashtable _calcSkillsets = new Hashtable(); //filled with hashtable of skills, key is skillset name. internal hashtable is keyed on skill name
private enum SkillSets
{
armor,
weapons,
magic,
survival,
lore,
all,
none
};
private SkillSets _skillset = SkillSets.all; //Default is sort all
private int _calcCircle = 0; //
private bool _calculating = false; //
private bool _sorting = false; //
private bool _parsing = false; //
private bool _enabled = true; //
/*
//Class Skill
//Used for storing all skill related info
//Used in a hashtable whose key is the name of the skill
private class Skill
{
public double rank = 0; //Rank of the skill
}
//Class Sortskill
//Used for sorting the skills for display in the Experience window
//Used in an array list for sorting, which is fed from a hashtable
public class Sortskill
{
public string name = ""; //Name of skill
public int sortLR = 0; //Ordered value based on Reading sort (Left to Right)
public int sortTB = 0; //Ordered value based on top to bottom, THEN left to right
}
*/
#endregion
#region IPlugin Properties
//Required for Plugin - Called when Genie needs the name of the plugin (On menu)
//Return Value:
// string: Text that is the name of the Plugin
public string Name
{
get { return _NAME; }
}
//Required for Plugin - Called when Genie needs the plugin version (error text
// or the plugins window)
//Return Value:
// string: Text that is the version of the plugin
public string Version
{
get { return _VERSION; }
}
//Required for Plugin - Called when Genie needs the plugin Author (plugins window)
//Return Value:
// string: Text that is the Author of the plugin
public string Author
{
get { return _AUTHOR; }
}
//Required for Plugin - Called when Genie needs the plugin Description (plugins window)
//Return Value:
// string: Text that is the description of the plugin
// This can only be up to 200 Characters long, else it will appear
// "truncated"
public string Description
{
get { return _DESCRIPTION; }
}
//Required for Plugin - Called when Genie needs disable/enable the plugin (Plugins window,
// or when Gneie needs to know the status of the plugin (???)
//Get:
// Not Known what it is used for
//Set:
// Used by Plugins Window
public bool Enabled
{
get
{
return _enabled;
}
set
{
_enabled = value;
}
}
#endregion
#region IPlugin Methods
//Required for Plugin - Called on first load
//Parameters:
// IHost Host: The host (instance of Genie) making the call
public void Initialize(IHost Host)
{
//Set Decimal Seperator to a period (.) if not set that way
if (System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator != ".")
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
}
//Set _host variable to the Instance of Genie that started the plugin (so can call host API commands)
_host = Host;
//Set Genie Variables if not already set
if (_host.get_Variable("CircleCalc.Display") == "")
_host.SendText("#var CircleCalc.Display 0");
if (_host.get_Variable("CircleCalc.Sort") == "")
_host.SendText("#var CircleCalc.Sort 0");
if (_host.get_Variable("CircleCalc.GagFunny") == "")
_host.SendText("#var CircleCalc.GagFunny 0");
_pluginPath = _host.get_Variable("PluginPath");
if (_pluginPath != "\\")
_pluginPath += "\\";
LoadReqsfromXML();
LoadSortfromXML();
/*
if (_reqsLoaded)
{
_host.EchoText("");
_host.EchoText("Beginning debug output:");
ICollection Keys = _GuildNameList.Keys;
GuildType tempGuild;
ArrayList tempSkillset;
ReqType tempReq;
foreach (string key in Keys)
_host.EchoText("Shortname: " + key + " Guildname: " + _GuildNameList[key].ToString());
Keys = _GuildReqList.Keys;
foreach (string key in Keys)
{
tempGuild = (GuildType)_GuildReqList[key];
_host.EchoText("Guild: " + key);
_host.EchoText("Skillsets:");
ICollection Keys2 = tempGuild.Skillsets.Keys;
foreach (string key2 in Keys2)
{
_host.EchoText(" Skillset: " + key2);
tempSkillset = (ArrayList)tempGuild.Skillsets[key2];
foreach (string skill in tempSkillset)
_host.EchoText(" " + skill);
}
_host.EchoText("Reqs:");
_host.EchoText(" Hard:");
Keys2 = tempGuild.HardReqs.Keys;
foreach (string key2 in Keys2)
{
_host.EchoText(" " + key2 + ":");
tempReq = (ReqType)tempGuild.HardReqs[key2];
_host.EchoText(" 1-10:" + tempReq.Circles1to10.ToString());
_host.EchoText(" 11-30:" + tempReq.Circles11to30.ToString());
_host.EchoText(" 31-70:" + tempReq.Circles31to70.ToString());
_host.EchoText(" 71-100:" + tempReq.Circles71to100.ToString());
_host.EchoText(" 101-150:" + tempReq.Circles101to150.ToString());
_host.EchoText(" 151+:" + tempReq.Circles151Up.ToString());
}
_host.EchoText(" Soft:");
Keys2 = tempGuild.SoftReqs.Keys;
foreach (string key2 in Keys2)
{
_host.EchoText(" " + key2 + ":");
tempReq = (ReqType)tempGuild.SoftReqs[key2];
_host.EchoText(" 1-10:" + tempReq.Circles1to10.ToString());
_host.EchoText(" 11-30:" + tempReq.Circles11to30.ToString());
_host.EchoText(" 31-70:" + tempReq.Circles31to70.ToString());
_host.EchoText(" 71-100:" + tempReq.Circles71to100.ToString());
_host.EchoText(" 101-150:" + tempReq.Circles101to150.ToString());
_host.EchoText(" 151+:" + tempReq.Circles151Up.ToString());
}
_host.EchoText(" N:");
foreach (ReqType Req in tempGuild.TopN)
{
_host.EchoText(" " + Req.Name + ":");
_host.EchoText(" Skillset: " + Req.Skillset);
_host.EchoText(" 1-10:" + Req.Circles1to10.ToString());
_host.EchoText(" 11-30:" + Req.Circles11to30.ToString());
_host.EchoText(" 31-70:" + Req.Circles31to70.ToString());
_host.EchoText(" 71-100:" + Req.Circles71to100.ToString());
_host.EchoText(" 101-150:" + Req.Circles101to150.ToString());
_host.EchoText(" 151+:" + Req.Circles151Up.ToString());
}
}
}
*/
}
//Required for Plugin - Called when user enters text in the command box
//Parameters:
// string Text: The text the user entered in the command box
//Return Value:
// string: Text that will be sent to the game
public string ParseInput(string Text)
{
//User asking for help with commands
if (Text == "/cc ?" || Text == "/calc ?" || Text == "/cc")
{
DisplaySyntax();
return "";
}
//help/system commands
if (Text.StartsWith("/cc "))
{
//Clean Input of leading/trailing whitespace
Text = Text.Trim();
if (Text == "/cc reload")
{
LoadReqsfromXML();
LoadSortfromXML();
}
else if (Text == "/cc reloadreqs")
LoadReqsfromXML();
else if (Text == "/cc reloadsort")
LoadSortfromXML();
else if (Text == "/cc debug")
{
_debug = !_debug;
SendOutput("Debug toggled. Now set to " + _debug+ ".");
}
else
DisplaySyntax();
return "";
}
//Start Calculating circle
if (Text.StartsWith("/calc ") || Text == "/calc")
{
_calcGuildName = _host.get_Variable("CircleCalc.Guild");
//Clean Input of leading/trailing whitespace
Text = Text.Trim();
Regex exp = new Regex(" ");
int space = exp.Matches(Text).Count;
//check for proper syntax (more than two spaces = bad syntax)
if (space > 2)
{
DisplaySyntax();
return "";
}
//If there is at least one space, means guild or circle, or both are on the line
if (Text.Contains(" "))
{
try
{
//circle should always be at the end, unless only guild specified
//if only guild is specified, should throw an exception to be caught later
_calcCircle = Convert.ToInt32(Text.Substring(Text.LastIndexOf(" "), Text.Length - Text.LastIndexOf(" ")));
//circle over 500 or under 2 are not supported
if (_calcCircle > 500)
{
SendOutput("");
SendOutput("Circle Calculator: maximum circle is 500");
return "";
}
else if (_calcCircle < 2)
{
SendOutput("");
SendOutput("Circle Calculator: minimum circle is 2");
return "";
}
//if two spaces, then guild is also included
if (space == 2)
{
//read guild from the line
_calcGuildName = Text.Substring(Text.IndexOf(" ") + 1, Text.LastIndexOf(" ") - Text.IndexOf(" ") - 1);
//if you can't find the guild
if (!GetGuild(_calcGuildName))
{
DisplaySyntax();
return "";
}
//set Calculating to tue, used in parsing
_calculating = true;
//Sends exp 0 to get all skills with ranks
Text = "exp 0";
return Text;
}
//check if default guild was set in Genie
if (_calcGuildName != "")
{
//if you can't find the guild
if (!GetGuild(_calcGuildName))
{
DisplaySyntax();
return "";
}
//set Calculating to tue, used in parsing
_calculating = true;
//Sends exp 0 to get all skills with ranks
Text = "exp 0";
return Text;
}
//set Calculating to tue, used in parsing
_calculating = true;
//Sends info to get the guild to calculate against
Text = "info";
return Text;
}
//catch the thrown exception if trying to convert text to a number
//means guild is at end and not a circle
catch
{
//if last item is a guild, and there is more than one space, syntax is wrong
if (space > 1)
{
DisplaySyntax();
return "";
}
//get the guild from the line to calc against
_calcGuildName = Text.Substring(Text.IndexOf(" ") + 1, Text.Length - 1 - Text.IndexOf(" "));
//If you cannot find the guild to calculate against
if (!GetGuild(_calcGuildName))
{
DisplaySyntax();
return "";
}
//set Calculating to tue, used in parsing
_calculating = true;
//Sends exp 0 to get all skills with ranks
Text = "exp 0";
return Text;
}
}
else
{
//check if default guild was set in Genie
if (_calcGuildName != "")
{
//if you can't find the guild
if (!GetGuild(_calcGuildName))
{
DisplaySyntax();
return "";
}
//set Calculating to tue, used in parsing
_calculating = true;
//Sends exp 0 to get all skills with ranks
Text = "exp 0";
return Text;
}
//if you got this far, it means the command was simply "calc"
//set Calculating to tue, used in parsing
_calculating = true;
Text = "info";
//Sends info to get the guild to calculate against
return Text;
}
}
//start sorting skills
if (Text.StartsWith("/sort"))
{
//clear leading/trailing spaces
Text = Text.Trim();
_skillset = SkillSets.all;
int _calcRank = 1;
//clear out any double spaces in the command line
while (Text.Contains(" "))
Text = Text.Replace(" ", " ");
Regex exp = new Regex(" ");
int space = exp.Matches(Text).Count;
//check for proper syntax (more than two spaces = bad syntax)
if (space > 2)
{
DisplaySyntax();
return "";
}
//if there is a space, means there is something after /sort (either skillset or rank or both)
if (Text.Contains(" "))
{
try
{
//rank should always be last, unless it is not specified
_calcRank = Convert.ToInt32(Text.Substring(Text.LastIndexOf(" "), Text.Length - Text.LastIndexOf(" ")));
//Min skill needs to be at least 1
if ( _calcRank < 1)
{
DisplaySyntax();
return "";
}
//if two spaces, then skillset is also included
if (space == 2)
{
//read skillset from the line and convert it to a skillset type (enum _Skillset)
string skillset = Text.Substring(Text.IndexOf(" ") + 1, Text.LastIndexOf(" ") - Text.IndexOf(" ") - 1);
_skillset = GetSkillSet(skillset);
if (_skillset == SkillSets.none)
{
if (!_sortLoaded)
{
SendOutput("Invalid sorting group!");
SendOutput("Custom sorting is disabled due to no sorting file loaded.");
return "";
}
else if (!_GroupNameList.ContainsKey(skillset))
{
SendOutput("Invalid sorting group!");
return "";
}
else
{
_CurrentSortGroup = ((SortSkillGroup)_SortGroupList[_GroupNameList[skillset]]);
if (_CurrentSortGroup.Skillset != SkillSets.all)
Text = "exp " + _CurrentSortGroup.Skillset.ToString() + " " + _calcRank.ToString();
else
Text = "exp " + _calcRank.ToString();
_sorting = true;
return Text;
}
}
Text = "exp " + _skillset.ToString() + " " + _calcRank.ToString();
_sorting = true;
return Text;
}
Text = "exp " + _calcRank.ToString();
_sorting = true;
return Text;
}
//catch the thrown exception if trying to convert text to a number
//means skillset should be at the end of the line
catch
{
//if last item is not a number, and there is more than one spce, syntax is wrong
if(space > 1)
{
DisplaySyntax();
return "";
}
string skillset = Text.Substring(Text.IndexOf(" ") + 1, Text.Length - 1 - Text.IndexOf(" "));
_skillset = GetSkillSet(skillset);
if (_skillset == SkillSets.none)
{
if (!_sortLoaded)
{
SendOutput("Invalid sorting group!");
SendOutput("Custom sorting is disabled due to no sorting file loaded.");
return "";
}
else if (!_GroupNameList.ContainsKey(skillset))
{
SendOutput("Invalid sorting group!");
return "";
}
else
{
_CurrentSortGroup = ((SortSkillGroup)_SortGroupList[_GroupNameList[skillset]]);
Text = "exp " + _CurrentSortGroup.Skillset.ToString() + " all";
_sorting = true;
return Text;
}
}
Text = "exp " + _skillset.ToString() + " all";
_sorting = true;
return Text;
}
}
else
{
Text = "exp " + _skillset.ToString() + " all";
_sorting = true;
return Text;
}
}
//means no special arguments, send command on to game
return Text;
}
private void DisplaySyntax()
{
SendOutput("");
SendOutput("Standalone Circle Calculator(Ver:" + _VERSION + ") Usage:");
SendOutput("/cc ? (shows this help");
SendOutput("/cc reload[reqs|sort] (attempts to reload the reqs and/or the sorting data)");
SendOutput("/calc [guild] [circle]");
SendOutput(" /calc (will calculate to one circle above you)");
SendOutput(" /calc <guild> (will calculate based on the guild you input)");
SendOutput(" /calc <circle> (will calculate what you need for the circle you input)");
SendOutput(" /calc <guild> <circle> (combination of the two above)");
SendOutput(" The guild name must be spelled out completely, but with no spaces(moonmage, warriormage).");
SendOutput("/sort [skillset] [rank]");
SendOutput(" /sort (will sort your all sills)");
SendOutput(" /sort <skillset> (will sort the skills in the skillset)");
SendOutput(" /sort <rank> (will sort the skills greather than rank)");
SendOutput(" /sort <skillset> <rank> (will sort the skills in the skillset)");
SendOutput(" <rank> must always be a positive integer");
}
//Required for Plugin -
//Parameters:
// string Text: That DIRECT text comes from the game (non-"xml")
//Return Value:
// string: Text that will be sent to the to the windows as if from the game
public string ParseText(string Text, string Window)
{
try
{
if (_host != null)
{
if (_calculating == true && Text.StartsWith("Name: ") && Text.Contains("Guild: "))
{
_calcGuildName = Text.Substring(Text.IndexOf("Guild: ") + 7).Trim();
if (!GetGuild(_calcGuildName))
{
DisplaySyntax();
_calculating = false;
return Text;
}
_host.SendText("exp 0");
}
if ((_calculating == true || _sorting == true) && _parsing == true)
{
if (Text.StartsWith("EXP HELP for more information"))
{
_parsing = false;
try
{
if (_calculating)
{
CalculateCirclebyXML();
//CalculateCircle();
}
if (_sorting)
SortSkills();
}
catch (Exception ex)
{
SendOutput(ex.ToString());
}
}
else if (Text.Contains("%"))
{
int i = Text.IndexOf("%");
string part = Text.Substring(0, i + 15).Trim();
ParseExperience(part);
part = Text.Substring(i + 23).Trim();
if (part.Contains("%"))
{
i = part.Contains("(") ? part.IndexOf("(") : part.Length;
part = part.Substring(0, i);
ParseExperience(part);
}
}
}
else if ((_sorting || _calculating) && Text.StartsWith("Circle: "))
_parsing = true;
}
}
catch
{
}
return Text;
}
//Required for Plugin -
//Parameters:
// string Text: That "xml" text comes from the game
public void ParseXML(string XML)
{
}
//Required for Plugin - Opens the settings window for the plugin
public void Show()
{
OpenSettingsWindow(_host.ParentForm);
}
public void VariableChanged(string Variable)
{
}
public void ParentClosing()
{
}
public void OpenSettingsWindow(System.Windows.Forms.Form parent)
{
frmCicleCalc form = new frmCicleCalc(ref _host);
if (_host.get_Variable("CircleCalc.Sort") == "1")
form.cboSort.Text = "Bottom";
else
form.cboSort.Text = "Top";
if (_host.get_Variable("CircleCalc.Display") == "1")
form.Post200Circle.Checked = true;
else if(_host.get_Variable("CircleCalc.Display") == "2")
form.NextCircle.Checked=true;
else
form.Normal.Checked = true;
if (_host.get_Variable("CircleCalc.Echo") == "1")
form.chkEcho.Checked = true;
else
form.chkEcho.Checked = false;
if (_host.get_Variable("CircleCalc.Log") == "1")
form.chkLog.Checked = true;
else
form.chkLog.Checked = false;
if (_host.get_Variable("CircleCalc.Parse") == "1")
form.chkParse.Checked = true;
else
form.chkParse.Checked = false;
if (_host.get_Variable("CircleCalc.GagFunny") == "1")
form.chkGag.Checked = true;
else
form.chkGag.Checked = false;
if (parent != null)
form.MdiParent = parent;
form.Show();
}
#endregion
#region Custom Parse/Display methods
private void ParseExperience(string line)
{
if (System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator != ".")
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
}
string name = "";
//End of name is ':'
int i = line.IndexOf(":");
//If no :, no name, return.
if (i == -1) return;
//name is from the trimed version, from 0 - i(trim remvoes leading/trailing spaces)
name = line.Substring(0, i).Trim();
// Skip lines with broke names - Conny
if (name.Contains("(")) return;
int j = line.IndexOf("%");
if (j == -1) return;
string rank = line.Substring(i + 1, j - i - 1).Trim();
//DR uses a space for the decimal seperator, this replaces the space with a decimal
rank = rank.Replace(" ", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
//Gets loc of Decimal Seperator
int k = rank.IndexOf(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
//If K is 0 or positive, a decimal was found
if (k > -1)
{
//
if (rank.Substring(k + 1).Length == 3)
{
rank = rank.Substring(0, k + 1) + rank.Substring(k + 2);
}
}
//Converts string rank to a double
double dRank = Double.Parse(rank);
if (_calculating)
{
_calcSkillList.Add(name, dRank);
DebugOutput("Added skill " + name + " at rank " + dRank.ToString());
}
if (_sorting)
{
_sortSkillList.Add(name, dRank);
DebugOutput("Added skill " + name + " at rank " + dRank.ToString());
}
}
private void DebugOutput(string output)
{
if (!_debug) return;
output = "DBG: "+output;
if (_host.get_Variable("CircleCalc.Parse") != "0")
_host.SendText("#parse " + output);
if (_host.get_Variable("CircleCalc.Log") != "0")
_host.SendText("#log \"" + output + "\"");
if (_host.get_Variable("CircleCalc.Echo") != "0")
_host.SendText("#echo red \"" + output + "\"");
}
private void SendOutput(string output)
{
if (_host.get_Variable("CircleCalc.Parse") != "0")
_host.SendText("#parse " + output);
if (_host.get_Variable("CircleCalc.Log") != "0")
_host.SendText("#log \"" + output + "\"");
if (_host.get_Variable("CircleCalc.Echo") != "0")
_host.SendText("#echo \"" + output + "\"");
}
#endregion
#region Circle Calculator/Skill Sorter
private Hashtable _calcSkillList = new Hashtable();
private Hashtable _sortSkillList = new Hashtable();
private ArrayList reqList = new ArrayList();
private ArrayList sortList;
private int totalTDPs;
private int totalRanks;
private int MaxRankLen;
private int MaxDigitLen;
private class CircleReq
{
public int circle;
public string name;
public int ranksNeeded;
public int ranks;
public int currentCircle;
//constructor
public CircleReq(int c, int cc, int rn, string n, int r)
{
circle = c;
currentCircle = cc;
ranksNeeded = rn;
name = n;
ranks = r;
}
}
private class SkillRanks
{
public double rank;
public string name;
public SkillRanks(double r, string n)
{
rank = r;
name = n;
}
}
private class ReqComparer : IComparer
{
public int Compare(object x, object y)
{
CircleReq req1 = (CircleReq)x;
CircleReq req2 = (CircleReq)y;
return req1.currentCircle.CompareTo(req2.currentCircle);
}
}
private class ReqComparerBottom : IComparer
{
public int Compare(object x, object y)
{
CircleReq req1 = (CircleReq)y;
CircleReq req2 = (CircleReq)x;
return req1.currentCircle.CompareTo(req2.currentCircle);
}
}
private class RankComparer : IComparer
{
public int Compare(object x, object y)
{
SkillRanks req1 = (SkillRanks)x;
SkillRanks req2 = (SkillRanks)y;
return req2.rank.CompareTo(req1.rank);
}
}
private bool GetGuild(string guild)
{
string guildcheck = guild.Trim().ToLower();
if (_GuildNameList.ContainsKey(guildcheck))
{
_calcGuild = (GuildType)_GuildReqList[(string)_GuildNameList[guildcheck]];
return true;
}
return false;
}
private SkillSets GetSkillSet(string skillset)
{
switch (skillset.ToLower())
{
case "armor":
case "armo":
case "arm":
return SkillSets.armor;
case "weapons":
case "weapon":
case "weapo":
case "weap":
case "wea":
return SkillSets.weapons;
case "magic":
case "magi":
case "mag":
return SkillSets.magic;
case "survival":
case "surviva":
case "surviv":
case "survi":
case "surv":
case "sur":
return SkillSets.survival;
case "lore":
case "lor":
return SkillSets.lore;
case "all":
return SkillSets.all;
default:
return SkillSets.none;
}
}
private void ShowReqs()
{
int circle;
bool LineBreak = false;
_calcCircle = 0;
if (_host.get_Variable("CircleCalc.Sort") == "0")
circle = ((CircleReq)reqList[0]).circle;
else
circle = ((CircleReq)reqList[reqList.Count-1]).circle;
//if (_host.get_Variable("CircleCalc.Sort") == "0")
SendOutput("Requirements for Circle " + circle.ToString() + ":");
SendOutput("");
foreach (CircleReq req in reqList)
{
if (((_host.get_Variable("CircleCalc.Sort") == "0" && req.circle != circle && LineBreak == false) ||
(_host.get_Variable("CircleCalc.Sort") == "1" && req.circle == circle && LineBreak == false)) &&
_host.get_Variable("CircleCalc.Display") != "2" )
{
SendOutput("");
LineBreak = true;
}
if ((_host.get_Variable("CircleCalc.Display") == "1" || req.circle <= 200) && ((_host.get_Variable("CircleCalc.Display") != "2") || req.circle == circle) )
SendOutput("You have enough " + req.name + " for Circle " + req.currentCircle + " and need " + (req.ranksNeeded - req.ranks).ToString() + " (" + req.ranksNeeded + ") ranks for Circle " + req.circle);
}
/*
if (_host.get_Variable("CircleCalc.Sort") == "1")
{
_host.SendText("#echo");
_host.SendText("#echo Requirements for Circle " + circle.ToString() + ".");
}
*/
SendOutput("");
SendOutput("TDPs Gained: " + String.Format("{0,6}", totalTDPs.ToString()));
SendOutput("Total Ranks: " + String.Format("{0,6}", totalRanks.ToString()));
if (_host.get_Variable("CircleCalc.GagFunny") != "1")
{
int seed = 0;
System.Random randomizer;
seed = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
randomizer = new System.Random(seed);
int rand = randomizer.Next();
switch (_calcGuildName)
{
case "Barbarian":
break;
case "Bard":
if (rand % 2 == 0)