-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathEmpireRating.cs
More file actions
130 lines (111 loc) · 4.44 KB
/
EmpireRating.cs
File metadata and controls
130 lines (111 loc) · 4.44 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using Utilities;
namespace EddiDataDefinitions
{
/// <summary>
/// Empire ratings
/// </summary>
public class EmpireRating
{
public class MaleRank ( string edname ) : ResourceBasedLocalizedEDName<EmpireRating.MaleRank>( edname, edname )
{
static MaleRank()
{
resourceManager = Properties.EmpireRatingsMale.ResourceManager;
resourceManager.IgnoreCase = false;
}
// dummy used to ensure that the static constructor has run
public MaleRank() : this("")
{ }
}
public class FemaleRank ( string edname )
: ResourceBasedLocalizedEDName<EmpireRating.FemaleRank>( edname, edname )
{
static FemaleRank()
{
resourceManager = Properties.EmpireRatingsFemale.ResourceManager;
resourceManager.IgnoreCase = false;
}
// dummy used to ensure that the static constructor has run
public FemaleRank() : this("")
{ }
}
private static readonly List<EmpireRating> AllOfThem = [ ];
public string edname { get; }
public int rank { get; }
public MaleRank maleRank { get; }
public FemaleRank femaleRank { get; }
// Included for consistency with other `Rating` type object definitions as defined by Variables.md
[PublicAPI]
public string name => maleRank.localizedName;
[PublicAPI]
public string invariantName => maleRank.invariantName;
[PublicAPI]
public string femininename => femaleRank.localizedName;
[PublicAPI]
public string feminineInvariantName => femaleRank.invariantName;
private EmpireRating(string edname, int rank)
{
this.edname = edname;
this.rank = rank;
this.maleRank = new MaleRank(edname);
this.femaleRank = new FemaleRank(edname);
AllOfThem.Add(this);
}
public static readonly EmpireRating None = new("None", 0);
public static readonly EmpireRating Outsider = new("Outsider", 1);
public static readonly EmpireRating Serf = new("Serf", 2);
public static readonly EmpireRating Master = new("Master", 3);
public static readonly EmpireRating Squire = new("Squire", 4);
public static readonly EmpireRating Knight = new("Knight", 5);
public static readonly EmpireRating Lord = new("Lord", 6);
public static readonly EmpireRating Baron = new("Baron", 7);
public static readonly EmpireRating Viscount = new("Viscount", 8);
public static readonly EmpireRating Count = new("Count", 9);
public static readonly EmpireRating Earl = new("Earl", 10); // normally Countess, but we need to distinguish from rank 9
public static readonly EmpireRating Marquis = new("Marquis", 11); // or Marchioness <https://en.wikipedia.org/wiki/Marquess>
public static readonly EmpireRating Duke = new("Duke", 12);
public static readonly EmpireRating Prince = new("Prince", 13);
public static readonly EmpireRating King = new("King", 14);
public static EmpireRating FromName(string from)
{
if (from == null)
{
return null;
}
var result = AllOfThem.FirstOrDefault(v =>
v.maleRank.invariantName == from
|| v.maleRank.localizedName == from
);
if (result == null)
{
Logging.Info("Unknown Empire Rating name " + from);
}
return result;
}
public static EmpireRating FromEDName(string from)
{
if (from == null)
{
return null;
}
var result = AllOfThem.FirstOrDefault(v => string.Equals( v.edname, from, StringComparison.OrdinalIgnoreCase ) );
if (result == null)
{
Logging.Info("Unknown Empire Rating ED name " + from);
}
return result;
}
public static EmpireRating FromRank(int from)
{
var result = AllOfThem.FirstOrDefault(v => v.rank == from);
if (result == null)
{
Logging.Info("Unknown Empire Rating rank " + from);
}
return result;
}
}
}