Poodletooth-iLand/toontown/estate/DistributedEstateAI.py

675 lines
22 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI
from toontown.toonbase import ToontownGlobals
from toontown.fishing.DistributedFishingPondAI import DistributedFishingPondAI
from toontown.fishing.DistributedFishingTargetAI import DistributedFishingTargetAI
from toontown.fishing.DistributedPondBingoManagerAI import DistributedPondBingoManagerAI
from toontown.fishing import FishingTargetGlobals
from toontown.safezone.DistributedFishingSpotAI import DistributedFishingSpotAI
from toontown.safezone.SZTreasurePlannerAI import SZTreasurePlannerAI
2015-04-29 06:48:29 -05:00
from toontown.safezone import DistributedTreasureAI
2015-03-03 16:10:12 -06:00
from toontown.safezone import TreasureGlobals
2015-04-29 06:48:29 -05:00
from DistributedCannonAI import *
from DistributedTargetAI import *
2015-05-12 14:46:35 -05:00
import CannonGlobals
import TableGlobals
import HouseGlobals
2015-05-24 18:23:54 -05:00
import GardenGlobals
from DistributedGardenPlotAI import DistributedGardenPlotAI
from DistributedGardenBoxAI import DistributedGardenBoxAI
from DistributedFlowerAI import DistributedFlowerAI
from DistributedGagTreeAI import DistributedGagTreeAI
from DistributedStatuaryAI import DistributedStatuaryAI
from DistributedToonStatuaryAI import DistributedToonStatuaryAI
2015-05-12 14:46:35 -05:00
import time
import random
from toontown.fishing import FishGlobals
2015-05-25 05:17:14 -05:00
from toontown.parties.DistributedPartyJukeboxActivityAI import DistributedPartyJukeboxActivityAI
2015-04-29 06:48:29 -05:00
class Rental:
2015-05-24 18:23:54 -05:00
2015-04-29 06:48:29 -05:00
def __init__(self, estate):
self.estate = estate
self.objects = set()
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
def destroy(self):
del self.estate
2015-05-24 18:23:54 -05:00
for obj in self.objects:
if not obj.isDeleted():
obj.requestDelete()
taskMgr.remove(obj.uniqueName('delete'))
2015-04-29 06:48:29 -05:00
self.objects = set()
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
class CannonRental(Rental):
2015-05-24 18:23:54 -05:00
def __init__(self, estate):
Rental.__init__(self, estate)
2015-04-29 06:48:29 -05:00
def generateObjects(self):
target = DistributedTargetAI(self.estate.air)
target.generateWithRequired(self.estate.zoneId)
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
for drop in CannonGlobals.cannonDrops:
cannon = DistributedCannonAI(self.estate.air)
cannon.setEstateId(self.estate.doId)
cannon.setTargetId(target.doId)
cannon.setPosHpr(*drop)
cannon.generateWithRequired(self.estate.zoneId)
self.objects.add(cannon)
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
self.generateTreasures()
self.estate.b_setClouds(1)
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
def destroy(self):
self.estate.b_setClouds(0)
Rental.destroy(self)
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
def generateTreasures(self):
doIds = []
z = 35
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
for i in xrange(20):
x = random.randint(100, 300) - 200
y = random.randint(100, 300) - 200
treasure = DistributedTreasureAI.DistributedTreasureAI(self.estate.air, self, 7, x, y, z)
2015-04-29 06:48:29 -05:00
treasure.generateWithRequired(self.estate.zoneId)
self.objects.add(treasure)
doIds.append(treasure.doId)
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
self.estate.sendUpdate("setTreasureIds", [doIds])
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
def grabAttempt(self, avId, treasureId):
av = self.estate.air.doId2do.get(avId)
if av == None:
self.estate.air.writeServerEvent('suspicious', avId, 'TreasurePlannerAI.grabAttempt unknown avatar')
self.estate.notify.warning('avid: %s does not exist' % avId)
return
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
treasure = self.estate.air.doId2do.get(treasureId)
if self.validAvatar(av):
treasure.d_setGrab(avId)
self.deleteTreasureSoon(treasure)
else:
treasure.d_setReject()
def deleteTreasureSoon(self, treasure):
taskName = treasure.uniqueName('delete')
taskMgr.doMethodLater(5, self.__deleteTreasureNow, taskName, extraArgs=(treasure, taskName))
def __deleteTreasureNow(self, treasure, taskName):
treasure.requestDelete()
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
def validAvatar(self, av):
if av.getMaxHp() == av.getHp():
return 0
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
av.toonUp(3)
return 1
# Once we make rental game tables.
2015-05-24 18:23:54 -05:00
class TableRental(Rental):
def __init__(self, estate):
Rental.__init__(self, estate)
2015-04-29 06:48:29 -05:00
def generateObjects(self):
for drop in TableGlobals.tableDrops:
table = None
table.setEstateId(self.estate.doId)
table.setPosHpr(*drop)
table.generateWithRequired(self.estate.zoneId)
self.objects.add(table)
def destroy(self):
Rental.destroy(self)
2015-03-23 07:56:48 -05:00
2015-03-03 16:10:12 -06:00
class DistributedEstateAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedEstateAI")
2015-05-24 18:23:54 -05:00
2015-03-03 16:10:12 -06:00
def __init__(self, air):
DistributedObjectAI.__init__(self, air)
self.toons = [0, 0, 0, 0, 0, 0]
self.items = [[], [], [], [], [], []]
2015-05-24 18:23:54 -05:00
self.boxes = [[], [], [], [], [], []]
self.plots = [[], [], [], [], [], []]
2015-03-03 16:10:12 -06:00
self.decorData = []
self.cloudType = 0
self.dawnTime = 0
self.lastEpochTimestamp = 0
2015-04-29 06:48:29 -05:00
self.rentalType = 0
self.rentalHandle = None
2015-03-03 16:10:12 -06:00
self.rentalTimestamp = 0
2015-04-06 17:53:47 -05:00
self.houses = [None] * 6
2015-03-03 16:10:12 -06:00
self.pond = None
self.spots = []
self.targets = []
2015-05-25 05:17:14 -05:00
self.jukebox = None
2015-03-03 16:10:12 -06:00
self.owner = None
2015-05-11 14:05:59 -05:00
2015-05-25 05:17:14 -05:00
@property
def hostId(self):
return 1000000001
2015-03-03 16:10:12 -06:00
def generate(self):
DistributedObjectAI.generate(self)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
self.pond = DistributedFishingPondAI(simbase.air)
self.pond.setArea(ToontownGlobals.MyEstate)
self.pond.generateWithRequired(self.zoneId)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
for i in xrange(FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)):
target = DistributedFishingTargetAI(self.air)
target.setPondDoId(self.pond.getDoId())
target.generateWithRequired(self.zoneId)
self.targets.append(target)
spot = DistributedFishingSpotAI(self.air)
spot.setPondDoId(self.pond.getDoId())
spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0)
spot.generateWithRequired(self.zoneId)
self.spots.append(spot)
spot = DistributedFishingSpotAI(self.air)
spot.setPondDoId(self.pond.getDoId())
spot.setPosHpr(46.5222, -134.739, 0.390713, 75, 0, 0)
spot.generateWithRequired(self.zoneId)
self.spots.append(spot)
spot = DistributedFishingSpotAI(self.air)
spot.setPondDoId(self.pond.getDoId())
spot.setPosHpr(41.31, -144.559, 0.375978, 45, 0, 0)
spot.generateWithRequired(self.zoneId)
self.spots.append(spot)
spot = DistributedFishingSpotAI(self.air)
spot.setPondDoId(self.pond.getDoId())
spot.setPosHpr(46.8254, -113.682, 0.46015, 135, 0, 0)
spot.generateWithRequired(self.zoneId)
self.spots.append(spot)
2015-05-25 05:17:14 -05:00
self.jukebox = DistributedPartyJukeboxActivityAI(
self.air,
self.doId,
(0, 0, 0, 0)
)
self.jukebox.generateWithRequired(self.zoneId)
self.jukebox.sendUpdate('setX', [-21.8630])
self.jukebox.sendUpdate('setY', [-154.669])
self.jukebox.sendUpdate('setH', [148.7050])
self.jukebox.sendUpdate('unloadSign')
2015-05-11 14:05:59 -05:00
self.createTreasurePlanner()
2015-03-03 16:10:12 -06:00
2015-05-24 18:23:54 -05:00
def generateRegisteredObjects(self, slot):
if len(self.plots[slot]) > 0:
for item in self.items[slot]:
plotData = GardenGlobals.estatePlots[slot][item[0]]
if item[1] == GardenGlobals.FLOWER_TYPE:
newItem = DistributedFlowerAI(self.air)
newItem.setEstate(self.doId)
newItem.setOwnerPlot(self.plots[slot][item[0]].doId)
newItem.setPlot(item[0])
newItem.setHeading(plotData[2])
newItem.setPosition(plotData[0], plotData[1], 1.3)
newItem.setOwnerIndex(slot)
newItem.setWaterLevel(item[4])
newItem.setGrowthLevel(item[5])
newItem.setTypeIndex(item[2])
newItem.setVariety(item[3])
elif item[1] == GardenGlobals.GAG_TREE_TYPE:
newItem = DistributedGagTreeAI(self.air)
newItem.setEstate(self.doId)
newItem.setOwnerPlot(self.plots[slot][item[0]].doId)
newItem.setPlot(item[0])
newItem.setHeading(plotData[2])
newItem.setPosition(plotData[0], plotData[1], 1.3)
newItem.setOwnerIndex(slot)
newItem.setTypeIndex(item[2])
newItem.setWaterLevel(item[4])
newItem.setGrowthLevel(item[5])
elif item[1] == GardenGlobals.STATUARY_TYPE:
newItem = DistributedStatuaryAI(self.air)
newItem.setEstate(self.doId)
newItem.setOwnerPlot(self.plots[slot][item[0]].doId)
newItem.setPlot(item[0])
newItem.setHeading(plotData[2])
newItem.setPosition(plotData[0], plotData[1], 1.3)
newItem.setOwnerIndex(slot)
newItem.setTypeIndex(item[2])
newItem.setWaterLevel(item[4])
newItem.setGrowthLevel(item[5])
elif item[1] == GardenGlobals.TOON_STATUARY_TYPE:
newItem = DistributedToonStatuaryAI(self.air)
newItem.setEstate(self.doId)
newItem.setOwnerPlot(self.plots[slot][item[0]].doId)
newItem.setPlot(item[0])
newItem.setHeading(plotData[2])
newItem.setPosition(plotData[0], plotData[1], 1.3)
newItem.setOwnerIndex(slot)
newItem.setTypeIndex(item[2])
newItem.setWaterLevel(item[4])
newItem.setGrowthLevel(item[5])
newItem.setOptional(item[6])
else:
continue
newItem.generateWithRequired(self.zoneId)
self.plots[slot][item[0]].planted = newItem
self.plots[slot][item[0]].sendUpdate('plantedItem', [newItem.doId])
self.plots[slot][item[0]].sendUpdate('setMovie', [GardenGlobals.MOVIE_PLANT, 999999999])
2015-05-24 18:23:54 -05:00
2015-03-03 16:10:12 -06:00
def destroy(self):
for house in self.houses:
if house:
house.requestDelete()
2015-04-06 17:53:47 -05:00
del self.houses[:]
2015-03-03 16:10:12 -06:00
if self.pond:
2015-04-06 17:53:47 -05:00
self.pond.requestDelete()
2015-03-03 16:10:12 -06:00
for spot in self.spots:
spot.requestDelete()
for target in self.targets:
target.requestDelete()
2015-04-06 17:53:47 -05:00
2015-05-25 05:17:14 -05:00
if self.jukebox:
self.jukebox.requestDelete()
2015-03-03 16:10:12 -06:00
if self.treasurePlanner:
self.treasurePlanner.stop()
2015-04-06 17:53:47 -05:00
2015-04-29 06:48:29 -05:00
if self.rentalHandle:
self.rentalHandle.destroy()
self.rentalHandle = None
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
self.requestDelete()
2015-04-06 17:53:47 -05:00
def setEstateReady(self):
pass
2015-03-03 16:10:12 -06:00
def setClientReady(self):
self.sendUpdate('setEstateReady', [])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def setClosestHouse(self, todo0):
pass
def setTreasureIds(self, todo0):
pass
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def createTreasurePlanner(self):
treasureType, healAmount, spawnPoints, spawnRate, maxTreasures = TreasureGlobals.SafeZoneTreasureSpawns[ToontownGlobals.MyEstate]
self.treasurePlanner = SZTreasurePlannerAI(self.zoneId, treasureType, healAmount, spawnPoints, spawnRate, maxTreasures)
self.treasurePlanner.start()
def requestServerTime(self):
avId = self.air.getAvatarIdFromSender()
self.sendUpdateToAvatarId(avId, 'setServerTime', [time.time() % HouseGlobals.DAY_NIGHT_PERIOD])
def setServerTime(self, todo0):
pass
def setDawnTime(self, dawnTime):
self.dawnTime = dawnTime
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setDawnTime(self, dawnTime):
self.sendUpdate('setDawnTime', [dawnTime])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setDawnTime(self, dawnTime):
self.setDawnTime(dawnTime)
self.d_setDawnTime(dawnTime)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getDawnTime(self):
return self.dawnTime
2015-04-06 17:53:47 -05:00
def placeOnGround(self, todo0):
pass
2015-03-03 16:10:12 -06:00
def setDecorData(self, decorData):
self.decorData = decorData
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setDecorData(self, decorData):
self.sendUpdate('setDecorData', [decorData])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setDecorData(self, decorData):
self.setDecorData(decorData)
self.d_setDecorData(decorData)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getDecorData(self):
return self.decorData
2015-05-11 14:05:59 -05:00
def setLastEpochTimeStamp(self, last):
2015-03-03 16:10:12 -06:00
self.lastEpochTimestamp = last
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setLastEpochTimeStamp(self, last):
self.sendUpdate('setLastEpochTimeStamp', [last])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setLastEpochTimeStamp(self, last):
self.setLastEpochTimeStamp(last)
self.d_setLastEpochTimeStamp(last)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getLastEpochTimeStamp(self):
return self.lastEpochTimestamp
def setRentalTimeStamp(self, rental):
self.rentalTimestamp = rental
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setRentalTimeStamp(self, rental):
self.sendUpdate('setRentalTimeStamp', [rental])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setRentalTimeStamp(self, rental):
2015-04-29 06:48:29 -05:00
self.setRentalTimeStamp(rental)
self.d_setRentalTimeStamp(rental)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getRentalTimeStamp(self):
return self.rentalTimestamp
2015-04-29 06:48:29 -05:00
def b_setRentalType(self, type):
self.d_setRentalType(type)
self.setRentalType(type)
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
def d_setRentalType(self, type):
self.sendUpdate("setRentalType", [type])
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
def setRentalType(self, type):
expirestamp = self.getRentalTimeStamp()
if expirestamp == 0:
expire = 0
else:
expire = int(expirestamp - time.time())
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
if expire < 0:
self.rentalType = 0
self.d_setRentalType(0)
self.b_setRentalTimeStamp(0)
else:
if self.rentalType == type:
return
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
self.rentalType = type
if self.rentalHandle:
self.rentalHandle.destroy()
self.rentalHandle = None
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
if self.rentalType == ToontownGlobals.RentalCannon:
self.rentalHandle = CannonRental(self)
elif self.rentalType == ToontownGlobals.RentalGameTable:
self.rentalHandle = TableRental(self)
2015-04-29 06:48:29 -05:00
else:
self.notify.warning('Unknown rental %s' % self.rentalType)
return
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
self.rentalHandle.generateObjects()
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getRentalType(self):
2015-04-29 06:48:29 -05:00
return self.rentalType
2015-05-11 14:05:59 -05:00
2015-04-29 06:48:29 -05:00
def rentItem(self, rentType, duration):
self.rentalType = rentType
self.b_setRentalTimeStamp(time.time() + duration * 60)
self.b_setRentalType(rentType)
2015-04-06 17:53:47 -05:00
2015-03-03 16:10:12 -06:00
def setSlot0ToonId(self, id):
self.toons[0] = id
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setSlot0ToonId(self, id):
self.sendUpdate('setSlot0ToonId', [id])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot0ToonId(self, id):
self.setSlot0ToonId(id)
self.d_setSlot0ToonId(id)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot0ToonId(self):
return self.toons[0]
def setSlot0Items(self, items):
self.items[0] = items
def d_setSlot0Items(self, items):
2015-05-24 18:23:54 -05:00
self.sendUpdate('setSlot0Items', [items])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot0Items(self, items):
self.setSlot0Items(items)
self.d_setSlot0Items(items)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot0Items(self):
return self.items[0]
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def setSlot1ToonId(self, id):
self.toons[1] = id
def d_setSlot1ToonId(self, id):
self.sendUpdate('setSlot1ToonId', [id])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot1ToonId(self, id):
self.setSlot1ToonId(id)
self.d_setSlot1ToonId(id)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot1ToonId(self):
return self.toons[1]
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def setSlot1Items(self, items):
self.items[1] = items
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setSlot1Items(self, items):
2015-05-24 18:23:54 -05:00
self.sendUpdate('setSlot1Items', [items])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot1Items(self, items):
2015-05-24 18:23:54 -05:00
self.setSlot1Items(items)
self.d_setSlot1Items(items)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot1Items(self):
return self.items[1]
def setSlot2ToonId(self, id):
self.toons[2] = id
def d_setSlot2ToonId(self, id):
self.sendUpdate('setSlot2ToonId', [id])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot2ToonId(self, id):
self.setSlot2ToonId(id)
self.d_setSlot2ToonId(id)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot2ToonId(self):
return self.toons[2]
def setSlot2Items(self, items):
self.items[2] = items
def d_setSlot2Items(self, items):
self.sendUpdate('setSlot2Items', [items])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot2Items(self, items):
self.setSlot2Items(items)
self.d_setSlot2Items(items)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot2Items(self):
return self.items[2]
def setSlot3ToonId(self, id):
self.toons[3] = id
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setSlot3ToonId(self, id):
self.sendUpdate('setSlot3ToonId', [id])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot3ToonId(self, id):
self.setSlot3ToonId(id)
self.d_setSlot3ToonId(id)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot3ToonId(self):
return self.toons[3]
def setSlot3Items(self, items):
self.items[3] = items
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setSlot3Items(self, items):
self.sendUpdate('setSlot3Items', [items])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot3Items(self, items):
self.setSlot3Items(items)
self.d_setSlot3Items(items)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot3Items(self):
return self.items[3]
def setSlot4ToonId(self, id):
self.toons[4] = id
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setSlot4ToonId(self, id):
self.sendUpdate('setSlot4ToonId', [id])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot5ToonId(self, id):
self.setSlot4ToonId(id)
self.d_setSlot4ToonId(id)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot4ToonId(self):
return self.toons[4]
def setSlot4Items(self, items):
self.items[4] = items
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setSlot4Items(self, items):
self.sendUpdate('setSlot4Items', [items])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot4Items(self, items):
self.setSlot4Items(items)
self.d_setSlot4Items(items)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot4Items(self):
return self.items[4]
def setSlot5ToonId(self, id):
self.toons[5] = id
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setSlot5ToonId(self, id):
self.sendUpdate('setSlot5ToonId', [id])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot5ToonId(self, id):
self.setSlot5ToonId(id)
self.d_setSlot5ToonId(id)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot5ToonId(self):
return self.toons[5]
def setSlot5Items(self, items):
self.items[5] = items
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setSlot5Items(self, items):
self.sendUpdate('setSlot5Items', [items])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setSlot5Items(self, items):
self.setSlot5Items(items)
self.d_setSlot5Items(items)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getSlot5Items(self):
return self.items[5]
def setIdList(self, idList):
for i in xrange(len(idList)):
if i >= 6:
return
self.toons[i] = idList[i]
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setIdList(self, idList):
self.sendUpdate('setIdList', [idList])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setIdList(self, idList):
self.setIdList(idList)
2015-05-24 18:23:54 -05:00
self.d_setIdList(idList)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def completeFlowerSale(self, todo0):
pass
2015-05-12 14:46:35 -05:00
def completeFishSale(self, sell):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
if av:
if sell:
trophyResult = self.air.fishManager.creditFishTank(av)
if trophyResult:
self.sendUpdateToAvatarId(avId, 'thankSeller', [ToontownGlobals.FISHSALE_TROPHY, len(av.fishCollection), FishGlobals.getTotalNumFish()])
else:
self.sendUpdateToAvatarId(avId, 'thankSeller', [ToontownGlobals.FISHSALE_COMPLETE, 0, 0])
else:
self.sendUpdateToAvatarId(avId, 'thankSeller', [ToontownGlobals.FISHSALE_NONE, 0, 0])
2015-03-03 16:10:12 -06:00
def awardedTrophy(self, todo0):
pass
def setClouds(self, clouds):
self.cloudType = clouds
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def d_setClouds(self, clouds):
self.sendUpdate('setClouds', [clouds])
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def b_setClouds(self, clouds):
self.setClouds(clouds)
self.d_setClouds(clouds)
2015-05-11 14:05:59 -05:00
2015-03-03 16:10:12 -06:00
def getClouds(self):
return self.cloudType
def cannonsOver(self):
pass
def gameTableOver(self):
pass
2015-05-24 18:23:54 -05:00
def placeStarterGarden(self, avatar):
2015-06-11 12:48:13 -05:00
# TODO: Place garden if a toon already owns one.
2015-05-24 18:23:54 -05:00
avId = avatar.doId
slot = self.toons.index(avId)
plotPos = GardenGlobals.estatePlots[slot]
boxPos = GardenGlobals.estateBoxes[slot]
for p, n in enumerate(boxPos):
x, y, h, i = n
newBox = DistributedGardenBoxAI(self.air)
newBox.setEstate(self.doId)
newBox.setTypeIndex(i)
newBox.setPlot(p)
newBox.setOwnerIndex(slot)
newBox.setPosition(x, y, 0)
newBox.setHeading(h)
newBox.generateWithRequired(self.zoneId)
self.boxes[slot].append(newBox)
for p, n in enumerate(plotPos):
i = n[3]
if i in [GardenGlobals.GAG_TREE_TYPE, GardenGlobals.STATUARY_TYPE]:
x, y, h = n[:3]
newPlot = DistributedGardenPlotAI(self.air)
newPlot.setEstate(self.doId)
newPlot.setPlot(p)
newPlot.setOwnerIndex(slot)
newPlot.setPosition(x, y, 0)
newPlot.setHeading(h)
newPlot.generateWithRequired(self.zoneId)
self.plots[slot].append(newPlot)
elif i == GardenGlobals.FLOWER_TYPE:
2015-06-11 12:48:13 -05:00
# TODO: Place flower plots more accurately.
2015-05-24 18:23:54 -05:00
x, y, h = n[:3]
newPlot = DistributedGardenPlotAI(self.air)
newPlot.setEstate(self.doId)
newPlot.setPlot(p)
newPlot.setOwnerIndex(slot)
newPlot.setPosition(x, y, 1.3)
newPlot.setHeading(h)
newPlot.generateWithRequired(self.zoneId)
self.plots[slot].append(newPlot)
self.generateRegisteredObjects(slot)
2015-03-03 16:10:12 -06:00
def updateToons(self):
self.d_setSlot0ToonId(self.toons[0])
self.d_setSlot1ToonId(self.toons[1])
self.d_setSlot2ToonId(self.toons[2])
self.d_setSlot3ToonId(self.toons[3])
self.d_setSlot4ToonId(self.toons[4])
self.d_setSlot5ToonId(self.toons[5])
self.sendUpdate('setIdList', [self.toons])
def updateItems(self):
self.d_setSlot0Items(self.items[0])
self.d_setSlot1Items(self.items[1])
self.d_setSlot2Items(self.items[2])
self.d_setSlot3Items(self.items[3])
self.d_setSlot4Items(self.items[4])
self.d_setSlot5Items(self.items[5])