Implement Fish Bingo

Every Wednesday and Saturday!
This commit is contained in:
John Cote 2015-07-22 10:47:02 -04:00
parent d8381d214b
commit ec388033c1
2 changed files with 34 additions and 16 deletions

View file

@ -8,10 +8,9 @@ from toontown.fishing.ThreewayBingo import ThreewayBingo
from toontown.fishing.DiagonalBingo import DiagonalBingo from toontown.fishing.DiagonalBingo import DiagonalBingo
from toontown.fishing.BlockoutBingo import BlockoutBingo from toontown.fishing.BlockoutBingo import BlockoutBingo
from toontown.fishing.FourCornerBingo import FourCornerBingo from toontown.fishing.FourCornerBingo import FourCornerBingo
from otp.ai.MagicWordGlobal import *
from direct.task import Task from direct.task import Task
from direct.distributed.ClockDelta import * from direct.distributed.ClockDelta import *
import random import random, datetime
RequestCard = {} RequestCard = {}
@ -25,26 +24,44 @@ class DistributedPondBingoManagerAI(DistributedObjectAI):
self.tileSeed = None self.tileSeed = None
self.typeId = None self.typeId = None
self.state = 'Off' self.state = 'Off'
self.pond = None
self.canCall = False self.canCall = False
self.shouldStop = False self.shouldStop = False
self.lastUpdate = globalClockDelta.getRealNetworkTime() self.lastUpdate = globalClockDelta.getRealNetworkTime()
self.cardId = 0 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): def setPondDoId(self, pondId):
self.pond = self.air.doId2do[pondId] self.pond = self.air.doId2do[pondId]
def getPondDoId(self): def getPondDoId(self):
return self.pond.getDoId() 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): def cardUpdate(self, cardId, cellId, genus, species):
avId = self.air.getAvatarIdFromSender() avId = self.air.getAvatarIdFromSender()
spot = self.pond.hasToon(avId) spot = self.pond.hasToon(avId)
@ -70,9 +87,6 @@ class DistributedPondBingoManagerAI(DistributedObjectAI):
elif result == BingoGlobals.UPDATE: elif result == BingoGlobals.UPDATE:
self.sendGameStateUpdate(cellId) self.sendGameStateUpdate(cellId)
def enableBingo(self):
createGame()
def d_enableBingo(self): def d_enableBingo(self):
self.sendUpdate('enableBingo', []) self.sendUpdate('enableBingo', [])
@ -150,8 +164,6 @@ class DistributedPondBingoManagerAI(DistributedObjectAI):
taskMgr.doMethodLater(5, DistributedPondBingoManagerAI.startWait, 'startWait%d' % self.getDoId(), [self]) taskMgr.doMethodLater(5, DistributedPondBingoManagerAI.startWait, 'startWait%d' % self.getDoId(), [self])
taskMgr.remove('finishGame%d' % self.getDoId()) taskMgr.remove('finishGame%d' % self.getDoId())
def finishGame(self): def finishGame(self):
self.state = 'GameOver' self.state = 'GameOver'
self.sendStateUpdate() self.sendStateUpdate()

View file

@ -5,6 +5,7 @@ from toontown.fishing.DistributedFishingPondAI import DistributedFishingPondAI
from toontown.hood import ZoneUtil from toontown.hood import ZoneUtil
from toontown.safezone import TreasureGlobals from toontown.safezone import TreasureGlobals
from toontown.safezone.DistributedFishingSpotAI import DistributedFishingSpotAI from toontown.safezone.DistributedFishingSpotAI import DistributedFishingSpotAI
from toontown.fishing.DistributedPondBingoManagerAI import DistributedPondBingoManagerAI
from toontown.safezone.DistributedPartyGateAI import DistributedPartyGateAI from toontown.safezone.DistributedPartyGateAI import DistributedPartyGateAI
from toontown.safezone.SZTreasurePlannerAI import SZTreasurePlannerAI from toontown.safezone.SZTreasurePlannerAI import SZTreasurePlannerAI
from toontown.suit import DistributedSuitPlannerAI from toontown.suit import DistributedSuitPlannerAI
@ -90,6 +91,11 @@ class HoodAI:
fishingPond.generateWithRequired(zoneId) fishingPond.generateWithRequired(zoneId)
fishingPond.start() fishingPond.start()
fishingPond.bingoMgr = DistributedPondBingoManagerAI(simbase.air)
fishingPond.bingoMgr.setPondDoId(fishingPond.getDoId())
fishingPond.bingoMgr.generateWithRequired(zoneId)
fishingPond.bingoMgr.initTasks()
fishingPonds.append(fishingPond) fishingPonds.append(fishingPond)
elif isinstance(dnaGroup, DNAVisGroup): elif isinstance(dnaGroup, DNAVisGroup):
zoneId = int(dnaGroup.getName().split(':')[0]) zoneId = int(dnaGroup.getName().split(':')[0])