| | |
| | | import NetPackCommon
|
| | | import IpyGameDataPY
|
| | | import ItemControler
|
| | | import PlayerSuccess
|
| | | import ChPyNetSendPack
|
| | | import PlayerActivity
|
| | | import PlayerControl
|
| | | import GameFuncComm
|
| | | import PlayerGubao
|
| | | import ShareDefine
|
| | | import ObjPool
|
| | | import PlayerTask
|
| | |
|
| | | import time
|
| | | import math
|
| | |
| | | if campID != cID:
|
| | | atWorkCnt += wCnt
|
| | |
|
| | | workersTotal = 0 # 总工人数
|
| | | workerState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldRushWorkerState)
|
| | | for index in range(ipyDataMgr.GetGoldRushWorkerCount()):
|
| | | ipyData = ipyDataMgr.GetGoldRushWorkerByIndex(index)
|
| | | workerID = ipyData.GetWorkerID()
|
| | | if workerState & pow(2, workerID):
|
| | | workersTotal += 1
|
| | | workersTotal = GetWorkerTotal(curPlayer) # 总工人数
|
| | | idleWorkers = workersTotal - atWorkCnt # 空闲工人数
|
| | | if idleWorkers <= 0:
|
| | | GameWorld.DebugLog("没有空闲工人,无法开始淘金! atWorkCnt=%s >= %s" % (atWorkCnt, workersTotal))
|
| | |
| | | campInfo = SetCampInfo(curPlayer, campID, refreshCnt, goldID, updWorkerCnt)
|
| | | GameWorld.DebugLog(" updWorkerCnt=%s,realNeedSeconds=%s,endTime=%s,campInfo=%s"
|
| | | % (updWorkerCnt, realNeedSeconds, GameWorld.ChangeTimeNumToStr(endTime), campInfo))
|
| | | |
| | | PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_GoldRush, 1)
|
| | | PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_OSAGoldRush, 1)
|
| | | return
|
| | |
|
| | | def GetWorkerTotal(curPlayer):
|
| | | ## 获取监工总数
|
| | | workersTotal = 0 # 总工人数
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | workerState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldRushWorkerState)
|
| | | for index in range(ipyDataMgr.GetGoldRushWorkerCount()):
|
| | | ipyData = ipyDataMgr.GetGoldRushWorkerByIndex(index)
|
| | | workerID = ipyData.GetWorkerID()
|
| | | if workerState & pow(2, workerID):
|
| | | workersTotal += 1
|
| | | return workersTotal
|
| | |
|
| | | def __onGoldRushCancel(curPlayer, campID):
|
| | | ## 取消
|
| | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldRushWorkerState, workerState)
|
| | | GameWorld.DebugLog("解锁淘金监工: workerID=%s,workerState=%s" % (workerID, workerState))
|
| | | SyncGoldRushInfo(curPlayer)
|
| | | |
| | | PlayerTask.UpdTaskValue(curPlayer, ChConfig.TaskType_GoldRushWorkers)
|
| | | workersTotal = GetWorkerTotal(curPlayer)
|
| | | PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_OSAGoldRushWorkers, workersTotal)
|
| | | return
|
| | |
|
| | | #// B0 38 淘金仓库领奖 #tagCSGoldRushWarehouseAward
|
| | |
| | | return
|
| | |
|
| | | def SyncGoldRushInfo(curPlayer):
|
| | | clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCGoldRushInfo)
|
| | | clientPack = ChPyNetSendPack.tagSCGoldRushInfo()
|
| | | clientPack.CampState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldRushCampState)
|
| | | clientPack.WorkerState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldRushWorkerState)
|
| | | clientPack.PanningCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldRushCnt)
|
| | |
| | | return
|
| | |
|
| | | def SyncGoldCampInfo(curPlayer, syncCampIDList=None):
|
| | | poolMgr = ObjPool.GetPoolMgr()
|
| | | campList = []
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetGoldRushCampCount()):
|
| | |
| | | if syncCampIDList and campID not in syncCampIDList:
|
| | | continue
|
| | | refreshCnt, goldID, workerCnt = GetCampInfo(curPlayer, campID)
|
| | | camp = poolMgr.acquire(ChPyNetSendPack.tagSCGoldRushCamp)
|
| | | camp = ChPyNetSendPack.tagSCGoldRushCamp()
|
| | | camp.CampID = campID
|
| | | camp.GoldID = goldID
|
| | | camp.RefreshCnt = refreshCnt
|
| | |
| | | campList.append(camp)
|
| | | if not campList:
|
| | | return
|
| | | clientPack = poolMgr.acquire(ChPyNetSendPack.tagSCGoldRushCampInfo)
|
| | | clientPack = ChPyNetSendPack.tagSCGoldRushCampInfo()
|
| | | clientPack.CampList = campList
|
| | | clientPack.CampCnt = len(clientPack.CampList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|