Poodletooth-iLand/toontown/coghq/CountryClubManagerAI.py
2015-03-03 17:10:12 -05:00

59 lines
2.3 KiB
Python

import random
from toontown.coghq import DistributedCountryClubAI
from direct.directnotify import DirectNotifyGlobal
from direct.showbase import DirectObject
from toontown.coghq import CountryClubLayout
from toontown.toonbase import ToontownGlobals
CountryClubId2Layouts = {
ToontownGlobals.BossbotCountryClubIntA: (0, 1, 2),
ToontownGlobals.BossbotCountryClubIntB: (3, 4, 5),
ToontownGlobals.BossbotCountryClubIntC: (6, 7, 8)
}
class CountryClubManagerAI(DirectObject.DirectObject):
notify = directNotify.newCategory('CountryClubManagerAI')
countryClubId = None
def __init__(self, air):
DirectObject.DirectObject.__init__(self)
self.air = air
def getDoId(self):
return 0
def createCountryClub(self, countryClubId, players):
for avId in players:
if bboard.has('countryClubId-%s' % avId):
countryClubId = bboard.get('countryClubId-%s' % avId)
break
numFloors = 1
layoutIndex = None
floor = 0
for avId in players:
if bboard.has('countryClubFloor-%s' % avId):
floor = bboard.get('countryClubFloor-%s' % avId)
floor = max(0, floor)
floor = min(floor, numFloors - 1)
break
for avId in players:
if bboard.has('countryClubRoom-%s' % avId):
roomId = bboard.get('countryClubRoom-%s' % avId)
for i in xrange(numFloors):
layout = CountryClubLayout.CountryClubLayout(countryClubId, i)
if roomId in layout.getRoomIds():
floor = i
else:
CountryClubRoomSpecs = CountryClubRoomSpecs
roomName = CountryClubRoomSpecs.BossbotCountryClubRoomId2RoomName[roomId]
CountryClubManagerAI.notify.warning('room %s (%s) not found in any floor of countryClub %s' % (roomId, roomName, countryClubId))
countryClubZone = self.air.allocateZone()
if layoutIndex is None:
layoutIndex = random.choice(CountryClubId2Layouts[countryClubId])
countryClub = DistributedCountryClubAI.DistributedCountryClubAI(self.air, countryClubId, countryClubZone, floor, players, layoutIndex)
countryClub.generateWithRequired(countryClubZone)
return countryClubZone