def newegg(self, arg, nick, private): if self.check_owner_vacation(nick): return "You cannot generate a new egg when on vacation." if self.num_pets(nick) >= self.MAX_PETS: return "You have reached the maximum number of pets." print("Generating new egg for {0}".format(nick)) with open("attributes/colour") as f: colours = [line.rstrip() for line in f] colour = random.choice(colours) with open("attributes/sound") as f: sounds = [line.rstrip() for line in f] sound = random.choice(sounds) pet = self.get_base_pet_stats() pet['colour'] = colour pet['sound'] = sound pet['stats'] = self.roll_stats() pet.update(faces.generate_face()) genetics_module = self.core.get_module('genetics') if genetics_module: pet['genes'] = genetics_module.generate_pet_genes(pet) record_id = self.db.pets.insert_one(pet).inserted_id self.db.owners.update({ "_id": nick }, { "$push": { "pets": record_id } }) return "You have received an egg! Its colour is {0}. It will hatch in one hour.".format(pet['colour'])
def genface(self, args, nick, private): if not args: return "Usage: !admin genface <owner> <pet id>" pet_module = self.core.modules['pets'] pet = pet_module.get_pet(args[1], args[0]) if not pet: return "No pet found." face = faces.generate_face() self.db.pets.update(pet, { "$set": face }) return "Face generated: {0}".format(faces.get_face(face))
def genface(self, args, nick, private): if not args: return "Usage: !admin genface <owner> <pet id>" pet_module = self.core.modules['pets'] pet = pet_module.get_pet(args[1], args[0]) if not pet: return "No pet found." face = faces.generate_face() self.db.pets.update(pet, {"$set": face}) return "Face generated: {0}".format(faces.get_face(face))