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
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package FunctionNPCCommon
# @todo: ¹¦ÄÜNPC¹ÜÀíÆ÷
#
# @author: panwei
# @date 2010-4-26
# @version 4.4
#
# @note: 
#---------------------------------------------------------------------
# @change: "2013-04-18 17:00" wdb ÎïÆ·ÑÕɫʹÓÃÐÞ¸Ä
# @change: "2013-04-26 16:00" wdb npcÉ̵êÐÞ¸Ä
# @change: "2013-05-03 17:00" wdb npcÉ̵êÅä±í·½Ê½ÐÞ¸Ä
# @change: "2013-05-20 15:00" wdb ×°±¸¸½¼ÓÊôÐÔ½Ó¿ÚÐÞ¸Ä
# @change: "2013-05-30 10:30" wdb ×°±¸±¦Ê¯ÏâǶµ÷Õû
# @change: "2013-07-19 20:00" Alee Ìí¼Ó»Ø¹º
# @change: "2013-07-22 17:00" Alee ÎïÆ·¿É°´ÊýÁ¿¹ºÂò
# @change: "2013-10-12 21:10" Alee ÏµÍ³Ìáʾ
# @change: "2013-10-22 11:10" Alee ÎïÆ·¼¼ÄÜÔöǿЧ¹û,ͳһº¯ÊýEquipAddAdditionEx
# @change: "2013-11-08 22:30" Alee É̳ÇÌí¼Ó´ò¿×
# @change: "2013-11-19 11:00" hxp Ð޸ijöÊÛÎïÆ·ÅжϽðÇ®ÉÏÏÞÂß¼­
# @change: "2014-01-16 13:54" xmnathan Õ½ÃËÉ̳ǹºÂò
# @change: "2014-01-28 00:55" Alee ¶ñħÉ̵êĬÈÏ׿ԽºÍÌ××°
# @change: "2014-02-12 14:00" Alee È¡ÏûºìÃû¹ºÂò³Í·£
# @change: "2014-04-07 11:30" Alee ·â°üDWORDµ¼Ö½ӿÚint±¨´í£¬·À·¶·¶Î§¹ý´ó
# @change: "2014-05-05 15:00" xmnathan Ì滻ϵͳÌáʾ
# @change: "2014-05-21 17:25" xcc Ôö¼Óħ·½Ñ°±¦»ý·Ö¶Ò»»ÎïÆ·¹¦ÄÜ
# @change: "2014-06-05 15:30" hxp É̵êNPCÎïÆ·¹ºÂòÔö¼ÓÿÈտɹºÂò´ÎÊýÉÏÏÞÖ§³Ö
# @change: "2014-08-04 16:00" Alee Ì××°ÎïÆ·É̵êÐÞ¸Ä
# @change: "2014-08-07 20:40" Alee ±¦²Ø»ý·Ö¶Ò»»×¿Ô½ÊôÐÔ×°±¸¹Ì¶¨2ÌõÊôÐÔ
# @change: "2014-10-20 16:20" Alee ¶Ò»»Ì××°3׿Խ
# @change: "2014-11-05 15:00" Alee É̵깺Âò°ó¶¨ÐÞ¸Ä
# @change: "2014-12-11 16:30" hxp É̵ê¶Ò»»×°±¸Ôö¼ÓÖ§³ÖÅäÖÃ×°±¸¶ÔӦ׿ԽÌõÊý
# @change: "2015-01-14 00:30" hxp Ôö¼ÓÎïÆ·±ä¸üʼþ»ã±¨
# @change: "2015-01-14 16:40" ljd Ôö¼ÓÎïÆ·¶Ò»»É̵ê
# @change: "2015-01-27 10:50" ljd Ôö¼Ó×°±¸ÎïÆ·À´Ô´±ê¼Ç
# @change: "2015-04-03 18:00" hxp ·À·¶»ØÊÕÕ¾Òì³£Çé¿öÎïÆ·Ïûʧ¶øÃ»ÓÐÖØÖñê¼Çλµ¼ÖÂÊýÖµÔ½½ç
# @change: "2015-04-16 19:10" ljd É̵긶Ǯʱ´«ÈëÖ§¸¶ÀàÐÍ
# @change: "2015-04-27 22:00" hxp Ôö¼ÓBuyItemÁ÷Ïò
# @change: "2016-07-20 14:30" hxp »õ±ÒÖ§¸¶Á÷ÏòÕûºÏ
# @change: "2016-08-04 18:00" hxp ³öÊۻعº¼Û¸ñÐÞ¸Ä
#---------------------------------------------------------------------
#"""Version = 2016-08-04 18:00"""
#---------------------------------------------------------------------
import ChPyNetSendPack
import NetPackCommon
import GameWorld
import EventShell
import IPY_GameWorld
import ItemControler
import ChConfig
import PlayerControl
import ItemCommon
import ShareDefine
import PlayerFlashSale
#import EventSrc
import ChItem
import IpyGameDataPY
import PlayerRune
import GameFuncComm
import PlayerFairyCeremony
import PlayerNewFairyCeremony
import PlayerSpringSale
import PyGameData
 
import random
import math
import time
 
# É̵êÀàÐͶ¨Òå
ShopType_FairyCeremony = 19 # ÏɽçÊ¢µäÑÌ»¨
 
g_mysticalShopDict = {} #ÉñÃØÉ̵ê{µÈ¼¶·¶Î§:[µÈ¼¶¶Î,{½ðÇ®ÀàÐÍ:¿â}]}
#---------------------------------------------------------------------
##¿ªÊ¼½»Ò×
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦
# @remarks ¿ªÊ¼½»Ò×
def StartTrade(curPlayer, tick):
 
    curActionObj = curPlayer.GetActionObj()
    if curActionObj == None:
        return
    
    if curActionObj.GetGameObjType() != IPY_GameWorld.gotNPC:
        return
            
    curActionNPC = GameWorld.GetNPCManager().GetNPCByIndex(curActionObj.GetIndex())
    curActionNPCID = curActionNPC.GetNPCID()
    
    # ÉèÖõ±Ç°É̵êµÄnpcid
    curPlayer.SetDict(ChConfig.Def_PlayerKey_TradeTagNPC, curActionNPCID)
    
    #É趨Ϊ½ûÖ¹ÕûÀí±³°ü
    curPlayer.SetForbiddenResetItem(1)
    curPlayer.BeginSpecialEvent(ShareDefine.TYPE_Event_Shop)
    return True
 
#------------------------------------------------------------------------------ 
## »ñȡԶ³ÌÉ̵êµÄnpc
# @param curPlayer Íæ¼ÒʵÀý
# @return Ô¶³ÌÉ̵êµÄnpc
def GetDirectNpcID():
    return 0
 
#---------------------------------------------------------------------
##½áÊøÊ¼þ
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦
# @remarks ½áÊøÊ¼þ
def ExitEvent(curPlayer, tick):
        
    EventShell.DoExitEvent(curPlayer)
    return True
 
#---------------------------------------------------------------------
##ÇëÇóÉ̵êÎïÆ·Áбí
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦
def QueryNPCShopItem(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    
    #ʱ¼ä¼ä¸ôδµ½
    if tick - curPlayer.GetTickByType(ChConfig.TYPE_Player_Tick_QueryFuncData) \
       < ChConfig.TYPE_Player_Tick_Time[ChConfig.TYPE_Player_Tick_QueryFuncData]:
        return
    
    curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_QueryFuncData, tick) 
    
    #Ö±½Ó²éѯ£¬´æÔÚ¸ÃNPCID¾Í·¢°ü
    tradeTagNPC = clientData.NPCShopID
    GameWorld.GetGameData().FilterShopItemByShopType(tradeTagNPC)
    shopItemCount = GameWorld.GetGameData().GetFilterShopItemCount()
    if shopItemCount <= 0:
        return
    
#    # É̵ênpcidÓ뵱ǰ¶Ô»°npc¶ÔÓ¦,0ΪԶ³ÌÉ̵ê
#    tradeTagNPC = clientData.NPCShopID
#    if tradeTagNPC != 0 and not CheckTradeTagNPC(curPlayer, tradeTagNPC):
#        return
    
    # ·¢ËÍÉÌÆ·½ñÈÕÒѹºÂò´ÎÊý
    #SyncShopItemTodayBuyCount(curPlayer)
    
    # ·¢ËÍÉ̵êÎïÆ·Áбí
    curPlayer.BeginShopEx(tradeTagNPC)    
    return
 
##ͬ²½É̵êNPCÎïÆ·½ñÈÕ¹ºÂò´ÎÊý
# @param curPlayer Íæ¼ÒʵÀý
# @param npcID
# @param itemIndex -1ʱͬ²½¸ÃNPCËùÓÐÎïÆ·
# @return 
def SyncShopItemTodayBuyCount(curPlayer, itemIndexList=[], isReset=False):
    dayBuyCntInfo = ChPyNetSendPack.tagMCShopItemDayBuyCntInfo()
    dayBuyCntInfo.DayBuyCntList = []
    if itemIndexList:
        for itemIndex in itemIndexList:
            __AppendShopItemDayBuyCntInfo(curPlayer, itemIndex, dayBuyCntInfo.DayBuyCntList, isReset)
    else:
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        for i in xrange(ipyDataMgr.GetStoreCount()):
            shopItem = ipyDataMgr.GetStoreByIndex(i)
            if not shopItem.GetLimitCnt():
                continue
            dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % shopItem.GetID()
            curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
            if curDayBuyCnt <= 0:
                continue
            __AppendShopItemDayBuyCntInfo(curPlayer, shopItem.GetID(), dayBuyCntInfo.DayBuyCntList, isReset)
            
    dayBuyCntInfo.Count = len(dayBuyCntInfo.DayBuyCntList)
    NetPackCommon.SendFakePack(curPlayer, dayBuyCntInfo)
    return
 
##Ôö¼ÓÉ̵êÎïÆ·½ñÈÕ¹ºÂò´ÎÊýÐÅÏ¢
# @param curPlayer Íæ¼ÒʵÀý
# @param npcID
# @param itemIndex
# @return 
def __AppendShopItemDayBuyCntInfo(curPlayer, itemIndex, dayBuyCntList, isReset):
    itemDayBuyCnt = ChPyNetSendPack.tagMCShopItemDayBuyCnt()
    itemDayBuyCnt.ItemIndex = itemIndex
    dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex
    curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
    itemDayBuyCnt.BuyCnt = curDayBuyCnt
    itemDayBuyCnt.IsReset = int(isReset)
    dayBuyCntList.append(itemDayBuyCnt)
    return
 
## µÇ¼
def ShopItemOnLogin(curPlayer):    
    SyncMysticalLimitShopInfo(curPlayer)
    SyncShopItemTodayBuyCount(curPlayer)
    if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopGoods % 0):
        __DoMysticalShopRefresh(curPlayer, True, GameWorld.GetGameWorld().GetTick())
    SyncMysticalShopInfo(curPlayer)
    return
 
##É̵êÎïÆ·OnDay
# @param curPlayer Íæ¼ÒʵÀý
# @return 
def ShopItemOnDay(curPlayer, onEventType):
    if onEventType == ShareDefine.Def_OnEventType:
        OSSaleOpenMail(curPlayer)
        refreshType = [3]
        #ÉñÃØÉ̵êˢдÎÊýÖØÖÃ
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopRefreshCnt, 0)
        SyncMysticalShopInfo(curPlayer)
        
    elif onEventType == ShareDefine.Def_OnEventTypeEx:
        refreshType = [4]
        openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)
        isMixServer = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_IsMixServer)
        if isMixServer:
            mixServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_MixServerDay)
            if mixServerDay % 3 == 0:
                refreshType.append(7)
        elif openServerDay % 3 == 0:
            refreshType.append(7)
    else:
        return
    ResetShopItemBuyCount(curPlayer, refreshType)
    return
 
##É̵êÎïÆ·OnWeek
# @param curPlayer Íæ¼ÒʵÀý
# @return 
def ShopItemOnWeek(curPlayer, onEventType):
    if onEventType == ShareDefine.Def_OnEventType:
        refreshType = [1]
    elif onEventType == ShareDefine.Def_OnEventTypeEx:
        refreshType = [2]
    else:
        return
    ResetShopItemBuyCount(curPlayer, refreshType)
    return
 
##É̵êÎïÆ·OnMonth
# @param curPlayer Íæ¼ÒʵÀý
# @return 
def ShopItemOnMonth(curPlayer, onEventType):
    if onEventType == ShareDefine.Def_OnEventType:
        refreshType = 5
    elif onEventType == ShareDefine.Def_OnEventTypeEx:
        refreshType = 6
    else:
        return
    ResetShopItemBuyCount(curPlayer, [refreshType])
    return
 
def ShopItemOnCrossPKSeasonChange(curPlayer):
    ## °´¿ç·þPKÈü¼¾ÖØÖÃ
    refreshType = 8
    ResetShopItemBuyCount(curPlayer, [refreshType])
    return
 
def ResetShopItemBuyCount(curPlayer, resetTypeList):
    #@param resetTypeList: ÐèÒªÖØÖõÄÀàÐÍÁбí
    #ÖØÖÃÉ̵êÎïÆ·¹ºÂò´ÎÊý  1£ºÖÜÒ»0µãˢР   2£ºÖÜÒ»5µãˢР   3£ºÃ¿ÈÕ0µãˢР   4£ºÃ¿ÈÕ5µãˢР   5ÿÔÂ0µã    6ÿÔÂ5µã   7ÿ3Ìì5µã  8ÿÈü¼¾
    if not resetTypeList:
        # Ôݶ¨±ØÐëÖ¸¶¨ÀàÐÍÁÐ±í£¬·ÀÖ¹ÖÕÉíÏÞ¹ºµÄÎó±»ÖØÖÃ
        return
    
    syncIndexList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for i in xrange(ipyDataMgr.GetStoreCount()):
        shopItem = ipyDataMgr.GetStoreByIndex(i)
        if not shopItem.GetLimitCnt():
            continue
        if shopItem.GetRefreshLimit():
            continue
        if shopItem.GetRefreshType() not in resetTypeList:
            continue
        dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % shopItem.GetID()
        curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
        if curDayBuyCnt <= 0:
            continue
        PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, 0)
        syncIndexList.append(shopItem.GetID())
    if syncIndexList:
        SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True)
    return
 
def ResetShopItemBuyCountByShopType(curPlayer, shopTypeList):
    ##¸ù¾ÝÉ̵êÀàÐÍÖØÖÃÉ̵êÏÞ¹ºÎïÆ·´ÎÊý
    syncIndexList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for i in xrange(ipyDataMgr.GetStoreCount()):
        shopItem = ipyDataMgr.GetStoreByIndex(i)
        if not shopItem.GetLimitCnt():
            continue
        if shopItem.GetRefreshLimit():
            continue
        if shopItem.GetShopType() not in shopTypeList:
            continue
        dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % shopItem.GetID()
        curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
        if curDayBuyCnt <= 0:
            continue
        PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, 0)
        syncIndexList.append(shopItem.GetID())
    if syncIndexList:
        SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True)
    return
 
def MysticalLimitShopOpen(curPlayer, befLV, aftLV):
    ##ÉñÃØÏÞ¹º¿ªÆô
    ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('Store', {'ShopType':16}, True)
    if not ipyDataList:
        return
    curTime = int(time.time())
    syncGoodsList = []
    for ipyData in ipyDataList:
        limitLV = ipyData.GetLimitLV()
        if befLV < limitLV and aftLV >= limitLV:
            goodsID = ipyData.GetID()
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopItemStartTime % goodsID, curTime)
            syncGoodsList.append(goodsID)
            GameWorld.DebugLog('ÉñÃØÏÞ¹ºÉÌÆ·%s ¿ªÂô'%goodsID, curPlayer.GetID())
    if syncGoodsList:
        SyncMysticalLimitShopInfo(curPlayer)
    return
 
def SyncMysticalLimitShopInfo(curPlayer):
    ##ÉñÃØÏÞ¹ºÍ¨Öª
    packData = ChPyNetSendPack.tagMCMysticalShopTimeInfo()
    packData.ShopTimeList = []
    ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('Store', {'ShopType':16}, True)
    curTime = int(time.time())
    for ipyData in ipyDataList:
        goodsID = ipyData.GetID()
        startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopItemStartTime % goodsID)
        if not startTime:
            continue
        if curTime - startTime >= ipyData.GetLimitValue():
            #³¬Ê±µÄÖØÖÃ
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopItemStartTime % goodsID, 0)
        else:
            goodsTime = ChPyNetSendPack.tagMCMysticalShopTime()
            goodsTime.GoodsID = goodsID
            goodsTime.StartTime = startTime
            packData.ShopTimeList.append(goodsTime)
    if not packData.ShopTimeList:
        return
    packData.Count = len(packData.ShopTimeList)
    NetPackCommon.SendFakePack(curPlayer, packData)
    return
 
def CheckMysticalShopRefresh(curPlayer, tick):
    ##ÉñÃØÉ̵êË¢ÐÂ
    createRoleTime = curPlayer.GetCreateRoleTime()
    diffTime = GameWorld.GetCurrentTime() - GameWorld.GetDateTimeByStr(createRoleTime, ChConfig.TYPE_Time_Format)
    pastSeconds = diffTime.days*24*60*60 + diffTime.seconds
    refreshTime = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 4)
    if refreshTime and pastSeconds % refreshTime == 0:
        __DoMysticalShopRefresh(curPlayer, True, tick)
    return
 
#// A2 32 ÉñÃØÉ̵êˢР#tagCMRefreshMysticalShop
#struct    tagCMRefreshMysticalShop
#{
#    tagHead        Head;
#};
def OnMysticalShopRefresh(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    __DoMysticalShopRefresh(curPlayer, False, tick)
    return
 
def __DoMysticalShopRefresh(curPlayer, isFree, tick):
    global g_mysticalShopDict #{µÈ¼¶·¶Î§:[µÈ¼¶¶Î,{½ðÇ®ÀàÐÍ:¿â}]}
    refreshTime = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 4)
    if not refreshTime:
        return
 
    lastTime = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MysticalShopLastTime)
    if lastTime and tick - lastTime < 1000:
        #GameWorld.DebugLog('ÉñÃØÉ̵êˢУ¬¹ýÓÚÆµ·±£¡')
        return
    curPlayer.SetDict(ChConfig.Def_PlayerKey_MysticalShopLastTime, tick)
    if not g_mysticalShopDict:
        ipyMgr= IpyGameDataPY.IPY_Data()
        for i in xrange(ipyMgr.GetMysteryShopCount()):
            ipyData = ipyMgr.GetMysteryShopByIndex(i)
            lvRange = ipyData.GetLVRange()
            goodsID = ipyData.GetGoodsID()
            goodsIpyData = IpyGameDataPY.GetIpyGameData('Store', goodsID)
            if not goodsIpyData:
                continue
            moneyType = goodsIpyData.GetMoneyType()
            weight = goodsIpyData.GetLimitValue()
            lvkey = tuple(lvRange)
            if lvkey not in g_mysticalShopDict:
                g_mysticalShopDict[lvkey] = [lvkey[0], {}]
                weightDict = {}
            if moneyType not in g_mysticalShopDict[lvkey][1]:
                g_mysticalShopDict[lvkey][1][moneyType] = []
            weightDict[moneyType] = weightDict.get(moneyType, 0) + weight
            g_mysticalShopDict[lvkey][1][moneyType].append([weightDict[moneyType], goodsID])
    if not g_mysticalShopDict:
        return 
    playerLV = curPlayer.GetLV()
    curLVDan, shopDict = GameWorld.GetDictValueByRangeKey(g_mysticalShopDict, playerLV)
    if not shopDict:
        return
    maxCnt = IpyGameDataPY.GetFuncCfg('MysteryShopGoods', 1)
    goldGoodsCnt =GameWorld.GetResultByRandomList(IpyGameDataPY.GetFuncEvalCfg('MysteryShopGoods', 2))
    if not goldGoodsCnt:
        return
    specialGoodsID = 0 #±Ø³öµÄÉÌÆ·ID
    if not isFree:
        #ÓÅÏȵÀ¾ß£¬ÔÙÏÉÓñ
        itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
        costItemID = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 1)
        costItemCntDict = IpyGameDataPY.GetFuncEvalCfg('MysteryShopRefresh', 2)
        curRefreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopRefreshCnt)
        cntList = [int(cnt) for cnt in costItemCntDict.keys()]
        cntList.sort()
        costItemCnt = costItemCntDict[str(cntList[-1])]
        for cnt in cntList:
            if curRefreshCnt < cnt:
                costItemCnt = costItemCntDict[str(cnt)]
                break
        enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(costItemID, itemPack, costItemCnt)
        costGold = 0
        if not enough:
            costGold = lackCnt * IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 3)
            if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, ChConfig.Def_Cost_MysteryShopRefresh):
                return
        ItemCommon.ReduceItem(curPlayer, itemPack, indexList, costItemCnt, False, "MysteryShopRefresh")
        curLVRefreshData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopLVRefreshCnt)
        curLVRefreshCnt, lvDan = curLVRefreshData / 10000, curLVRefreshData % 10000 
        updLVRefreshCnt = 1 if curLVDan != lvDan else curLVRefreshCnt + 1 #µÈ¼¶¶Î±ä¸ü£¬ÖØÖøõȼ¶¶ÎµÄˢдÎÊý
        updLVRefreshData = min(updLVRefreshCnt * 10000+curLVDan, ChConfig.Def_UpperLimit_DWord)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopLVRefreshCnt, updLVRefreshData)
        specialRefreshCfg = IpyGameDataPY.GetFuncEvalCfg('MysteryShopRefresh', 5)
        if curLVDan in specialRefreshCfg and updLVRefreshCnt == specialRefreshCfg[curLVDan][0]:
            specialGoodsID = specialRefreshCfg[curLVDan][1]
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopRefreshCnt, curRefreshCnt+1)
        
    goldGoodsCnt = min(goldGoodsCnt, maxCnt)
    sliverGoodsCnt = maxCnt - goldGoodsCnt
    goodsResultList = []
    if goldGoodsCnt:
        goodsResultList += GameWorld.GetResultByRandomListEx(shopDict.get(IPY_GameWorld.TYPE_Price_Gold_Money, []), goldGoodsCnt, [])
    if sliverGoodsCnt:
        goodsResultList += GameWorld.GetResultByRandomListEx(shopDict.get(IPY_GameWorld.TYPE_Price_Silver_Money, []), sliverGoodsCnt, [])
    if specialGoodsID and specialGoodsID not in goodsResultList:
        goodsResultList[0] = specialGoodsID
        GameWorld.DebugLog('ÉñÃØÉ̵êË¢ÐÂÌØÊâ¹æÔò£¬µÈ¼¶¶Î£º%s,updLVRefreshCnt=%s,specialGoodsID=%s'%(curLVDan, updLVRefreshCnt, specialGoodsID))
    
    GameWorld.DebugLog('ÉñÃØÉ̵êË¢ÐÂisFree=%s,goldGoodsCnt=%s,sliverGoodsCnt=%s,goodsResultList=%s'%(isFree, goldGoodsCnt, sliverGoodsCnt, goodsResultList))
    syncIndexList = []
    for i in xrange(maxCnt):
        goodsID = goodsResultList[i] if i < len(goodsResultList) else 0
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopGoods % i, goodsID)
        
        dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % goodsID
        curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
        if curDayBuyCnt:
            PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, 0)
            syncIndexList.append(goodsID)
    if syncIndexList:
        SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True)
    #֪ͨ
    SyncMysticalShopInfo(curPlayer)
    return
 
def SyncMysticalShopInfo(curPlayer):
    ##ÉñÃØÉ̵ê֪ͨ
    packData = ChPyNetSendPack.tagMCMysticalShopInfo()
    packData.RefreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopRefreshCnt)
    packData.GoodsList = []
    maxCnt = IpyGameDataPY.GetFuncCfg('MysteryShopGoods', 1)
    for i in xrange(maxCnt):
        goodsID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopGoods % i)
        goodsInfo = ChPyNetSendPack.tagMCMysticalShopGoods()
        goodsInfo.GoodsID = goodsID
        packData.GoodsList.append(goodsInfo)
    packData.Count = len(packData.GoodsList)
    NetPackCommon.SendFakePack(curPlayer, packData)
    return
 
## »Ø¹ºÎïÆ·
#  @param None
#  @return None
def BuyItemBack(curPlayer, clientPack, tick):
    index = clientPack.Index
 
    backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptRecycle)
    if index >= backPack.GetCount():
        #¼Ù°üÍ˳ö
        return
    
    curItem = backPack.GetAt(index)
    if not curItem or curItem.IsEmpty():
        #ûÓÐÎïÆ·Í˳ö
        return
    
    realPutCount = curItem.GetCount()
    itemControl = ItemControler.PlayerItemControler(curPlayer)
    if not itemControl.CanPutInItem(IPY_GameWorld.rptItem, 
                                    curItem.GetItemTypeID(), 
                                    realPutCount, 
                                    curItem.GetIsBind()):
        #ÎïÆ·²»ÄÜ·ÅÈëÍ˳ö
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])
        return 
    
    itemPrice, priceType = __GetItemSellPrice(curPlayer, curItem)
    itemPrice = int(itemPrice) * realPutCount
    if not priceType or not itemPrice:
        return
         
    #¸¶Ç®
    infoDict = {ChConfig.Def_Cost_Reason_SonKey:curItem.GetItemTypeID()}
    if not PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyItemBack, infoDict):
        return
    
    itemControl.PutInItem(IPY_GameWorld.rptItem, curItem, event=["BuyItemBack", False, {}])
    
    itemIndexs = str(curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_DelPackIndex))
    itemIndexs = itemIndexs.replace(str(index + 1), '')
    if itemIndexs == '':
        #ûÓÐÎïÆ·±£Áô 0
        itemIndexs = '0'
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_DelPackIndex, int(itemIndexs))
    return
 
def PayAutoBuyItem(curPlayer, lackItemDict, priceType, costType=ChConfig.Def_Cost_Unknown, infoDict={}, isCheck=False, shopItemIndexDict=None):
    ''' Ö§¸¶×Ô¶¯¹ºÂòÎïÆ·ÏûºÄ£¬´ÓÉ̳ÇÖйºÂò£¬Ö±½Ó¿ÛÇ®£¬²»²úÉúÎïÆ·
            Ò»°ãÓÃÓÚ»ù´¡É̵ê×Ô¶¯¹ºÂòÎïÆ·£¬²»¿¼ÂǸ´ÔÓµÄÏÞ¹ºÂß¼­
    @param isCheck: ÊÇ·ñÖ»ÊǼì²é£¬²»Ö´ÐÐʵ¼ÊÏûºÄÂß¼­
    @param shopItemIndexDict: Ö¸¶¨¹ºÂòµÄÉÌÆ·¶ÔÓ¦É̳DZíÉÌÆ·IDË÷Òý×ֵ䣬Èç¹ûûÓÐÖ¸¶¨ÉÌÆ·Ë÷Òý£¬Ôò°´ÏûºÄµÄ¼Û¸ñÀàÐÍ×Ô¶¯ËÑË÷É̳DZí
    '''
    
    addLimitCountInfo = {}
    totalMoney = 0
    # ¼ÆËã×Ô¶¯¹ºÂòÏûºÄ
    for itemID, lackCnt in lackItemDict.items():
        if lackCnt <= 0:
            continue
        
        curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
        if not curItem:
            return
        
        if shopItemIndexDict and itemID in shopItemIndexDict:
            itemIndex = shopItemIndexDict[itemID]
            ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex)
        else:
            ipyData = ItemCommon.GetShopItemPriceIpyData(itemID, priceType)
        if not ipyData:
            return
        
        itemIndex = ipyData.GetID()
        shopType = ipyData.GetShopType()
        priceType = ipyData.GetMoneyType()
        itemMoney = ipyData.GetMoneyNum()
        limitCntList = ipyData.GetLimitCnt()
        if limitCntList:
            limitBuyCnt = limitCntList[0]
            curDayBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex)
            canBuyCnt = max(0, limitBuyCnt - curDayBuyCnt)
            if canBuyCnt < lackCnt:
                GameWorld.Log("×Ô¶¯¹ºÂò´ÎÊý²»×㣡shopType=%s,itemIndex=%s,itemID=%s,limitBuyCnt=%s,curDayBuyCnt=%s,canBuyCnt=%s < %s" 
                              % (shopType, itemIndex, itemID, limitBuyCnt, curDayBuyCnt, canBuyCnt, lackCnt), curPlayer.GetPlayerID())
                return
            addLimitCountInfo[itemIndex] = lackCnt
            
        totalMoney += (lackCnt * itemMoney)
        
    if totalMoney <= 0:
        return
    
    if isCheck:
        return PlayerControl.HaveMoney(curPlayer, priceType, totalMoney)
    
    GameWorld.DebugLog("¿Û³ý×Ô¶¯¹ºÂòÏûºÄ: lackItemDict=%s,priceType=%s,totalMoney=%s,costType=%s,addLimitCountInfo=%s" 
                       % (lackItemDict, priceType, totalMoney, costType, addLimitCountInfo), curPlayer.GetPlayerID())
    
    if not PlayerControl.PayMoney(curPlayer, priceType, totalMoney, costType, infoDict):
        return
    
    if addLimitCountInfo:
        syncIndexList = []
        for itemIndex, lackCnt in addLimitCountInfo.items():
            curDayBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex, curDayBuyCnt + lackCnt)
            syncIndexList.append(itemIndex)
        SyncShopItemTodayBuyCount(curPlayer, syncIndexList)
        
    return True
 
##¹ºÂòÎïÆ·
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦
def BuyItem(curPlayer, tick):
    
    if GameWorld.IsCrossServer():
        return
    
    buyItemList = IPY_GameWorld.IPY_CBuyItemList()    
    itemIndex = buyItemList.GetBuyItemIndex()
    if itemIndex < 0:
        return
    
    clientBuyCount = buyItemList.GetBuyCount()
    if not clientBuyCount:
        return
    
    ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex)
    if not ipyData:
        return
    shopType = ipyData.GetShopType()
    operationActionShopType = ipyData.GetOperationActionShop()
    if operationActionShopType == 1:
        if not PlayerSpringSale.IsSpringSaleShopType(shopType):
            return
    elif operationActionShopType == 2:
        if not PlayerFlashSale.IsFlashSaleShopType(shopType):
            return
        
    # ÎïÆ·ÐÅÏ¢
    limitLV = ipyData.GetLimitLV()
    if limitLV and curPlayer.GetLV() < limitLV:
        return
    LimitVIPLVList = ipyData.GetLimitVIPLV()
    LimitCntList = ipyData.GetLimitCnt()
    limitBuyCnt = 0
    if LimitVIPLVList or LimitCntList:
        if not LimitVIPLVList:
            LimitVIPLVList = [0]
        if not LimitCntList:
            LimitCntList = [0]
 
        if len(LimitVIPLVList) != len(LimitCntList):
            GameWorld.Log("    ¹ºÂòÎïÆ·LimitVIPLV  LimitCnt ³¤¶È²»Í¬")
            return
        curVIPlv = curPlayer.GetVIPLv()
        limitBuyCnt = -1
        for i, viplv in enumerate(LimitVIPLVList):
            if curVIPlv < viplv:
                break
            limitBuyCnt = LimitCntList[i]
        if limitBuyCnt == -1:
            GameWorld.DebugLog("    vip%s²ÅÄܹºÂò"%viplv)
            return
    
    curDayBuyCnt = 0
    dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex
    if limitBuyCnt > 0:
        curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
        canBuyCnt = max(0, limitBuyCnt - curDayBuyCnt)
        if canBuyCnt <= 0:
            GameWorld.DebugLog("BuyShopItem ½ñÈÕ¹ºÂò´ÎÊýÒÑÂú£¡shopType=%s,itemIndex=%s" % (shopType, itemIndex))
            return
        if clientBuyCount > canBuyCnt:
            GameWorld.DebugLog("BuyShopItem ÐÞÕý¹ºÂò´ÎÊý£¡shopType=%s,itemIndex=%s,clientBuyCount=%s,canBuyCnt=%s" 
                               % (shopType, itemIndex, clientBuyCount, canBuyCnt))
            clientBuyCount = canBuyCnt
    serverLimitCnt = ipyData.GetServerLimitCnt()
    if serverLimitCnt > 0:
        clientBuyCount = min(serverLimitCnt, clientBuyCount)
        
    itemID, itemCount, isBind = ipyData.GetItemID(), ipyData.GetItemCnt(), ipyData.GetIsBind()
    itemListEx = ipyData.GetItemListEx()
    priceType, itemPrice = ipyData.GetMoneyType(), ipyData.GetMoneyNum()
    
    itemPrice *= clientBuyCount
    job = curPlayer.GetJob()
    jobItemList = ipyData.GetJobItem()
    totalItemList = []
    if itemID:
        jobItemID = GetShopJobItem(job, itemID, jobItemList)
        totalItemList.append([jobItemID, itemCount * clientBuyCount, isBind])
    for itemIDEx, itemCountEx, isBindEx in itemListEx:
        jobItemID = GetShopJobItem(job, itemIDEx, jobItemList)
        totalItemList.append([jobItemID, itemCountEx * clientBuyCount, isBindEx])
    #ÔÊÐí¼ÛÇ®ÅäÖÃ0£¬ÓÃÀ´Ãâ·Ñ¹ºÂò
    if not totalItemList:
        GameWorld.ErrLog("Store shop item error! shopType=%s,totalItemList=%s,itemPrice=%s" % (shopType, totalItemList, itemPrice))
        return
    
    mainItemID = 0
    needPackSpaceDict = {}
    for i, itemInfo in enumerate(totalItemList):
        itemID = itemInfo[0]
        itemCnt = itemInfo[1]
        curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
        if not curItem:
            GameWorld.ErrLog("Store shop item error! shopType=%s,itemID=%s" % (shopType, itemID))
            return
        packType = ChConfig.GetItemPackType(curItem)
        needSpace = ItemControler.GetItemNeedPackCount(packType, curItem, itemCnt)
        needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
        
        if i == 0:
            mainItemID = itemID
    
    if not mainItemID:
        return
    
    GameWorld.DebugLog("¹ºÂòÎïÆ·: shopType=%s,itemIndex=%s,clientBuyCount=%s,totalItemList=%s,mainItemID=%s,needPackSpaceDict=%s" 
                       % (shopType, itemIndex, clientBuyCount, totalItemList, mainItemID, needPackSpaceDict), curPlayer.GetPlayerID())
    mailKey = ipyData.GetMailKey()
    isLackPack = False #ÊÇ·ñ±³°ü²»×ã
    for packType, needSpace in needPackSpaceDict.items():
        if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):
            isLackPack = True
            if mailKey:
                break
            else:
                curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoPlace)
                PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
                return
    sendMailKey = mailKey if isLackPack and mailKey else '' #±³°ü²»×ãÇÒÅäÖÃÁËmailKeyµÄ²Å·¢Óʼþ
        
    # ¹ºÂòÏÞÖÆÌõ¼þÀ©Õ¹
    if CheckBuyItemLimitEx(curPlayer, shopType, itemIndex, mainItemID, ipyData.GetLimitValue(), clientBuyCount):
        GameWorld.Log("Store shop item buy limit! shopType=%s,itemIndex=%s,limitValue=%s" 
                      % (shopType, itemIndex, ipyData.GetLimitValue()), curPlayer.GetPlayerID())
        return
    if not PlayerControl.HaveMoney(curPlayer, priceType, itemPrice):
        curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoMoney)
        return
    
    if serverLimitCnt > 0: #È«·þÏÞ¹ºÅжϷŵ½×îºóÃæ£¬GameServerÖ±½Ó¼Ó´ÎÊý
        if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_StoreQueryState) == 1:
            #ÒѾ­ÔÚ²éѯÖÐ, ²»Öظ´²éѯ
            GameWorld.DebugLog("È«·þ¹ºÂò´ÎÊýÒѾ­ÔÚ²éѯÖÐ, ²»Öظ´²éѯ itemIndex=%s" % itemIndex)
            return
        cmdStr = '%s' % ([itemIndex, serverLimitCnt, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey])
        GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0,
                                        "GetStoreServerBuyCnt", cmdStr, len(cmdStr))
        #ÉèÖÃ״̬²éѯÖÐ
        curPlayer.SetDict(ChConfig.Def_PlayerKey_StoreQueryState, 1)
        return
    #-------------------------¿ªÊ¼¹ºÂòÎïÆ·-----------------------------
    DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey, ipyData)
    
    return
 
def DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey, ipyData=None):
    if not ipyData:
        ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex)
    priceType, itemPrice = ipyData.GetMoneyType(), ipyData.GetMoneyNum()
    itemPrice *= clientBuyCount
    shopType = ipyData.GetShopType()
    
    beforeMoney = PlayerControl.GetMoney(curPlayer, priceType)
    infoDict = {"TotalItemList":totalItemList, "ClientBuyCount":clientBuyCount, "ShopType":shopType,
                "ShopItemIndex":itemIndex, ChConfig.Def_Cost_Reason_SonKey:mainItemID}
    if not PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyStoreItem, infoDict, clientBuyCount):
        GameWorld.ErrLog("¹ºÂòÉ̳ÇÎïÆ·Êµ¼Ê¿Û³ý»õ±Òʱʧ°Ü: itemIndex=%s,clientBuyCount=%s,priceType=%s,itemPrice=%s" 
                         % (itemIndex, clientBuyCount, priceType, itemPrice))
        return
        
    afterMoney = PlayerControl.GetMoney(curPlayer, priceType)
    
    # ½ñÈÕ¹ºÂò´ÎÊý+1
    if limitBuyCnt > 0:
        dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex
        curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
        PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, curDayBuyCnt + clientBuyCount)
        SyncShopItemTodayBuyCount(curPlayer, [itemIndex])
        
    dataDict = {"ShopType":shopType, "ShopItemIndex":itemIndex, "ClientBuyCount":clientBuyCount, 
                "ItemPrice":itemPrice, "MoneyType":priceType, 
                "BeforeMoney":beforeMoney, "AfterMoney":afterMoney}
    isForceEvent = priceType not in [IPY_GameWorld.TYPE_Price_Silver_Money]
 
    itemControl = ItemControler.PlayerItemControler(curPlayer)
    for itemID, itemCount, isBind in totalItemList:
        curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, False, curPlayer=curPlayer)
        if not curItemObj:
            continue
        userData = curItemObj.GetUserData()
        if not sendMailKey:
            packType = ChConfig.GetItemPackType(curItemObj)
            if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
                curItemObj.Clear()
                continue
        else:
            curItemObj.Clear()
        EventShell.EventRespons_BuyItem(curPlayer, itemID, itemCount)
        
        if ipyData.GetNotifyMark() and itemID == mainItemID:
            PlayerControl.WorldNotify(0, ipyData.GetNotifyMark(), [curPlayer.GetName(), mainItemID, userData])
            
        # ¹ºÂòÓÀ¾ÃÊØ»¤Ê±É¾³ýÏÞÊ±ÊØ»¤
        if itemID == 4101:
            delGuardItem = ItemCommon.FindItemInPackByItemID(curPlayer, 4105, IPY_GameWorld.rptItem)
            if delGuardItem:
                ItemCommon.DelItem(curPlayer, delGuardItem, 1)
                
    if sendMailKey:
        PlayerControl.SendMailByKey(sendMailKey, [curPlayer.GetID()], totalItemList, detail=dataDict)
    else:
        ItemControler.NotifyGiveAwardInfo(curPlayer, totalItemList, ChConfig.ItemGive_BuyItem, dataEx=shopType)
    #´¥·¢ÈÎÎñ¹ºÂòÎïÆ·
    EventShell.EventRespons_ShopBuy(curPlayer, shopType)
    #curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrShopOK)
    SyncShoppingResult(curPlayer, itemIndex, clientBuyCount)
    
    if shopType == ShopType_FairyCeremony:
        PlayerFairyCeremony.OnBuyFireworks(curPlayer, itemIndex, clientBuyCount)
#    if itemIndex in IpyGameDataPY.GetFuncEvalCfg('NewCeremonyFireParty', 1, {}).values():
#        PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_Fireworks, clientBuyCount)
    return
 
def GetShopJobItem(job, itemID, jobItemList):
    ## »ñÈ¡É̳ÇÎïÆ·¶ÔÓ¦µÄÖ°ÒµÎïÆ·£¬ Ö°Òµ´Ó1¿ªÊ¼
    for jobItemIDList in jobItemList:
        if type(jobItemIDList) not in [list, tuple]:
            GameWorld.ErrLog("É̳ÇÖ°ÒµÎïÆ·×é¸ñʽ´íÎó!shopItemID=%s,jobItemList=%s" % (itemID, jobItemList))
            return itemID
        if itemID in jobItemIDList:
            if job <= 0 or job > len(jobItemIDList):
                GameWorld.ErrLog("É̳ÇÖ°ÒµÎïÆ·ÅäÖôíÎó,ûÓиÃÖ°Òµ¶ÔÓ¦ÎïÆ·ID!shopItemID=%s,job=%s" % (itemID, job))
                return itemID
            return jobItemIDList[job - 1]
    return itemID
 
def SyncShoppingResult(curPlayer, itemIndex, itemCnt):
    #֪ͨ¹ºÂò½á¹û
    resultInfo = ChPyNetSendPack.tagMCShoppingResult()
    resultInfo.ItemIndex = itemIndex
    resultInfo.ItemCnt = itemCnt
    NetPackCommon.SendFakePack(curPlayer, resultInfo)
    return
 
## É̵깺ÂòÎïÆ·ÏÞÖÆÌõ¼þÀ©Õ¹
#  @param curPlayer Íæ¼ÒʵÀý
#  @return 
def CheckBuyItemLimitEx(curPlayer, shopNPCID, itemIndex, curItemID, limitValue, clientBuyCount):
    if shopNPCID == 7: #·ûÓ¡É̵ê
        return not PlayerRune.GetIsOpenByRuneID(curPlayer, curItemID)
    if shopNPCID in [8, 9, 10]: #ÏÉÃËÉ̵ê
        if curPlayer.GetFamilyID() == 0:
            #ÎÞ¼Ò×å
            return True
        curFamilyLV = curPlayer.GetFamilyLV()
        if curFamilyLV <= 0:
            curFamilyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyLV)
        return curFamilyLV < limitValue
    if shopNPCID in [15]: # ¿ª·þÌØ»ÝÉ̵ê
        #playerCreateRoleDays = GameWorld.GetCreateRoleDays(curPlayer)
        openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1
        return openServerDay != limitValue
    
    #ÏɽçÊ¢µä - ÑÌ»¨¿ñ»¶
    if shopNPCID == ShopType_FairyCeremony:
        return not PlayerFairyCeremony.IsCanBuyFireworks(curPlayer, itemIndex, clientBuyCount)
    
    #ÁíÒ»¸öÏɽçÊ¢µä¿ÉÓÃÆäËûÉ̵êNPCID£¬ÕâÀïÏÈ×¢ÊÍ£¬Ö®ºóÔÙ¸Ä
#    if itemIndex in IpyGameDataPY.GetFuncEvalCfg('NewCeremonyFireParty', 1, {}).values():
#        return not PlayerNewFairyCeremony.IsCanBuyFireworks(curPlayer, itemIndex)
    
    if shopNPCID == 16:#ÉñÃØÏÞ¹º
        startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopItemStartTime % itemIndex)
        curTime = int(time.time())
        return not startTime or curTime - startTime >= limitValue
        
#    
#    limitPlusDict = {shopItem.GetLimitPlusType1():shopItem.GetLimitPlusValue1(),
#                     shopItem.GetLimitPlusType2():shopItem.GetLimitPlusValue2(),
#                     shopItem.GetLimitPlusType3():shopItem.GetLimitPlusValue3(),
#                     }
#    
#    for limitType, limitValue in limitPlusDict.items():
#        if limitType <= 0:
#            continue
#        
#        # ÓÅÏÈÅжÏNPC¶ÀÓеÄ
#        callFunc = GameWorld.GetExecFunc(EventSrc, "FunctionNPCShopBuyCheck.CheckByNPC_%s_%s" 
#                                         % (shopNPCID, limitType))
#        
#        if callFunc:
#            return callFunc(curPlayer, shopItem.GetItemID(), limitValue)
#        
#        # ¹«¹²ÏÞÖÆÌõ¼þÅжÏ
#        callFunc = GameWorld.GetExecFunc(EventSrc, "FunctionNPCShopBuyCheck.CheckPublic_%s" % limitType)
#        
#        if callFunc:
#            return callFunc(curPlayer, shopItem.GetItemID(), limitValue)
    
    # Ä¬Èϲ»ÏÞÖÆ
    return False
 
def OSSaleOpenMail(curPlayer):
    #¿ª·þÌØ»Ý¿ªÆôÓʼþ
    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_OSSail):
        return
    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1
    if openServerDay not in IpyGameDataPY.GetFuncEvalCfg('OSSaleOpenMail'):
        return
    addItemList = IpyGameDataPY.GetFuncEvalCfg('OSSaleOpenMail', 2)
    PlayerControl.SendMailByKey('SellMail1', [curPlayer.GetID()], addItemList)
    return
 
 
## É̵ênpcid
#  @param curPlayer Íæ¼ÒʵÀý
#  @return 
def GetCurTradeTagNPC(curPlayer):
    curActionNPCID = -1
 
    # µ±Ç°É̵êµÄnpcid
    tradeTagNPC = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TradeTagNPC)
    # Ô¶³ÌÉ̵ê
    if not tradeTagNPC:
        return GetDirectNpcID()
 
    # É̵ênpcidÓ뵱ǰ¶Ô»°npc¶ÔÓ¦
    elif CheckTradeTagNPC(curPlayer, tradeTagNPC):
        return tradeTagNPC
    
    else:
        GameWorld.ErrLog("GetCurStoreItemList:trade tag NPC not match:%s"%tradeTagNPC,
                          curPlayer.GetPlayerID())
           
    return curActionNPCID
 
## ÅжϼǼµÄÉ̵ênpcidÊÇ·ñÕýÈ·
#  @param curPlayer Íæ¼ÒʵÀý
#  @param tradeTagNPC 
#  @return 
def CheckTradeTagNPC(curPlayer, tradeTagNPC):
    
    curActionObj = curPlayer.GetActionObj()
    if not curActionObj:
        return False
    
    if curActionObj.GetGameObjType() != IPY_GameWorld.gotNPC:
        return False
    
    curActionNPC = GameWorld.GetNPCManager().GetNPCByIndex(curActionObj.GetIndex())
    if curActionNPC.GetNPCID() != tradeTagNPC:
        return False
 
    return True
 
#--------------------³öÊÛÎïÆ·
##³öÊÛÎïÆ·
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÕæ, Âß¼­ÔËÐгɹ¦
# @remarks ³öÊÛÎïÆ·
def SellItem(curPlayer, tick):
    #1¼ì²éʼþ·¢ÉúµÄ˳Ðò
    sendData = IPY_GameWorld.IPY_CPlayerSellItem()
    packType = sendData.GetPackType()
    itemIndex = sendData.GetItemIndex()
    shopType = ChConfig.Def_ShopType_NpcShop
    
    return SellPackItem(curPlayer, packType, [itemIndex], shopType)
 
#// A3 11 ÅúÁ¿³öÊÛÎïÆ· #tagCMSellItem
#
#struct    tagCMSellItem
#{
#    tagHead        Head;
#    BYTE        PackType;        //±³°üÀàÐÍ
#    BYTE        Count;            //Ë÷ÒýÊýÁ¿
#    BYTE        ItemIndex[Count];        //ÎïÆ·Ë÷Òý
#};
def OnSellManyItem(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    packType = clientData.PackType
    ItemIndexList = clientData.ItemIndex
    if not ItemIndexList:
        return
    shopType = ChConfig.Def_ShopType_NpcShop
    isOk = SellPackItem(curPlayer, packType, ItemIndexList, shopType)
    if isOk:
        curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitKeySell, 1)
        
    return 
#---------------------------------------------------------------------
##³öÊÛÖ¸¶¨±³°üÎïÆ·
# @param curPlayer Íæ¼ÒʵÀý
# @param packType ±³°üÀàÐÍ
# @param itemIndex ÎïÆ·Ë÷Òý
# @param shopType É̵êÀàÐÍ,1NPCÉ̵꣬2Ô¶³Ì··ÊÛ
# @return ·µ»ØÖµÕæ, ¼ì²éͨ¹ý
# @remarks ³öÊÛÖ¸¶¨±³°üÎïÆ·
def SellPackItem(curPlayer, packType, itemIndexList, shopType):
    backPack = curPlayer.GetItemManager().GetPack(packType)
    if backPack == None:
        return False
    
    totalSellPriceDict = {}
    hasSellOK = False
    notForceRecordEquipTypeList = range(ChConfig.Def_ItemType_retWeapon, ChConfig.Def_ItemType_retNeck)
    for itemIndex in itemIndexList:
        curItem = backPack.GetAt(itemIndex)
        
        if not __CheckItemSell(curPlayer, curItem):
            continue
        hasSellOK = True
        #µ±Ç°ÎïÆ·ÊýÁ¿
        curItemCount = curItem.GetCount()
        #itemName = curItem.GetName()
        #»ñµÃµ¥¸öÎïÆ·ÏúÊÛ¼Û¸ñ
        curItemSellPrice, curItemSellType = __GetItemSellPrice(curPlayer, curItem)
        #»ñµÃÕû×éÏúÊÛ¼Û¸ñ
        curAllItemSellPrice = int(curItemSellPrice) * curItemCount
        totalSellPriceDict[curItemSellType] = totalSellPriceDict.get(curItemSellType, 0) + curAllItemSellPrice
        #GameWorld.Log('curItemSellPrice=%s,curAllItemSellPrice=%s,curItemCount=%s'%(curItemSellPrice,curAllItemSellPrice,curItemCount))
        
        #===========================================================================================
        # #ÒòÈռǼǼ¹ý´ó, Ìí¼Ó¼Ç¼ɸѡÌõ¼þ
        # if ItemControler.ItemNeedRecord(curItem):
        #    #Ïêϸ¼Ç¼װ±¸ÐÅÏ¢
        #    DataRecordPack.DR_GetMoneyBySellPackItem(curPlayer, curItemSellType, curAllItemSellPrice)
        #===========================================================================================
        
        isForceDR = curItem.GetType() not in notForceRecordEquipTypeList and not ItemControler.ItemNotNeedRecord(curItem)
        #ÎïÆ·Ïûʧ
        ItemCommon.DelItem(curPlayer, curItem, curItemCount, False, ChConfig.ItemDel_SellPackItem, isForceDR=isForceDR)
        #PutItemInBuyBackPack(curPlayer, curItem)
    if not hasSellOK:
        return False
    for priceType, priceMoney in totalSellPriceDict.items():
        #Íæ¼ÒÇ®Ôö¼Ó
        addDataDict = {}
        PlayerControl.GiveMoney(curPlayer, priceType, priceMoney, ChConfig.Def_GiveMoney_SellPackItem, addDataDict, False)
        PlayerControl.NotifyCode(curPlayer, "GetMoney01", [priceType, priceMoney])
    return True
 
 
## ÊÛÂôÎïÆ·»Ø¹º±³°üµÄ´¦Àí, ·ÅÈë¿Õλ²»µþ¼Ó(±¾ÏîĿûÓлعº£¬ÏÈÆÁ±Î)
#  @param None
#  @return None
def PutItemInBuyBackPack(curPlayer, curItem):
    return
    itemIndexs = str(curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_DelPackIndex))
    backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptRecycle)
    emptyIndex = ItemCommon.GetEmptyIndexInPack(curPlayer, IPY_GameWorld.rptRecycle)
    if emptyIndex == -1:
        #Çå³ý¾ÉÎïÆ·
        emptyIndex = int(itemIndexs[0]) - 1
        item = backPack.GetAt(emptyIndex)
        item.Clear()
        itemIndexs = itemIndexs[1:]
    else:
        # Çå¿Õ¿Õ¸ñλ·À·¶, ·ÀÖ¹Òì³£Çé¿öÎïÆ·Ïûʧ¶øÃ»ÓÐÖØÖñê¼Çλµ¼ÖÂÊýÖµÔ½½ç
        itemIndexs = itemIndexs.replace(str(emptyIndex + 1), '')
        item = backPack.GetAt(emptyIndex)
        
    itemIndexs = "%s%s"%(itemIndexs, emptyIndex + 1)
    
    #·ÅÈëÐÂÎïÆ·
    item.PutIn(curItem)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_DelPackIndex, int(itemIndexs))
    return
 
 
##¼ì²éÎïÆ·ÊÇ·ñ¿ÉÒÔ³öÊÛ
# @param curPlayer Íæ¼ÒʵÀý
# @param curItem ÎïÆ·ÊµÀý
# @return ·µ»ØÖµÕæ, ¼ì²éͨ¹ý
# @remarks ¼ì²éÎïÆ·ÊÇ·ñ¿ÉÒÔ³öÊÛ
def __CheckItemSell(curPlayer, curItem) :
    if not ItemCommon.CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_644055")
        return
    
    #if ItemControler.IsEventItem(curItem):
    #    PlayerControl.NotifyCode(curPlayer, "itemuse_chenxin_31379")
    #    return
    
    if curItem.GetCanSell() == 0:
        #²»ÄܳöÊÛµÄÎïÆ·,ÎÞ·¨³öÊÛ
        PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_272921")
        return
    
    #»ñµÃµ¥¸öÎïÆ·ÏúÊÛ¼Û¸ñ
    itemPrice , priceType = __GetItemSellPrice(curPlayer, curItem)
    itemPrice = int(itemPrice) * curItem.GetCount()
    
    if not itemPrice or not priceType:
        PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_272921")
        return
    
    if not PlayerControl.CanGiveMoney(curPlayer, priceType, itemPrice):
        # ¶Ô²»Æð£¬ÄúЯ´øµÄ½ðÇ®ÒѾ­´ïÉÏÏÞ,²Ù×÷ÎÞЧ
        #PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_609765")
        return
        
    return True
 
#---------------------------------------------------------------------
##»ñµÃÎïÆ·µÄ³öÊÛ¼Û¸ñ
# @param curPlayer Íæ¼ÒʵÀý
# @param curItem ÎïÆ·ÊµÀý
# @return ·µ»ØÖµ, ÎïÆ·µÄ³öÊÛ¼Û¸ñ
# @remarks »ñµÃÎïÆ·µÄ³öÊÛ¼Û¸ñ
def __GetItemSellPrice(curPlayer, curItem):
    #ΪÅäºÏ¿Í»§¶Ë,½øÐÐÒÔÏÂÂß¼­(ÏòÉÏÈ¡Õû)
    #2012-03-26 jiang Ä;ÃÕâÀï²»½øÐгýChConfig.Def_EndureRepairParameterµÄת»»¸ÃÓй«Ê½×Ô¼º¼ÆËã
    #curItemEndure = curItem.GetCurDurg()
    #curItemMaxEndure = curItem.GetMaxEndure()
    
    # Ð޸Ĵ˺¯ÊýÇëͬʱÐ޸ĠÍÑ»ú¹Ò³öÊÛ
    #µ±Ç°ÎïÆ·¼Û¸ñ Ô­¼Û³öÊÛ
    priceType = curItem.GetGoldPaperPrice()
    if not priceType:
        priceType = IPY_GameWorld.TYPE_Price_Silver_Money
    curItemPrice = curItem.GetSilverPrice()
    return curItemPrice, priceType
 
##¼ì²éÍæ¼Ò¿É·ñ¿ªÊ¼NPCʼþ
# @param curPlayer Íæ¼ÒʵÀý
# @return ·µ»ØÖµÕæ, ¼ì²éͨ¹ý
# @remarks ¼ì²éÍæ¼Ò¿É·ñ¿ªÊ¼NPCʼþ
def CheckPlayerCanStateEvent(curPlayer):
    if curPlayer.GetPlayerAction() not in ChConfig.Def_Player_DoEvent_State :
        #CannotDoing ¶Ô²»Æð£¬Äúµ±Ç°×´Ì¬ÎÞ·¨½øÐд˲Ù×÷£¬²Ù×÷ÎÞЧ
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_740826")
        return False
    
    return True
 
#---------------------------------------------------------------------
##¼ì²éÎïÆ·ÊÇ·ñ¿ÉÒÔ·ÅÈëºÏ³É±³°ü.
# @param curItem ÎïÆ·ÊµÀý
# @return ²¼¶ûÖµ
# @remarks ¼ì²éÎïÆ·ÊÇ·ñ¿ÉÒÔ·ÅÈëºÏ³É±³°ü
def __CheckItemCanPutInComposePack(curItem):
    return curItem.GetType() in ChConfig.Def_Compose_Can_Put_List
 
#---------------------------------------------------------------------
##ͨÓñ³°ü·ÅÈë²Ù×÷
# @param curPlayer Íæ¼ÒʵÀý
# @param srcBackpack Æðµã±³°ü
# @param desBackPack Ä¿±ê±³°ü
# @param srcIndex ÆðµãË÷Òý
# @param destIndex Ä¿±êË÷Òý
# @param putItemCount ·ÅÈëÊýÁ¿
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks Í¨Óñ³°ü·ÅÈë²Ù×÷
def BackpackOperate(curPlayer, srcBackpack, desBackPack, srcIndex, destIndex, putItemCount, tick):
    #»ñµÃÐèÒª²Ù×÷µÄÎïÆ·µÄÎïÆ·
    scrItem = __GetBackPackOperateItem(curPlayer, srcBackpack, desBackPack, srcIndex)
    
    if scrItem == None:
        return
 
    itemControl = ItemControler.PlayerItemControler(curPlayer)
    
    if not itemControl.CanPutInItem(desBackPack, scrItem.GetItemTypeID(), putItemCount, scrItem.GetIsBind()):
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [desBackPack])   
        return
    
    #ÍÏ×§ÎïÆ·
    ItemControler.DragItem(curPlayer, srcBackpack, srcIndex, desBackPack, destIndex, putItemCount)
    return
#---------------------------------------------------------------------
##ͨÓñ³°ü²Ù×÷¼ì²é
# @param scrItem ·ÅÈëÎïÆ·
# @param desBackPack Ä¿±ê±³°ü
# @return ²¼¶ûÖµ
# @remarks Í¨Óñ³°ü²Ù×÷¼ì²é
def __CheckBackPackOperate(scrItem, desBackPack):
    #ÌØÊâ¼ì²é
    if desBackPack in ChConfig.Def_ComposePack_List:
        if not __CheckItemCanPutInComposePack(scrItem):
            GameWorld.ErrLog('BackpackOperate ItemErr = %s, ItemType = %s'%(scrItem.GetItemTypeID(), scrItem.GetType()))
            return False
 
    return True
#---------------------------------------------------------------------
##»ñµÃ±³°üµ±Ç°²Ù×÷µÄÎïÆ·
# @param curPlayer Íæ¼ÒʵÀý
# @param srcBackpack Æðʼ±³°ü
# @param desBackPack Ä¿µÄ±³°ü
# @param srcIndex ÆðʼÎïÆ·Ë÷Òý
# @return ²Ù×÷ÎïÆ·ÊµÀý»òÕßNone
# @remarks »ñµÃ±³°üµ±Ç°²Ù×÷µÄÎïÆ·
def __GetBackPackOperateItem(curPlayer, srcBackpack, desBackPack, srcIndex):
    #²Ù×÷±³°ü¼ì²é
    if srcBackpack not in ChConfig.Def_BackpackOperate_List or desBackPack not in ChConfig.Def_BackpackOperate_List:
        GameWorld.ErrLog('PackItemExchange packErr, srcBackpack = %s, \
            desBackPack = %s'%(srcBackpack, desBackPack), curPlayer.GetID())
        return
    
    #»ñµÃ·ÅÈëµÄÎïÆ·
    scrItem = curPlayer.GetItemManager().GetPack(srcBackpack).GetAt(srcIndex)
    
    #---ÎïÆ·¼ì²é---
    if not ItemCommon.CheckItemCanUse(scrItem):
        return
    
    #ÌØÊâ¼ì²é
    if not __CheckBackPackOperate(scrItem, desBackPack):
        return
    
    return scrItem
#---------------------------------------------------------------------
##ͨÓñ³°ü½»»»²Ù×÷
# @param curPlayer Íæ¼ÒʵÀý
# @param srcBackpack Æðµã±³°ü
# @param destBackPack Ä¿±ê±³°ü
# @param srcIndex ÆðµãË÷Òý
# @param destIndex Ä¿±êË÷Òý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks Í¨Óñ³°ü½»»»²Ù×÷
def PackItemExchange(curPlayer, srcBackpack, destBackPack, srcIndex, destIndex, tick):
    #»ñµÃÐèÒª²Ù×÷µÄÎïÆ·µÄÎïÆ·
    scrItem = __GetBackPackOperateItem(curPlayer, srcBackpack, destBackPack, srcIndex)
    
    if scrItem == None:
        return
    
    #---Ñé֤Ŀ±ê±³°ü¸ñ×Ó--
    destItem = curPlayer.GetItemManager().GetPack(destBackPack).GetAt(destIndex)
    #Ä¿±ê¸ñ×ÓÖ»ÑéÖ¤Ëø¶¨, ¿ÉÒÔÔÊÐí¿Õλ
    if destItem == None or destItem.GetIsLocked():
        return
    
    ItemCommon.DoLogicSwitchItem(curPlayer, scrItem, destItem, destBackPack)
    return
 
 
## »ñµÃ½ðÇ®¸¶·Ñ×Öµä
#  @param moneyList ½ðÇ®Áбí [½ðÇ®ÀàÐÍ£¬ ½ðÇ®ÊýÁ¿£¬¡£¡£¡£]
#  @param payMoneyDict ½ðÇ®ÀÛ¼Ó×Öµä
#  @return ½ðÇ®ÀÛ¼Ó×Öµä
#  @remarks »ñµÃ½ðÇ®¸¶·Ñ×Öµä
def GetPayMoneyDict(moneyList, payMoneyDict={}):
    length = len(moneyList)
    
    for index in range(0, length, 2):
        moneyType = moneyList[index]
        money = moneyList[index + 1]
        
        payMoney = payMoneyDict.get(moneyType)
        if payMoney == None:
            payMoneyDict[moneyType] = money
        else:
            payMoneyDict[moneyType] += money
    
    return payMoneyDict
 
 
## ¼ì²é½ðÇ®
#  @param curPlayer Íæ¼Ò
#  @param payMoneyDict ¸¶Ç®×Öµä
#  @return BOOLÊÇ·ñ×ã¹»
#  @remarks ¼ì²é½ðÇ®
def CheckPayMoney(curPlayer, payMoneyDict):
    
    for moneyType, money in payMoneyDict.items():
        
        #ÑéÖ¤ÊÖÐø·Ñ
        if not PlayerControl.HaveMoney(curPlayer, moneyType, money):
            return False
    
    return True