From ec388033c1dc1018f6ffc19b66d63f632aea6464 Mon Sep 17 00:00:00 2001 From: John Cote Date: Wed, 22 Jul 2015 10:47:02 -0400 Subject: [PATCH] Implement Fish Bingo Every Wednesday and Saturday! --- .../fishing/DistributedPondBingoManagerAI.py | 44 ++++++++++++------- toontown/hood/HoodAI.py | 6 +++ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/toontown/fishing/DistributedPondBingoManagerAI.py b/toontown/fishing/DistributedPondBingoManagerAI.py index 2abd4284..f5d6e3e4 100755 --- a/toontown/fishing/DistributedPondBingoManagerAI.py +++ b/toontown/fishing/DistributedPondBingoManagerAI.py @@ -8,10 +8,9 @@ from toontown.fishing.ThreewayBingo import ThreewayBingo from toontown.fishing.DiagonalBingo import DiagonalBingo from toontown.fishing.BlockoutBingo import BlockoutBingo from toontown.fishing.FourCornerBingo import FourCornerBingo -from otp.ai.MagicWordGlobal import * from direct.task import Task from direct.distributed.ClockDelta import * -import random +import random, datetime RequestCard = {} @@ -25,26 +24,44 @@ class DistributedPondBingoManagerAI(DistributedObjectAI): self.tileSeed = None self.typeId = None self.state = 'Off' + self.pond = None self.canCall = False self.shouldStop = False self.lastUpdate = globalClockDelta.getRealNetworkTime() self.cardId = 0 + def initTasks(self): + now = datetime.datetime.now() + weekday = now.weekday() + targetday = 2 # Wednesday + if weekday in (3, 4): + targetday = 5 + togo = targetday - weekday + if togo < 0: + togo += 7 + s = now + datetime.timedelta(days=togo) + start = datetime.datetime(s.year, s.month, s.day) + secs = max(0, (start - now).total_seconds()) + self.notify.debug('Today it\'s %d, so we wait for %d, togo: %d %d' % (weekday, targetday, togo, secs)) + taskMgr.doMethodLater(secs, DistributedPondBingoManagerAI.startTask, self.taskName('start'), extraArgs=[self]) + + def startTask(self): + self.notify.debug('Starting game') + + def stop(task): + self.notify.debug('Stopping game') + self.shouldStop = True + return task.done + + taskMgr.doMethodLater(24 * 60 * 60, stop, self.taskName('stop')) + self.createGame() + def setPondDoId(self, pondId): self.pond = self.air.doId2do[pondId] def getPondDoId(self): return self.pond.getDoId() - def updateGameState(self, gameState, cellId): - pass - - def setCardState(self, cardId, typeId, tileSeed, gameState): - pass - - def setState(self, state, timeStamp): - pass - def cardUpdate(self, cardId, cellId, genus, species): avId = self.air.getAvatarIdFromSender() spot = self.pond.hasToon(avId) @@ -70,9 +87,6 @@ class DistributedPondBingoManagerAI(DistributedObjectAI): elif result == BingoGlobals.UPDATE: self.sendGameStateUpdate(cellId) - def enableBingo(self): - createGame() - def d_enableBingo(self): self.sendUpdate('enableBingo', []) @@ -150,8 +164,6 @@ class DistributedPondBingoManagerAI(DistributedObjectAI): taskMgr.doMethodLater(5, DistributedPondBingoManagerAI.startWait, 'startWait%d' % self.getDoId(), [self]) taskMgr.remove('finishGame%d' % self.getDoId()) - - def finishGame(self): self.state = 'GameOver' self.sendStateUpdate() diff --git a/toontown/hood/HoodAI.py b/toontown/hood/HoodAI.py index 592e302f..8b0446ad 100755 --- a/toontown/hood/HoodAI.py +++ b/toontown/hood/HoodAI.py @@ -5,6 +5,7 @@ from toontown.fishing.DistributedFishingPondAI import DistributedFishingPondAI from toontown.hood import ZoneUtil from toontown.safezone import TreasureGlobals from toontown.safezone.DistributedFishingSpotAI import DistributedFishingSpotAI +from toontown.fishing.DistributedPondBingoManagerAI import DistributedPondBingoManagerAI from toontown.safezone.DistributedPartyGateAI import DistributedPartyGateAI from toontown.safezone.SZTreasurePlannerAI import SZTreasurePlannerAI from toontown.suit import DistributedSuitPlannerAI @@ -90,6 +91,11 @@ class HoodAI: fishingPond.generateWithRequired(zoneId) fishingPond.start() + fishingPond.bingoMgr = DistributedPondBingoManagerAI(simbase.air) + fishingPond.bingoMgr.setPondDoId(fishingPond.getDoId()) + fishingPond.bingoMgr.generateWithRequired(zoneId) + fishingPond.bingoMgr.initTasks() + fishingPonds.append(fishingPond) elif isinstance(dnaGroup, DNAVisGroup): zoneId = int(dnaGroup.getName().split(':')[0])