mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Newer pet manager.
This commit is contained in:
parent
2c451321b2
commit
7505459b59
1 changed files with 28 additions and 27 deletions
|
@ -1,38 +1,38 @@
|
|||
import PetUtil, PetDNA
|
||||
from toontown.toonbase import ToontownGlobals, TTLocalizer
|
||||
import PetUtil, PetDNA, time, random
|
||||
import time, random, os
|
||||
|
||||
DAY = 24 * 60 * 60
|
||||
MINUTE = 60
|
||||
HOUR = 60 * MINUTE
|
||||
DAY = 24 * HOUR
|
||||
|
||||
def getDayId():
|
||||
return int(time.time() / DAY)
|
||||
return int(time.time() // DAY)
|
||||
|
||||
class PetManagerAI:
|
||||
NUM_DAILY_PETS = 10
|
||||
NUM_DAILY_PETS = 5 # per hood
|
||||
|
||||
def __init__(self, air):
|
||||
self.air = air
|
||||
self.seeds = simbase.backups.load('pet-seeds', (self.air.districtId,), default={})
|
||||
|
||||
if self.seeds.get('day', -1) != getDayId():
|
||||
self.generateSeeds()
|
||||
|
||||
def generateSeeds(self):
|
||||
seeds = range(0, 255)
|
||||
random.shuffle(seeds)
|
||||
random.Random(getDayId()).shuffle(seeds)
|
||||
|
||||
self.seeds = {}
|
||||
for hood in (ToontownGlobals.ToontownCentral, ToontownGlobals.DonaldsDock, ToontownGlobals.DaisyGardens,
|
||||
ToontownGlobals.MinniesMelodyland, ToontownGlobals.TheBrrrgh, ToontownGlobals.DonaldsDreamland):
|
||||
self.seeds[str(hood)] = [seeds.pop() for _ in xrange(self.NUM_DAILY_PETS)]
|
||||
ToontownGlobals.MinniesMelodyland, ToontownGlobals.TheBrrrgh, ToontownGlobals.DonaldsDreamland,
|
||||
ToontownGlobals.FunnyFarm):
|
||||
self.seeds[hood] = [seeds.pop() for _ in xrange(self.NUM_DAILY_PETS)]
|
||||
|
||||
self.seeds['day'] = getDayId()
|
||||
simbase.backups.save('pet-seeds', (self.air.districtId,), self.seeds)
|
||||
|
||||
def getAvailablePets(self, safezoneId):
|
||||
def getAvailablePets(self, seed, safezoneId):
|
||||
if self.seeds.get('day', -1) != getDayId():
|
||||
self.generateSeeds()
|
||||
|
||||
return self.seeds.get(str(safezoneId), [random.randint(0, 255)])
|
||||
return list(set(self.seeds.get(safezoneId, [seed])))
|
||||
|
||||
def createNewPetFromSeed(self, avId, seed, nameIndex, gender, safeZoneId):
|
||||
av = self.air.doId2do[avId]
|
||||
|
@ -64,4 +64,5 @@ class PetManagerAI:
|
|||
if pet:
|
||||
if pet in self.air.doId2do:
|
||||
self.air.doId2do[pet].requestDelete()
|
||||
|
||||
av.b_setPetId(0)
|
Loading…
Reference in a new issue