#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package GameWorldLogic.FBProcess.GameLogic_IceLode
|
#
|
# @todo:±ù¾§¿óÂö
|
# @author xdh
|
# @date 2017-9-14
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ±ù¾§¿óÂö
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2017-09-14 15:30"""
|
#-------------------------------------------------------------------------------
|
|
import FBCommon
|
import GameWorld
|
import IPY_GameWorld
|
import NPCCustomRefresh
|
import GameWorldProcess
|
import PlayerControl
|
import ShareDefine
|
import IpyGameDataPY
|
import PyGameData
|
import ChConfig
|
import PlayerActivity
|
import ItemCommon
|
import ItemControler
|
import EventReport
|
import EventShell
|
import ChPyNetSendPack
|
import NetPackCommon
|
import PlayerSuccess
|
import PlayerWeekParty
|
import PlayerActLogin
|
import BuffSkill
|
|
import random
|
import datetime
|
import time
|
import math
|
|
#---¸±±¾ÅäÖöÔÓ¦keyÖµ---
|
(
|
Def_PrepareTime, # ¸±±¾×¼±¸Ê±¼ä(Ãë)
|
Def_FightTime, # ½øÐÐʱ¼ä(Ãë)
|
Def_PickTime, # ʰȡʱ¼ä(Ãë)£¨°üº¬Í˳öʱ¼ä£©
|
Def_LeaveTime, # Í˳öʱ¼ä(Ãë)
|
Def_StarTime, #ÐǼ¶Ê±¼ä
|
) = range(5)
|
|
|
#---¸±±¾·ÖÏßÅäÖÃË÷ÒýÐÅÏ¢---
|
(
|
Def_RefreshMark, # Ë¢¹Ö±êʶµã
|
DL_NPCID, # NPCID
|
DL_TotalNPCCnt, # ÀÛ¼ÆË¢NPC×ܸöÊý
|
DL_ScreenMaxNPC, # ͬʱ´æÔÚNPCÊý
|
) = range(4)
|
|
|
#µ±Ç°¸±±¾µØÍ¼µÄ״̬
|
(
|
FB_Step_Open, # ¸±±¾¿ªÆô
|
FB_Step_Prepare, # ¸±±¾µÈ´ý
|
FB_Step_Fighting, # ¸±±¾½øÐÐÖÐ
|
FB_Step_PickItem, # ʰȡÎïÆ·ÖÐ
|
FB_Step_Over, # ¸±±¾½áÊø
|
FB_Step_Close, # ¸±±¾¹Ø±Õ
|
) = range(6)
|
|
|
FBPlayerDict_RemainNPCCnt = 'FBPlayerDict_RemainNPCCnt' # Ê£Óà¹ÖÊýÁ¿
|
FBPlayerDict_TotalPoint = 'FBPlayerDict_TotalPoint' # »ñµÃµÄ×ÜÅÆøÖµ
|
FBPlayerDict_CostTime = 'FBPlayerDict_CostTime' #ͨ¹ØÊ±¼ä
|
FBPlayerDict_TotalExp = 'FBPlayerDict_TotalExp' # »ñµÃµÄ×ܾÑé
|
FBPlayerDict_TotalExpPoint = 'FBPlayerDict_TotalExpPoint' # »ñµÃµÄ×ܾÑéµã
|
FBPlayerDict_FBStar = 'FBPlayerDict_FBStar' # µ±Ç°ÐǼ¶
|
|
|
|
##---»ñµÃ¸±±¾·ÖÏßÅäÖÃ---
|
# @param None
|
# @return ÅäÖÃÐÅÏ¢
|
def GetIceLodeNPCCfg():
|
lineID = FBCommon.GetFBPropertyMark()
|
return FBCommon.GetFBLineRefreshNPC(GameWorld.GetMap().GetMapID(), lineID)
|
|
def GetPointByNPCID(npcid):
|
'''ͨ¹ýNPCID»ñÈ¡¶ÔÓ¦µÄ»ý·Ö'''
|
npcPointDict = IpyGameDataPY.GetFuncEvalCfg('IceLodeNeedPoint', 2, {})
|
|
return npcPointDict.get(npcid, 0)
|
|
|
## OnDay´¦Àí
|
# @param curPlayer
|
# @return None
|
def OnFBPlayerOnDay(curPlayer):
|
if curPlayer.GetMapID() == ChConfig.Def_FBMapID_IceLode:
|
#Íæ¼Ò»¹ÔÚ¸±±¾ÖУ¬µÈÕâ´Î¸±±¾½áÊø£¬ÒÔ×îеÄ×ÜÐǼ¶¸ø·¢½±Àø
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeIsInFBOnDay, 1)
|
return
|
|
#²¹·¢½±Àø
|
CheckIceLodeStarAwardMail(curPlayer)
|
return
|
|
def OnFBPlayerOnLogin(curPlayer):
|
isInFBOnDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeIsInFBOnDay)
|
if isInFBOnDay and curPlayer.GetMapID() != ChConfig.Def_FBMapID_IceLode: #ÔÚ¸±±¾Àï¹ýÌ죬¸±±¾½áÊøºóÔÙ²¹·¢½±Àø
|
if CheckIceLodeStarAwardMail(curPlayer):
|
return
|
starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
|
if not lineList:
|
__RandomLine(curPlayer, lineList)
|
SyncIceLoddInfo(curPlayer)
|
return
|
|
def __RandomLine(curPlayer, oldlineList):
|
# Ëæ»ú½ñÈÕÍæ·¨
|
maxCnt, randomCnt = IpyGameDataPY.GetFuncEvalCfg('IceLodeCfg', 2)
|
lineList = range(maxCnt)
|
newlineList = list(set(lineList) - set(oldlineList))
|
if len(newlineList) < randomCnt:
|
random.shuffle(oldlineList)
|
newlineList += oldlineList[:randomCnt-len(newlineList)]
|
else:
|
random.shuffle(newlineList)
|
newlineList = newlineList[:randomCnt]
|
#random.shuffle(lineList)
|
for lineID in lineList:
|
GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_IceLoadLineID, lineID, 1 if lineID in newlineList else 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeDayLV, curPlayer.GetLV())
|
GameWorld.DebugLog(' Ëæ»ú±ù¾§¿óÂö½ñÈÕÍæ·¨ oldlineList=%s, newlineList =%s'%(oldlineList, newlineList), curPlayer.GetID())
|
return
|
|
## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param mapID µØÍ¼ID
|
# @param lineID Ïß·id
|
# @param tick ʱ¼ä´Á
|
# @return ²¼¶ûÖµ
|
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
|
starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
|
if lineID not in lineList:
|
GameWorld.DebugLog('±ù¾§¿óÂö½ñÈÕûÓиÃÏß· lineID=%s,lineList=%s'%(lineID, lineList))
|
return False
|
return True
|
|
|
|
##¸±±¾Íæ¼Ò½øÈëµã
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param mapID µØÍ¼ID
|
# @param lineId ·ÖÏßID
|
# @param ipyEnterPosInfo ¹¦ÄÜÏß·IPYÅäÖÃ×ø±êÐÅÏ¢
|
# @param tick ʱ¼ä´Á
|
# @return posX, posY, Ëæ»ú°ë¾¶(¿ÉÑ¡)
|
def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
|
return ipyEnterPosInfo
|
|
|
##²éѯÊÇ·ñ¿ÉÒÔ½øÈëµØÍ¼
|
# @param ask:ÇëÇó½á¹¹Ìå(IPY_BMChangeMapAsk)
|
# @param tick:ʱ¼ä´Á
|
# @return IPY_GameWorld.cme ö¾Ù
|
def OnChangeMapAsk(ask, tick):
|
return IPY_GameWorld.cmeAccept
|
|
|
## ½ø¸±±¾
|
# @param curPlayer
|
# @param tick
|
# @return None
|
def DoEnterFB(curPlayer, tick):
|
PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default * 2)
|
playerID = curPlayer.GetPlayerID()
|
mapID = GameWorld.GetGameWorld().GetMapID()
|
gameFB = GameWorld.GetGameFB()
|
lineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ReqFBFuncLine)
|
GameWorld.DebugLog("DoEnterFB...lineID=%s"%lineID, playerID)
|
hadDelTicket = FBCommon.GetHadDelTicket(curPlayer)
|
if not hadDelTicket:
|
PyGameData.g_fbPickUpItemDict.pop(playerID, 0)
|
GameWorld.DebugLog("DoEnterFB ¿Û³ýÈ볡ȯ£¬ÖØÖÃÐÅÏ¢£¡")
|
delResult = FBCommon.DelFBEnterTicket(curPlayer, mapID)
|
isOK = delResult[0]
|
#hasBind = delResult[1]
|
if not isOK:
|
PlayerControl.PlayerLeaveFB(curPlayer)
|
return
|
#ÐǼ¶Îª0ÔòÃâ·Ñ,·ñÔòÊÕÇ®
|
curStar = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, False, [mapID])
|
if curStar:
|
costGold = IpyGameDataPY.GetFuncCfg('IceLodeCfg')
|
if costGold:
|
costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costGold)
|
if not costMoneyList:
|
GameWorld.Log('Ç®²»¹» lineID=%s,costGold=%s'%(lineID, costGold))
|
PlayerControl.PlayerLeaveFB(curPlayer)
|
return
|
for moneyType, moneyNum in costMoneyList:
|
PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_BuyFBCnt, {"MapID":mapID, 'lineID':lineID})
|
|
FBCommon.SetFBPropertyMark(lineID)
|
FBCommon.SetHadDelTicket(curPlayer)
|
FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_IceLode)
|
FBCommon.SetFBStep(FB_Step_Prepare, tick)
|
EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_IceLode, 0, ChConfig.CME_Log_Start)
|
|
fbStep = gameFB.GetFBStep()
|
if fbStep <= FB_Step_Prepare:
|
mapID = GameWorld.GetMap().GetMapID()
|
notify_tick = FBCommon.GetFBLineStepTime(mapID)[Def_PrepareTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttAddUpTime, 0, max(notify_tick, 0), True)
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttWaitStart, 0, max(notify_tick, 0), True)
|
|
elif fbStep == FB_Step_Fighting:
|
mapID = GameWorld.GetMap().GetMapID()
|
notify_tick = FBCommon.GetFBLineStepTime(mapID)[Def_FightTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True)
|
__UpdIceLoadFBStar(tick, True, curPlayer)
|
DoFBHelp(curPlayer, tick)
|
return
|
|
##Íæ¼ÒÍ˳ö¸±±¾
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param tick ʱ¼ä´Á
|
# @return ÎÞÒâÒå
|
def DoExitFB(curPlayer, tick):
|
PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default)
|
return
|
|
##Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param tick ʱ¼ä´Á
|
# @return ·µ»ØÖµÎÞÒâÒå
|
def DoPlayerLeaveFB(curPlayer, tick):
|
PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default)
|
return
|
|
##Íæ¼ÒÇл»µØÍ¼
|
def DoPlayerChangeMapLogic(curPlayer):
|
tick = GameWorld.GetGameWorld().GetTick()
|
for buffID in IpyGameDataPY.GetFuncEvalCfg('IceLodeSpecial', 2):
|
BuffSkill.DelBuffBySkillID(curPlayer, buffID, tick)
|
return
|
|
def OnPickUpItem(curPlayer, curItem, tick):
|
return
|
mapItemType = curItem.GetType()
|
if mapItemType == ChConfig.Def_ItemType_Money:
|
return
|
playerID = curPlayer.GetID()
|
isEquip = ItemCommon.CheckItemIsEquip(curItem)
|
jsonItem = ItemCommon.GetJsonItem(curItem)
|
if playerID in PyGameData.g_fbPickUpItemDict:
|
if isEquip:
|
PyGameData.g_fbPickUpItemDict[playerID].append(jsonItem)
|
else:
|
for itemInfo in PyGameData.g_fbPickUpItemDict[playerID]:
|
if itemInfo["ItemID"] == jsonItem["ItemID"] and itemInfo.get("IsBind") == jsonItem.get("IsBind"):
|
itemInfo["Count"] = itemInfo.get("Count", 1)+ jsonItem.get("Count", 1)
|
else:
|
PyGameData.g_fbPickUpItemDict[playerID] = [jsonItem]
|
|
isItemAllPickUp = (GameWorld.GetMapItemManager().GetMapItemCount() <= 1)
|
if isItemAllPickUp and GameWorld.GetGameFB().GetFBStep() == FB_Step_PickItem:
|
__DoIceLodeOver(True)
|
|
|
#GameWorld.Log('PyGameData.g_fbPickUpItemDict=%s'%PyGameData.g_fbPickUpItemDict)
|
return
|
|
|
## »ñµÃ¸±±¾°ïÖúÐÅÏ¢
|
# @param curPlayer µ±Ç°Íæ¼Ò£¨±»Í¨Öª¶ÔÏó£©
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
def DoFBHelp(curPlayer, tick):
|
gameFB = GameWorld.GetGameFB()
|
|
# »ñµÃ¸±±¾ÐÅÏ¢
|
star = gameFB.GetGameFBDictByKey(FBPlayerDict_FBStar)
|
lineID = FBCommon.GetFBPropertyMark()
|
#¸±±¾°ïÖú
|
helpDict = {FBCommon.Help_grade:star, FBCommon.Help_lineID:lineID}
|
GameWorld.DebugLog("DoFBHelp %s" % str(helpDict))
|
FBCommon.Notify_FBHelp(curPlayer, helpDict)
|
return
|
|
|
##---¸±±¾×ÜÂß¼¼ÆÊ±Æ÷---
|
# @param tick:ʱ¼ä´Á
|
# @return ÎÞÒâÒå
|
# @remarks ¸±±¾×ÜÂß¼¼ÆÊ±Æ÷
|
def OnProcess(tick):
|
fbStep = GameWorld.GetGameFB().GetFBStep()
|
|
# ¸±±¾×¼±¸
|
if fbStep == FB_Step_Prepare:
|
__DoLogic_FB_Prepare(tick)
|
# ¸±±¾½øÐÐÖÐ
|
elif fbStep == FB_Step_Fighting:
|
__DoLogic_FB_Fighting(tick)
|
__UpdIceLoadFBStar(tick)
|
# ¸±±¾Ê°È¡ÖÐ
|
elif fbStep == FB_Step_PickItem:
|
__DoLogic_FB_PickItem(tick)
|
# ¸±±¾½áÊø
|
elif fbStep == FB_Step_Over:
|
__DoLogic_FB_Over(tick)
|
|
return
|
|
|
## ¸üе±Ç°¸±±¾ÐǼ¶
|
def __UpdIceLoadFBStar(tick, isEnter=False, curPlayer=None):
|
gameFB = GameWorld.GetGameFB()
|
curStar = gameFB.GetGameFBDictByKey(FBPlayerDict_FBStar)
|
if curStar == 1:
|
return curStar
|
|
mapID = GameWorld.GetMap().GetMapID()
|
useSecond = int(math.ceil((tick - gameFB.GetFBStepTick()) / 1000.0))
|
icelodeTimeCfg = FBCommon.GetFBLineStepTime(mapID)
|
starTimeList = icelodeTimeCfg[Def_StarTime]
|
diffSecond = 0
|
updStar = 1 # ĬÈÏÖÁÉÙ1ÐÇ
|
for star, starTime in enumerate(starTimeList, 2):
|
if useSecond <= starTime:
|
updStar = star
|
diffSecond = starTime-useSecond
|
|
if curStar == updStar and not isEnter:
|
return curStar
|
|
gameFB.SetGameFBDict(FBPlayerDict_FBStar, updStar)
|
|
GameWorld.DebugLog("__UpdFBStar useSecond=%s,curStar=%s,updStar=%s, diffSecond=%s"
|
% (useSecond, curStar, updStar, diffSecond))
|
|
if curPlayer:
|
DoFBHelp(curPlayer, tick)
|
if updStar != 1:
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttFlagTake, 0, diffSecond * 1000, True)
|
else:
|
playerManager = GameWorld.GetMapCopyPlayerManager()
|
for index in xrange(playerManager.GetPlayerCount()):
|
curPlayer = playerManager.GetPlayerByIndex(index)
|
if not curPlayer:
|
continue
|
DoFBHelp(curPlayer, tick)
|
if updStar != 1:
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttFlagTake, 0, diffSecond * 1000, True)
|
|
|
return updStar
|
|
## ¸±±¾×¼±¸Âß¼
|
# @param tick:ʱ¼ä´Á
|
# @return ÎÞÒâÒå
|
def __DoLogic_FB_Prepare(tick):
|
gameFB = GameWorld.GetGameFB()
|
mapID = GameWorld.GetMap().GetMapID()
|
stepTimeCfg = FBCommon.GetFBLineStepTime(mapID)
|
# ¼ä¸ôδµ½
|
if tick - gameFB.GetFBStepTick() < stepTimeCfg[Def_PrepareTime] * 1000:
|
return
|
|
# ÉèÖÿªÊ¼Ë¢¹Ö
|
npcCnt = 0
|
npcCfg = GetIceLodeNPCCfg()
|
for npcInfo in npcCfg:
|
npcid = npcInfo[DL_NPCID]
|
maxCnt = npcInfo[DL_ScreenMaxNPC]
|
totalMaxCnt = npcInfo[DL_TotalNPCCnt]
|
NPCCustomRefresh.SetNPCRefresh(npcInfo[Def_RefreshMark], [npcid], maxCnt, totalMaxCnt)
|
npcCnt += totalMaxCnt
|
NPCCustomRefresh.ProcessAllNPCRefresh(tick) # Á¢¼´³ö·¢Ò»´Î±êʶµãË¢ÐÂ
|
gameFB.SetGameFBDict(FBPlayerDict_RemainNPCCnt, npcCnt)
|
GameWorld.DebugLog('ÉèÖÿªÊ¼Ë¢¹Ö remainNPCCnt=%s'%npcCnt)
|
# ¸±±¾¿ªÊ¼
|
FBCommon.SetFBStep(FB_Step_Fighting, tick)
|
FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttTowerTake, stepTimeCfg[Def_FightTime] * 1000)
|
return
|
|
|
## ¸±±¾½øÐÐÖÐ
|
# @param tick:ʱ¼ä´Á
|
# @return ÎÞÒâÒå
|
def __DoLogic_FB_Fighting(tick):
|
# ¼ä¸ôδµ½
|
mapID = GameWorld.GetMap().GetMapID()
|
if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_FightTime] * 1000:
|
return
|
|
__DoIceLodeOver(False)
|
return
|
|
## ¸±±¾Ê°È¡
|
# @param tick:ʱ¼ä´Á
|
# @return ÎÞÒâÒå
|
def __DoLogic_FB_PickItem(tick):
|
# ¼ä¸ôδµ½
|
mapID = GameWorld.GetMap().GetMapID()
|
if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_PickTime] * 1000:
|
return
|
|
#¸±±¾¹Ø±Õ
|
GameWorldProcess.CloseFB(tick)
|
FBCommon.SetFBStep(FB_Step_Close, tick)
|
return
|
|
|
##¸±±¾¹Ø±ÕÖÐ
|
# @param tick:ʱ¼ä´Á
|
# @return ÎÞÒâÒå
|
# @remarks ¸±±¾¹Ø±ÕÖÐ
|
def __DoLogic_FB_Over(tick):
|
|
# ¼ä¸ôδµ½
|
mapID = GameWorld.GetMap().GetMapID()
|
if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_LeaveTime] * 1000:
|
return
|
|
#¸±±¾¹Ø±Õ
|
GameWorldProcess.CloseFB(tick)
|
FBCommon.SetFBStep(FB_Step_Close, tick)
|
return
|
|
## »ñµÃ¾Ñé
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @param addExp »ñµÃµÄ¾Ñé
|
# @param expViewType ¾ÑéÀàÐÍ
|
# @return True or False
|
def OnGetExp(curPlayer, addExp, expViewType):
|
|
if expViewType != ShareDefine.Def_ViewExpType_KillNPC:
|
return
|
|
playerID = curPlayer.GetID()
|
gameFB = GameWorld.GetGameFB()
|
exp = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExp)
|
expPoint = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExpPoint)
|
totalExp = expPoint * ChConfig.Def_PerPointValue + exp
|
updTotalExp = totalExp + addExp
|
updExp = updTotalExp % ChConfig.Def_PerPointValue
|
updExpPoint = updTotalExp / ChConfig.Def_PerPointValue
|
gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_TotalExp, updExp)
|
gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_TotalExpPoint, updExpPoint)
|
|
|
GameWorld.DebugLog("OnGetExp() totalExp=%s,addExp=%s,updTotalExp=%s"
|
% (totalExp, addExp, updTotalExp), playerID)
|
|
return
|
|
## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼ÓÉÍâ²ã¾ö¶¨
|
# @param attacker ¹¥»÷·½
|
# @param defender ·ÀÊØ·½
|
# @return bool
|
def CheckCanAttackTagObjInFB(attacker, defender):
|
gameFB = GameWorld.GetGameFB()
|
if gameFB.GetFBStep() != FB_Step_Fighting:
|
return False
|
return True
|
|
def __OnKillNPC(curNPC, tick):
|
gameFB = GameWorld.GetGameFB()
|
npcid = curNPC.GetNPCID()
|
npcCfg = GetIceLodeNPCCfg()
|
isfbnpc = False
|
for npcInfo in npcCfg:
|
if npcid == npcInfo[DL_NPCID]:
|
isfbnpc = True
|
break
|
if not isfbnpc:
|
return
|
|
remainNPCCnt = max(0, gameFB.GetGameFBDictByKey(FBPlayerDict_RemainNPCCnt) - 1)
|
gameFB.SetGameFBDict(FBPlayerDict_RemainNPCCnt, remainNPCCnt)
|
GameWorld.DebugLog('__OnKillNPC remainNPCCnt=%s'%remainNPCCnt)
|
if remainNPCCnt <=0 or npcid in IpyGameDataPY.GetFuncEvalCfg('IceLodeSpecial'):
|
__DoIceLodeOver(True)
|
return
|
|
def DoFB_NPCDead(curNPC):
|
__OnKillNPC(curNPC, GameWorld.GetGameWorld().GetTick())
|
return
|
|
#def DoFB_Npc_KillNPC(attacker, curNPC, tick):
|
# GameWorld.Log('__OnKillNPC 1111111111')
|
# __OnKillNPC(attacker, curNPC, tick)
|
# return
|
|
## Ö´Ðи±±¾É±¹ÖÂß¼
|
# @param curPlayer ɱ¹ÖµÄÈË
|
# @param curNPC ±»É±µÄ¹Ö
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
#def DoFB_Player_KillNPC(curPlayer, curNPC, tick):
|
# GameWorld.Log('__OnKillNPC 2222222222')
|
# __OnKillNPC(curPlayer, curNPC, tick)
|
#
|
|
# addPoint = GetPointByNPCID(npcid)
|
# if not addPoint:
|
# return
|
# totalPoint = gameFB.GetGameFBDictByKey(FBPlayerDict_TotalPoint)
|
# maxPoint = IpyGameDataPY.GetFuncCfg('IceLodeNeedPoint')
|
# updPoint = min(totalPoint + addPoint, maxPoint)
|
# gameFB.SetGameFBDict(FBPlayerDict_TotalPoint, updPoint)
|
#
|
# if updPoint >= maxPoint:
|
# costTime = tick - GameWorld.GetGameFB().GetFBStepTick()
|
# gameFB.SetGameFBDict(FBPlayerDict_CostTime, costTime)
|
# FBCommon.SetFBStep(FB_Step_PickItem, tick)
|
# mapID = GameWorld.GetMap().GetMapID()
|
# curPlayer.Sync_TimeTick(ChConfig.tttPickupItem, 0, FBCommon.GetFBLineStepTime(mapID)[Def_PickTime] * 1000, True)
|
#
|
# FBCommon.ClearFBNPC()
|
# npcCfg = GetIceLodeNPCCfg()
|
# for npcInfo in npcCfg:
|
# NPCCustomRefresh.CloseNPCRefresh(npcInfo[Def_RefreshMark], tick)
|
#
|
# #__DoIceLodeOver(True)
|
|
#DoFBHelp(curPlayer, tick)
|
return
|
|
## ÊÇ·ñ¸±±¾¸´»î
|
# @param None
|
# @return ÊÇ·ñ¸±±¾¸´»î
|
def OnPlayerReborn():
|
return True
|
|
## ¸±±¾½áÊø´¦Àí
|
def __DoIceLodeOver(isPass):
|
gameFB = GameWorld.GetGameFB()
|
if gameFB.GetFBStep() == FB_Step_Over:
|
return
|
tick = GameWorld.GetGameWorld().GetTick()
|
curPlayer = None
|
playerManager = GameWorld.GetMapCopyPlayerManager()
|
if playerManager.GetPlayerCount() > 0:
|
curPlayer = playerManager.GetPlayerByIndex(0)
|
|
if not curPlayer:
|
GameWorldProcess.CloseFB(tick)
|
return
|
|
__UpdIceLoadFBStar(tick) # ½áËãǰ¸üÐÂÒ»´ÎÐǼ¶
|
playerID = curPlayer.GetPlayerID()
|
lineID = FBCommon.GetFBPropertyMark()
|
star = GameWorld.GetGameFB().GetGameFBDictByKey(FBPlayerDict_FBStar)
|
mapID = ChConfig.Def_FBMapID_IceLode
|
isInFBOnDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeIsInFBOnDay)
|
#¸üÐÂÐǼ¶
|
lastStar = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, False, [mapID])
|
if isPass and star > lastStar:
|
GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, star, False, [mapID])
|
FBCommon.Sync_FBPlayerFBInfoData(curPlayer, mapID) # ͬ²½ÐÅÏ¢
|
if not lastStar and not isInFBOnDay: #ÿÈջ
|
PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_IceLode)
|
PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_IceLode, 1)
|
PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_IceLode, 1)
|
|
if isInFBOnDay: #ÔÚ¸±±¾Àï¹ýÌ죬¸±±¾½áÊøºóÔÙ²¹·¢ÐǼ¶½±Àø
|
CheckIceLodeStarAwardMail(curPlayer)
|
# exp = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExp)
|
# expPoint = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExpPoint)
|
# totalExp = expPoint * ChConfig.Def_PerPointValue + exp
|
|
costTime = gameFB.GetGameFBDictByKey(FBPlayerDict_CostTime)
|
if not costTime:
|
costTime = tick - GameWorld.GetGameFB().GetFBStepTick()
|
#jsonItemList = PyGameData.g_fbPickUpItemDict.get(playerID, [])
|
overDict = {FBCommon.Over_isPass:int(isPass), FBCommon.Over_costTime:costTime}
|
if isPass:
|
itemList = FBCommon.GetFBLineReward(mapID, lineID)
|
# ¸øÎïÆ·
|
needSpace = len(itemList)
|
packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
|
if needSpace > packSpace:
|
PlayerControl.SendMailByKey('', [curPlayer.GetID()], itemList)
|
else:
|
for itemID, itemCount, isBind in itemList:
|
ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
|
|
jsonItemList = FBCommon.GetJsonItemList(itemList)
|
overDict[FBCommon.Over_itemInfo] = jsonItemList
|
EventShell.EventRespons_FBEvent(curPlayer, 'icelode')
|
PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_IceLode, 1)
|
|
# ֪ͨ½á¹û
|
__SendIceLodeOverInfo(curPlayer, overDict)
|
|
# ½øÈëÀ뿪½×¶Î
|
FBCommon.SetFBStep(FB_Step_Over, tick)
|
FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttLeaveMap, FBCommon.GetFBLineStepTime(mapID)[Def_LeaveTime] * 1000)
|
|
# Çå¹Ö£¬¹Ø±ÕË¢¹Ö
|
# FBCommon.ClearFBNPC()
|
# npcCfg = GetIceLodeNPCCfg()
|
# for npcInfo in npcCfg:
|
# NPCCustomRefresh.CloseNPCRefresh(npcInfo[Def_RefreshMark], tick)
|
|
return
|
|
## ·¢ËÍÌôÕ½½á¹ûÐÅÏ¢£¬É¨µ´½á¹ûͨÓÃ
|
def __SendIceLodeOverInfo(curPlayer, overDict):
|
overDict[FBCommon.Over_dataMapID] = ChConfig.Def_FBMapID_IceLode
|
GameWorld.DebugLog("__SendIceLodeOverInfo overDict=%s" % (str(overDict)), curPlayer.GetPlayerID())
|
|
FBCommon.Notify_FB_Over(curPlayer, overDict)
|
return
|
|
|
## ¸±±¾ÐÐΪ
|
# @param curPlayer Íæ¼Ò
|
# @param actionType ÐÐΪÀàÐÍ
|
# @param actionInfo ÐÐΪÐÅÏ¢
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
def DoFBAction(curPlayer, actionType, actionInfo, tick):
|
|
return
|
|
## ¿É·ñɨµ´
|
def OnPlayerFBSweepAsk(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx):
|
if curPlayer.GetMapID() == ChConfig.Def_FBMapID_IceLode:
|
GameWorld.DebugLog('±ù¾§¿óÂöɨµ´ ¸±±¾Àï²»ÄÜɨµ´ ')
|
return
|
#Õ½Á¦ÅжÏ
|
LVIpyData = PlayerControl.GetPlayerLVIpyData(curPlayer.GetLV())
|
reFightPower = 0 if not LVIpyData else LVIpyData.GetIceLodeFightPower() # µ±Ç°µÈ¼¶²Î¿¼Õ½Á¦
|
if PlayerControl.GetFightPower(curPlayer) < reFightPower:
|
GameWorld.DebugLog('±ù¾§¿óÂöɨµ´ Õ½Á¦²»×ã %s'%(reFightPower))
|
return
|
#vipÅжÏ
|
if curPlayer.GetVIPLv() < IpyGameDataPY.GetFuncCfg('IceLodeCfg', 5):
|
GameWorld.DebugLog('±ù¾§¿óÂöɨµ´ vip²»×ã ')
|
return
|
|
#Ç®
|
if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeHasSweep):
|
costMoney = IpyGameDataPY.GetFuncCfg('IceLodeCfg', 3)
|
else:
|
costMoney = 0
|
if costMoney:
|
costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney)
|
if not costMoneyList:
|
return
|
for moneyType, moneyNum in costMoneyList:
|
if not PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_FBSweep):
|
GameWorld.DebugLog("±ù¾§¿óÂöɨµ´ÏÉÓñ²»×ã!costGold=%s" % (costMoney))
|
return
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeHasSweep, 1)
|
|
SyncIceLoddInfo(curPlayer)
|
return True
|
|
## ɨµ´½á¹û
|
def OnPlayerFBSweepResult(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx):
|
itemList = IpyGameDataPY.GetFuncEvalCfg('IceLodeCfg', 4)
|
jsonItemList = FBCommon.GetJsonItemList(itemList)
|
needSpace = len(itemList)
|
if needSpace > ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace):
|
PlayerControl.SendMailByKey(0, [curPlayer.GetID()], itemList)
|
else:
|
for itemID, itemCnt, isBind in itemList:
|
ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])
|
#Ö±½Ó½«5ÌõÏßÐǼ¶¸ÄΪ3ÐÇ
|
addCnt = 0
|
starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
|
for lineid in lineList:
|
curStar = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineid, False, [mapID])
|
if curStar == 0:
|
addCnt += 1
|
GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineid, 3, False, [mapID])
|
PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_IceLode, addCnt)
|
PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_IceLode, addCnt)
|
PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_IceLode, addCnt)
|
PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_IceLode, len(lineList))
|
FBCommon.Sync_FBPlayerFBInfoData(curPlayer, mapID) # ͬ²½ÐÅÏ¢
|
# npcCountDict = {}
|
# iceLodeSweepDict = IpyGameDataPY.GetFuncEvalCfg('IceLodeSweep')
|
# for npcID, count in iceLodeSweepDict.items():
|
# npcCountDict[npcID] = count * sweepCnt
|
#
|
# exp_rate = PlayerControl.GetLimitExpRate(curPlayer, ChConfig.ExpRateLimitType_Sweep)
|
# jsonItemList, totalExp, totalMoney = NPCCommon.GiveKillNPCDropPrize(curPlayer, mapID, npcCountDict, exp_rate)
|
GameWorld.DebugLog("ɨµ´½±Àø: ´ÎÊý=%s,jsonItemList=%s" % (sweepCnt, jsonItemList))
|
overDict = {FBCommon.Over_isPass:1, FBCommon.Over_isSweep:1, FBCommon.Over_itemInfo:jsonItemList}
|
__SendIceLodeOverInfo(curPlayer, overDict)
|
for _ in xrange(sweepCnt):
|
EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_IceLode, 0, ChConfig.CME_Log_Start)
|
return True
|
|
|
def GetIceLodeStarAward(curPlayer, starIndex):
|
## ÁìÈ¡±ù¾§¿óÂöÐǼ¶½±Àø
|
ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('IceLodeStarAward', {'Index':starIndex}, True)
|
if not ipyDataList:
|
return
|
playerLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeDayLV)
|
#playerLV = curPlayer.GetLV()
|
awardList = []
|
needStar = 0
|
for ipyData in ipyDataList:
|
lvLimit = ipyData.GetLVLimit()
|
if lvLimit[0]<=playerLV <=lvLimit[1]:
|
awardList = ipyData.GetItemList()
|
needStar = ipyData.GetStar()
|
break
|
if not awardList:
|
GameWorld.Log(' ÁìÈ¡±ù¾§¿óÂöÐǼ¶½±Àø£¬Ã»ÕÒµ½½±Àø starIndex=%s,playerLV=%s'%(starIndex,playerLV), curPlayer.GetID())
|
return
|
awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeStarAwardRecord)
|
if awardRecord & pow(2, starIndex):
|
GameWorld.DebugLog('ÁìÈ¡±ù¾§¿óÂöÐǼ¶½±Àø£¬ ½±ÀøÒÑÁìÈ¡ starIndex=%s'%starIndex)
|
return
|
|
starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
|
if starCnt < needStar:
|
GameWorld.DebugLog('ÁìÈ¡±ù¾§¿óÂöÐǼ¶½±Àø£¬ ×ÜÐÇÊý²»×ãstarIndex=%s starCnt=%s£¬needStar=%s'%(starIndex,starCnt,needStar))
|
return
|
|
# ¼ì²é±³°ü
|
needSpace = len(awardList)
|
packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
|
if needSpace > packSpace:
|
PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
|
return
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeStarAwardRecord, awardRecord|pow(2, starIndex))
|
|
for itemID, itemCount, isBind in awardList:
|
ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
|
#֪ͨ
|
SyncIceLoddInfo(curPlayer)
|
return
|
|
def GetIceLodeAllStarCnt(curPlayer):
|
##»ñÈ¡µ±Ç°×ÜÐÇÊý
|
maxCnt, randomCnt = IpyGameDataPY.GetFuncEvalCfg('IceLodeCfg', 2)
|
starCnt = 0
|
lineList = []
|
for i in xrange(maxCnt):
|
if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_IceLoadLineID, i):
|
starCnt += GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, i, False, [ChConfig.Def_FBMapID_IceLode])
|
lineList.append(i)
|
if lineList and len(lineList) != randomCnt:
|
GameWorld.ErrLog(' ±ù¾§¿óÂö»ñÈ¡µ±Ç°×ÜÐÇÊý£¬µ±Ç°Ïß·ÊýÁ¿Òì³££¡lineList=%s'%lineList)
|
return starCnt, lineList[:randomCnt]
|
|
def CheckIceLodeStarAwardMail(curPlayer):
|
#Óʼþ²¹·¢Î´ÁìÈ¡ÐǼ¶½±Àø
|
serverTime = GameWorld.GetCurrentTime()
|
curDateTimeStr = "%d-%d-%d 00:00:00" % (serverTime.year, serverTime.month, serverTime.day)
|
curDateTime = datetime.datetime.strptime(curDateTimeStr, ChConfig.TYPE_Time_Format)
|
curDateTime = int(time.mktime(curDateTime.timetuple()))
|
lastCheckTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeLastCheckTime)
|
if lastCheckTime and lastCheckTime == curDateTime:
|
return
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeLastCheckTime, curDateTime)
|
|
itemList = []
|
mailStarList = []
|
awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeStarAwardRecord)
|
playerLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeDayLV)
|
starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
|
ipyMgr = IpyGameDataPY.IPY_Data()
|
newRecord = awardRecord
|
for i in xrange(ipyMgr.GetIceLodeStarAwardCount()):
|
ipyData = ipyMgr.GetIceLodeStarAwardByIndex(i)
|
starIndex = ipyData.GetIndex()
|
lvLimit = ipyData.GetLVLimit()
|
if lvLimit[0]<=playerLV <=lvLimit[1]:
|
if starCnt >= ipyData.GetStar() and not awardRecord & pow(2, starIndex):
|
itemList += ipyData.GetItemList()
|
newRecord |= pow(2, starIndex)
|
mailStarList.append(starIndex)
|
if itemList:
|
PlayerControl.SendMailByKey('IceLodeStarReward', [curPlayer.GetID()], itemList, detail=mailStarList)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeIsInFBOnDay, 0)
|
maxCnt, randomCnt = IpyGameDataPY.GetFuncEvalCfg('IceLodeCfg', 2)
|
for i in xrange(maxCnt):
|
GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, i, 0, False, [ChConfig.Def_FBMapID_IceLode])
|
FBCommon.Sync_FBPlayerFBInfoData(curPlayer, ChConfig.Def_FBMapID_IceLode) # ͬ²½ÐÅÏ¢
|
#ÖØÖÃÁì½±¼Ç¼
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeStarAwardRecord, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeHasSweep, 0)
|
#Ëæ»ú½ñÈÕÍæ·¨
|
__RandomLine(curPlayer, lineList)
|
#֪ͨ
|
SyncIceLoddInfo(curPlayer)
|
return True
|
|
def SyncIceLoddInfo(curPlayer):
|
starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
|
packdata = ChPyNetSendPack.tagMCIceLodeInfo()
|
packdata.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeStarAwardRecord)
|
packdata.DayLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeDayLV)
|
packdata.HasSweep = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeHasSweep)
|
packdata.LineList = lineList
|
packdata.Cnt = len(packdata.LineList)
|
NetPackCommon.SendFakePack(curPlayer, packdata)
|
return
|