hxp
2019-01-10 94c9b0759bfa49e66bfce3f790c40f15d362ba1a
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Player.RemoteQuery.GY_Query_ShopItem
#
# @todo:×Ô¶¨ÒåÉ̵ê
# @author hxp
# @date 2014-06-21
# @version 1.0
#
# ÏêϸÃèÊö: ×Ô¶¨ÒåÉ̵ê
#
#---------------------------------------------------------------------
"""Version = 2014-06-21 15:20"""
 
import GameWorld
import ShareDefine
import ShopItemManage
 
 
#Âß¼­ÊµÏÖ
## ÇëÇóÂß¼­
#  @param query_Type ÇëÇóÀàÐÍ
#  @param query_ID ÇëÇóµÄÍæ¼ÒID
#  @param packCMDList ·¢°üÃüÁî [ ]
#  @param tick µ±Ç°Ê±¼ä
#  @return "True" or "False" or ""
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoLogic(query_Type, query_ID, packCMDList, tick):
    return packCMDList
 
#---------------------------------------------------------------------
#Ö´Ðнá¹û
## Ö´Ðнá¹û
#  @param curPlayer ·¢³öÇëÇóµÄÍæ¼Ò
#  @param callFunName ¹¦ÄÜÃû³Æ
#  @param funResult ²éѯµÄ½á¹û
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoResult(curPlayer, callFunName, funResult, tick):
    if funResult == '':
        return
    GameWorld.Log("GY_Query_ShopItem DoResult funResult=%s" % funResult)
    #»¹Ô­¸ñʽ '[]' -> []
    funResult = eval(funResult)
    queryType = funResult[0]
    
    # Í¬²½¹ºÂò´ÎÊý[queryType, shopID, buyCntDict]
    if queryType == ShareDefine.Def_ShopItem_QueryServerBuyCnt:
        shopID = funResult[1]
        buyCntDict = funResult[2] # È«·þÒѹºÂò´ÎÊý×Öµä
        ShopItemManage.Send_ShopItemAllBuyCntInfo(curPlayer, shopID, buyCntDict)
    
    # ¹ºÂòÎïÆ·[queryType, shopID, itemShopIndex, buyCount, canBuy, serverBuyCnt]
    elif queryType == ShareDefine.Def_ShopItem_BuyItem:
        shopID = funResult[1]
        itemShopIndex = funResult[2]
        buyCount = funResult[3]
        canBuy = funResult[4] # ·´À¡µÄ¿É·ñ¹ºÂò
        serverBuyCnt = funResult[5] # ¸üкóµÄÈ«·þÏÞ¹º´ÎÊý
        
        # ²»¿ÉÒÔÂò£¬²»´¦Àí
        if not canBuy:
            GameWorld.DebugLog("    GameServer·´À¡²»¿É¹ºÂò£¡")
            return
        
        itemInfoDict = ShopItemManage.GetShopItemInfoDict(shopID, itemShopIndex)
        if not itemInfoDict:
            return
        
        ShopItemManage.DoBuyShopItem(curPlayer, itemInfoDict, buyCount, serverBuyCnt)
    
    # Çå¿ÕÈ«·þÏÞ¹º´ÎÊý[queryType, shopID]
    elif queryType == ShareDefine.Def_ShopItem_ClearBuyCnt:
        shopID = funResult[1]
        shopItemList = ShopItemManage.GetShopItemList(shopID)
        
        ShopItemManage.Send_ShopItem(curPlayer, shopItemList)
        ShopItemManage.ClearPlayerShopItemBuyCnt(curPlayer, shopID)
        ShopItemManage.Send_ShopItemAllBuyCntInfo(curPlayer, shopID, {})
        
    # Í¬²½µ¥Æ·ÏÞ¹º´ÎÊý[queryType, shopID, itemShopIndex, serverBuyCnt]
    elif queryType == ShareDefine.Def_ShopItem_SyncServerBuyCnt:
        shopID = funResult[1]
        itemShopIndex = funResult[2]
        serverBuyCnt = funResult[3]
        ShopItemManage.Send_ShopItemBuyCntInfo(curPlayer, shopID, [itemShopIndex], 
                                               {itemShopIndex:serverBuyCnt})
    
    else:
        pass
 
    return