summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XJokerKingDocument.cs
blob: 401b088f23f2bfde5b2196232f2ff64e64fab061 (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
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
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XJokerKingDocument : XDocComponent
	{
		public override uint ID
		{
			get
			{
				return XJokerKingDocument.uuID;
			}
		}

		public uint JokerKingTimes
		{
			get
			{
				return this.m_JokerKingTimes;
			}
		}

		public CardMatchState MatchState
		{
			get
			{
				return this.m_matchState;
			}
		}

		public double TimeLeft
		{
			get
			{
				return this.m_timeLeft;
			}
			set
			{
				this.m_timeLeft = value;
			}
		}

		public uint ChangeCount
		{
			get
			{
				return this.m_changeount;
			}
		}

		public uint MatchRound
		{
			get
			{
				return this.m_matchRound;
			}
		}

		public uint MatchResult
		{
			get
			{
				return this.m_matchResult;
			}
		}

		public List<uint> MatchJockers
		{
			get
			{
				return this.m_matchJokers;
			}
		}

		public uint MatchJockerStore
		{
			get
			{
				return this.m_matchJockerStore;
			}
		}

		public List<uint> MatchBestJockers
		{
			get
			{
				return this.m_matchBestJockers;
			}
		}

		public string MatchBestJockerName
		{
			get
			{
				return this.m_matchBestName;
			}
		}

		public List<string> MatchRankNames
		{
			get
			{
				return this.m_matchRankName;
			}
		}

		public List<int> MatchRankScores
		{
			get
			{
				return this.m_matchRankScore;
			}
		}

		public List<ItemBrief> MatchItems
		{
			get
			{
				return this.m_matchItems;
			}
		}

		public bool IsBegin
		{
			get
			{
				return this.m_isBegion;
			}
		}

		public bool IsCanBegin
		{
			get
			{
				return this.m_isCanBegion;
			}
		}

		public bool IsSignUp
		{
			get
			{
				return this.m_isSignUp;
			}
		}

		public bool bAvaiableIconWhenShow
		{
			get
			{
				return this.m_bAvaiableIconWhenShow;
			}
			set
			{
				this.m_bAvaiableIconWhenShow = value;
				XSingleton<XDebug>.singleton.AddGreenLog("bAvaiableIconWhenShow:", this.bAvaiableIconWhenShow.ToString(), null, null, null, null);
				XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_JockerKing, true);
				DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.RefreshH5ButtonState(XSysDefine.XSys_JockerKing, true);
				bool flag = DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.IsVisible();
				if (flag)
				{
					this.JokerKingMatchQuery();
				}
			}
		}

		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("XJokerKingDocument");

		public static XTableAsyncLoader AsynLoader = new XTableAsyncLoader();

		public static PokerTournamentReward JokerTournamed = new PokerTournamentReward();

		private CardMatchState m_matchState;

		private double m_timeLeft;

		private uint m_changeount;

		private uint m_matchRound;

		private uint m_matchResult;

		private uint m_matchJockerStore;

		private uint m_oldJockerID = 0u;

		private string m_matchBestName = string.Empty;

		private List<uint> m_matchJokers = new List<uint>();

		private List<uint> m_matchBestJockers = new List<uint>();

		private List<ItemBrief> m_matchItems = new List<ItemBrief>();

		private List<string> m_matchRankName = new List<string>();

		private List<int> m_matchRankScore = new List<int>();

		private uint JokerToken;

		private bool m_isBegion = false;

		private bool m_isSignUp = false;

		private bool m_isCanBegion = false;

		private uint m_JokerKingTimes = 0u;

		public bool wattingPTC = false;

		private bool m_bAvaiableIconWhenShow = false;

		public void JokerKingGameOver()
		{
			this.m_isSignUp = false;
			this.m_matchState = CardMatchState.CardMatch_StateDummy;
			this.bAvaiableIconWhenShow = false;
			XSingleton<XDebug>.singleton.AddGreenLog("JokerKingGameOver", null, null, null, null, null);
			bool flag = DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.SetVisibleWithAnimation(false, null);
			}
		}

		public static void Execute(OnLoadedCallback callback = null)
		{
			XJokerKingDocument.AsynLoader.AddTask("Table/PokerTournamentReward", XJokerKingDocument.JokerTournamed, false);
			XJokerKingDocument.AsynLoader.Execute(callback);
		}

		public void JokerKingMatchQuery()
		{
			this.SendJokerKingMsg(CardMatchOp.CardMatch_Query, 0u);
		}

		public void JokerKingMatchAdd()
		{
			this.SendJokerKingMsg(CardMatchOp.CardMatch_Add, 0u);
		}

		public void JokerKingMatchExit()
		{
			this.SendJokerKingMsg(CardMatchOp.CardMatch_Del, 0u);
		}

		public void JokerKingMatchSignUp()
		{
			int @int = XSingleton<XGlobalConfig>.singleton.GetInt("PokerTournamentSignUpNum");
			bool flag = (ulong)this.m_JokerKingTimes < (ulong)((long)@int);
			if (flag)
			{
				this.SendJokerKingMsg(CardMatchOp.CardMatch_SignUp, 0u);
			}
			else
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("JOKERKING_TIME_FULL"), "fece00");
			}
		}

		public void JokerKingRoundChange(uint card)
		{
			bool flag = this.wattingPTC;
			if (!flag)
			{
				this.wattingPTC = true;
				this.SendJokerKingMsg(CardMatchOp.CardMatch_RoundChange, card);
			}
		}

		private void SendJokerKingMsg(CardMatchOp op, uint card = 0u)
		{
			XSingleton<XDebug>.singleton.AddGreenLog("Send JokerKing Message:", op.ToString(), null, null, null, null);
			PtcC2M_PokerTournamentReq ptcC2M_PokerTournamentReq = new PtcC2M_PokerTournamentReq();
			ptcC2M_PokerTournamentReq.Data.op = op;
			ptcC2M_PokerTournamentReq.Data.card = card;
			this.m_oldJockerID = card;
			XSingleton<XClientNetwork>.singleton.Send(ptcC2M_PokerTournamentReq);
		}

		public void JokerKingRoundOver()
		{
			PtcC2M_PokerTournamentReq ptcC2M_PokerTournamentReq = new PtcC2M_PokerTournamentReq();
			ptcC2M_PokerTournamentReq.Data.op = CardMatchOp.CardMatch_RoundEnd;
			XSingleton<XClientNetwork>.singleton.Send(ptcC2M_PokerTournamentReq);
		}

		public void SendJokerMatchRank()
		{
			PtcC2M_GuildCardRankReq ptcC2M_GuildCardRankReq = new PtcC2M_GuildCardRankReq();
			ptcC2M_GuildCardRankReq.Data.type = 3u;
			XSingleton<XClientNetwork>.singleton.Send(ptcC2M_GuildCardRankReq);
		}

		public void ReceiveJokerRank(List<string> names, List<int> scores)
		{
			XSingleton<XDebug>.singleton.AddGreenLog("Length:", names.Count.ToString(), null, null, null, null);
			this.m_matchRankName.Clear();
			this.m_matchRankName.AddRange(names);
			this.m_matchRankScore.Clear();
			this.m_matchRankScore.AddRange(scores);
			int score = 0;
			int rank = -1;
			for (int i = 0; i < names.Count; i++)
			{
				bool flag = names[i] == XSingleton<XAttributeMgr>.singleton.XPlayerData.Name;
				if (flag)
				{
					bool flag2 = i < scores.Count;
					if (flag2)
					{
						score = scores[i];
						rank = i;
						break;
					}
				}
			}
			bool flag3 = DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (flag3)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.SetRankInfo(this.m_matchRankName.Count);
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.RefreshSelfRank(score, rank);
			}
		}

		public void ReceiveJokerKingMatchInfo(GuildCardMatchNtf ntf)
		{
			XSingleton<XDebug>.singleton.AddGreenLog("Receive JokerKing Message:", ntf.op.ToString(), null, null, null, null);
			switch (ntf.op)
			{
			case CardMatchOp.CardMatch_Begin:
				this.JokerBegion();
				break;
			case CardMatchOp.CardMatch_Add:
				this.ShowJokerJoin(ntf);
				this.SendJokerMatchRank();
				break;
			case CardMatchOp.CardMatch_RoundBegin:
				this.ShowMatchBegin(ntf);
				break;
			case CardMatchOp.CardMatch_RoundChange:
				this.ChangeJocker(ntf);
				break;
			case CardMatchOp.CardMatch_RoundEnd:
				this.SendJokerMatchRank();
				this.EndJockerGame(ntf);
				break;
			case CardMatchOp.CardMatch_End:
				this.SendJokerMatchRank();
				this.JokerMatchOver();
				break;
			case CardMatchOp.CardMatch_Query:
				this.ShowJokerQuery(ntf);
				break;
			case CardMatchOp.CardMatch_RoundWaiting:
				this.ShowWaittingJocker(ntf);
				this.SendJokerMatchRank();
				break;
			case CardMatchOp.CardMatch_SignUp:
				this.JokerSignUpResult(ntf);
				break;
			}
		}

		private void JokerBegion()
		{
			this.m_matchState = CardMatchState.CardMatch_StateBegin;
			bool flag = !DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.RefreshData();
			}
		}

		private void JokerMatchOver()
		{
			this.m_matchJokers.Clear();
			this.m_timeLeft = 0.0;
			this.m_matchState = CardMatchState.CardMatch_StateEnd;
			bool flag = !DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.RefreshWhenShow();
			}
		}

		private void SetMatchData(GuildCardMatchNtf ntf)
		{
			this.m_matchState = ntf.state;
			this.m_timeLeft = ntf.timeleft + 1u;
			this.m_changeount = ntf.changecount;
			this.m_matchResult = ntf.result;
			this.m_matchJockerStore = ntf.store;
			this.m_matchItems.Clear();
			this.m_matchItems.AddRange(ntf.items);
			this.m_matchRound = (uint)((long)XSingleton<XGlobalConfig>.singleton.GetInt("PokerTournamentRound") - (long)((ulong)((ntf.round == uint.MaxValue) ? 0u : (ntf.round + 1u))));
			this.m_matchJokers.Clear();
			this.m_matchJokers.AddRange(ntf.cards);
		}

		private void ShowJokerJoin(GuildCardMatchNtf ntf)
		{
			this.SetMatchData(ntf);
			this.ClearBestJoker();
			bool flag = !DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.SetVisibleWithAnimation(true, null);
			}
		}

		private void ShowMatchBegin(GuildCardMatchNtf ntf)
		{
			this.SetMatchData(ntf);
			this.ClearBestJoker();
			bool flag = !DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.RefreshWhenShow();
			}
		}

		public override void Update(float fDeltaT)
		{
			base.Update(fDeltaT);
			bool flag = this.m_timeLeft > (double)fDeltaT;
			if (flag)
			{
				this.m_timeLeft -= (double)fDeltaT;
			}
			else
			{
				this.m_timeLeft = 0.0;
			}
		}

		private void ShowJokerQuery(GuildCardMatchNtf ntf)
		{
			this.m_matchState = ntf.state;
			this.m_isBegion = ntf.isbegin;
			this.m_isCanBegion = true;
			this.m_timeLeft = ntf.timeleft;
			this.m_isSignUp = ntf.sign_up;
			this.m_JokerKingTimes = ntf.sign_up_num;
			XSingleton<XDebug>.singleton.AddGreenLog("ntf:", this.m_matchState.ToString(), " ", this.m_isSignUp.ToString(), null, null);
			bool flag = DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.RefreshData();
			}
		}

		private void ShowWaittingJocker(GuildCardMatchNtf ntf)
		{
			this.m_timeLeft = ntf.timeleft + 1u;
			this.m_matchState = ntf.state;
			this.m_matchJokers.Clear();
			bool flag = !DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.RefreshWhenShow();
			}
		}

		public void EndJockerGame(GuildCardMatchNtf ntf)
		{
			this.m_matchState = CardMatchState.CardMatch_StateRoundEnd;
			this.m_matchJockerStore = 5u;
			this.MatchJockers.Clear();
			this.m_matchItems.Clear();
			this.m_matchItems.AddRange(ntf.items);
			bool flag = DlgBase<XGuildJockerMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (flag)
			{
				bool flag2 = this.MatchResult != 8u;
				if (flag2)
				{
					XSingleton<XAudioMgr>.singleton.PlayUISound("Audio/UI/pukeshenli", true, AudioChannel.Action);
					DlgBase<XGuildJockerMatchView, XGuildJokerBehaviour>.singleton.JokerStatus(2);
					XSingleton<XTimerMgr>.singleton.KillTimer(this.JokerToken);
					this.JokerToken = XSingleton<XTimerMgr>.singleton.SetTimer(1f, DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.ResetJokerStatusCb, null);
				}
				else
				{
					XSingleton<XAudioMgr>.singleton.PlayUISound("Audio/UI/pukeshibai", true, AudioChannel.Action);
					DlgBase<XGuildJockerMatchView, XGuildJokerBehaviour>.singleton.JokerStatus(3);
					XSingleton<XTimerMgr>.singleton.KillTimer(this.JokerToken);
					this.JokerToken = XSingleton<XTimerMgr>.singleton.SetTimer(1f, DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.ResetJokerStatusCb, null);
				}
			}
			bool flag3 = !DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag3)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.RefreshWhenShow();
			}
		}

		private void ChangeJocker(GuildCardMatchNtf ntf)
		{
			this.wattingPTC = false;
			this.m_matchResult = ntf.result;
			bool flag = this.m_changeount > 0u;
			if (flag)
			{
				this.m_changeount -= 1u;
			}
			uint oldJockerID = this.m_oldJockerID;
			uint newCard = 0u;
			int num = 0;
			int i = 0;
			int count = ntf.cards.Count;
			while (i < count)
			{
				bool flag2 = !this.m_matchJokers.Contains(ntf.cards[i]);
				if (flag2)
				{
					newCard = ntf.cards[i];
					num = this.m_matchJokers.IndexOf(this.m_oldJockerID);
					bool flag3 = num > -1;
					if (flag3)
					{
						this.m_matchJokers[num] = ntf.cards[i];
					}
					break;
				}
				i++;
			}
			bool flag4 = !DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag4)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.ChangeCard(oldJockerID, newCard, num);
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.SetGameCount();
			}
		}

		private void JokerSignUpResult(GuildCardMatchNtf ntf)
		{
			XSingleton<XDebug>.singleton.AddGreenLog("Sign Up:", ntf.sign_up.ToString(), null, null, null, null);
			this.m_isSignUp = ntf.sign_up;
			this.m_JokerKingTimes = ntf.sign_up_num;
			bool flag = DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.RefreshData();
			}
		}

		private void JokerKingQueryResult(GuildCardMatchNtf ntf)
		{
			XSingleton<XDebug>.singleton.AddGreenLog("ntf Query:", ntf.state.ToString(), ntf.isbegin.ToString(), ntf.sign_up.ToString(), null, null);
			this.m_matchState = ntf.state;
			this.m_isBegion = ntf.isbegin;
			this.m_isSignUp = ntf.sign_up;
			bool flag = DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<JokerKingMainView, JokerKingMainBehavior>.singleton.RefreshData();
			}
		}

		public void SetBestJocker(List<uint> jockers, string name)
		{
			this.m_matchBestJockers.Clear();
			this.m_matchBestJockers.AddRange(jockers);
			this.m_matchBestName = name;
			bool flag = !DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.SetupBestCard();
			}
		}

		private void ClearBestJoker()
		{
			this.m_matchBestJockers.Clear();
			this.m_matchBestName = string.Empty;
			bool flag = !DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<JokerKingMatchView, XGuildJokerBehaviour>.singleton.SetupBestCard();
			}
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
		}
	}
}