summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XNormalShopDocument.cs
blob: 82711c72ea8b1ab668a8cca9f906e8c4e1729408 (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
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

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

		public static XNormalShopDocument ShopDoc
		{
			get
			{
				return XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
			}
		}

		public List<XNormalShopGoods> GoodsList
		{
			get
			{
				return this.m_goodsList;
			}
		}

		public XNormalShopView View
		{
			get
			{
				return (!this.IsTabShop(this.m_curSysType)) ? DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton._NormalShopView : DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton._TabCategoryHandler;
			}
		}

		public XShopPurchaseView PurchaseView
		{
			get
			{
				return this._purchase;
			}
			set
			{
				this._purchase = value;
			}
		}

		public uint RereshCount
		{
			get
			{
				return this._refresh_count;
			}
		}

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

		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		private List<XNormalShopGoods> m_goodsList = new List<XNormalShopGoods>();

		private XShopPurchaseView _purchase = null;

		private static ShopTypeTable _shoptable = new ShopTypeTable();

		private static ShopTable _shop = new ShopTable();

		private uint _refresh_count = 0u;

		private bool isRedPointSend = false;

		private static ulong HONER_BOX_ID = 301UL;

		private static ulong HONER_POINT_SHOW_REDPOINT = 150UL;

		public ulong ToSelectShopItemID = 0UL;

		private XSysDefine m_curSysType = XSysDefine.XSys_None;

		public static void Execute(OnLoadedCallback callback = null)
		{
			XNormalShopDocument.AsyncLoader.AddTask("Table/ShopType", XNormalShopDocument._shoptable, false);
			XNormalShopDocument.AsyncLoader.AddTask("Table/Shop", XNormalShopDocument._shop, false);
			XNormalShopDocument.AsyncLoader.Execute(null);
		}

		protected override void EventSubscribe()
		{
			base.EventSubscribe();
		}

		public override void OnDetachFromHost()
		{
			this.isRedPointSend = false;
		}

		public override void OnEnterSceneFinally()
		{
			base.OnEnterSceneFinally();
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall && !this.isRedPointSend;
			if (flag)
			{
				this.ReqGoodsList(XSysDefine.XSys_Mall_Honer);
				this.isRedPointSend = true;
			}
		}

		public List<int> GetTabListOfShop(XSysDefine sys)
		{
			List<int> list = new List<int>();
			uint shopId = this.GetShopId(sys);
			for (int i = 0; i < XNormalShopDocument._shop.Table.Length; i++)
			{
				bool flag = XNormalShopDocument._shop.Table[i].Type == shopId && !list.Contains((int)XNormalShopDocument._shop.Table[i].ShopItemType);
				if (flag)
				{
					list.Add((int)XNormalShopDocument._shop.Table[i].ShopItemType);
				}
			}
			return list;
		}

		public static uint GetLimitNumByShopId(uint shopid)
		{
			for (int i = 0; i < XNormalShopDocument._shop.Table.Length; i++)
			{
				bool flag = XNormalShopDocument._shop.Table[i].ID == shopid;
				if (flag)
				{
					return (uint)XNormalShopDocument._shop.Table[i].DailyCountCondition;
				}
			}
			return 0u;
		}

		public static ShopTable.RowData GetDataByShopId(uint shopid)
		{
			for (int i = 0; i < XNormalShopDocument._shop.Table.Length; i++)
			{
				bool flag = XNormalShopDocument._shop.Table[i].ItemId == shopid;
				if (flag)
				{
					return XNormalShopDocument._shop.Table[i];
				}
			}
			return null;
		}

		public static ShopTable.RowData GetDataById(uint id)
		{
			for (int i = 0; i < XNormalShopDocument._shop.Table.Length; i++)
			{
				bool flag = XNormalShopDocument._shop.Table[i].ID == id;
				if (flag)
				{
					return XNormalShopDocument._shop.Table[i];
				}
			}
			return null;
		}

		public static ShopTable.RowData GetDataByItemId(uint id)
		{
			for (int i = 0; i < XNormalShopDocument._shop.Table.Length; i++)
			{
				bool flag = XNormalShopDocument._shop.Table[i].ItemId == id;
				if (flag)
				{
					return XNormalShopDocument._shop.Table[i];
				}
			}
			return null;
		}

		public uint GetShopId(XSysDefine shop)
		{
			ShopTypeTable.RowData shopTypeData = this.GetShopTypeData(shop);
			bool flag = shopTypeData == null;
			uint result;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog(string.Format("ShopTypeTable not find this SysId = {0}", shop), null, null, null, null, null);
				result = 0u;
			}
			else
			{
				result = shopTypeData.ShopID;
			}
			return result;
		}

		public int GetShopViewDefaultTab()
		{
			int result = 0;
			bool flag = this.ToSelectShopItemID > 0UL;
			if (flag)
			{
				ShopTable.RowData dataByItemId = XNormalShopDocument.GetDataByItemId((uint)this.ToSelectShopItemID);
				bool flag2 = dataByItemId != null;
				if (flag2)
				{
					return (int)dataByItemId.ShopItemType;
				}
			}
			return result;
		}

		public bool CanBuyPreciousShopItem()
		{
			for (int i = 0; i < this.m_goodsList.Count; i++)
			{
				XNormalShopGoods xnormalShopGoods = this.m_goodsList[i];
				ShopTable.RowData dataById = XNormalShopDocument.GetDataById((uint)xnormalShopGoods.item.uid);
				bool flag = dataById != null && dataById.IsPrecious;
				if (flag)
				{
					uint dailyCountCondition = (uint)dataById.DailyCountCondition;
					int weekCountCondition = (int)dataById.WeekCountCondition;
					int num = 0;
					bool flag2 = dataById.CountCondition > 0u;
					if (flag2)
					{
						num = xnormalShopGoods.totalSoldNum;
					}
					else
					{
						bool flag3 = dailyCountCondition > 0u;
						if (flag3)
						{
							num = xnormalShopGoods.soldNum;
						}
						else
						{
							bool flag4 = weekCountCondition != 0;
							if (flag4)
							{
								num = (int)xnormalShopGoods.weeklyBuyCount;
							}
						}
					}
					int countCondition = (int)dataById.CountCondition;
					bool flag5 = dailyCountCondition == 0u && countCondition == 0 && weekCountCondition == 0;
					if (!flag5)
					{
						bool flag6 = countCondition != 0;
						bool result;
						if (flag6)
						{
							bool flag7 = num >= countCondition;
							if (flag7)
							{
								goto IL_111;
							}
							result = true;
						}
						else
						{
							bool flag8 = dailyCountCondition != 0u && (long)num >= (long)((ulong)dailyCountCondition);
							if (flag8)
							{
								goto IL_111;
							}
							bool flag9 = weekCountCondition != 0 && num >= weekCountCondition;
							if (flag9)
							{
								goto IL_111;
							}
							result = true;
						}
						return result;
					}
				}
				IL_111:;
			}
			return false;
		}

		public List<List<uint>> GetShopItemByPlayLevelAndShopType(XSysDefine shop)
		{
			List<uint> item = new List<uint>();
			List<uint> item2 = new List<uint>();
			List<uint> item3 = new List<uint>();
			List<List<uint>> list = new List<List<uint>>
			{
				item,
				item2,
				item3
			};
			uint shopId = this.GetShopId(shop);
			bool flag = shopId > 0u;
			if (flag)
			{
				for (int i = 0; i < XNormalShopDocument._shop.Table.Length; i++)
				{
					ShopTable.RowData rowData = XNormalShopDocument._shop.Table[i];
					bool flag2 = rowData.Type == shopId && XSingleton<XAttributeMgr>.singleton.XPlayerData.Level >= rowData.LevelShow[0] && XSingleton<XAttributeMgr>.singleton.XPlayerData.Level <= rowData.LevelShow[1] && rowData.ShopItemCategory >= 1u && rowData.ShopItemCategory <= 3u;
					if (flag2)
					{
						bool flag3 = !list[(int)(rowData.ShopItemCategory - 1u)].Contains(rowData.ItemId);
						if (flag3)
						{
							list[(int)(rowData.ShopItemCategory - 1u)].Add(rowData.ItemId);
						}
					}
				}
			}
			return list;
		}

		public ShopTypeTable.RowData GetShopTypeData(XSysDefine shop)
		{
			return XNormalShopDocument._shoptable.GetBySystemId((uint)XFastEnumIntEqualityComparer<XSysDefine>.ToInt(shop));
		}

		public void ReqGoodsList(XSysDefine sys)
		{
			this.m_curSysType = sys;
			bool flag = sys != XSysDefine.XSys_Mall_Partner && sys != XSysDefine.XSys_DragonGuildShop;
			if (flag)
			{
				RpcC2G_QueryShopItem rpcC2G_QueryShopItem = new RpcC2G_QueryShopItem();
				ShopTypeTable.RowData shopTypeData = this.GetShopTypeData(sys);
				bool flag2 = shopTypeData != null;
				if (flag2)
				{
					rpcC2G_QueryShopItem.oArg.type = shopTypeData.ShopID;
					rpcC2G_QueryShopItem.oArg.isrefresh = false;
				}
				else
				{
					XSingleton<XDebug>.singleton.AddErrorLog("ShopTypeTable not find this sytemId = " + sys, null, null, null, null, null);
				}
				XSingleton<XClientNetwork>.singleton.Send(rpcC2G_QueryShopItem);
			}
			else
			{
				bool flag3 = sys == XSysDefine.XSys_Mall_Partner;
				if (flag3)
				{
					RpcC2M_GetPartnerShop rpc = new RpcC2M_GetPartnerShop();
					XSingleton<XClientNetwork>.singleton.Send(rpc);
				}
				else
				{
					bool flag4 = sys == XSysDefine.XSys_DragonGuildShop;
					if (flag4)
					{
						RpcC2M_GetDragonGuildShop rpc2 = new RpcC2M_GetDragonGuildShop();
						XSingleton<XClientNetwork>.singleton.Send(rpc2);
					}
				}
			}
		}

		public void OnGetGoodsList(QueryShopItemArg oArg, QueryShopItemRes oRes)
		{
			this._refresh_count = oRes.refreshcount;
			this.SetGoodsList(oRes.ShopItem, oArg.type, oRes.cooklevel);
			ShopTypeTable.RowData shopTypeData = this.GetShopTypeData(XSysDefine.XSys_Mall_Card1);
			ShopTypeTable.RowData shopTypeData2 = this.GetShopTypeData(XSysDefine.XSys_Mall_Card2);
			ShopTypeTable.RowData shopTypeData3 = this.GetShopTypeData(XSysDefine.XSys_Mall_Card3);
			ShopTypeTable.RowData shopTypeData4 = this.GetShopTypeData(XSysDefine.XSys_Mall_Card4);
			bool flag = (shopTypeData != null && oArg.type == shopTypeData.ShopID) || (shopTypeData2 != null && oArg.type == shopTypeData2.ShopID) || (shopTypeData3 != null && oArg.type == shopTypeData3.ShopID) || (shopTypeData4 != null && oArg.type == shopTypeData4.ShopID);
			if (flag)
			{
				bool flag2 = DlgBase<CardCollectView, CardCollectBehaviour>.singleton.ShopHandler != null;
				if (flag2)
				{
					DlgBase<CardCollectView, CardCollectBehaviour>.singleton.ShopHandler.SetCardShop(this.GoodsList);
				}
			}
		}

		public bool IsTabShop(XSysDefine sys)
		{
			bool result = false;
			ShopTypeTable.RowData shopTypeData = this.GetShopTypeData(sys);
			bool flag = shopTypeData != null && shopTypeData.IsHasTab == 1;
			if (flag)
			{
				result = true;
			}
			return result;
		}

		public bool IsShop(XSysDefine sys)
		{
			return this.GetShopTypeData(sys) != null;
		}

		public void OnGetGoodsList(GetPartnerShopArg oArg, GetPartnerShopRes oRes)
		{
			bool flag = oRes == null;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(ErrorCode.ERR_FAILED, "fece00");
			}
			else
			{
				this._refresh_count = 0u;
				this.SetGoodsList(oRes.item);
			}
		}

		public void OnGetGoodsList(GetDragonGuildShopArg oArg, GetDragonGuildShopRes oRes)
		{
			bool flag = oRes == null;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(ErrorCode.ERR_FAILED, "fece00");
			}
			else
			{
				this._refresh_count = 0u;
				this.SetGoodsList(oRes.items);
			}
		}

		public void ReqBuy(int index)
		{
			bool flag = index >= this.m_goodsList.Count;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("Item index out of range. ", index.ToString(), null, null, null, null);
			}
			else
			{
				XNormalShopGoods xnormalShopGoods = this.m_goodsList[index];
				ShopTable.RowData dataById = XNormalShopDocument.GetDataById((uint)xnormalShopGoods.item.uid);
				uint itemnum = (dataById == null) ? 1u : dataById.ItemOverlap;
				this.DoBuyItem(xnormalShopGoods, itemnum);
			}
		}

		public void DoBuyItem(XNormalShopGoods goods, uint itemnum)
		{
			bool flag = this.m_curSysType != XSysDefine.XSys_Mall_Partner && this.m_curSysType != XSysDefine.XSys_DragonGuildShop;
			if (flag)
			{
				RpcC2G_BuyShopItem rpcC2G_BuyShopItem = new RpcC2G_BuyShopItem();
				rpcC2G_BuyShopItem.oArg.ItemUniqueId = goods.item.uid;
				rpcC2G_BuyShopItem.oArg.count = itemnum;
				XSingleton<XClientNetwork>.singleton.Send(rpcC2G_BuyShopItem);
			}
			else
			{
				bool flag2 = this.m_curSysType == XSysDefine.XSys_Mall_Partner;
				if (flag2)
				{
					RpcC2M_BuyPartnerShopItem rpcC2M_BuyPartnerShopItem = new RpcC2M_BuyPartnerShopItem();
					rpcC2M_BuyPartnerShopItem.oArg.count = itemnum;
					rpcC2M_BuyPartnerShopItem.oArg.id = (uint)goods.item.uid;
					XSingleton<XClientNetwork>.singleton.Send(rpcC2M_BuyPartnerShopItem);
				}
				else
				{
					bool flag3 = this.m_curSysType == XSysDefine.XSys_DragonGuildShop;
					if (flag3)
					{
						RpcC2M_BuyDragonGuildShopItem rpcC2M_BuyDragonGuildShopItem = new RpcC2M_BuyDragonGuildShopItem();
						rpcC2M_BuyDragonGuildShopItem.oArg.count = itemnum;
						rpcC2M_BuyDragonGuildShopItem.oArg.id = (uint)goods.item.uid;
						XSingleton<XClientNetwork>.singleton.Send(rpcC2M_BuyDragonGuildShopItem);
					}
				}
			}
		}

		public void ReqBuyPanel(int index)
		{
			XNormalShopGoods goods = this.m_goodsList[index];
			DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.PurchaseView.OnBuyItem(goods);
		}

		public void OnGetBuy(BuyShopItemArg oArg, BuyShopItemRes oRes)
		{
			bool flag = oRes.ErrorCode > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				for (int i = 0; i < this.m_goodsList.Count; i++)
				{
					bool flag2 = this.m_goodsList[i].item.uid == oArg.ItemUniqueId;
					if (flag2)
					{
						ShopTable.RowData dataById = XNormalShopDocument.GetDataById((uint)this.m_goodsList[i].item.uid);
						ItemList.RowData itemConf = XBagDocument.GetItemConf((int)dataById.ConsumeItem[0]);
						bool flag3 = dataById != null && itemConf != null;
						if (flag3)
						{
							bool flag4 = oRes.ErrorCode == ErrorCode.ERR_SHOP_LEVELLIMIT;
							if (flag4)
							{
								XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString(oRes.ErrorCode), dataById.LevelCondition), "fece00");
								return;
							}
							bool flag5 = oRes.ErrorCode == ErrorCode.ERR_ITEM_NOT_ENOUGH;
							if (flag5)
							{
								string itemQualityRGB = XSingleton<UiUtility>.singleton.GetItemQualityRGB((int)itemConf.ItemQuality);
								string arg = string.Concat(new string[]
								{
									"[",
									itemQualityRGB,
									"]",
									itemConf.ItemName[0],
									"[-]"
								});
								XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("ERR_NOT_ENOUGH"), arg), "fece00");
								return;
							}
						}
					}
				}
				XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.ErrorCode, "fece00");
			}
			else
			{
				this.RefreshShopData(oArg.ItemUniqueId, oArg.count);
				bool flag6 = DlgBase<CardCollectView, CardCollectBehaviour>.singleton.CurPage == CardPage.CardShop && DlgBase<CardCollectView, CardCollectBehaviour>.singleton.ShopHandler != null;
				if (flag6)
				{
					DlgBase<CardCollectView, CardCollectBehaviour>.singleton.ShopHandler.RefreshChipNum();
				}
			}
		}

		public void OnGetBuy(BuyPartnerShopItemArg oArg, BuyPartnerShopItemRes oRes)
		{
			bool flag = oRes == null;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(ErrorCode.ERR_FAILED, "fece00");
			}
			else
			{
				bool flag2 = oRes.result > ErrorCode.ERR_SUCCESS;
				if (flag2)
				{
					ErrorCode result = oRes.result;
					if (result != ErrorCode.ERR_PARTNER_LN_NOT_ENOUGH)
					{
						if (result - ErrorCode.ERR_PARTNER_ITEM_NOT_FOUND > 2)
						{
							XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.result, "fece00");
						}
						else
						{
							this.ReqGoodsList(XSysDefine.XSys_Mall_Partner);
							XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.result, "fece00");
						}
					}
					else
					{
						ShopTable.RowData dataById = XNormalShopDocument.GetDataById(oArg.id);
						bool flag3 = dataById != null;
						if (flag3)
						{
							XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XSingleton<XStringTable>.singleton.GetString("ERR_PARTNER_LEVEL_NOT_ENOUGH"), dataById.LevelCondition), "fece00");
						}
					}
				}
				else
				{
					this.RefreshShopData((ulong)oArg.id, oArg.count);
				}
			}
		}

		public void OnGetBuy(BuyDragonGuildShopItemArg oArg, BuyDragonGuildShopItemRes oRes)
		{
			bool flag = oRes == null;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(ErrorCode.ERR_FAILED, "fece00");
			}
			else
			{
				bool flag2 = oRes.result > ErrorCode.ERR_SUCCESS;
				if (flag2)
				{
					ErrorCode result = oRes.result;
					if (result != ErrorCode.ERR_PARTNER_LN_NOT_ENOUGH)
					{
						if (result - ErrorCode.ERR_PARTNER_ITEM_NOT_FOUND > 2)
						{
							XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.result, "fece00");
						}
						else
						{
							this.ReqGoodsList(XSysDefine.XSys_DragonGuildShop);
							XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.result, "fece00");
						}
					}
					else
					{
						ShopTable.RowData dataById = XNormalShopDocument.GetDataById(oArg.id);
						bool flag3 = dataById != null;
						if (flag3)
						{
							XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XSingleton<XStringTable>.singleton.GetString("ERR_PARTNER_LEVEL_NOT_ENOUGH"), dataById.LevelCondition), "fece00");
						}
					}
				}
				else
				{
					this.RefreshShopData((ulong)oArg.id, oArg.count);
				}
			}
		}

		private void RefreshShopData(ulong uid, uint count)
		{
			for (int i = 0; i < this.m_goodsList.Count; i++)
			{
				bool flag = this.m_goodsList[i].item.uid == uid;
				if (flag)
				{
					this.m_goodsList[i].soldNum += (int)count;
					this.m_goodsList[i].totalSoldNum += (int)count;
					this.m_goodsList[i].weeklyBuyCount += count;
					bool flag2 = this.View != null && this.View.IsVisible();
					if (flag2)
					{
						this.View.UpdateShopItemInfo(this.m_goodsList[i]);
					}
					this.RefreshYyMallView();
					break;
				}
			}
		}

		private void SetGoodsList(List<ShopItem> goodsList, uint type = 0u, uint cooklevel = 0u)
		{
			this.m_goodsList.Clear();
			int num = 0;
			bool flag = goodsList != null;
			if (flag)
			{
				ShopTypeTable.RowData shopTypeData = this.GetShopTypeData(XSysDefine.XSys_Mall_Home);
				foreach (ShopItem shopItem in goodsList)
				{
					bool flag2 = shopTypeData != null && shopTypeData.ShopID == type;
					if (flag2)
					{
						ShopTable.RowData dataById = XNormalShopDocument.GetDataById((uint)shopItem.Item.uid);
						bool flag3 = cooklevel < (uint)dataById.CookLevel;
						if (flag3)
						{
							continue;
						}
					}
					this.m_goodsList.Add(XNormalShopGoods.MakeGoodsFromData(shopItem));
					num++;
				}
			}
			this.RefreshYyMallView();
			bool flag4 = this.View != null && this.View.IsVisible();
			if (flag4)
			{
				this.View.RefreshGoodsList();
			}
			else
			{
				ShopTypeTable.RowData shopTypeData2 = this.GetShopTypeData(XSysDefine.XSys_Mall_Honer);
				bool flag5 = shopTypeData2 != null && shopTypeData2.ShopID == type;
				if (flag5)
				{
					foreach (ShopItem shopItem2 in goodsList)
					{
						ShopTable.RowData dataById2 = XNormalShopDocument.GetDataById((uint)shopItem2.Item.uid);
						bool flag6 = shopItem2.Item.uid == XNormalShopDocument.HONER_BOX_ID && dataById2 != null;
						if (flag6)
						{
							bool flag7 = XBagDocument.BagDoc.GetItemCount(XFastEnumIntEqualityComparer<ItemEnum>.ToInt(ItemEnum.HORNOR_POINT)) >= XNormalShopDocument.HONER_POINT_SHOW_REDPOINT && (uint)dataById2.DailyCountCondition - shopItem2.dailybuycount > 0u;
							if (flag7)
							{
								XGameMallDocument specificDocument = XDocuments.GetSpecificDocument<XGameMallDocument>(XGameMallDocument.uuID);
								specificDocument.RefreshShopRedPoint(XSysDefine.XSys_Mall_Honer, true);
							}
						}
					}
				}
			}
		}

		private void RefreshYyMallView()
		{
			bool flag = DlgBase<XWelfareView, XWelfareBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgHandlerBase dlgHandlerBase;
				DlgBase<XWelfareView, XWelfareBehaviour>.singleton.m_AllHandlers.TryGetValue(XSysDefine.XSys_Welfare_YyMall, out dlgHandlerBase);
				bool flag2 = dlgHandlerBase != null && dlgHandlerBase.IsVisible();
				if (flag2)
				{
					dlgHandlerBase.RefreshData();
				}
			}
		}

		private void SetGoodsList(List<PartnerShopItemClient> goodsList)
		{
			this.m_goodsList.Clear();
			bool flag = goodsList != null;
			if (flag)
			{
				foreach (PartnerShopItemClient data in goodsList)
				{
					this.m_goodsList.Add(XNormalShopGoods.MakeGoodsFromData(data));
				}
			}
			bool flag2 = this.View != null && this.View.IsVisible();
			if (flag2)
			{
				this.View.RefreshGoodsList();
			}
		}

		private void SetGoodsList(List<DragonGuildShopItemClient> goodsList)
		{
			this.m_goodsList.Clear();
			bool flag = goodsList != null;
			if (flag)
			{
				foreach (DragonGuildShopItemClient data in goodsList)
				{
					this.m_goodsList.Add(XNormalShopGoods.MakeGoodsFromData(data));
				}
			}
			bool flag2 = this.View != null && this.View.IsVisible();
			if (flag2)
			{
				this.View.RefreshGoodsList();
			}
		}

		private void SelectDefaultShopItem()
		{
			bool flag = this.ToSelectShopItemID > 0UL && this.m_goodsList.Count > 0;
			if (flag)
			{
				int num = -1;
				for (int i = 0; i < this.m_goodsList.Count; i++)
				{
					bool flag2 = this.m_goodsList[i].item.itemID == (int)this.ToSelectShopItemID;
					if (flag2)
					{
						num = i;
						break;
					}
				}
				bool flag3 = num >= 0;
				if (flag3)
				{
					XNormalShopGoods value = this.m_goodsList[num];
					for (int j = num - 1; j >= 0; j--)
					{
						this.m_goodsList[j + 1] = this.m_goodsList[j];
					}
					this.m_goodsList[0] = value;
				}
			}
		}

		protected bool OnVirtualItemChanged(XEventArgs args)
		{
			XVirtualItemChangedEventArgs xvirtualItemChangedEventArgs = args as XVirtualItemChangedEventArgs;
			bool flag = DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.IsLoaded() && DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.OnVirtualItemChanged(xvirtualItemChangedEventArgs.e, xvirtualItemChangedEventArgs.newValue);
			}
			return true;
		}

		protected bool OnItemNumChanged(XEventArgs args)
		{
			XItemNumChangedEventArgs xitemNumChangedEventArgs = args as XItemNumChangedEventArgs;
			bool flag = DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.IsLoaded() && DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.OnItemCountChanged(xitemNumChangedEventArgs.item.itemID, xitemNumChangedEventArgs.item.itemCount);
			}
			return true;
		}

		protected bool OnAddItem(XEventArgs args)
		{
			XAddItemEventArgs xaddItemEventArgs = args as XAddItemEventArgs;
			bool flag = DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.IsLoaded() && DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.IsVisible();
			if (flag)
			{
				for (int i = 0; i < xaddItemEventArgs.items.Count; i++)
				{
					DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.OnItemCountChanged(xaddItemEventArgs.items[i].itemID, xaddItemEventArgs.items[i].itemCount);
				}
			}
			return true;
		}

		protected bool OnRemoveItem(XEventArgs args)
		{
			XRemoveItemEventArgs xremoveItemEventArgs = args as XRemoveItemEventArgs;
			bool flag = DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.IsLoaded() && DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.IsVisible();
			if (flag)
			{
				for (int i = 0; i < xremoveItemEventArgs.ids.Count; i++)
				{
					DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.OnItemCountChanged(xremoveItemEventArgs.ids[i], 0);
				}
			}
			return true;
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
		}

		public bool IsShopAvailable(XSysDefine sys)
		{
			bool flag = !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(sys);
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				int hour = DateTime.Now.Hour;
				int minute = DateTime.Now.Minute;
				bool flag2 = false;
				ShopTypeTable.RowData shopTypeData = this.GetShopTypeData(sys);
				bool flag3 = shopTypeData != null;
				if (flag3)
				{
					for (int i = 0; i < shopTypeData.ShopOpen.Count; i++)
					{
						int num = hour * 100 + minute;
						bool flag4 = (long)num >= (long)((ulong)shopTypeData.ShopOpen[i, 0]) && (long)num <= (long)((ulong)shopTypeData.ShopOpen[i, 1]);
						if (flag4)
						{
							flag2 = true;
						}
					}
				}
				result = flag2;
			}
			return result;
		}

		public bool IsExchangeMoney(int itemid)
		{
			return itemid == 1 || itemid == 7 || itemid == 88;
		}

		public bool IsMoneyOrItemEnough(int itemid, int reqnum)
		{
			ulong itemCount = XSingleton<XGame>.singleton.Doc.XBagDoc.GetItemCount(itemid);
			bool flag = reqnum > (int)itemCount;
			return !flag;
		}

		public void ProcessItemOrMoneyNotEnough(int itemid)
		{
			ItemList.RowData itemConf = XBagDocument.GetItemConf(itemid);
			bool flag = itemConf != null;
			if (flag)
			{
				string itemQualityRGB = XSingleton<UiUtility>.singleton.GetItemQualityRGB((int)itemConf.ItemQuality);
				string arg = string.Concat(new string[]
				{
					"[",
					itemQualityRGB,
					"]",
					itemConf.ItemName[0],
					"[-]"
				});
				XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("ERR_NOT_ENOUGH"), arg), "fece00");
			}
			bool flag2 = itemid == 88;
			if (flag2)
			{
				XSingleton<UiUtility>.singleton.ShowItemAccess(itemid, null);
			}
			else
			{
				DlgBase<XPurchaseView, XPurchaseBehaviour>.singleton.ShowBorad((ItemEnum)itemid);
			}
		}
	}
}