| | |
| | | import IpyGameDataPY
|
| | | import NetPackCommon
|
| | | import ChPyNetSendPack
|
| | | import ItemControler
|
| | | import PlayerControl
|
| | | import PlayerFamily
|
| | | import CrossPlayer
|
| | | import GameWorld
|
| | | import DBDataMgr
|
| | |
|
| | |
| | | #};
|
| | | def OnZhenbaogeOP(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | opType = clientData.OpType
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | familyID = curPlayer.GetFamilyID()
|
| | | opType = clientData.OpType
|
| | | |
| | | reqDataEx = {}
|
| | | # 砍价
|
| | | if opType == 0:
|
| | | leaveTimeEx = PlayerControl.GetLeaveFamilyTimeEx(curPlayer)
|
| | | cutState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeCut)
|
| | | if cutState and leaveTimeEx:
|
| | | cutCDTimes = IpyGameDataPY.GetFuncCfg("Zhenbaoge", 3) * 60
|
| | | passTimes = int(time.time()) - leaveTimeEx
|
| | | if passTimes < cutCDTimes:
|
| | | GameWorld.DebugLog("今日已砍价变更仙盟砍价CD中! passTimes=%s < %s" % (passTimes, cutCDTimes), playerID)
|
| | | return
|
| | | reqDataEx["cutState"] = cutState
|
| | | # 购买
|
| | | elif opType == 1:
|
| | | buyState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy)
|
| | | if buyState:
|
| | | GameWorld.DebugLog("珍宝阁今日已购买!", playerID)
|
| | | return
|
| | | moneyType = IpyGameDataPY.GetFuncCfg("Zhenbaoge", 1)
|
| | | playerMoneyValue = PlayerControl.GetMoney(curPlayer, moneyType)
|
| | | reqDataEx["playerMoneyValue"] = playerMoneyValue
|
| | | |
| | | PlayerFamily.FamilyPyPackForwarding(curPlayer, clientData, tick, "PlayerFamilyZhenbaoge.__OnZhenbaogeOP", True, 20, reqDataEx=reqDataEx)
|
| | | return
|
| | | def __OnZhenbaogeOP(crossPlayer, clientData, tick, fromServerID=0, reqDataEx=None):
|
| | | opType = clientData.OpType
|
| | | playerID = crossPlayer.GetPlayerID()
|
| | | familyID = crossPlayer.GetFamilyID()
|
| | | if not familyID:
|
| | | GameWorld.DebugLog("没有仙盟无法操作珍宝阁!", playerID)
|
| | | return
|
| | |
| | | GameWorld.DebugLog("珍宝阁还没有刷新! familyID=%s" % familyID, playerID)
|
| | | return
|
| | |
|
| | | if not reqDataEx:
|
| | | return
|
| | | |
| | | # 砍价
|
| | | if opType == 0:
|
| | | leaveTimeEx = PlayerControl.GetLeaveFamilyTimeEx(curPlayer)
|
| | | cutState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeCut)
|
| | | if cutState and leaveTimeEx:
|
| | | cutCDTimes = IpyGameDataPY.GetFuncCfg("Zhenbaoge", 3) * 60
|
| | | passTimes = int(time.time()) - leaveTimeEx
|
| | | if passTimes < cutCDTimes:
|
| | | GameWorld.DebugLog("今日已砍价变更仙盟砍价CD中! passTimes=%s < %s" % (passTimes, cutCDTimes), playerID)
|
| | | return
|
| | | cutState = reqDataEx["cutState"]
|
| | |
|
| | | cutPrice = CalcCutPrice(curFamily, gActionData, playerID)
|
| | | if not cutPrice:
|
| | | return
|
| | |
|
| | | AddCutPrice(familyID, playerID, curPlayer.GetName(), cutPrice, gActionData)
|
| | | PlayerControl.NotifyCode(curPlayer, "ZhenbaogeCut", [cutPrice])
|
| | | if not curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeCut):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyZhenbaogeCut, 1)
|
| | | Sync_ZhenbaogeInfo(curPlayer)
|
| | | AddCutPrice(familyID, playerID, crossPlayer.GetPlayerName(), cutPrice, gActionData)
|
| | | CrossPlayer.NotifyCode(crossPlayer, "ZhenbaogeCut", [cutPrice])
|
| | | if not cutState:
|
| | | CrossPlayer.SetPlayerNomalDict(crossPlayer, {ChConfig.Def_Player_Dict_FamilyZhenbaogeCut:1}, True)
|
| | | #Sync_ZhenbaogeInfo(crossPlayer)
|
| | |
|
| | | # 购买
|
| | | elif opType == 1:
|
| | | buyState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy)
|
| | | if buyState:
|
| | | GameWorld.DebugLog("珍宝阁今日已购买!", playerID)
|
| | | return
|
| | | #buyState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy)
|
| | | #if buyState:
|
| | | # GameWorld.DebugLog("珍宝阁今日已购买!", playerID)
|
| | | # return
|
| | | moneyType = IpyGameDataPY.GetFuncCfg("Zhenbaoge", 1)
|
| | | playerMoneyValue = PlayerControl.GetMoney(curPlayer, moneyType)
|
| | | playerMoneyValue = reqDataEx["playerMoneyValue"]
|
| | |
|
| | | actionData = GetZhenbaogeActionData(familyID, playerID)
|
| | | if not actionData:
|
| | |
| | | SetFABuyState(actionData, 1)
|
| | | PlayerFamily.SendFamilyAction(actionData)
|
| | |
|
| | | moneyDict = {moneyType:0} # 奖励货币
|
| | | if nowPrice > 0:
|
| | | if not PlayerControl.PayMoney(curPlayer, moneyType, nowPrice, "Zhenbaoge"):
|
| | | GameWorld.ErrLog("珍宝阁购买货币不足! nowPrice=%s" % nowPrice, playerID)
|
| | | return
|
| | | CrossPlayer.CostPlayerResources(crossPlayer, "Zhenbaoge", {moneyType:nowPrice})
|
| | | elif nowPrice < 0:
|
| | | PlayerControl.GiveMoney(curPlayer, moneyType, -nowPrice, "Zhenbaoge")
|
| | | moneyDict[moneyType] = -nowPrice
|
| | | else: # 0不处理
|
| | | pass
|
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy, 1)
|
| | | CrossPlayer.SetPlayerNomalDict(crossPlayer, {ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy:1}, True)
|
| | | #Sync_ZhenbaogeInfo(curPlayer)
|
| | | |
| | | CrossPlayer.GivePlayerResources(crossPlayer, giveItemList, moneyDict, eventName="Zhenbaoge")
|
| | | |
| | | return True
|
| | |
|
| | | def __OnZhenbaogeOP_Ret(curPlayer, clientData, isOK):
|
| | | if not isOK:
|
| | | return
|
| | | Sync_ZhenbaogeInfo(curPlayer)
|
| | | |
| | | if giveItemList:
|
| | | ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList, event=["Zhenbaoge", False, {}], isNotifyAward=False)
|
| | | ItemControler.NotifyGiveAwardInfo(curPlayer, giveItemList, "Zhenbaoge", moneyInfo={moneyType:0 if nowPrice > 0 else -nowPrice})
|
| | | |
| | | return
|
| | |
|
| | | def Sync_ZhenbaogeInfo(curPlayer):
|