mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
Merge branch 'master' of gitlab.com:toontownunited/src
This commit is contained in:
commit
662acabe1f
7 changed files with 62 additions and 287 deletions
|
@ -47,14 +47,15 @@ class CatalogRentalItem(CatalogItem.CatalogItem):
|
||||||
return TTLocalizer.RentalTypeName
|
return TTLocalizer.RentalTypeName
|
||||||
|
|
||||||
def recordPurchase(self, avatar, optional):
|
def recordPurchase(self, avatar, optional):
|
||||||
|
self.notify.debug('rental -- record purchase')
|
||||||
if avatar:
|
if avatar:
|
||||||
self.notify.debug('rental -- has avatar')
|
self.notify.debug('rental -- has avater')
|
||||||
estate = simbase.air.estateManager._lookupEstate(avatar)
|
estate = simbase.air.estateManager._lookupEstate(avatar.doId)
|
||||||
if estate:
|
if estate:
|
||||||
self.notify.debug('rental -- has estate')
|
self.notify.debug('rental -- has estate')
|
||||||
estate.rentItem(self.typeIndex, self.duration)
|
estate.rentItem(self.typeIndex, self.duration)
|
||||||
else:
|
else:
|
||||||
self.notify.warning('rental -- something not there')
|
self.notify.debug('rental -- something not there')
|
||||||
return ToontownGlobals.P_ItemAvailable
|
return ToontownGlobals.P_ItemAvailable
|
||||||
|
|
||||||
def getPicture(self, avatar):
|
def getPicture(self, avatar):
|
||||||
|
@ -105,9 +106,6 @@ class CatalogRentalItem(CatalogItem.CatalogItem):
|
||||||
dg.addUint16(self.duration)
|
dg.addUint16(self.duration)
|
||||||
dg.addUint16(self.typeIndex)
|
dg.addUint16(self.typeIndex)
|
||||||
|
|
||||||
def getDeliveryTime(self):
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def isRental(self):
|
def isRental(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -132,4 +130,3 @@ def getAllRentalItems():
|
||||||
list.append(CatalogRentalItem(rentalType, 2880, 1000))
|
list.append(CatalogRentalItem(rentalType, 2880, 1000))
|
||||||
|
|
||||||
return list
|
return list
|
||||||
|
|
||||||
|
|
|
@ -1,102 +1,57 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||||
from direct.distributed.ClockDelta import *
|
|
||||||
from toontown.minigame import CannonGameGlobals
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
|
||||||
import CannonGlobals
|
|
||||||
|
|
||||||
class DistributedCannonAI(DistributedObjectAI):
|
class DistributedCannonAI(DistributedObjectAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCannonAI")
|
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCannonAI")
|
||||||
|
|
||||||
def __init__(self, air):
|
def setEstateId(self, todo0):
|
||||||
DistributedObjectAI.__init__(self, air)
|
pass
|
||||||
self.estateId = 0
|
|
||||||
self.targetId = 0
|
|
||||||
self.posHpr = (0, 0, 0, 0, 0, 0)
|
|
||||||
self.bumperPos = ToontownGlobals.PinballCannonBumperInitialPos
|
|
||||||
self.active = 0
|
|
||||||
self.avId = 0
|
|
||||||
|
|
||||||
def setEstateId(self, estateId):
|
|
||||||
self.estateId = estateId
|
|
||||||
|
|
||||||
def getEstateId(self):
|
|
||||||
return self.estateId
|
|
||||||
|
|
||||||
def setTargetId(self, targetId):
|
def setTargetId(self, todo0):
|
||||||
self.targetId = targetId
|
pass
|
||||||
|
|
||||||
def getTargetId(self):
|
|
||||||
return self.targetId
|
|
||||||
|
|
||||||
def setPosHpr(self, x, y, z, h, p, r):
|
def setPosHpr(self, todo0, todo1, todo2, todo3, todo4, todo5):
|
||||||
self.posHpr = (x, y, z, h, p, r)
|
pass
|
||||||
|
|
||||||
def getPosHpr(self):
|
|
||||||
return self.posHpr
|
|
||||||
|
|
||||||
def setActive(self, active):
|
def setActive(self, todo0):
|
||||||
self.active = active
|
pass
|
||||||
self.sendUpdate("setActiveState", [active])
|
|
||||||
|
def setActiveState(self, todo0):
|
||||||
|
pass
|
||||||
|
|
||||||
def requestEnter(self):
|
def requestEnter(self):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
pass
|
||||||
av = self.air.doId2do.get(avId)
|
|
||||||
if not av:
|
|
||||||
return
|
|
||||||
|
|
||||||
if not self.avId:
|
|
||||||
self.avId = avId
|
|
||||||
self.d_setMovie(CannonGlobals.CANNON_MOVIE_LOAD)
|
|
||||||
self.acceptOnce(self.air.getAvatarExitEvent(avId), self.__handleUnexpectedExit, extraArgs=[avId])
|
|
||||||
|
|
||||||
else:
|
|
||||||
self.air.writeServerEvent('suspicious', avId, 'DistributedCannonAI.requestEnter cannon already occupied')
|
|
||||||
self.notify.warning('requestEnter() - cannon already occupied')
|
|
||||||
|
|
||||||
def setMovie(self, mode, avId, extraInfo):
|
|
||||||
self.avId = avId
|
|
||||||
self.sendUpdate('setMovie', [mode, avId, extraInfo])
|
|
||||||
|
|
||||||
def __handleUnexpectedExit(self, avId):
|
|
||||||
self.notify.warning('avatar:' + str(avId) + ' has exited unexpectedly')
|
|
||||||
self.__doExit()
|
|
||||||
|
|
||||||
def __doExit(self, movie=CannonGlobals.CANNON_MOVIE_FORCE_EXIT):
|
|
||||||
self.ignore(self.air.getAvatarExitEvent(self.avId))
|
|
||||||
self.d_setMovie(movie)
|
|
||||||
self.avId = 0
|
|
||||||
|
|
||||||
def requestExit(self):
|
def requestExit(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def d_setMovie(self, movie):
|
def setMovie(self, todo0, todo1):
|
||||||
self.sendUpdate("setMovie", [movie, self.avId])
|
pass
|
||||||
|
|
||||||
def setCannonPosition(self, zRot, angle):
|
def setCannonPosition(self, todo0, todo1):
|
||||||
self.sendUpdate("updateCannonPosition", [self.avId, zRot, angle])
|
pass
|
||||||
|
|
||||||
def setCannonLit(self, zRot, angle):
|
def setCannonLit(self, todo0, todo1):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
pass
|
||||||
if avId != self.avId:
|
|
||||||
return
|
|
||||||
|
|
||||||
fireTime = CannonGameGlobals.FUSE_TIME
|
|
||||||
self.sendUpdate('setCannonWillFire', [avId, fireTime, zRot, angle, globalClockDelta.getRealNetworkTime()])
|
|
||||||
|
|
||||||
def setFired(self):
|
def setFired(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setLanded(self):
|
def setLanded(self):
|
||||||
self.__doExit(CannonGlobals.CANNON_MOVIE_CLEAR)
|
pass
|
||||||
self.sendUpdate('setCannonExit', [self.avId])
|
|
||||||
|
def updateCannonPosition(self, todo0, todo1, todo2):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def setCannonWillFire(self, todo0, todo1, todo2, todo3, todo4):
|
||||||
|
pass
|
||||||
|
|
||||||
def setCannonExit(self, todo0):
|
def setCannonExit(self, todo0):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def requestBumperMove(self, x, y, z):
|
def requestBumperMove(self, todo0, todo1, todo2):
|
||||||
self.bumperPos = (x, y, z)
|
pass
|
||||||
self.sendUpdate('setCannonBumperPos', self.getCannonBumperPos())
|
|
||||||
|
def setCannonBumperPos(self, todo0, todo1, todo2):
|
||||||
|
pass
|
||||||
|
|
||||||
def getCannonBumperPos(self):
|
|
||||||
return self.bumperPos
|
|
||||||
|
|
|
@ -149,82 +149,6 @@ class GardenManager:
|
||||||
return packGardenData(NULL_FLOWERS + NULL_TREES, NULL_STATUARY, False)
|
return packGardenData(NULL_FLOWERS + NULL_TREES, NULL_STATUARY, False)
|
||||||
return packGardenData(g.flowersData + g.treesData, g.statuaryIndex)
|
return packGardenData(g.flowersData + g.treesData, g.statuaryIndex)
|
||||||
|
|
||||||
class Rental:
|
|
||||||
def __init__(self, estate):
|
|
||||||
self.estate = estate
|
|
||||||
self.objects = set()
|
|
||||||
|
|
||||||
def destroy(self):
|
|
||||||
del self.estate
|
|
||||||
for object in self.objects:
|
|
||||||
if not object.isDeleted():
|
|
||||||
object.requestDelete()
|
|
||||||
taskMgr.remove(object.uniqueName('delete'))
|
|
||||||
self.objects = set()
|
|
||||||
|
|
||||||
class CannonRental(Rental):
|
|
||||||
def generateObjects(self):
|
|
||||||
target = DistributedTargetAI(self.estate.air)
|
|
||||||
target.generateWithRequired(self.estate.zoneId)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
self.generateTreasures()
|
|
||||||
self.estate.b_setClouds(1)
|
|
||||||
|
|
||||||
def destroy(self):
|
|
||||||
self.estate.b_setClouds(0)
|
|
||||||
Rental.destroy(self)
|
|
||||||
|
|
||||||
def generateTreasures(self):
|
|
||||||
doIds = []
|
|
||||||
z = 35
|
|
||||||
|
|
||||||
for i in xrange(20):
|
|
||||||
x = random.randint(100, 300) - 200
|
|
||||||
y = random.randint(100, 300) - 200
|
|
||||||
treasure = DistributedTreasureAI.DistributedTreasureAI(self.estate.air, self, 9, x, y, z)
|
|
||||||
treasure.generateWithRequired(self.estate.zoneId)
|
|
||||||
self.objects.add(treasure)
|
|
||||||
doIds.append(treasure.doId)
|
|
||||||
|
|
||||||
self.estate.sendUpdate("setTreasureIds", [doIds])
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
def validAvatar(self, av):
|
|
||||||
if av.getMaxHp() == av.getHp():
|
|
||||||
return 0
|
|
||||||
|
|
||||||
av.toonUp(3)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
class DistributedEstateAI(DistributedObjectAI):
|
class DistributedEstateAI(DistributedObjectAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedEstateAI")
|
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedEstateAI")
|
||||||
def __init__(self, air):
|
def __init__(self, air):
|
||||||
|
@ -398,56 +322,17 @@ class DistributedEstateAI(DistributedObjectAI):
|
||||||
self.sendUpdate('setRentalTimeStamp', [rental])
|
self.sendUpdate('setRentalTimeStamp', [rental])
|
||||||
|
|
||||||
def b_setRentalTimeStamp(self, rental):
|
def b_setRentalTimeStamp(self, rental):
|
||||||
self.b_setRentalTimeStamp(rental)
|
self.setRentalTimeStamp(self, rental)
|
||||||
|
self.b_setRentalTimeStamp(self, rental)
|
||||||
|
|
||||||
def getRentalTimeStamp(self):
|
def getRentalTimeStamp(self):
|
||||||
return self.rentalTimestamp
|
return self.rentalTimestamp
|
||||||
|
|
||||||
def b_setRentalType(self, type):
|
def setRentalType(self, todo0):
|
||||||
self.d_setRentalType(type)
|
pass
|
||||||
self.setRentalType(type)
|
|
||||||
|
|
||||||
def d_setRentalType(self, type):
|
|
||||||
self.sendUpdate("setRentalType", [type])
|
|
||||||
|
|
||||||
def setRentalType(self, type):
|
|
||||||
expirestamp = self.getRentalTimeStamp()
|
|
||||||
if expirestamp == 0:
|
|
||||||
expire = 0
|
|
||||||
|
|
||||||
else:
|
|
||||||
expire = int(expirestamp - time.time())
|
|
||||||
|
|
||||||
if expire < 0:
|
|
||||||
self.rentalType = 0
|
|
||||||
self.d_setRentalType(0)
|
|
||||||
self.b_setRentalTimeStamp(0)
|
|
||||||
|
|
||||||
else:
|
|
||||||
if self.rentalType == type:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.rentalType = type
|
|
||||||
if self.rentalHandle:
|
|
||||||
self.rentalHandle.destroy()
|
|
||||||
self.rentalHandle = None
|
|
||||||
|
|
||||||
if self.rentalType == ToontownGlobals.RentalCannon:
|
|
||||||
self.rentalHandle = CannonRental(self)
|
|
||||||
|
|
||||||
else:
|
|
||||||
self.notify.warning('Unknown rental %s' % self.rentalType)
|
|
||||||
return
|
|
||||||
|
|
||||||
self.rentalHandle.generateObjects()
|
|
||||||
|
|
||||||
def getRentalType(self):
|
def getRentalType(self):
|
||||||
return self.rentalType
|
return 0
|
||||||
|
|
||||||
def rentItem(self, rentType, duration):
|
|
||||||
self.rentalType = rentType
|
|
||||||
self.b_setRentalTimeStamp(time.time() + duration * 60)
|
|
||||||
self.b_setRentalType(rentType)
|
|
||||||
|
|
||||||
def setSlot0ToonId(self, id):
|
def setSlot0ToonId(self, id):
|
||||||
self.toons[0] = id
|
self.toons[0] = id
|
||||||
|
|
|
@ -1,88 +1,30 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||||
import CannonGlobals
|
|
||||||
|
|
||||||
class DistributedTargetAI(DistributedObjectAI):
|
class DistributedTargetAI(DistributedObjectAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedTargetAI")
|
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedTargetAI")
|
||||||
|
|
||||||
def __init__(self, air):
|
def setPosition(self, todo0, todo1, todo2):
|
||||||
DistributedObjectAI.__init__(self, air)
|
|
||||||
self.enabled = 0
|
|
||||||
self.highscore = 0
|
|
||||||
self.scoreDict = {}
|
|
||||||
|
|
||||||
self.__newGame()
|
|
||||||
|
|
||||||
def announceGenerate(self):
|
|
||||||
DistributedObjectAI.announceGenerate(self)
|
|
||||||
taskMgr.doMethodLater(10, self.__startNewGame, self.taskName('newGame'))
|
|
||||||
|
|
||||||
def __newGame(self):
|
|
||||||
self.power = 1
|
|
||||||
self.time = CannonGlobals.CANNON_TIMEOUT
|
|
||||||
|
|
||||||
def getPosition(self):
|
|
||||||
return (0, 0, 40)
|
|
||||||
|
|
||||||
def getState(self):
|
|
||||||
return self.enabled, 2**self.power, self.time
|
|
||||||
|
|
||||||
def d_updateState(self):
|
|
||||||
self.sendUpdate("setState", self.getState())
|
|
||||||
|
|
||||||
def d_setReward(self, reward):
|
|
||||||
self.sendUpdate("setReward", [reward])
|
|
||||||
|
|
||||||
def setResult(self, avId):
|
|
||||||
if avId and self.enabled:
|
|
||||||
self.power += 1
|
|
||||||
self.time = int(CannonGlobals.CANNON_TIMEOUT / self.power)
|
|
||||||
taskMgr.remove(self.taskName('gameover'))
|
|
||||||
taskMgr.doMethodLater(self.time, self.__gameOver, self.taskName('gameover'))
|
|
||||||
self.d_updateState()
|
|
||||||
|
|
||||||
def __gameOver(self, task):
|
|
||||||
self.enabled = 0
|
|
||||||
self.time = 0
|
|
||||||
self.d_updateState()
|
|
||||||
taskMgr.doMethodLater(10, self.__startNewGame, self.taskName('newGame'))
|
|
||||||
|
|
||||||
for avId in self.scoreDict:
|
|
||||||
av = self.air.doId2do.get(avId)
|
|
||||||
if av:
|
|
||||||
if av.zoneId == self.zoneId:
|
|
||||||
av.toonUp(2 ** self.power)
|
|
||||||
|
|
||||||
return task.done
|
|
||||||
|
|
||||||
def __startNewGame(self, task):
|
|
||||||
self.enabled = 1
|
|
||||||
self.__newGame()
|
|
||||||
self.d_updateState()
|
|
||||||
taskMgr.doMethodLater(self.time, self.__gameOver, self.taskName('gameover'))
|
|
||||||
return task.done
|
|
||||||
|
|
||||||
def setBonus(self, bonus):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setCurPinballScore(self, avId, score, bonus):
|
def setState(self, todo0, todo1, todo2):
|
||||||
av = self.air.doId2do.get(avId)
|
pass
|
||||||
if not av:
|
|
||||||
return
|
|
||||||
|
|
||||||
S = score * bonus
|
|
||||||
self.scoreDict[avId] = S
|
|
||||||
if S > self.highscore:
|
|
||||||
self.highscore = S
|
|
||||||
self.d_updateHighscore(av, S)
|
|
||||||
|
|
||||||
def d_updateHighscore(self, av, score):
|
def setReward(self, todo0):
|
||||||
self.sendUpdate("setPinballHiScorer", [av.getName()])
|
pass
|
||||||
self.sendUpdate("setPinballHiScore", [score])
|
|
||||||
|
|
||||||
def delete(self):
|
def setResult(self, todo0):
|
||||||
taskMgr.remove(self.taskName('newGame'))
|
pass
|
||||||
taskMgr.remove(self.taskName('gameover'))
|
|
||||||
|
|
||||||
|
|
||||||
|
def setBonus(self, todo0):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def setCurPinballScore(self, todo0, todo1, todo2):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def setPinballHiScorer(self, todo0):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def setPinballHiScore(self, todo0):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
|
@ -74,10 +74,6 @@ class LoadHouseFSM(FSM):
|
||||||
self.demand('LoadHouse')
|
self.demand('LoadHouse')
|
||||||
|
|
||||||
def enterLoadHouse(self):
|
def enterLoadHouse(self):
|
||||||
# Load the garden if they have one.
|
|
||||||
if self.toon['setGardenStarted'][0]:
|
|
||||||
self.estate.spawnGarden(self.houseIndex)
|
|
||||||
|
|
||||||
# Activate the house:
|
# Activate the house:
|
||||||
self.mgr.air.sendActivate(self.houseId, self.mgr.air.districtId, self.estate.zoneId,
|
self.mgr.air.sendActivate(self.houseId, self.mgr.air.districtId, self.estate.zoneId,
|
||||||
self.mgr.air.dclassesByName['DistributedHouseAI'],
|
self.mgr.air.dclassesByName['DistributedHouseAI'],
|
||||||
|
|
|
@ -121,7 +121,7 @@ class PhotoAlbumPage(ShtikerPage.ShtikerPage):
|
||||||
oldName = self.selectedFileName
|
oldName = self.selectedFileName
|
||||||
numUnders = oldName.count(separator)
|
numUnders = oldName.count(separator)
|
||||||
if numUnders == 0:
|
if numUnders == 0:
|
||||||
newName = oldName[0:18] + separator + str + separator + oldName[17:]
|
newName = oldName[0:21] + separator + str + separator + oldName[20:]
|
||||||
elif numUnders == 2:
|
elif numUnders == 2:
|
||||||
sp = oldName.split(separator)
|
sp = oldName.split(separator)
|
||||||
newName = sp[0] + separator + str + separator + sp[2]
|
newName = sp[0] + separator + str + separator + sp[2]
|
||||||
|
@ -232,7 +232,7 @@ class PhotoAlbumPage(ShtikerPage.ShtikerPage):
|
||||||
files = os.listdir(self.photoPath)
|
files = os.listdir(self.photoPath)
|
||||||
photos = []
|
photos = []
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
if fileName[0:17] == 'united-screenshot' and fileName[-4:] == '.jpg':
|
if fileName[0:20] == 'united-screenshot' and fileName[-4:] == '.jpg':
|
||||||
photos.append(fileName)
|
photos.append(fileName)
|
||||||
|
|
||||||
return photos
|
return photos
|
||||||
|
|
|
@ -5446,9 +5446,9 @@ NumToColor = ['White',
|
||||||
'Gray',
|
'Gray',
|
||||||
'Neon Orange',
|
'Neon Orange',
|
||||||
'Sapphire',
|
'Sapphire',
|
||||||
'Hacker Red',
|
'Pure Red',
|
||||||
'Hacker Blue',
|
'Pure Blue',
|
||||||
'Hacker Green',
|
'Pure Green',
|
||||||
'Crimson',
|
'Crimson',
|
||||||
'Emerald',
|
'Emerald',
|
||||||
'Bronze']
|
'Bronze']
|
||||||
|
|
Loading…
Reference in a new issue