| | |
| | | import SkillCommon
|
| | | import SkillShell
|
| | | import AttackCommon
|
| | | import FBLogic
|
| | |
|
| | | import random
|
| | | import time
|
| | |
| | |
|
| | | self.startTime = 0 # 开始时间戳,支持毫秒小数
|
| | | self.costTime = 0 # 单场战斗总耗时,支持毫秒小数
|
| | | |
| | | #玩家武将行动后击杀目标
|
| | | self.playerKillObjIDList = [] # [objID, ...]
|
| | | return
|
| | |
|
| | | def setTurn(self, mapID, funcLineID, turnMax, isNeedReport=False, msgDict={}):
|
| | |
| | | overLineupList = [] # 本回合已经结束行动的阵容列表 [(faction, num), ...], 所有阵容全部结束代表本回合结束
|
| | |
|
| | | turnNum = turnFight.turnNum
|
| | | unXiantaoCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCnt)
|
| | | GameWorld.DebugLog("unXiantaoCnt=%s,turnNum=%s,doMax=%s,actionIndex=%s,%s" % (unXiantaoCnt, turnNum, doMax, turnFight.actionIndex, turnFight.actionSortList))
|
| | | GameWorld.DebugLog("turnNum=%s,doMax=%s,actionIndex=%s,%s" % (turnNum, doMax, turnFight.actionIndex, turnFight.actionSortList))
|
| | | while doCnt < doMax and len(overLineupList) < len(turnFight.actionSortList):
|
| | | doCnt += 1
|
| | | turnNum = turnFight.turnNum
|
| | |
| | | if turnFight.actionIndex >= len(turnFight.actionSortList):
|
| | | turnFight.actionIndex = 0
|
| | |
|
| | | playerHeroAtk = False # 玩家阵容行动标记
|
| | | faction, num = turnFight.actionSortList[turnFight.actionIndex]
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | |
| | | continue
|
| | |
|
| | | if faction == Def_FactionA:
|
| | | if not PlayerControl.PayMoney(curPlayer, ShareDefine.TYPE_Price_Xiantao, fightPoint, isNotify=False):
|
| | | return
|
| | | playerHeroAtk = True
|
| | | |
| | | break
|
| | |
|
| | | turnFight.actionIndex += 1
|
| | |
| | | if turnFight.checkOverByKilled():
|
| | | break
|
| | |
|
| | | nowUnXiantaoCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCnt)
|
| | | if unXiantaoCnt != nowUnXiantaoCnt:
|
| | | # 玩家有消耗战锤则停止,一段段执行
|
| | | GameWorld.DebugLog("玩家有消耗战锤则停止,nowUnXiantaoCnt=%s" % (nowUnXiantaoCnt))
|
| | | if playerHeroAtk:
|
| | | # 玩家武将有行动则停止,一段段执行
|
| | | GameWorld.DebugLog("玩家武将有行动则停止!")
|
| | | break
|
| | |
|
| | | if turnFight.winFaction:
|
| | |
| | | GameWorld.DebugLog(" 自残: curTD=%s,tagID=%s,skillID=%s,hurtType=%s,hurtValue=%s,lostHP=%s,curHP=%s"
|
| | | % (curID, tagID, skillID, hurtType, hurtValue, lostHP, GameObj.GetHP(curObj)))
|
| | |
|
| | | if lostHP and curID != tagID:
|
| | | AddTurnFightXP(tagObj, __GetAddXP_Defender(tagObj, lostHP), "skillID:%s" % skillID)
|
| | | if lostHP > 0 and curID != tagID:
|
| | | addXP = IpyGameDataPY.GetFuncCfg("AngerXP", 4)
|
| | | AddTurnFightXP(tagObj, addXP, "skillID:%s" % skillID)
|
| | | return
|
| | |
|
| | | def __GetAddXP_Attack(attack, curSkill):
|
| | | ## 攻击方增加的XP值根据主动普攻技能获得
|
| | | if not curSkill:
|
| | | return 0
|
| | | if not SkillCommon.isTurnNormalAtkSkill(curSkill):
|
| | | return 0
|
| | | return IpyGameDataPY.GetFuncCfg("AngerXP", 3)
|
| | |
|
| | | def __GetAddXP_Defender(defender, lostHP):
|
| | | ## 掉血方增加的XP值根据掉血百分比获得
|
| | | if lostHP <= 0:
|
| | | return 0
|
| | | return IpyGameDataPY.GetFuncCfg("AngerXP", 4)
|
| | |
|
| | | def AddTurnFightXP(gameObj, addXP, reason=""):
|
| | | ## 回合战斗增加XP
|
| | |
| | |
|
| | | for useInfo in useSkillList:
|
| | | useSkill = useInfo[-1]
|
| | | skillID = useSkill.GetSkillID()
|
| | | #skillID = useSkill.GetSkillID()
|
| | | atkOK, tagObj = DoNPCUseSkill(curNPC, useSkill, tick)
|
| | | if atkOK:
|
| | | AddTurnFightXP(curNPC, __GetAddXP_Attack(curNPC, useSkill), "skillID:%s" % skillID)
|
| | | break
|
| | |
|
| | | curNPC.SetDict(ChConfig.Def_Obj_Dict_TurnBattleType, 0) # 无论攻击成功与否都重置战斗类型
|
| | |
| | | return tagNPC
|
| | | return
|
| | |
|
| | | def SetKilled(gameObj, killer=None):
|
| | | def SetTurnObjKilled(gameObj, killer=None):
|
| | | if not gameObj.GetDictByKey(ChConfig.Def_Obj_Dict_TurnFightPosInfo):
|
| | | #GameWorld.DebugLog("非回合战斗主体被击杀: curID=%s" % gameObj.GetID())
|
| | | return
|
| | |
|
| | | GameWorld.DebugLog(" %s 回合战斗主体被击杀: curID=%s" % (GetObjName(gameObj), gameObj.GetID()))
|
| | | objID = gameObj.GetID()
|
| | | GameWorld.DebugLog(" %s 回合战斗主体被击杀: curID=%s" % (GetObjName(gameObj), objID))
|
| | | gameObj.SetCurAction(IPY_GameWorld.laNPCDie)
|
| | | if GameObj.GetHP(gameObj) != 0:
|
| | | GameObj.SetHP(gameObj, 0) # 回合制死亡仅设置为0,实例暂时不回收
|
| | | gameObj.SetVisible(False)
|
| | |
|
| | | turnFight = GetTurnFightMgr().getNPCTurnFight(gameObj.GetID())
|
| | | if turnFight:
|
| | | turnFight = GetTurnFightMgr().getNPCTurnFight(objID)
|
| | | if not turnFight:
|
| | | return True
|
| | | clientPack = ChPyNetSendPack.tagMCTurnFightObjDead()
|
| | | clientPack.ObjID = gameObj.GetID()
|
| | | clientPack.ObjID = objID
|
| | | turnFight.addBatPack(clientPack)
|
| | |
|
| | | # 记录主动发起的玩家阵营击杀
|
| | | curPlayer = turnFight.curPlayer
|
| | | if killer and curPlayer and killer.GetDictByKey(ChConfig.Def_Obj_Dict_LineupPlayerID) == curPlayer.GetPlayerID():
|
| | | if objID not in turnFight.playerKillObjIDList:
|
| | | turnFight.playerKillObjIDList.append(objID)
|
| | | GameWorld.DebugLog("玩家单次击杀统计: %s" % turnFight.playerKillObjIDList)
|
| | | |
| | | return True
|
| | |
|
| | | def OnTurnfightAttackSuccess(curObj, tagObj, curSkill):
|
| | | ## 回合战斗攻击成功额外处理,AttackResult之前,一般处理技能相关
|
| | | if curObj.GetGameObjType() != IPY_GameWorld.gotNPC:
|
| | | return
|
| | | if not curObj.GetDictByKey(ChConfig.Def_Obj_Dict_TurnFightPosInfo):
|
| | | return
|
| | | |
| | | objID = curObj.GetID()
|
| | | turnFight = GetTurnFightMgr().getNPCTurnFight(objID)
|
| | | if not turnFight:
|
| | | return
|
| | | |
| | | skillID = curSkill.GetSkillID() if curSkill else 0
|
| | | isXP = SkillCommon.isXPSkill(curSkill)
|
| | | if isXP:
|
| | | GameObj.SetXP(curObj, 0)
|
| | | elif curSkill:
|
| | | if SkillCommon.isTurnNormalAtkSkill(curSkill):
|
| | | addXP = IpyGameDataPY.GetFuncCfg("AngerXP", 3)
|
| | | AddTurnFightXP(curObj, addXP, "skillID:%s" % skillID)
|
| | | |
| | | curPlayer = turnFight.curPlayer
|
| | | # 仅主动发起玩家阵容触发
|
| | | if curPlayer and curObj.GetDictByKey(ChConfig.Def_Obj_Dict_LineupPlayerID) == curPlayer.GetPlayerID():
|
| | | FBLogic.OnPlayerLineupAttackSuccess(curPlayer, curObj, tagObj, curSkill, turnFight.mapID, turnFight.funcLineID)
|
| | | |
| | | return
|
| | |
|
| | | def OnTurnfightAttackResult(curObj, tagObj, curSkill):
|
| | | ## 回合战斗攻击结果额外处理,AttackResult 之后,一般处理击杀结算相关
|
| | | if curObj.GetGameObjType() != IPY_GameWorld.gotNPC:
|
| | | return
|
| | | if not curObj.GetDictByKey(ChConfig.Def_Obj_Dict_TurnFightPosInfo):
|
| | | return
|
| | | |
| | | objID = curObj.GetID()
|
| | | turnFight = GetTurnFightMgr().getNPCTurnFight(objID)
|
| | | if not turnFight:
|
| | | return
|
| | | |
| | | curPlayer = turnFight.curPlayer
|
| | | # 仅主动发起玩家阵容触发
|
| | | if curPlayer and curObj.GetDictByKey(ChConfig.Def_Obj_Dict_LineupPlayerID) == curPlayer.GetPlayerID():
|
| | | FBLogic.OnPlayerLineupAttackResult(curPlayer, curObj, tagObj, curSkill, turnFight.mapID, turnFight.funcLineID)
|
| | | |
| | | turnFight.playerKillObjIDList = []
|
| | | return
|
| | |
|
| | | def OnTurnAllOver(guid):
|
| | | ## 所有回合已经全部执行完毕
|
| | | GameWorld.DebugLog("所有回合结束")
|