hxp
2024-07-09 03a39e5d596b6430db2c406a3349a1dae75c7f2e
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCoin.py
@@ -138,6 +138,7 @@
    for i in xrange(ipyDataMgr.GetCTGCount()):
        ipyData = ipyDataMgr.GetCTGByIndex(i)
        recordID = ipyData.GetRecordID()
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CTGSelectItemValue % recordID, 0)
        if not ipyData.GetCanResetBuyCount():
            continue
        totalBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % recordID)
@@ -165,6 +166,7 @@
        return
    playerID = curPlayer.GetPlayerID()
    for recordID in resetCTGIDList:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CTGSelectItemValue % recordID, 0)
        totalBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % recordID)
        todayBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TodayCTGCount % recordID)
        weekBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_WeekCTGCount % recordID)
@@ -200,9 +202,11 @@
        #if not ipyData.GetDailyBuyCount():
        #    continue
        recordID = ipyData.GetRecordID()
        if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TodayCTGCount % recordID):
        selectItemValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGSelectItemValue % recordID)
        if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TodayCTGCount % recordID) and not selectItemValue:
            continue
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TodayCTGCount % recordID, 0)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CTGSelectItemValue % recordID, 0)
        syncRecordIDList.append(recordID)
    if syncRecordIDList:
        Sync_CoinToGoldCountInfo(curPlayer, syncRecordIDList)
@@ -252,6 +256,35 @@
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    recordID = clientData.RecordID
    Sync_CoinToGoldCountInfo(curPlayer, [recordID] if recordID else [])
    return
#// A1 26 充值自选物品选择 #tagCMSelectCTGItem
#
#struct    tagCMSelectCTGItem
#{
#    tagHead        Head;
#    WORD        RecordID;    //充值ID
#    DWORD        SelectItemValue; // 自选物品索引值,每两位存储每个自选索引对应选择的物品索引+1,存储位值为0代表未选择,最多支持选择4种物品
#};
def OnSelectCTGItem(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    recordID = clientData.RecordID
    selectItemValue = clientData.SelectItemValue
    if selectItemValue > ChConfig.Def_UpperLimit_DWord:
        GameWorld.ErrLog("充值自选物品选择值溢出! recordID=%s,selectItemValue=%s" % (recordID, selectItemValue), playerID)
        return
    ipyData = IpyGameDataPY.GetIpyGameData("CTG", recordID)
    if not ipyData:
        return
    selectItemInfo = ipyData.GetSelectItemInfo()
    selectItemList, errorInfo = GetSelectItemListInfo(selectItemInfo, selectItemValue)
    if errorInfo:
        GameWorld.ErrLog("充值自选物品选择错误! recordID=%s,errorInfo=%s" % (recordID, errorInfo), playerID)
        return
    GameWorld.DebugLog("充值自选物品: recordID=%s,selectItemValue=%s,selectItemList=%s" % (recordID, selectItemValue, selectItemList), playerID)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CTGSelectItemValue % recordID, selectItemValue)
    Sync_CoinToGoldCountInfo(curPlayer, [recordID])
    return
#// A1 25 代币购买充值商品编号商品 #tagCMCoinBuyOrderInfo
@@ -514,6 +547,17 @@
            ExchangePayCoin(curPlayer, "Pay count limit month!monthBuyCount=%s" % monthBuyCount, addDRDict)
            return
        
    selectItemList = []
    selectItemInfo = ipyData.GetSelectItemInfo()
    if selectItemInfo:
        selectItemValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGSelectItemValue % recordID)
        addDRDict.update({"selectItemValue":selectItemValue})
        selectItemList, errorInfo = GetSelectItemListInfo(selectItemInfo, selectItemValue)
        if errorInfo:
            ExchangePayCoin(curPlayer, errorInfo, addDRDict)
            return
        addDRDict.update({"selectItemList":selectItemList})
    totalBuyCountUpd = min(totalBuyCount + 1, ChConfig.Def_UpperLimit_DWord)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CTGGoodsBuyCount % recordID, totalBuyCountUpd)
    addDRDict.update({"totalBuyCountUpd":totalBuyCountUpd})
@@ -530,7 +574,10 @@
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MonthCTGCount % recordID, monthBuyCountUpd)
    addDRDict.update({"monthBuyCountUpd":monthBuyCountUpd})
    
    giveItemList = GetCTGGiveItemList(ipyData)
    giveItemList = []
    giveItemList += GetCTGGiveItemList(ipyData)
    giveItemList += selectItemList
    moneyType = ipyData.GetMoneyType() # 获得货币类型
    addGold = ipyData.GetGainGold() # 获得货币数
    gainGoldPrize = ipyData.GetGainGoldPrize() # 赠送货币数,首次充值赠送仙玉时,此仙玉不给
@@ -544,6 +591,30 @@
        
    Sync_CoinToGoldCountInfo(curPlayer, [recordID])
    return moneyType, addGold, prizeGold, giveItemList, ipyData
def GetSelectItemListInfo(selectItemInfo, selectItemValue):
    errorInfo = ""
    selectItemList = []
    selectValue = selectItemValue
    GameWorld.DebugLog("selectItemValue=%s,selectItemInfo=%s" % (selectItemValue, selectItemInfo))
    for selectNum, selectIDList in enumerate(selectItemInfo, 1):
        selectIndex = selectValue % 100 - 1 # 记录的时候+1
        if selectIndex < 0:
            errorInfo = "Select item is not complete!selectItemValue=%s,selectNum=%s,selectIndex=%s" % (selectItemValue, selectNum, selectIndex)
            return selectItemList, errorInfo
        if selectIndex >= len(selectIDList):
            errorInfo = "Select item index out of range!selectItemValue=%s,selectNum=%s,selectIndex=%s" % (selectItemValue, selectNum, selectIndex)
            return selectItemList, errorInfo
        selectID = selectIDList[selectIndex]
        selectIpyData = IpyGameDataPY.GetIpyGameData("CTGSelectItem", selectID)
        if not selectIpyData:
            errorInfo = "SelectID is not exist!selectItemValue=%s,selectNum=%s,selectIndex=%s,selectID=%s" % (selectItemValue, selectNum, selectIndex, selectID)
            return selectItemList, errorInfo
        selectItemList.append([selectIpyData.GetItemID(), selectIpyData.GetItemCount(), selectIpyData.GetIsAuctionItem()])
        selectValue = selectValue / 100
        GameWorld.DebugLog("    selectNum=%s,selectIndex=%s,selectID=%s,selectItemList=%s,selectItemValue=%s"
                           % (selectNum, selectIndex, selectID, selectItemList, selectItemValue))
    return selectItemList, errorInfo
def GetCTGGiveItemList(ipyData):
    ## 获取充值ID对应给物品列表
@@ -792,6 +863,7 @@
        countInfo.TotalPayCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % recordID)
        countInfo.WeekPayCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_WeekCTGCount % recordID)
        countInfo.MonthPayCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MonthCTGCount % recordID)
        countInfo.SelectItemValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGSelectItemValue % recordID)
        countInfoPack.CTGCountInfoList.append(countInfo)
    countInfoPack.RecordCount = len(countInfoPack.CTGCountInfoList)
    NetPackCommon.SendFakePack(curPlayer, countInfoPack)