Ejemplo n.º 1
0
 def enterFinish(self):
     DistCogdoGameAI.enterFinish(self)
     self.ignoreAll()
     self._announceGameDoneTask = taskMgr.doMethodLater(
         Globals.Gameplay.FinishDurationSeconds, self.announceGameDone,
         self.taskName(DistCogdoFlyingGameAI.AnnounceGameDoneTimerTaskName),
         [])
Ejemplo n.º 2
0
 def enterFinish(self):
     DistCogdoGameAI.enterFinish(self)
     if self.numPickedUp > self.maxPickups:
         self.logSuspiciousEvent(
             0,
             'CogdoMazeGameAI: collected more memos than possible: %s, players: %s'
             % (self.numPickedUp, self.getToonIds()))
     time = globalClock.getRealTime() - self.getStartTime()
     adjustedTime = min(max(time - cogdoMazePerfectTime, 0),
                        cogdoMazeMaxTime)
     timeScore = 1 - adjustedTime / cogdoMazeMaxTime
     pickupScore = 0
     if self.maxPickups:
         pickupScore = float(self.numPickedUp) / self.maxPickups
     weightedPickup = pickupScore * cogdoMazePickupScoreRatio
     weightedTime = timeScore * cogdoMazeTimeScoreRatio
     score = min(weightedPickup + weightedTime, 1.0)
     self.air.writeServerEvent(
         'CogdoMazeGame', self._interior.toons,
         'Memos: %s/%s Weighted Memos: %s Time: %s Weighted Time: %s Score: %s'
         % (self.numPickedUp, self.maxPickups, weightedPickup, time,
            weightedTime, score))
     self.setScore(score)
     self._announceGameDoneTask = taskMgr.doMethodLater(
         Globals.FinishDurationSeconds, self.announceGameDone,
         self.taskName(DistCogdoMazeGameAI.AnnounceGameDoneTimerTaskName),
         [])
    def exitGame(self):
        DistCogdoGameAI.exitGame(self)
        for (toonId, token) in self._toonId2speedToken.iteritems():
            self._speedMonitor.removeNodepath(token)

        self._toonId2speedToken = {}
        self._removeTimeoutTimerTask()
        self._removeEndGameTimerTask()
Ejemplo n.º 4
0
 def handleToonWentSad(self, toonId):
     DistCogdoGameAI.handleToonWentSad(self, toonId)
     if toonId in self.toonsOnEndPlatform:
         self.toonsOnEndPlatform.remove(toonId)
     if toonId in self.toonsInWinState:
         self.toonsInWinState.remove(toonId)
     self.updateGotoWinState()
     self.updateGameFinished()
Ejemplo n.º 5
0
 def __init__(self, air, id):
     DistCogdoGameAI.__init__(self, air, id)
     self.toonsOnEndPlatform = []
     self.toonsInWinState = []
     self.eagleId2targetIds = {}
     self.pickups = []
     self.memoCount = 0
     self.toonId2buffList = {}
     self.broadcastedGotoWinState = False
     self.broadcastedGameFinished = False
     self._gameState = False
     if 0 and simbase.config.GetBool('schellgames-dev', True):
         self.accept('onCodeReload', self.__sgOnCodeReload)
    def enterGame(self):
        DistCogdoGameAI.enterGame(self)
        endTime = Globals.SecondsUntilTimeout - (globalClock.getRealTime() - self.getStartTime())
        self._countdownTimerTask = taskMgr.doMethodLater(endTime - Globals.SecondsForTimeAlert, self.handleCountdownTimer, self.taskName(DistCogdoMazeGameAI.CountdownTimerTaskName), [])
        self._startGameTimer()
        self._timeoutTimerTask = taskMgr.doMethodLater(endTime, self.handleEndGameTimerExpired, self.taskName(DistCogdoMazeGameAI.TimeoutTimerTaskName), [])
        if self.SkipCogdoGames:
            self.fsm.request('Finish')

        for toonId in self.getToonIds():
            toon = self.air.doId2do.get(toonId)
            if toon:
                token = self._speedMonitor.addNodepath(toon)
                self._toonId2speedToken[toonId] = token
                self._speedMonitor.setSpeedLimit(token, config.GetFloat('cogdo-maze-speed-limit', Globals.ToonRunSpeed * 1.1), Functor(self._toonOverSpeedLimit, toonId))
 def __init__(self, air, id):
     DistCogdoGameAI.__init__(self, air, id)
     self.doorIsOpen = False
     self.toonsInDoor = []
     self.pickups = []
     self.pickupsDropped = 0
     self.maxPickups = 0
     self.numPickedUp = 0
     self.suits = {}
     self.lastRequestId = None
     self.requestStartTime = globalClock.getFrameTime()
     self.requestCount = None
     self.jokeLastRequestId = None
     self.jokeRequestStartTime = globalClock.getFrameTime()
     self.jokeRequestCount = None
     if __debug__ and simbase.config.GetBool('schellgames-dev', True):
         self.accept('onCodeReload', self.__sgOnCodeReload)
Ejemplo n.º 8
0
    def exitGame(self):
        self._gameState = False
        DistCogdoGameAI.exitGame(self)
        if hasattr(self, '_gameTimerExpiredTask'):
            taskMgr.remove(self._gameTimerExpiredTask)
            del self._gameTimerExpiredTask
        taskMgr.removeTasksMatching(
            DistCogdoFlyingGameAI.InvulBuffRemoveTaskName % '*')
        taskMgr.removeTasksMatching(
            DistCogdoFlyingGameAI.EagleExitCooldownTaskName % '*')
        for toonId in self.toonId2buffList:
            del self.toonId2buffList[toonId][:]

        self.toonId2buffList.clear()
        self.eagleId2targetIds.clear()
        del self.pickups[:]
        del self.toonsOnEndPlatform[:]
        del self.toonsInWinState[:]
    def generate(self):
        DistCogdoGameAI.generate(self)
        mazeFactory = self.createMazeFactory(self.createRandomNumGen())
        waterCoolerList = []
        mazeModel = mazeFactory._loadAndBuildMazeModel()
        for waterCooler in mazeModel.findAllMatches('**/*waterCooler'):
            waterCoolerList.append((waterCooler.getPos(mazeModel), waterCooler.getHpr(mazeModel)))

        waterCoolerList.sort()
        baseNp = NodePath('base')
        rotNp = baseNp.attachNewNode('rot')
        childNp = rotNp.attachNewNode('child')
        childNp.setPos(*Globals.WaterCoolerTriggerOffset)
        self._waterCoolerPosList = []
        for (pos, hpr) in waterCoolerList:
            rotNp.setHpr(hpr)
            offset = childNp.getPos(baseNp)
            self._waterCoolerPosList.append(pos + offset)

        self._speedMonitor = SpeedMonitor('cogdoMazeGame-%s' % self.doId)
        self._toonId2speedToken = {}
 def delete(self):
     self.ignoreAll()
     self._speedMonitor.destroy()
     DistCogdoGameAI.delete(self)
 def exitFinish(self):
     DistCogdoGameAI.exitFinish(self)
     taskMgr.remove(self._announceGameDoneTask)
     del self._announceGameDoneTask
 def setExteriorZone(self, exteriorZone):
     DistCogdoGameAI.setExteriorZone(self, exteriorZone)
     self.difficulty = self.getDifficulty()
     self.createSuits()
 def handleToonWentSad(self, toonId):
     DistCogdoGameAI.handleToonWentSad(self, toonId)
     self._removeToonFromGame(toonId)
 def handleToonDisconnected(self, toonId):
     DistCogdoGameAI.handleToonDisconnected(self, toonId)
     self._removeToonFromGame(toonId)
Ejemplo n.º 15
0
 def delete(self):
     self.ignoreAll()
     DistCogdoGameAI.delete(self)
Ejemplo n.º 16
0
 def enterGame(self):
     DistCogdoGameAI.enterGame(self)
     self._gameState = True