mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
Start work on pets
This commit is contained in:
parent
40ada7cdf1
commit
f04bb95b95
6 changed files with 48 additions and 113 deletions
|
@ -20,7 +20,7 @@ dc-file astron/dclass/toon.dc
|
|||
dc-file astron/dclass/otp.dc
|
||||
|
||||
# Core features:
|
||||
want-pets #f
|
||||
want-pets #t
|
||||
want-parties #t
|
||||
want-cogdominiums #f
|
||||
want-achievements #f
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
import random
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from toontown.toonbase import TTLocalizer
|
||||
import os
|
||||
from direct.showbase import AppRunnerGlobal
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from pandac.PandaModules import *
|
||||
|
||||
class PetNameGenerator:
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('PetNameGenerator')
|
||||
boyFirsts = []
|
||||
girlFirsts = []
|
||||
neutralFirsts = []
|
||||
|
||||
def __init__(self):
|
||||
self.generateLists()
|
||||
|
||||
def generateLists(self):
|
||||
self.boyFirsts = []
|
||||
self.girlFirsts = []
|
||||
self.neutralFirsts = []
|
||||
self.nameDictionary = {}
|
||||
searchPath = DSearchPath()
|
||||
if AppRunnerGlobal.appRunner:
|
||||
searchPath.appendDirectory(Filename.expandFrom('$TT_3_ROOT/phase_3/etc'))
|
||||
else:
|
||||
searchPath.appendDirectory(Filename('/phase_3/etc'))
|
||||
if os.path.expandvars('$TOONTOWN') != '':
|
||||
searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('$TOONTOWN/src/configfiles')))
|
||||
else:
|
||||
searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('toontown/src/configfiles')))
|
||||
searchPath.appendDirectory(Filename('.'))
|
||||
if __debug__:
|
||||
filename = '../resources/phase_3/etc/'+TTLocalizer.PetNameMaster
|
||||
else:
|
||||
filename = '/phase_3/etc/'+TTLocalizer.PetNameMaster
|
||||
input = open(filename, 'r')
|
||||
if not input:
|
||||
self.notify.error('PetNameGenerator: Error opening name list text file.')
|
||||
currentLine = input.readline()
|
||||
while currentLine:
|
||||
if currentLine.lstrip()[0:1] != '#':
|
||||
a1 = currentLine.find('*')
|
||||
a2 = currentLine.find('*', a1 + 1)
|
||||
self.nameDictionary[int(currentLine[0:a1])] = (int(currentLine[a1 + 1:a2]), currentLine[a2 + 1:len(currentLine) - 1].strip())
|
||||
currentLine = input.readline()
|
||||
|
||||
masterList = [self.boyFirsts, self.girlFirsts, self.neutralFirsts]
|
||||
for tu in self.nameDictionary.values():
|
||||
masterList[tu[0]].append(tu[1])
|
||||
|
||||
return 1
|
||||
|
||||
def getName(self, uniqueID):
|
||||
try:
|
||||
return self.nameDictionary[uniqueID][1]
|
||||
except:
|
||||
return self.nameDictionary[0][1]
|
||||
|
||||
def returnUniqueID(self, name):
|
||||
newtu = [(), (), ()]
|
||||
newtu[0] = (0, name)
|
||||
newtu[1] = (1, name)
|
||||
newtu[2] = (2, name)
|
||||
for tu in self.nameDictionary.items():
|
||||
for g in newtu:
|
||||
if tu[1] == g:
|
||||
return tu[0]
|
||||
|
||||
return -1
|
||||
|
||||
def randomName(self, gender = None, seed = None):
|
||||
S = random.getstate()
|
||||
if seed is not None:
|
||||
random.seed(seed)
|
||||
if gender is None:
|
||||
gender = random.choice([0, 1])
|
||||
retString = ''
|
||||
firstList = self.neutralFirsts[:]
|
||||
if gender == 0:
|
||||
firstList += self.boyFirsts
|
||||
elif gender == 1:
|
||||
firstList += self.girlFirsts
|
||||
else:
|
||||
self.error('Must be boy or girl.')
|
||||
retString += random.choice(firstList)
|
||||
random.setstate(S)
|
||||
return retString
|
|
@ -1,16 +1,12 @@
|
|||
from toontown.pets import PetDNA, PetTraits, PetConstants
|
||||
from toontown.pets import PetNameGenerator
|
||||
from toontown.toonbase import TTLocalizer
|
||||
from direct.showbase import PythonUtil
|
||||
import random
|
||||
|
||||
def getPetInfoFromSeed(seed, safezoneId):
|
||||
S = random.getstate()
|
||||
random.seed(seed)
|
||||
dnaArray = PetDNA.getRandomPetDNA(safezoneId)
|
||||
gender = PetDNA.getGender(dnaArray)
|
||||
nameString = PetNameGenerator.PetNameGenerator().randomName(gender=gender, seed=seed + safezoneId)
|
||||
nameString = TTLocalizer.getRandomPetName(gender=gender, seed=seed + safezoneId)
|
||||
traitSeed = PythonUtil.randUint31()
|
||||
random.setstate(S)
|
||||
return (nameString, dnaArray, traitSeed)
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ from toontown.hood import ZoneUtil
|
|||
from toontown.pets import Pet, PetConstants
|
||||
from toontown.pets import PetDNA
|
||||
from toontown.pets import PetDetail
|
||||
from toontown.pets import PetNameGenerator
|
||||
from toontown.pets import PetTraits
|
||||
from toontown.pets import PetUtil
|
||||
from toontown.toonbase import TTLocalizer
|
||||
|
@ -66,14 +65,12 @@ class PetshopGUI(DirectObject):
|
|||
self.petModel.reparentTo(self.petView)
|
||||
self.petModel.setH(225)
|
||||
self.petModel.enterNeutralHappy()
|
||||
self.ng = PetNameGenerator.PetNameGenerator()
|
||||
if gender == 1:
|
||||
self.allNames = self.ng.boyFirsts
|
||||
self.allNames = TTLocalizer.NeutralPetNames
|
||||
if gender == 0:
|
||||
self.allNames += TTLocalizer.BoyPetNames
|
||||
else:
|
||||
self.allNames = self.ng.girlFirsts
|
||||
self.allNames += self.ng.neutralFirsts
|
||||
self.allNames += TTLocalizer.GirlPetNames
|
||||
self.allNames.sort()
|
||||
self.checkNames()
|
||||
self.letters = []
|
||||
for name in self.allNames:
|
||||
if name[0:TTLocalizer.PGUIcharLength] not in self.letters:
|
||||
|
@ -87,7 +84,7 @@ class PetshopGUI(DirectObject):
|
|||
self.rebuildNameList()
|
||||
self.randomButton = DirectButton(parent=self, relief=None, image=(self.gui.find('**/RandomUpButton'), self.gui.find('**/RandomDownButton'), self.gui.find('**/RandomRolloverButton')), scale=self.guiScale, text=TTLocalizer.RandomButton, text_pos=(-0.8, -5.7), text_scale=0.8, text_fg=text2Color, pressEffect=False, command=self.randomName)
|
||||
self.nameResult = DirectLabel(parent=self, relief=None, scale=self.guiScale, text='', text_align=TextNode.ACenter, text_pos=(-1.85, 2.6), text_fg=text0Color, text_scale=0.6, text_wordwrap=8)
|
||||
self.submitButton = DirectButton(parent=self, relief=None, image=(self.gui.find('**/SubmitUpButton'), self.gui.find('**/SubmitDownButton'), self.gui.find('**/SubmitRolloverButton')), scale=self.guiScale, text=TTLocalizer.PetshopAdopt, text_pos=(3.3, -5.7), text_scale=TTLocalizer.PGUIsubmitButton, text_fg=text0Color, pressEffect=False, command=lambda : messenger.send(doneEvent, [self.ng.returnUniqueID(self.curName)]))
|
||||
self.submitButton = DirectButton(parent=self, relief=None, image=(self.gui.find('**/SubmitUpButton'), self.gui.find('**/SubmitDownButton'), self.gui.find('**/SubmitRolloverButton')), scale=self.guiScale, text=TTLocalizer.PetshopAdopt, text_pos=(3.3, -5.7), text_scale=TTLocalizer.PGUIsubmitButton, text_fg=text0Color, pressEffect=False, command=lambda : messenger.send(doneEvent, [TTLocalizer.getPetNameId(self.curName)]))
|
||||
model = loader.loadModel('phase_4/models/gui/PetShopInterface')
|
||||
modelScale = 0.1
|
||||
cancelImageList = (model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelButtonRollover'))
|
||||
|
@ -95,12 +92,6 @@ class PetshopGUI(DirectObject):
|
|||
self.cancelButton = DirectButton(parent=self, relief=None, pos=(-0.04, 0, -0.47), image=cancelImageList, geom=cancelIcon, scale=modelScale, pressEffect=False, command=lambda : messenger.send(doneEvent, [-1]))
|
||||
self.randomName()
|
||||
|
||||
def checkNames(self):
|
||||
if __dev__:
|
||||
for name in self.allNames:
|
||||
if not name.replace(' ', '').isalpha():
|
||||
self.notify.warning('Bad name:%s' % name)
|
||||
|
||||
def destroy(self):
|
||||
self.petModel.delete()
|
||||
DirectFrame.destroy(self)
|
||||
|
@ -208,7 +199,7 @@ class PetshopGUI(DirectObject):
|
|||
def __init__(self, doneEvent, petSeed, petNameIndex):
|
||||
zoneId = ZoneUtil.getCanonicalSafeZoneId(base.localAvatar.getZoneId())
|
||||
name, dna, traitSeed = PetUtil.getPetInfoFromSeed(petSeed, zoneId)
|
||||
name = PetNameGenerator.PetNameGenerator().getName(petNameIndex)
|
||||
name = TTLocalizer.getPetName(petNameIndex)
|
||||
cost = PetUtil.getPetCostFromSeed(petSeed, zoneId)
|
||||
model = loader.loadModel('phase_4/models/gui/AdoptPet')
|
||||
modelPos = (0, 0, -0.3)
|
||||
|
|
|
@ -104,7 +104,7 @@ class DistributedNPCPetclerkAI(DistributedNPCToonBaseAI):
|
|||
if av.petId != 0:
|
||||
simbase.air.petMgr.deleteToonsPet(avId)
|
||||
gender = petNum % len(PetDNA.PetGenders)
|
||||
if nameIndex not in xrange(0, TTLocalizer.PetNameIndexMAX):
|
||||
if nameIndex not in xrange(0, len(TTLocalizer.PetNameDictionary) - 1):
|
||||
self.air.writeServerEvent('avoid_crash', avId, "DistributedNPCPetclerkAI.petAdopted and didn't have valid nameIndex!")
|
||||
self.notify.warning("somebody called petAdopted and didn't have valid nameIndex to adopt! avId: %s" % avId)
|
||||
return
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue