-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHazeron.cs
142 lines (122 loc) · 6.03 KB
/
Hazeron.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace HazeronAdviser
{
class Hazeron
{
public const int AbandonmentInterval = 7;
public const int CurrencyPadding = 16;
protected static NumberFormatInfo _numberFormat;
public static NumberFormatInfo NumberFormat
{
get { return _numberFormat; }
//set { _numberFormat = value; }
}
protected static DateTimeFormatInfo _dateTimeFormat;
public static DateTimeFormatInfo DateTimeFormat
{
get { return _dateTimeFormat; }
//set { _dateTimeFormat = value; }
}
protected static string[] _pirateEmpires;
public static string[] PirateEmpires
{
get { return _pirateEmpires; }
//set { _pirateEmpires = value; }
}
protected static Dictionary<string, int> _moraleBuildingCityThresholds;
public static Dictionary<string, int> MoraleBuildingCityThresholds
{
get { return _moraleBuildingCityThresholds; }
//set { _moraleBuildingCityThresholds = value; }
}
protected static Dictionary<string, int> _moraleBuildingBaseThresholds;
public static Dictionary<string, int> MoraleBuildingBaseThresholds
{
get { return _moraleBuildingBaseThresholds; }
//set { _moraleBuildingBaseThresholds = value; }
}
static Hazeron()
{
System.Globalization.CultureInfo tempCulture = new System.Globalization.CultureInfo("en-US");
_numberFormat = tempCulture.NumberFormat;
_numberFormat.NumberDecimalDigits = 0;
_numberFormat.NumberDecimalSeparator = ".";
_numberFormat.NumberGroupSeparator = "'";
_numberFormat.CurrencyDecimalDigits = 0;
_numberFormat.CurrencyDecimalSeparator = ".";
_numberFormat.CurrencyGroupSeparator = "'";
_numberFormat.CurrencySymbol = "¢";
_numberFormat.CurrencyPositivePattern = 1; // https://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencypositivepattern.aspx
_numberFormat.CurrencyNegativePattern = 5; // https://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencynegativepattern.aspx
_numberFormat.NegativeInfinitySymbol = "-∞";
_numberFormat.PositiveInfinitySymbol = "∞";
_dateTimeFormat = tempCulture.DateTimeFormat;
_dateTimeFormat.FullDateTimePattern = "yyyy-MM-dd HH:mm"; // TimeDate format information: http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
_pirateEmpires = new string[] { "Akson"
, "Balorite"
, "Dendrae"
, "Haxu"
, "Kla'tra"
, "Malaco"
, "Myntaka"
, "Ogar"
, "Otari"
, "Seledon"
, "Syth"
, "Tassad"
, "Vilmorti"
, "Vreen"
, "Zuul"
};
_moraleBuildingCityThresholds = new Dictionary<string, int>();
_moraleBuildingCityThresholds.Add("Church", 45);
_moraleBuildingCityThresholds.Add("Cantina", 50);
_moraleBuildingCityThresholds.Add("Retail Store", 55);
_moraleBuildingCityThresholds.Add("University", 70);
_moraleBuildingCityThresholds.Add("Hospital", 80);
_moraleBuildingCityThresholds.Add("Park", 90);
_moraleBuildingCityThresholds.Add("Grocery", 100);
_moraleBuildingCityThresholds.Add("Zoo", 150);
_moraleBuildingCityThresholds.Add("Arena", 175);
_moraleBuildingCityThresholds.Add("Casino", 200);
_moraleBuildingBaseThresholds = new Dictionary<string, int>();
_moraleBuildingBaseThresholds.Add("Cantina", 50);
_moraleBuildingBaseThresholds.Add("Retail Store", 55);
_moraleBuildingBaseThresholds.Add("Star Fleet Academy", 250);
}
public static int MoraleBuildingsRequiredCity(string buildingType, int population)
{
if (!_moraleBuildingCityThresholds.ContainsKey(buildingType))
throw new Exception($"Invalid building type. {buildingType}");
int jobsNeeded = 0;
if (population >= _moraleBuildingCityThresholds[buildingType])
jobsNeeded = Math.Max(population / (_moraleBuildingCityThresholds[buildingType] * 3), 1);
if (buildingType == "Church")
jobsNeeded += 2;
else if (buildingType == "Cantina")
jobsNeeded += 1;
return jobsNeeded;
}
public static int MoraleBuildingsRequiredBase(string buildingType, int population)
{
if (!_moraleBuildingBaseThresholds.ContainsKey(buildingType))
throw new Exception($"Invalid building type. {buildingType}");
int jobsNeeded = 0;
if (population >= _moraleBuildingBaseThresholds[buildingType])
jobsNeeded = Math.Max(population / (_moraleBuildingBaseThresholds[buildingType] * 3), 1);
else if (buildingType == "Cantina")
jobsNeeded += 1;
return jobsNeeded;
}
public static bool ValidID(string id)
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"^[A-Z]+$");
System.Text.RegularExpressions.Match regexMatch = regex.Match(id);
return (id == null || id == "" || !regexMatch.Success);
}
}
}