summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/Team/XTeamBriefData.cs
blob: 8e3929802d9468aeb4781bdaf7aad38f066996d8 (plain)
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
using System;
using System.Collections.Generic;
using KKSG;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XTeamBriefData : XDataBase, IComparable<XTeamBriefData>
	{
		public ExpeditionTable.RowData rowData;

		public int currentMemberCount;

		public int totalMemberCount;

		public XTeamCategory category;

		public uint dungeonID = 0u;

		public int teamID;

		public string leaderName;

		public int leaderLevel = 44;

		public uint leaderPPT = 555u;

		public RoleType leaderProfession = RoleType.Role_Warrior;

		public XTeamState state = XTeamState.TS_NOT_FULL;

		public TeamState actualState = TeamState.TEAM_WAITING;

		public KMatchType matchType = KMatchType.KMT_NONE;

		public bool hasPwd;

		public string password;

		public string dungeonName;

		public string teamName;

		public uint dungeonLevel;

		public List<XTeamMemberBriefData> members = new List<XTeamMemberBriefData>();

		public XTeamRelation relation = new XTeamRelation();

		public uint teamPPT = 0u;

		public bool isTarja = false;

		public XGoldGroupData goldGroup = default(XGoldGroupData);

		public XTeamRift rift = null;

		public bool regression = false;

		public static int[] DefaultSortDirection = new int[]
		{
			1,
			1,
			-1,
			1,
			1,
			1
		};

		public static TeamBriefSortType sortType = TeamBriefSortType.TBST_TEAM_ID;

		public static int dir = 1;

		public static string GetStrTeamPPT(double teamPPT, double myPPT)
		{
			bool flag = teamPPT == 0.0;
			string result;
			if (flag)
			{
				result = XStringDefineProxy.GetString("NONE");
			}
			else
			{
				bool flag2 = myPPT == 0.0;
				if (flag2)
				{
					myPPT = XSingleton<XAttributeMgr>.singleton.XPlayerData.GetAttr(XAttributeDefine.XAttr_POWER_POINT_Basic);
				}
				bool flag3 = myPPT < teamPPT;
				if (flag3)
				{
					result = XSingleton<XCommon>.singleton.StringCombine("[ff0000]", teamPPT.ToString(), "[-]");
				}
				else
				{
					result = teamPPT.ToString();
				}
			}
			return result;
		}

		public XTeamBriefData()
		{
			this.goldGroup.teamBrief = this;
		}

		public string GetStrTeamPPT(double myPPT = 0.0)
		{
			return XTeamBriefData.GetStrTeamPPT(this.teamPPT, myPPT);
		}

		private void _UpdateRelation()
		{
			this.relation.Reset();
			for (int i = 0; i < this.members.Count; i++)
			{
				XTeamMemberBriefData xteamMemberBriefData = this.members[i];
				bool flag = xteamMemberBriefData.uid == XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID;
				if (flag)
				{
					xteamMemberBriefData.relation.Reset();
				}
				else
				{
					xteamMemberBriefData.relation.UpdateRelation(xteamMemberBriefData.uid, xteamMemberBriefData.guildid, xteamMemberBriefData.dragonguildid);
					this.relation.Append(xteamMemberBriefData.relation.ActualRelation, true);
				}
			}
		}

		public void SetMembers(List<TeamMember> memberDatas)
		{
			this.isTarja = false;
			this.regression = false;
			for (int i = 0; i < memberDatas.Count; i++)
			{
				XTeamMemberBriefData data = XDataPool<XTeamMemberBriefData>.GetData();
				data.SetData(memberDatas[i], this.leaderName);
				this.members.Add(data);
				this.regression = (this.regression || data.regression);
				this.isTarja = (this.isTarja || (data.isTarja && XTeamDocument.InTarja(this.dungeonID, (uint)XFastEnumIntEqualityComparer<RoleType>.ToInt(data.profession))));
			}
			this.members.Sort();
			this._UpdateRelation();
		}

		public void SetData(TeamBrief brief, XExpeditionDocument expDoc)
		{
			bool flag = this.dungeonID != brief.expID;
			if (flag)
			{
				this.dungeonID = brief.expID;
				this.category = expDoc.TeamCategoryMgr.GetCategoryByExpID((int)this.dungeonID);
				this.rowData = expDoc.GetExpeditionDataByID((int)this.dungeonID);
				bool flag2 = this.rowData != null;
				if (flag2)
				{
					this.dungeonLevel = this.rowData.DisplayLevel;
					this.dungeonName = XExpeditionDocument.GetFullName(this.rowData);
					this.totalMemberCount = this.rowData.PlayerNumber;
				}
				else
				{
					XSingleton<XDebug>.singleton.AddErrorLog("cant find exp id: " + this.dungeonID.ToString(), null, null, null, null, null);
				}
			}
			this.leaderName = brief.leaderName;
			this.teamID = brief.teamID;
			this.leaderLevel = (int)brief.leaderLevel;
			this.leaderPPT = brief.leaderPowerPoint;
			this.leaderProfession = brief.leaderProfession;
			this.currentMemberCount = brief.teamMemberCount;
			this.password = brief.password;
			this.hasPwd = brief.haspassword;
			this.actualState = (TeamState)brief.teamState;
			this.matchType = brief.matchtype;
			this.teamName = XStringDefineProxy.GetString("TEAM_NAME", new object[]
			{
				this.leaderName
			});
			this.regression = brief.kingback;
			TeamState teamState = this.actualState;
			if (teamState != TeamState.TEAM_IN_BATTLE)
			{
				if (teamState != TeamState.TEAM_VOTE)
				{
					bool flag3 = this.currentMemberCount < this.totalMemberCount;
					if (flag3)
					{
						this.state = XTeamState.TS_NOT_FULL;
					}
					else
					{
						this.state = XTeamState.TS_FULL;
					}
				}
				else
				{
					this.state = XTeamState.TS_VOTING;
				}
			}
			else
			{
				this.state = XTeamState.TS_FIGHTING;
			}
			bool flag4 = brief.extrainfo != null;
			if (flag4)
			{
				this.teamPPT = brief.extrainfo.pptlimit;
				this.goldGroup.SetData(brief.extrainfo, this.rowData);
				bool flag5 = brief.extrainfo.rift != null;
				if (flag5)
				{
					bool flag6 = this.rift == null;
					if (flag6)
					{
						this.rift = XDataPool<XTeamRift>.GetData();
					}
					this.rift.SetData(brief.extrainfo.rift, this.rowData);
				}
				else
				{
					bool flag7 = this.rift != null;
					if (flag7)
					{
						this.rift.Recycle();
						this.rift = null;
					}
				}
			}
			else
			{
				this.teamPPT = 0u;
				this.goldGroup.bActive = false;
			}
		}

		public static int CompareToAccordingToRelation(XTeamBriefData left, XTeamBriefData right)
		{
			int num = XFastEnumIntEqualityComparer<XTeamState>.ToInt(left.state).CompareTo(XFastEnumIntEqualityComparer<XTeamState>.ToInt(right.state));
			bool flag = num == 0;
			if (flag)
			{
				num = left.relation.CompareTo(right.relation);
			}
			bool flag2 = num == 0;
			int result;
			if (flag2)
			{
				result = left.CompareTo(right);
			}
			else
			{
				result = num;
			}
			return result;
		}

		public int CompareTo(XTeamBriefData other)
		{
			int num = 0;
			switch (XTeamBriefData.sortType)
			{
			case TeamBriefSortType.TBST_TEAM_NAME:
				num = this.teamName.CompareTo(other.teamName);
				break;
			case TeamBriefSortType.TBST_DUNGEON_LEVEL:
				num = -this.dungeonLevel.CompareTo(other.dungeonLevel);
				break;
			case TeamBriefSortType.TBST_MEMBER_COUNT:
				num = this.currentMemberCount.CompareTo(other.currentMemberCount);
				break;
			case TeamBriefSortType.TBST_CATEGORY:
				num = this.category.category.CompareTo(other.category.category);
				break;
			case TeamBriefSortType.TBST_DUNGEON_ID:
				num = this.dungeonID.CompareTo(other.dungeonID);
				break;
			}
			bool flag = num == 0;
			if (flag)
			{
				num = XFastEnumIntEqualityComparer<XTeamState>.ToInt(this.state).CompareTo(XFastEnumIntEqualityComparer<XTeamState>.ToInt(other.state));
			}
			bool flag2 = num == 0;
			if (flag2)
			{
				num = this.relation.CompareTo(other.relation) * XTeamBriefData.dir;
			}
			bool flag3 = num == 0;
			if (flag3)
			{
				double attr = XSingleton<XAttributeMgr>.singleton.XPlayerData.GetAttr(XAttributeDefine.XAttr_POWER_POINT_Basic);
				bool flag4 = attr >= this.teamPPT;
				bool value = attr >= other.teamPPT;
				num = -flag4.CompareTo(value);
			}
			bool flag5 = num == 0;
			if (flag5)
			{
				num = this.hasPwd.CompareTo(other.hasPwd);
			}
			bool flag6 = num == 0;
			if (flag6)
			{
				bool flag7 = this.rift != null && other.rift != null;
				if (flag7)
				{
					num = -this.rift.floor.CompareTo(other.rift.floor);
				}
			}
			bool flag8 = num == 0;
			if (flag8)
			{
				num = this.teamID.CompareTo(other.teamID);
			}
			return num * XTeamBriefData.dir;
		}

		public override void Recycle()
		{
			base.Recycle();
			for (int i = 0; i < this.members.Count; i++)
			{
				this.members[i].Recycle();
			}
			this.members.Clear();
			bool flag = this.rift != null;
			if (flag)
			{
				this.rift.Recycle();
				this.rift = null;
			}
			XDataPool<XTeamBriefData>.Recycle(this);
		}
	}
}