| | |
| | | import PyDataManager
|
| | | import ChPyNetSendPack
|
| | | import PyGameDataStruct
|
| | | import PlayerCompensation
|
| | | import PlayerViewCache
|
| | | import PlayerDBGSEvent
|
| | | import PlayerControl
|
| | |
| | | # 物品实例额外属性名
|
| | | MineItemAttr_MoveSpeed = "MoveSpeed"
|
| | | MineItemAttr_EndTime = "EndTime"
|
| | | MineItemAttr_HelpTick = "HelpTick"
|
| | |
|
| | | # 物品类型
|
| | | MineType_Normal = 0 # 常规物品
|
| | |
| | | # 不入库的属性
|
| | | setattr(mineItemData, MineItemAttr_EndTime, 0)
|
| | | setattr(mineItemData, MineItemAttr_MoveSpeed, 0)
|
| | | setattr(mineItemData, MineItemAttr_HelpTick, 0)
|
| | | return
|
| | |
|
| | | def GetMineItem(self, playerID, index):
|
| | |
| | | def DoMineAreaFuncOpen(curPlayer):
|
| | | ## 福地功能开启
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | mineItemMgr = PyDataManager.GetDBPyMineAreaItemManager()
|
| | | # 还没有福地物品数据,则刷新初始化
|
| | | if playerID not in mineItemMgr.playerMineItemDict:
|
| | | __DoMineItemRefresh(playerID, curPlayer)
|
| | | __DoMineItemRefresh(playerID, curPlayer)
|
| | | return
|
| | |
|
| | | def OnPlayerLogin(curPlayer):
|
| | |
| | | mineItemMgr.socialIDListDict[playerID] = socialIDList
|
| | | return socialIDList
|
| | |
|
| | | def OnTurnFightRequest(curPlayer, mapID, funcLineID, tagPlayerID, valueList):
|
| | | |
| | | # 摇人帮助请求、自己驱赶请求
|
| | | if funcLineID == 0 or funcLineID == 1:
|
| | | return __OnMineHelpRequest(curPlayer, mapID, funcLineID, tagPlayerID, valueList)
|
| | | |
| | | return
|
| | |
|
| | | def OnTurnFightOver(curPlayer, mapID, funcLineID, tagPlayerID, valueList, fightRet, awardItemList):
|
| | | |
| | | # 摇人帮助结果、自己驱赶结果
|
| | | if funcLineID == 0 or funcLineID == 1:
|
| | | return __OnMineHelpOver(curPlayer, mapID, funcLineID, tagPlayerID, valueList, fightRet, awardItemList)
|
| | | |
| | | return
|
| | |
|
| | | def __OnMineHelpRequest(curPlayer, mapID, funcLineID, tagPlayerID, valueList):
|
| | | # 摇人帮助请求、自己驱赶请求
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | if not valueList or len(valueList) < 2:
|
| | | GameWorld.DebugLog("没有指定valueList!", playerID)
|
| | | return
|
| | | areaPlayerID = valueList[0]
|
| | | itemIndex = valueList[1]
|
| | | |
| | | if funcLineID == 0:
|
| | | if playerID == areaPlayerID:
|
| | | GameWorld.DebugLog("不能帮助自己! areaPlayerID=%s" % areaPlayerID, playerID)
|
| | | return
|
| | | elif funcLineID == 1:
|
| | | if playerID != areaPlayerID:
|
| | | GameWorld.DebugLog("不是自己的福地,无法自己驱赶! areaPlayerID=%s" % areaPlayerID, playerID)
|
| | | return
|
| | | |
| | | mineItemMgr = PyDataManager.GetDBPyMineAreaItemManager()
|
| | | mineItemData = mineItemMgr.GetMineItem(areaPlayerID, itemIndex)
|
| | | mineID = mineItemData.MineID
|
| | | if not mineID:
|
| | | # 该资源已消失
|
| | | PlayerControl.NotifyCode(curPlayer, "MineDisappeared")
|
| | | return
|
| | | |
| | | robPlayerID = mineItemData.RobPlayerID
|
| | | if not robPlayerID or robPlayerID != tagPlayerID:
|
| | | # 当前资源无争夺者或已被其他玩家完成
|
| | | PlayerControl.NotifyCode(curPlayer, "MineHelpFinished")
|
| | | return
|
| | | |
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | helpTick = getattr(mineItemData, MineItemAttr_HelpTick)
|
| | | if helpTick and tick - helpTick < 10000:
|
| | | GameWorld.DebugLog("已经有其他人在帮助中!", playerID)
|
| | | return
|
| | | setattr(mineItemData, MineItemAttr_HelpTick, tick)
|
| | | |
| | | return True
|
| | |
|
| | | def __OnMineHelpOver(curPlayer, mapID, funcLineID, tagPlayerID, valueList, fightRet, awardItemList):
|
| | | # 摇人帮助结果、自己驱赶结果
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | helpPlayerName = curPlayer.GetName()
|
| | | |
| | | areaPlayerID = valueList[0]
|
| | | itemIndex = valueList[1]
|
| | | isWin = fightRet[0]
|
| | | |
| | | mineItemMgr = PyDataManager.GetDBPyMineAreaItemManager()
|
| | | mineItemData = mineItemMgr.GetMineItem(areaPlayerID, itemIndex)
|
| | | setattr(mineItemData, MineItemAttr_HelpTick, 0)
|
| | | |
| | | if not isWin:
|
| | | #GameWorld.DebugLog("帮助失败")
|
| | | return
|
| | | |
| | | robPlayerID = mineItemData.RobPlayerID
|
| | | # 赶走抢夺者
|
| | | if robPlayerID and robPlayerID == tagPlayerID:
|
| | | __DoCancelPull(tagPlayerID, areaPlayerID, itemIndex)
|
| | | |
| | | # 帮助的发奖
|
| | | if funcLineID == 0:
|
| | | robCacheDict = PlayerViewCache.GetCachePropDataDict(PlayerViewCache.FindViewCache(tagPlayerID))
|
| | | robPlayerName = robCacheDict.get("Name", "")
|
| | | |
| | | areaCacheDict = PlayerViewCache.GetCachePropDataDict(PlayerViewCache.FindViewCache(areaPlayerID))
|
| | | areaPlayerName = areaCacheDict.get("Name", "")
|
| | | |
| | | # 邮件发放奖励
|
| | | PlayerCompensation.SendMailByKey("MineHelpAward", [playerID], awardItemList, [areaPlayerName, robPlayerName])
|
| | | |
| | | # 通知福地玩家
|
| | | PlayerCompensation.SendMailByKey("MineHelpReqOK", [areaPlayerID], [], [helpPlayerName, robPlayerName])
|
| | | |
| | | # 自己驱赶的
|
| | | elif funcLineID == 1:
|
| | | # 自己驱赶的,不用再通知地图,直接return
|
| | | return
|
| | | |
| | | return True
|
| | |
|
| | | def MapServer_MineArea(curPlayer, msgList):
|
| | | mapID = curPlayer.GetRealMapID()
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
| | |
|
| | | # 拉物品
|
| | | if msgType == "Pull":
|
| | | __DoPullItem(playerID, curPlayer, dataMsg)
|
| | | ret = __DoPullItem(playerID, curPlayer, dataMsg)
|
| | |
|
| | | # 刷新福地物品
|
| | | elif msgType == "MineItemRefresh":
|
| | |
| | | __RefreshMineItemSpeed(mineItemData, True)
|
| | |
|
| | | SyncMineAreaItemInfo(areaPlayerID, [itemIndex], notifyPlayerIDListEx)
|
| | | return
|
| | | return True
|
| | |
|
| | | def __DoCancelPull(playerID, areaPlayerID, itemIndex):
|
| | | ## 取消拉取
|