Inventories can now be loaded into penguin data model

This commit is contained in:
Ben 2019-06-07 00:43:56 +01:00
parent 798b4e77b4
commit 717ee41004
2 changed files with 35 additions and 1 deletions

View File

@ -1,5 +1,13 @@
from houdini.data import db
from houdini.data.permission import PermissionCrumbsCollection
from houdini.data.item import ItemCrumbsCollection
from houdini.data.igloo import IglooCrumbsCollection, FlooringCrumbsCollection, LocationCrumbsCollection
from houdini.data.stamp import StampCrumbsCollection
from houdini.data.ninja import CardCrumbsCollection
from houdini.data.mail import PostcardCrumbsCollection
from houdini.data.pet import PuffleCrumbsCollection, PuffleItemCrumbsCollection
class Penguin(db.Model):
__tablename__ = 'penguin'
@ -66,6 +74,32 @@ class Penguin(db.Model):
rejection_de = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
rejection_ru = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
def __init__(self, *args, **kwargs):
self.inventory = None
self.permissions = None
self.igloos = None
self.flooring = None
self.locations = None
self.stamps = None
self.cards = None
self.postcards = None
self.puffles = None
self.puffle_items = None
super().__init__(*args, **kwargs)
async def load_inventories(self):
self.inventory = await ItemCrumbsCollection.get_collection(self.id)
self.permissions = await PermissionCrumbsCollection.get_collection(self.id)
self.igloos = await IglooCrumbsCollection.get_collection(self.id)
self.flooring = await FlooringCrumbsCollection.get_collection(self.id)
self.locations = await LocationCrumbsCollection.get_collection(self.id)
self.stamps = await StampCrumbsCollection.get_collection(self.id)
self.cards = await CardCrumbsCollection.get_collection(self.id)
self.postcards = await PostcardCrumbsCollection.get_collection(self.id)
self.puffles = await PuffleCrumbsCollection.get_collection(self.id)
self.puffle_items = await PuffleItemCrumbsCollection.get_collection(self.id)
def safe_nickname(self, language_bitmask):
return self.nickname if self.approval & language_bitmask else "P" + str(self.id)

View File

@ -20,5 +20,5 @@ async def handle_join_server(p, penguin_id: int, login_key: str, lang: str):
spawn = random.choice(p.server.spawn_rooms)
await spawn.add_penguin(p)
await p.load()
await p.data.load_inventories()
p.joined_world = True