From 217627970593db2f63ddb62d6c3d4c5e787871fe Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期一, 25 三月 2019 20:43:11 +0800 Subject: [PATCH] 6385 【后端】【2.0】五行灵根开发 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py | 115 +++++++++++++++++++++++++-------------------------------- 1 files changed, 51 insertions(+), 64 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py index 0398233..7968a40 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py @@ -1730,80 +1730,67 @@ #@return 返回值无意义 #@remarks //03 01 加属性点#tagCAddPoint def AddPoint(index, tick): - GameWorld.GetPsycoFunc(__Func_AddPoint)(index, tick) return -##//03 01 加属性点#tagCAddPoint -#@param index 玩家索引 -#@param tick 时间戳 -#@return 返回值无意义 -#@remarks //03 01 加属性点#tagCAddPoint -def __Func_AddPoint(index, tick): +#// B2 06 玩家加点 #tagCMAddPoint +# +#struct tagCMAddPoint +#{ +# tagHead Head; +# BYTE PointAttrIDCount; // 加点属性ID个数 +# BYTE PointAttrIDList[PointAttrIDCount]; // 加点属性ID列表 +# WORD PointValueList[PointAttrIDCount]; // 加点属性ID对应的点数列表 +#}; +def OnAddPoint(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) - playerControl = PlayerControl.PlayerControl(curPlayer) - #JobQuotiety = PlayerControl.JobQuotiety + pointAttrIDList = clientData.PointAttrIDList + pointValueList = clientData.PointValueList + if not pointAttrIDList or not pointValueList or len(pointAttrIDList) != len(pointValueList): + return + + needTotalPoint = 0 + for i, attrID in enumerate(pointAttrIDList): + if not IpyGameDataPY.GetIpyGameData("RolePoint", attrID): + return + needTotalPoint += pointValueList[i] + curFreePoint = curPlayer.GetFreePoint() - #job = curPlayer.GetJob() - recvAddPoint = IPY_GameWorld.IPY_CAddPoint() - addValue = recvAddPoint.GetPoint() - - #检验是否能够加点 - if addValue < 1 or addValue > curFreePoint: - #检验不通过, 返回 - #GameWorld.ErrLog("(%s,%s)检验是否能够加点,检验不通过, 返回"%(addValue,curFreePoint) , curPlayer.GetPlayerID()) + if needTotalPoint > curFreePoint: + GameWorld.DebugLog("剩余点数不足! curFreePoint(%s) < needTotalPoint(%s)" % (curFreePoint, needTotalPoint)) return - #封包加点类型 - addPointType = recvAddPoint.GetType() - - #加点 - if addPointType == ShareDefine.Def_Effect_STR: - curPlayer.SetBaseSTR(addValue + curPlayer.GetBaseSTR()) + curPlayer.SetFreePoint(curFreePoint - needTotalPoint) + for i, attrID in enumerate(pointAttrIDList): + addPoint = pointValueList[i] + curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AddPointValue % attrID) + updPoint = curPoint + addPoint + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AddPointValue % attrID, updPoint) + GameWorld.DebugLog("玩家加点: attrID=%s,curPoint=%s,addPoint=%s,updPoint=%s" % (attrID, curPoint, addPoint, updPoint)) - elif addPointType == ShareDefine.Def_Effect_PNE: - curPlayer.SetBasePNE(addValue + curPlayer.GetBasePNE()) - - elif addPointType == ShareDefine.Def_Effect_PHY: - curPlayer.SetBasePHY(addValue + curPlayer.GetBasePHY()) - - elif addPointType == ShareDefine.Def_Effect_CON: - curPlayer.SetBaseCON(addValue + curPlayer.GetBaseCON()) - - else: - #异常超出边界 - GameWorld.ErrLog("AddPoint GetTypeErr = %s" % (addPointType) , curPlayer.GetID()) - return - - curPlayer.SetFreePoint(curFreePoint - addValue) - - DataRecordPack.DR_Freepoint(curPlayer, "AddPoint", curFreePoint, {"AddPointType":addPointType}) - playerControl.RefreshPlayerAttrState() - + NotifyPlayerBasePoint(curPlayer, pointAttrIDList) + playerControl = PlayerControl.PlayerControl(curPlayer) + playerControl.RefreshPlayerAttrState() return -def NotifyPlayerBasePoint(curPlayer): - #上线通知基础属性点 - notifyList = [] - notifyBasePointDict = { - IPY_GameWorld.CDBPlayerRefresh_BaseSTR:'BaseSTR', - IPY_GameWorld.CDBPlayerRefresh_BasePHY:'BasePHY', - IPY_GameWorld.CDBPlayerRefresh_BaseCON:'BaseCON', - IPY_GameWorld.CDBPlayerRefresh_BasePNE:'BasePNE', - } - for refreshType, keyStr in notifyBasePointDict.items(): - notifyStruct = ChPyNetSendPack.tagRefreshType() - notifyStruct.RefreshType = refreshType - notifyStruct.Value = getattr(curPlayer, 'Get%s'%keyStr)() - notifyList.append(notifyStruct) +def NotifyPlayerBasePoint(curPlayer, syncAttrIDList=[]): + # 通知基础属性点,已分配的自由点数 + + if not syncAttrIDList: + ipyDataMgr = IpyGameDataPY.IPY_Data() + syncAttrIDList = [ipyDataMgr.GetRolePointByIndex(index).GetAttrID() for index in xrange(ipyDataMgr.GetRolePointCount())] - #属性组合包 通知自己 - sendPack = ChPyNetSendPack.tagObjInfoListRefresh() - sendPack.Clear() - sendPack.ObjID = curPlayer.GetID() - sendPack.ObjType = curPlayer.GetGameObjType() - sendPack.Count = len(notifyList) - sendPack.RefreshType = notifyList - NetPackCommon.SendFakePack(curPlayer, sendPack) + pointAttrIDList = [] + pointValueList = [] + for attrID in syncAttrIDList: + curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AddPointValue % attrID) + pointAttrIDList.append(attrID) + pointValueList.append(curPoint) + + pointInfo = ChPyNetSendPack.tagMCRolePointInfo() + pointInfo.PointAttrIDList = pointAttrIDList + pointInfo.PointValueList = pointValueList + pointInfo.PointAttrIDCount = len(pointAttrIDList) + NetPackCommon.SendFakePack(curPlayer, pointInfo) return #=============================================================================== -- Gitblit v1.8.0