-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.cs
More file actions
364 lines (360 loc) · 15.3 KB
/
Copy pathCharacter.cs
File metadata and controls
364 lines (360 loc) · 15.3 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
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
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OlyCommonClasses
{
public class Character
{
public int _CharId { get; set; }
public string _Name { get; set; }
public string _Char_Type { get; set; }
public string _First_Line { get; set; }
public int _PlayerId { get; set; }
public int _CH_Attack { get; set; }
public int _CH_Behind { get; set; }
public int _CH_Break_Point { get; set; }
public List<int> _CH_Contact { get; set; }
public int _CH_Defense { get; set; }
public int _CH_Guard { get; set; }
public int _CH_Health { get; set; }
public int _CH_Lord { get; set; }
public int _CH_LOY_Kind { get; set; }
public int _CH_LOY_Rate { get; set; }
public int _CH_Missile { get; set; }
public int _CH_NPC_Unit_Type { get; set; }
public int _CH_Prisoner { get; set; }
public int _CH_Rank { get; set; }
public int _CH_Sick { get; set; }
public List<int> _CH_Skills_List { get; set; }
public int _CM_Appear_Common { get; set; }
public List<int> _CM_Auraculum { get; set; }
public int _CM_Magician { get; set; }
public int _CM_Pledged_To { get; set; }
public int _CM_Max_Aura { get; set; }
public int _CM_Cur_Aura { get; set; }
public int _CM_Vision_Protect { get; set; }
public int _CM_Hide_Self { get; set; }
public List<int> _CM_Already_Visioned { get; set; }
public int _LI_Where { get; set; }
public List<int> _LI_Here_List { get; set; }
public int _MI_Garrison_Castle { get; set; }
public string _MI_Cmd_Allow { get; set; }
public List<int> _Item_List { get; set; }
public List<int> _Trade_List { get; set; }
public List<int> _Defend_List { get; set; }
public List<int> _Neutral_List { get; set; }
public List<int> _Hostile_List { get; set; }
public int Accumulated_Weight { get; set; }
public int Accumulated_Land_Cap { get; set; }
public int Accumulated_Riding_Cap { get; set; }
public int Accumulated_Flying_Cap { get; set; }
public int Accumulated_Men { get; set; }
public int Ultimate_Lord { get; set; }
public string Calc_CurrentLoc { get; set; }
public int Calc_CurrentRegion { get; set; }
public static void Add(string InputKey, string InputString, List<Character> _characters)
{
JObject j1 = JObject.Parse(InputString);
JArray myfl;
string mychartype;
if (j1.SelectToken("firstline") != null && j1.SelectToken("firstline").HasValues)
{
myfl = (JArray)j1.SelectToken("firstline");
string[] type_array = myfl[0].ToString().Split(default(string[]), StringSplitOptions.RemoveEmptyEntries);
mychartype = type_array[2];
}
else
{
myfl = null;
mychartype = null;
}
_characters.Add(new Character
{
_CharId = Convert.ToInt32(InputKey),
_First_Line = myfl[0].ToString(),
_Char_Type = mychartype,
_PlayerId = 0,
_Item_List = JSON.list_Token(j1,"il"),
_Defend_List = JSON.list_Token(j1, "ad"),
_Hostile_List = JSON.list_Token(j1, "ah"),
_Neutral_List = JSON.list_Token(j1, "an"),
Accumulated_Weight = 0,
Accumulated_Riding_Cap = 0,
Accumulated_Men = 0,
Accumulated_Land_Cap = 0,
Accumulated_Flying_Cap = 0,
Ultimate_Lord = 0,
_CH_Attack = JSON.int_Token(j1, "CH.at"),
_CH_Behind = JSON.int_Token(j1, "CH.bh"),
_CH_Break_Point = JSON.int_Token(j1, "CH.bp"),
_CH_Contact = JSON.list_Token(j1, "CH.ct"),
_CH_Defense = JSON.int_Token(j1, "CH.df"),
_CH_Guard = JSON.int_Token(j1, "CH.gu"),
_CH_Health = JSON.int_Token(j1, "CH.he"),
_CH_LOY_Kind = JSON.int_Token(j1, "CH.lk", -2),
_CH_Lord = JSON.int_Token(j1, "CH.lo"),
_CH_LOY_Rate = JSON.int_Token(j1, "CH.lr"),
_CH_Missile = JSON.int_Token(j1, "CH.mi"),
_CH_NPC_Unit_Type = JSON.int_Token(j1, "CH.ni"),
_CH_Prisoner = JSON.int_Token(j1, "CH.pr"),
_CH_Rank = JSON.int_Token(j1, "CH.ra"),
_CH_Sick = JSON.int_Token(j1, "CH.si"),
_CH_Skills_List = JSON.list_Token(j1, "CH.sl"),
_CM_Appear_Common = JSON.int_Token(j1, "CM.cm"),
_CM_Auraculum = JSON.list_Token(j1, "CM.ar"),
_CM_Cur_Aura = JSON.int_Token(j1, "CM.ca"),
_CM_Hide_Self = JSON.int_Token(j1, "CM.hs"),
_CM_Magician = JSON.int_Token(j1, "CM.im"),
_CM_Max_Aura = JSON.int_Token(j1, "CM.ma"),
_CM_Pledged_To = JSON.int_Token(j1, "CM.pl"),
_CM_Already_Visioned = JSON.list_Token(j1, "CM.vi"),
_CM_Vision_Protect = JSON.int_Token(j1, "CM.vp"),
_LI_Here_List = JSON.list_Token(j1, "LI.hl"),
_LI_Where = JSON.int_Token(j1, "LI.wh"),
_MI_Cmd_Allow = JSON.string_Token(j1, "MI.ca"),
_MI_Garrison_Castle = JSON.int_Token(j1, "MI.gc")
});
var Character = (_characters.Find(x => x._CharId == Convert.ToInt32(InputKey)));
if (Character != null)
{
if (Character._CharId.Equals(Convert.ToInt32(InputKey)))
{
if (j1.SelectToken("na") != null && j1.SelectToken("na").HasValues)
{
JArray myna;
myna = (JArray)j1.SelectToken("na");
Character._Name = myna[0].ToString();
}
else
{
if (Character._Char_Type.Equals("garrison"))
{
Character._Name = Character._Char_Type.First().ToString().ToUpper() + Character._Char_Type.Substring(1);
}
}
}
if (j1.SelectToken("tl") != null && j1.SelectToken("tl").HasValues)
{
JArray mytl;
List<int> mytla;
mytl = (JArray)j1.SelectToken("tl");
mytla = mytl.ToObject<List<int>>();
Character._Trade_List = mytla.ToList();
}
}
}
public static void Post_PlayerId(List<Character> _characters, List<Player> _players)
{
foreach (Player _myplayer in _players)
{
if (_myplayer._Unit_List != null)
{
foreach (int _unit in _myplayer._Unit_List)
{
Character _mychar = _characters.Find(x => x._CharId == _unit);
if (_mychar != null)
{
_mychar._PlayerId = _myplayer._FactionId;
}
}
}
}
}
public static void Determine_Ultimate_Lord(List<Character> _characters)
{
foreach (Character _myChar in _characters)
{
if (_myChar._CM_Pledged_To != 0)
{
_myChar.Ultimate_Lord = Utilities.Chase_Pledge_Chain(_myChar._CharId, _characters);
}
}
}
public static bool Is_Priest(Character _mychar)
{
if (_mychar._CH_Skills_List != null)
{
int iterations = _mychar._CH_Skills_List.Count / 4;
for (int i = 0; i < iterations; i++)
{
if (_mychar._CH_Skills_List[(i * 4) + 0] == 750)
{
if (!_mychar._CH_Skills_List[(i * 4) + 1].Equals(0))
{
return true;
}
}
}
}
return false;
}
public static string Mage_Type(Character _mychar)
{
if (_mychar._CM_Magician == 1)
{
if (_mychar._CM_Max_Aura <= 5)
{
return "";
}
else
{
if (_mychar._CM_Max_Aura <= 10)
{
return "conjurer";
}
else
{
if (_mychar._CM_Max_Aura <= 15)
{
return "mage";
}
else
{
if (_mychar._CM_Max_Aura <= 20)
{
return "wizard";
}
else
{
if (_mychar._CM_Max_Aura <= 30)
{
return "sorcerer";
}
else
{
if (_mychar._CM_Max_Aura <= 40)
{
return "6th black circle";
}
else
{
if (_mychar._CM_Max_Aura <= 50)
{
return "5th black circle";
}
else
{
if (_mychar._CM_Max_Aura <= 60)
{
return "4th black circle";
}
else
{
if (_mychar._CM_Max_Aura <= 70)
{
return "3rd black circle";
}
else
{
if (_mychar._CM_Max_Aura <= 80)
{
return "2nd black circle";
}
}
}
}
}
}
}
}
}
}
}
else
{
return "";
}
return "master of the black arts";
}
public static bool Is_Magician(Character mychar)
{
if (mychar._CM_Magician > 1)
{
return true;
}
return false;
}
public static Weight Determine_Unit_Weights(Character _myChar, List<Itemz> _items)
{
Weight myweight = new Weight()
{
_animals = 0,
_total_weight = 0,
_land_cap = 0,
_land_weight = 0,
_ride_cap = 0,
_ride_weight = 0,
_fly_cap = 0,
_fly_weight = 0
};
if (_myChar._Item_List != null)
{
int unit_type = (_myChar._CH_NPC_Unit_Type != 0 ? _myChar._CH_NPC_Unit_Type : 10);
Itemz myitem = _items.Find(x => x._ItemId == unit_type);
myweight = Itemz.Add_Item_Weight(myitem, 1, myweight);
myitem = null;
int iterations = _myChar._Item_List.Count / 2;
for (int i = 0; i < iterations; i++)
{
if (_items.Find(x => x._ItemId == _myChar._Item_List[i * 2]) != null)
{
myitem = _items.Find(x => x._ItemId == _myChar._Item_List[i * 2]);
myweight = Itemz.Add_Item_Weight(myitem, (_myChar._Item_List[(i * 2) + 1]), myweight);
}
}
}
return myweight;
}
public static Boolean ReallyHidden(Character mychar, List<Character> _characters, List<Itemz> _items, List<Location> _locations, List<Ship> _ships)
{
if (mychar._CM_Hide_Self == 1)
{
if (mychar._Item_List != null)
{
int iterations = mychar._Item_List.Count / 2;
for (int i = 0; i < iterations; i++)
{
if (_items.Find(x => x._ItemId == mychar._Item_List[i * 2]) != null)
{
Itemz myitem = _items.Find(x => x._ItemId == mychar._Item_List[i * 2]);
if (Itemz.Is_Fighter(myitem) || myitem._IT_Man_Item == 1)
{
return false;
}
}
}
}
if (mychar._LI_Here_List != null)
{
return false;
}
if (_characters.Find(x=>x._CharId == mychar._LI_Where) != null)
{
return false;
}
if (_ships.Find(x=>x._ShipId == mychar._LI_Where) != null)
{
if (_ships.Find(x=>x._ShipId == mychar._LI_Where)._LI_Here_List[0] == mychar._CharId)
{
return false;
}
}
if (_locations.Find(x => x._LocId == mychar._LI_Where) != null)
{
if (_locations.Find(x => x._LocId == mychar._LI_Where)._SL_Defense > 0)
{
if (_locations.Find(x => x._LocId == mychar._LI_Where)._LI_Here_List[0] == mychar._CharId)
{
return false;
}
}
}
return true;
}
return false;
}
}
}