| | |
| | | #"""Version = 2017-07-17 15:00"""
|
| | | #---------------------------------------------------------------------
|
| | | import GameWorld
|
| | | import ChEquip
|
| | | import SkillShell
|
| | | import ChConfig
|
| | | import EffGetSet
|
| | | import PlayerHorse
|
| | | import PlayerTeam
|
| | | import SkillCommon
|
| | | import MirrorAttack
|
| | | import GameMap
|
| | | import FBLogic
|
| | | import GameWorldProcess
|
| | |
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import DataRecordPack
|
| | | import CalcNoLineEffect
|
| | | import CalcLineEffect
|
| | | import PlayerEquipDecompose
|
| | | import FormulaControl
|
| | | import PlayerDienstgrad
|
| | | import PlayerPrestigeSys
|
| | | import OpenServerCampaign
|
| | | import PlayerGodWeapon
|
| | | import PlayerExpandPackCfgMgr
|
| | | import PlayerActivity
|
| | | import FBCommon
|
| | | import PassiveBuffEffMng
|
| | | import EventReport
|
| | | import PlayerGatherSoul
|
| | | import PlayerGatherTheSoul
|
| | | import PlayerSuccess
|
| | | import PlayerPet
|
| | | import ItemControler
|
| | | import GameFuncComm
|
| | | import IpyGameDataPY
|
| | | import PlayerRune
|
| | | import PyGameData
|
| | | import PlayerMagicWeapon
|
| | | import PlayerFeastTravel
|
| | | import PlayerActTurntable
|
| | | import GameLogic_SealDemon
|
| | | import GameLogic_ZhuXianBoss
|
| | | import GameLogic_CrossDemonKing
|
| | | import PlayerVip
|
| | | import PlayerRefineStove
|
| | | import PlayerFamilyTech
|
| | | import PlayerFamilyZhenfa
|
| | | import PlayerCostRebate
|
| | | import PlayerActLunhuidian
|
| | | import PlayerActGarbageSorting
|
| | |
| | | import PlayerTongTianLing
|
| | | import FunctionNPCCommon
|
| | | import PlayerGoldInvest
|
| | | import IPY_PlayerDefine
|
| | | import CrossRealmPlayer
|
| | | import CrossPlayerData
|
| | | import NPCHurtManager
|
| | | import ChNetSendPack
|
| | | import PlayerLianTi
|
| | | import PlayerCoat
|
| | | import PlayerAssist
|
| | | import PlayerState
|
| | | import PlayerDogz
|
| | | import PlayerFaQi
|
| | | import PlayerLove
|
| | | import PlayerGubao
|
| | | import PlayerShentong
|
| | | import PlayerOnline
|
| | | import PlayerCharm
|
| | | import PlayerTask
|
| | | import PlayerFace
|
| | | import PlayerMail
|
| | | import ChPlayer
|
| | | import GameObj
|
| | |
| | | # @return 返回值无意义
|
| | | def ClearPyPlayerAction(curPlayer):
|
| | | #清除py自定义状态
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_PyPlayerAction, 0) |
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_PyPlayerAction, 0) |
| | | return
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
| | | curPlayer.Stand()
|
| | |
|
| | |
|
| | | return
|
| | | #---------------------------------------------------------------------
|
| | | ##玩家播放表情
|
| | | # @param curPlayer 玩家实例
|
| | | # @return 返回值无意义
|
| | | # @remarks 玩家播放表情
|
| | | def DoPlayerShowPlayerFace(curPlayer, faceType):
|
| | | #清空玩家点击
|
| | | curPlayer.SetActionObj(None)
|
| | | #通知中断战斗对峙
|
| | | ExitPlayerConfronting(curPlayer)
|
| | | #通知停止移动
|
| | | curPlayer.StopMove()
|
| | | #通知客户端播放表情
|
| | | curPlayer.View_ShowPlayerFace(faceType)
|
| | | return
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
| | | #刷新技能剩余时间
|
| | | SkillCommon.RefreshAllSkillRemainTime(curPlayer, tick)
|
| | |
|
| | | #队伍玩家退出地图
|
| | | PlayerTeam.TeamPlayerLeaveMap(curPlayer, tick, isDisconnect)
|
| | |
|
| | | #退出采集
|
| | | NPCCommon.ClearCollectNPC(curPlayer)
|
| | |
|
| | |
| | | CrossPlayerData.ClearCrossSyncDataCache(curPlayer)
|
| | | PyGameData.g_fbBuyBuffTimeDict.pop(playerID, None)
|
| | | #清除地图玩家缓存
|
| | | PyGameData.g_playerFuncAttrDict.pop(playerID, None)
|
| | | PyGameData.g_playerEquipPartAttrDict.pop(playerID, None)
|
| | | PyGameData.g_playerReqEnterFBEx.pop(playerID, None)
|
| | | NPCCommon.ClearPriWoodPile(curPlayer)
|
| | | #移除地图缓存的境界难度玩家ID信息
|
| | |
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FromFBLineID, lineID)
|
| | | GameWorld.DebugLog("进入副本时,最后一次离开的可返回的副本ID更新!mapID=%s,lineID=%s,Pos(%s,%s)" % (mapID, lineID, posX, posY))
|
| | |
|
| | | # 离开地图
|
| | | PlayerAssist.OnPlayerLeaveMap(curPlayer)
|
| | | |
| | | # 从副本中切图
|
| | | if GameWorld.GetMap().GetMapFBType() != IPY_GameWorld.fbtNull:
|
| | | #默认回满血
|
| | |
| | |
|
| | | if not FBLogic.OnEnterFBEvent(curPlayer, mapID, lineID, tick):
|
| | | GameWorld.DebugLog(" OnEnterFBEvent False!", curPlayer.GetPlayerID())
|
| | | if mapID in [ChConfig.Def_FBMapID_CrossBattlefield]:
|
| | | NotifyCode(curPlayer, "GeRen_chenxin_268121")
|
| | | else:
|
| | | NotifyCode(curPlayer, "SingleEnterDefaul")
|
| | | NotifyCode(curPlayer, "SingleEnterDefaul")
|
| | | return
|
| | |
|
| | | # 需要动态分布线路的地图,发送到跨服服务器进行分配
|
| | | if mapID in ChConfig.Def_CrossDynamicLineMap:
|
| | | extendInfo = {}
|
| | | if mapID == ChConfig.Def_FBMapID_CrossDemonKing:
|
| | | bossID = GameLogic_CrossDemonKing.GetCurFBLineBOSSID(mapID, lineID)
|
| | | if not bossID:
|
| | | return
|
| | | extendInfo["BossID"] = bossID
|
| | | |
| | | msgDict = {"PlayerID":curPlayer.GetPlayerID(), "MapID":mapID, "FuncLineID":lineID, "LV":curPlayer.GetLV()}
|
| | | if extendInfo:
|
| | | msgDict.update(extendInfo)
|
| | |
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | if CheckMoveToFB(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, tick) != ShareDefine.EntFBAskRet_OK:
|
| | | return
|
| | | # if mapID == ChConfig.Def_FBMapID_XMZZ:
|
| | | # #仙魔之争
|
| | | # GameLogic_XMZZ.XMZZStartFight(curPlayer)
|
| | | # return
|
| | | if posX == 0 and posY == 0:
|
| | | ipyEnterPosInfo = FBCommon.GetFBLineEnterPosInfo(mapID, lineID, fbLineIpyData)
|
| | | retPos = FBLogic.OnGetFBEnterPos(curPlayer, mapID, lineID, ipyEnterPosInfo, tick)
|
| | |
| | | if isSendToGameServer or mapID in ChConfig.Def_MapID_SendToGameServer \
|
| | | or mapID in ReadChConfig.GetEvalChConfig("MapID_SendToGameServer"):
|
| | | extendParamList = []
|
| | | if mapID == ChConfig.Def_FBMapID_SealDemon:
|
| | | newbielineList = IpyGameDataPY.GetFuncEvalCfg('SealDemonNewbieLine', 1)
|
| | | # 新手线路特殊处理,直接进入
|
| | | if lineID in newbielineList:
|
| | | GameWorld.DebugLog("封魔坛虚拟线路只能通过自定义场景进入挑战!")
|
| | | return
|
| | | else:
|
| | | bossID = GameLogic_SealDemon.CurFBLineBOSSID(lineID)
|
| | | extendParamList = [bossID]
|
| | | elif mapID == ChConfig.Def_FBMapID_ZhuXianBoss:
|
| | | bossID = GameLogic_ZhuXianBoss.CurFBLineBOSSID(lineID)
|
| | | extendParamList = [bossID, -1]
|
| | | enterCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_EnterFbCntDay % ChConfig.Def_FBMapID_ZhuXianBoss)
|
| | | if enterCnt >= FBCommon.GetEnterFBMaxCnt(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss):
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhuXianBossHelpCnt):
|
| | | extendParamList = [bossID, curPlayer.GetFamilyID()]
|
| | | elif mapID == ChConfig.Def_FBMapID_DemonKing:
|
| | | bossID = GameLogic_CrossDemonKing.GetCurFBLineBOSSID(mapID, lineID)
|
| | | extendParamList = [bossID]
|
| | | elif mapID in ChConfig.Def_MapID_LineIDToPropertyID:
|
| | | if mapID in ChConfig.Def_MapID_LineIDToPropertyID:
|
| | | enterCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_EnterFbCntDay % mapID)
|
| | | extendParamList = [enterCnt]
|
| | | elif mapID in ChConfig.MirrorBattleMapIDList:
|
| | |
| | | #轮回殿
|
| | | PlayerActLunhuidian.AddLunhuidianValue(curPlayer, PlayerActLunhuidian.AwardType_PayMoney, type_Price, price)
|
| | | if type_Price == ShareDefine.TYPE_Price_Xiantao:
|
| | | # 累加未结算战锤 - 经验
|
| | | unXiantaoCntExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntExp)
|
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntExp, unXiantaoCntExp + price)
|
| | | # 累加未结算战锤 - 装备
|
| | | unXiantaoCntEquip = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntEquip)
|
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntEquip, unXiantaoCntEquip + price)
|
| | | # 累加未结算战锤 - 战利品
|
| | | chapterID = GetMainLevelNowInfo(curPlayer)[0]
|
| | | chapterIpyData = IpyGameDataPY.GetIpyGameData("MainChapter", chapterID)
|
| | | if chapterIpyData:
|
| | | DailyBootyUpperList = chapterIpyData.GetDailyBootyUpperList()
|
| | | for itemID, upperCnt in DailyBootyUpperList:
|
| | | if upperCnt <= 0:
|
| | | continue
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BootyDropToday % itemID) >= upperCnt:
|
| | | continue
|
| | | unXiantaoCntBooty = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntBooty % itemID)
|
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntBooty % itemID, unXiantaoCntBooty + price)
|
| | | |
| | | PlayerPrestigeSys.AddRealmTaskValue(curPlayer, PlayerPrestigeSys.RealmTaskType_UseXiantao, price)
|
| | | unitPrice = price if quantity == 1 else int(math.ceil(price * 1.0 / quantity)) # 单价
|
| | | #reason_name = "Unknown" if not costType else costType
|
| | |
| | |
|
| | | def GetFabaoAddPoint(curPlayer):
|
| | | #法宝额外增加玩家每级获得的灵根点
|
| | | mwID = IpyGameDataPY.GetFuncCfg('FabaoAddPoint', 1)
|
| | | if not PlayerMagicWeapon.GetIsActiveMagicWeapon(curPlayer, mwID, lv=1):
|
| | | return 0
|
| | | return IpyGameDataPY.GetFuncCfg('FabaoAddPoint', 2)
|
| | | return 0
|
| | |
|
| | | def DoAddPointOpen(curPlayer):
|
| | | '''加点功能开启'''
|
| | |
| | |
|
| | | # 杀怪
|
| | | if expViewType == ShareDefine.Def_ViewExpType_KillNPC:
|
| | | exp_rate = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TotalExpRate)
|
| | | #exp_rate = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TotalExpRate)
|
| | | exp_rate = 10000
|
| | | elif expViewType in [ShareDefine.Def_ViewExpType_GameEvent, ShareDefine.Def_ViewExpType_Sit]:
|
| | | exp_rate = curPlayer.GetGameEventExpRate()
|
| | | #exp_rate += GetFamilySitExpPer(curPlayer)
|
| | |
| | |
|
| | | # 升级需要执行的游戏功能处理
|
| | | GameFuncComm.DoFuncOpenLogic(curPlayer)
|
| | | #ChEquip.RefreshPlayerLingQiEquipAttr(curPlayer) # 灵器属性会随等级成长
|
| | | #if aftLV%10 == 0:
|
| | | # # 控制下刷新次数
|
| | | # PlayerPet.CalcPetItemAddPlayerAttr(curPlayer) # 宠物有随等级变化的技能
|
| | |
|
| | | PlayerOnline.CalcRoleBase(curPlayer)
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).RefreshRoleAttr()
|
| | |
| | | DoPlayerDead(curPlayer)
|
| | |
|
| | | GameObj.ClearPyPlayerState(curPlayer)
|
| | | |
| | | MirrorAttack.OnPlayerDead(curPlayer)
|
| | | return
|
| | |
|
| | |
|
| | |
| | | # return False
|
| | |
|
| | | return True
|
| | | #------------------------------------------------------------------------------------
|
| | | ##初始化玩家背包.
|
| | | # @param curPlayer 玩家实例
|
| | | # @return 返回值无意义
|
| | | # @remarks 初始化玩家背包
|
| | | def Init_ItemPack(curPlayer):
|
| | | packType = IPY_GameWorld.rptItem
|
| | | |
| | | #初始化玩家背包
|
| | | if packType not in ChConfig.Def_Type_CanBuyPack_PlayerDict.keys():
|
| | | return
|
| | | |
| | | #获取玩家背包
|
| | | curPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | |
| | | #默认14格子 + 开启的
|
| | | keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict.get(packType)[ChConfig.Def_PlayerPackDict_Index_Key]
|
| | | count = ItemCommon.GetPackInitCount(packType) + curPlayer.NomalDictGetProperty(keyName)
|
| | | curPack.SetCount(count)
|
| | | |
| | | #通知客户端背包格子数目
|
| | | # curPlayer.Sync_ItemCount(curPack.GetCount())
|
| | | curPack.Sync_PackCanUseCount()
|
| | | return
|
| | |
|
| | | #------------------------------------------------------------------------------------
|
| | | ##初始化玩家仓库.
|
| | | # @param curPlayer 玩家实例
|
| | | # @return 返回值无意义
|
| | | # @remarks 初始化玩家仓库
|
| | | def Init_Warehouse(curPlayer):
|
| | | |
| | | packType = IPY_GameWorld.rptWarehouse
|
| | | |
| | | #初始化玩家背包
|
| | | if packType not in ChConfig.Def_Type_CanBuyPack_PlayerDict.keys():
|
| | | return
|
| | | |
| | | #获取玩家背包
|
| | |
|
| | | def Init_PackCount(curPlayer, packType, defaultMax=False, isSync=True):
|
| | | ## 初始化刷新玩家某个背包格子数
|
| | | curPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | |
| | | #默认42格子 + 开启的
|
| | | keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict.get(packType)[ChConfig.Def_PlayerPackDict_Index_Key]
|
| | | count = ItemCommon.GetPackInitCount(packType) + curPlayer.NomalDictGetProperty(keyName)
|
| | | |
| | | curPack.SetCount(count)
|
| | | |
| | | #通知客户端
|
| | | curPack.Sync_PackCanUseCount()
|
| | | maxCount = curPack.GetMaxCount()
|
| | | if defaultMax:
|
| | | curPack.SetCount(maxCount)
|
| | | else:
|
| | | count = ItemCommon.GetPackInitCount(packType) + ItemCommon.GetPackOpenItemCnt(curPlayer, packType)
|
| | | curPack.SetCount(min(count, maxCount))
|
| | | if isSync:
|
| | | curPack.Sync_PackCanUseCount()
|
| | | return
|
| | |
|
| | | def Init_HeroPack(curPlayer):
|
| | | packType = ShareDefine.rptHero |
| | | #获取玩家背包
|
| | | curPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | initCount = ItemCommon.GetPackInitCount(packType)
|
| | | if packType in ChConfig.Def_Type_CanBuyPack_PlayerDict.keys():
|
| | | keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict.get(packType)[ChConfig.Def_PlayerPackDict_Index_Key]
|
| | | initCount += curPlayer.NomalDictGetProperty(keyName)
|
| | | curPack.SetCount(initCount)
|
| | | #通知客户端背包格子数目
|
| | | # curPlayer.Sync_ItemCount(curPack.GetCount())
|
| | | curPack.Sync_PackCanUseCount()
|
| | | return
|
| | |
|
| | |
|
| | | ##初始化寻宝背包
|
| | | # @param curPlayer 玩家实例
|
| | | # @return None
|
| | | def Init_TreasurePack(curPlayer):
|
| | | curPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptTreasure)
|
| | | curPack.SetCount(ItemCommon.GetPackInitCount(ShareDefine.rptTreasure))
|
| | | |
| | | #通知客户端
|
| | | curPack.Sync_PackCanUseCount()
|
| | | return
|
| | |
|
| | | ##初始化玩家收纳柜
|
| | | # @param curPlayer 玩家实例
|
| | | # @param packType 背包类型
|
| | | # @return 返回值无意义
|
| | | def Init_CabinetCountByType(curPlayer, packType):
|
| | | keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict.get(packType)[ChConfig.Def_PlayerPackDict_Index_Key]
|
| | | if keyName == None:
|
| | | GameWorld.ErrLog("Init_Pack Error type=%s" % packType)
|
| | | return
|
| | | |
| | | #初始化时装武器背包
|
| | | curPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | #默认14格子 + 开启的
|
| | | count = ChConfig.Def_PackCnt_WeaponCoat + curPlayer.NomalDictGetProperty(keyName)
|
| | | curPack.SetCount(count)
|
| | | |
| | | #通知客户端
|
| | | curPack.Sync_PackCanUseCount()
|
| | | return
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | def IsInOperationAction(curPlayer, actName, actIDKey, crossActName="", crossActIDKey=""):
|
| | | ## 玩家是否有正在进行中运营活动,不含参与结束阶段
|
| | |
|
| | |
| | | def Sync_ExpRateChange(curPlayer):
|
| | | totalExpRate = GetPlayerExpRate(curPlayer)
|
| | | fightExpRate = curPlayer.GetFightExpRate() # 系统及功能累加
|
| | | fightExpRate += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_FightExpRate) # VIP加成
|
| | | fightExpRate += PlayerGoldInvest.GetAddFightExpRate(curPlayer)
|
| | |
|
| | | actExpRateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_ExpRate, {})# 多倍经验活动加成
|
| | |
| | | #===============================================================================
|
| | | #---------------------------------------------------------------------------
|
| | |
|
| | | ##获取可免费开启的格子数
|
| | | # @param curPlayer 玩家对象
|
| | | # @param packType 背包类型
|
| | | # @param openCnt 实际要开启的格子数
|
| | | # @return 获取可免费开启的格子数
|
| | | def GetCanAutoOpenPackCount(curPlayer, packType, openCnt, tick):
|
| | | if packType not in [IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]:
|
| | | return 0
|
| | | cfgObj = PlayerExpandPackCfgMgr.GetExpandPackCfg(curPlayer, packType)
|
| | | #找不到这种背包的配置信息对象
|
| | | if not cfgObj:
|
| | | return 0
|
| | | #已购买或自动开启的格子数
|
| | | keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict[packType][ChConfig.Def_PlayerPackDict_Index_Key]
|
| | | curCount = curPlayer.NomalDictGetProperty(keyName)
|
| | | |
| | | # nextCountIndex = curCount + 1
|
| | | # infoObj = cfgObj.GetAttrInfoByInex(nextCountIndex)
|
| | | # if None == infoObj:
|
| | | # return 0
|
| | | # #更新下玩家的在线时间
|
| | | # UpdateOnLineTime(curPlayer, tick)
|
| | | # onlineTime = curPlayer.GetOnlineTime()
|
| | | # #需要的时间
|
| | | # needOnlineTime = infoObj["OnlineTime"]
|
| | | # #最后一次自动开启背包的在线时间tick
|
| | | # lastAutoOpenPackTick = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_LastAutoOpenPackTick)
|
| | | # if onlineTime - lastAutoOpenPackTick > needOnlineTime:
|
| | | # return 1
|
| | | # return 0
|
| | | |
| | | #最大可增加的背包数
|
| | | maxCanAddCount = cfgObj.GetCanAddCount()
|
| | | forCount = min(openCnt, maxCanAddCount - curCount)
|
| | | |
| | | #可以再增加的格子数
|
| | | count = 0
|
| | | #遍历可增加的背包格子数
|
| | | UpdateOnLineTime(curPlayer, tick)
|
| | | onlineTime = curPlayer.GetOnlineTime()
|
| | | lastAutoOpenPackTick = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_LastAutoOpenPackTick % packType)
|
| | | lastInfoObj = cfgObj.GetTotalAddAttrInfoByCount(curCount)
|
| | | notOnlineTime = 0
|
| | | if lastInfoObj:
|
| | | notOnlineTime = lastInfoObj["OnlineTime"]
|
| | | # GameWorld.Log("get online time = %s"%onlineTime)
|
| | | for i in range(forCount):
|
| | | nextCount = curCount + i + 1
|
| | | infoObj = cfgObj.GetTotalAddAttrInfoByCount(nextCount)
|
| | | if None == infoObj:
|
| | | break
|
| | | # (小于0的不具有免费开启功能)
|
| | | if infoObj["OnlineTime"] < 0:
|
| | | continue
|
| | | needOnlineTime = infoObj["OnlineTime"] - notOnlineTime
|
| | | # GameWorld.Log("get need online time = %s"%needOnlineTime)
|
| | | #要求的在线时间,大于当前的在线时间,没办法加背包格子
|
| | | if needOnlineTime > onlineTime - lastAutoOpenPackTick:
|
| | | break
|
| | | count += 1
|
| | | return count
|
| | |
|
| | | ## 获取玩家当前等级升级所需总经验
|
| | | # @param playerLv 玩家等级
|
| | | # @return 返回值, 升级需要的总经验
|
| | |
| | | # @param allAttrList 属性列表
|
| | | # @return None
|
| | | def CalcAttrDict_Type(attrType, value, allAttrList):
|
| | | if value == 0:
|
| | | return
|
| | | |
| | | #[属性索引, 是否基础属性,(非)线性]
|
| | | attrInfo = ChConfig.ItemEffect_AttrDict.get(attrType, [])
|
| | | if attrInfo == []:
|
| | | return
|
| | | |
| | | index = ChConfig.Def_CalcAttrIndexDict[(attrInfo[1], attrInfo[2])]
|
| | | |
| | | attrDict = allAttrList[index]
|
| | | for i in attrInfo[0]:
|
| | | GameWorld.AddDictValue(attrDict, {i:value})
|
| | | return
|
| | |
|
| | | def CalcAttrDict_TypeEx(attrType, value, allAttrDict):
|
| | | ## 统计玩家属性,累加
|
| | | if value == 0:
|
| | | return
|
| | | |
| | | #[属性索引, 是否基础属性,(非)线性]
|
| | | attrInfo = ChConfig.ItemEffect_AttrDict.get(attrType, [])
|
| | | if attrInfo == []:
|
| | | return
|
| | | for i in attrInfo[0]:
|
| | | GameWorld.AddDictValue(allAttrDict, {i:value})
|
| | | return
|
| | |
|
| | | ## 培养境界等级
|
| | |
| | |
|
| | | ## 设置保存功能事先计算好的属性值
|
| | | def SetCalcAttrListValue(curPlayer, funcIndex, allAttrList, insidePerAttrDict=None, customAttrDict=None):
|
| | | # 设置值之前先清空重置
|
| | | # @param customAttrDict: 自定义的属性信息,必须是格式 {"自定义属性描述名key":属性信息, ...} 自定义属性描述名key - 建议不同功能点之间不要重复
|
| | | ClearCalcAttrListValue(curPlayer, funcIndex)
|
| | | if insidePerAttrDict == None:
|
| | | insidePerAttrDict = {}
|
| | | if customAttrDict == None:
|
| | | customAttrDict = {}
|
| | | |
| | | battleAttrDict = allAttrList[ChConfig.CalcAttr_Battle]
|
| | | if ChConfig.TYPE_Calc_PerLVAtk in battleAttrDict:
|
| | | # 每1级加的攻击力不一定满1点,所以这里按万分率来算,支持小数算法
|
| | | addAtk = int(curPlayer.GetLV() * battleAttrDict[ChConfig.TYPE_Calc_PerLVAtk] / float(ShareDefine.Def_MaxRateValue))
|
| | | battleAttrDict[ChConfig.TYPE_Calc_AttrATKMin] = battleAttrDict.get(ChConfig.TYPE_Calc_AttrATKMin, 0) + addAtk
|
| | | battleAttrDict[ChConfig.TYPE_Calc_AttrATKMax] = battleAttrDict.get(ChConfig.TYPE_Calc_AttrATKMax, 0) + addAtk
|
| | | |
| | | if ChConfig.TYPE_Calc_PerLVMaxHP in battleAttrDict:
|
| | | # 每1级加的生命值不会少于1点,所以直接乘
|
| | | addMaxHP = curPlayer.GetLV() * battleAttrDict[ChConfig.TYPE_Calc_PerLVMaxHP]
|
| | | battleAttrDict[ChConfig.TYPE_Calc_AttrMaxHP] = battleAttrDict.get(ChConfig.TYPE_Calc_AttrMaxHP, 0) + addMaxHP
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | if playerID not in PyGameData.g_playerFuncAttrDict:
|
| | | PyGameData.g_playerFuncAttrDict[playerID] = {}
|
| | | funcAttrDict = PyGameData.g_playerFuncAttrDict[playerID]
|
| | | funcAttrDict[funcIndex] = [allAttrList, insidePerAttrDict, customAttrDict]
|
| | | #GameWorld.DebugLog("保存功能点属性: funcIndex=%s, %s, %s" % (funcIndex, allAttrList, insidePerAttrDict))
|
| | | return
|
| | |
|
| | | def GetCalcAttrListValue(curPlayer, funcIndex):
|
| | |
| | | attrList = [{} for _ in range(4)]
|
| | | insidePerAttrDict = {}
|
| | | customAttrDict = {}
|
| | | if isinstance(funcIndex, int):
|
| | | funcIndexList = [funcIndex]
|
| | | elif isinstance(funcIndex, list):
|
| | | funcIndexList = funcIndex
|
| | | else:
|
| | | return attrList, insidePerAttrDict, customAttrDict
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | if playerID not in PyGameData.g_playerFuncAttrDict:
|
| | | return attrList, insidePerAttrDict, customAttrDict
|
| | | funcAttrDict = PyGameData.g_playerFuncAttrDict[playerID]
|
| | | for funcIndex in funcIndexList:
|
| | | if funcIndex not in funcAttrDict:
|
| | | continue
|
| | | funcAttrList, funcInsidePerAttrDict, funcCustomAttrDict = funcAttrDict[funcIndex]
|
| | | for i, attrDict in enumerate(attrList):
|
| | | curAttrDict = funcAttrList[i]
|
| | | AddAttrDictValue(attrDict, curAttrDict)
|
| | | customAttrDict.update(funcCustomAttrDict)
|
| | | AddAttrDictValue(insidePerAttrDict, funcInsidePerAttrDict)
|
| | | return attrList, insidePerAttrDict, customAttrDict
|
| | |
|
| | | ## 重置缓存
|
| | | def ClearCalcAttrListValue(curPlayer, funcIndex):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | if playerID not in PyGameData.g_playerFuncAttrDict:
|
| | | return
|
| | | funcAttrDict = PyGameData.g_playerFuncAttrDict[playerID]
|
| | | funcAttrDict.pop(funcIndex, None)
|
| | | return
|
| | |
|
| | | def AddAttrListValue(attrList):
|
| | | addAttrList = [{} for _ in range(4)]
|
| | | for aList in attrList:
|
| | | for i in ChConfig.CalcAttrIndexList:
|
| | | AddAttrDictValue(addAttrList[i], aList[i])
|
| | | return addAttrList
|
| | |
|
| | | ## 属性值字典累加
|
| | | def AddAttrDictValue(dict1, dict2):
|
| | | for key, value in dict2.items():
|
| | | if key not in dict1:
|
| | | dict1[key] = value
|
| | | else:
|
| | | aValue = dict1[key]
|
| | | if key in ChConfig.TYPE_Calc_DeclineList:
|
| | | # 这种算法的属性一般是万分率的,最大不超过百分百,故暂默认万分率, 若有不是万分率的属性再做处理
|
| | | dict1[key] = 10000 - (10000 - aValue) * (10000 - value)
|
| | | else:
|
| | | dict1[key] = aValue + value
|
| | | return
|
| | |
|
| | | def GetLordAttr(curPlayer):
|
| | | ## 获取主公属性汇总
|
| | | lordAttrDict = {"Atk":curPlayer.GetMaxAtk(), "Def":curPlayer.GetDef(), "MaxHP":GameObj.GetMaxHP(curPlayer), |
| | | "Hit":curPlayer.GetHit(), "Miss":curPlayer.GetMiss()}
|
| | | return lordAttrDict
|
| | |
|
| | | #-------------------------------------------------------------------------------
|
| | | ## 设置玩家字典值, 存库
|