From 550704132bb99a9ec752162b95e7a2f130ee5f83 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 22 Apr 2019 01:17:56 +0100 Subject: [PATCH] Setup default penguin string builders on server boot --- Houdini/HoudiniFactory.py | 5 +++++ Houdini/Penguin.py | 22 +++++++++++++++++++++- Houdini/__init__.py | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/Houdini/HoudiniFactory.py b/Houdini/HoudiniFactory.py index 2d8f410..7db4a22 100644 --- a/Houdini/HoudiniFactory.py +++ b/Houdini/HoudiniFactory.py @@ -57,6 +57,7 @@ class HoudiniFactory: self.client_class = Spheniscidae self.penguin_string_compiler = None + self.anonymous_penguin_string_compiler = None self.penguins_by_id = {} self.penguins_by_username = {} @@ -135,6 +136,10 @@ class HoudiniFactory: self.client_class = Penguin self.penguin_string_compiler = PenguinStringCompiler() + self.anonymous_penguin_string_compiler = PenguinStringCompiler() + + PenguinStringCompiler.setup_default_builder(self.penguin_string_compiler) + PenguinStringCompiler.setup_anonymous_default_builder(self.anonymous_penguin_string_compiler) self.load_handler_modules(exclude_load="Houdini.Handlers.Login.Login") self.logger.info('World server started') diff --git a/Houdini/Penguin.py b/Houdini/Penguin.py index 019e0a2..85ff190 100644 --- a/Houdini/Penguin.py +++ b/Houdini/Penguin.py @@ -3,7 +3,8 @@ from Houdini.Spheniscidae import Spheniscidae class Penguin(Spheniscidae): - __slots__ = ['x', 'y', 'room', 'waddle', 'table', 'data'] + __slots__ = ['x', 'y', 'room', 'waddle', 'table', 'data', 'member', + 'membership_days', 'avatar', 'walking_puffle'] def __init__(self, *args): super().__init__(*args) @@ -15,8 +16,27 @@ class Penguin(Spheniscidae): self.data = None + self.member = None + self.membership_days = 0 + + self.avatar = None + + self.walking_puffle = None + self.logger.debug('New penguin created') + @property + def party_state(self): + return str() + + @property + def puffle_state(self): + return str() + + @property + def penguin_state(self): + return str() + async def add_inventory(self, item): pass diff --git a/Houdini/__init__.py b/Houdini/__init__.py index 4ae8ce1..07e6b80 100644 --- a/Houdini/__init__.py +++ b/Houdini/__init__.py @@ -38,3 +38,42 @@ class PenguinStringCompiler(OrderedDict): async def attribute_method(p): return getattr(p.data, attribute_name) return attribute_method + + @classmethod + def setup_default_builder(cls, string_builder): + string_builder.update({ + 'ID': PenguinStringCompiler.data_attribute_by_name('ID'), + 'Nickname': PenguinStringCompiler.data_attribute_by_name('Nickname'), + 'Approval': PenguinStringCompiler.attribute_by_name('approval'), + 'Color': PenguinStringCompiler.data_attribute_by_name('Color'), + 'Head': PenguinStringCompiler.data_attribute_by_name('Head'), + 'Face': PenguinStringCompiler.data_attribute_by_name('Face'), + 'Neck': PenguinStringCompiler.data_attribute_by_name('Neck'), + 'Body': PenguinStringCompiler.data_attribute_by_name('Body'), + 'Hand': PenguinStringCompiler.data_attribute_by_name('Name'), + 'Photo': PenguinStringCompiler.data_attribute_by_name('Photo'), + 'X': PenguinStringCompiler.attribute_by_name('x'), + 'Y': PenguinStringCompiler.attribute_by_name('y'), + 'Frame': PenguinStringCompiler.attribute_by_name('frame'), + 'Member': PenguinStringCompiler.attribute_by_name('member'), + 'MemberDays': PenguinStringCompiler.attribute_by_name('membership_days'), + 'Avatar': PenguinStringCompiler.attribute_by_name('avatar'), + 'PenguinState': PenguinStringCompiler.attribute_by_name('penguin_state'), + 'PartyState': PenguinStringCompiler.attribute_by_name('party_state'), + 'PuffleState': PenguinStringCompiler.attribute_by_name('puffle_state') + }) + + @classmethod + def setup_anonymous_default_builder(cls, string_builder): + string_builder.update({ + 'ID': PenguinStringCompiler.attribute_by_name('ID'), + 'Nickname': PenguinStringCompiler.attribute_by_name('Nickname'), + 'Approval': PenguinStringCompiler.attribute_by_name('approval'), + 'Color': PenguinStringCompiler.attribute_by_name('Color'), + 'Head': PenguinStringCompiler.attribute_by_name('Head'), + 'Face': PenguinStringCompiler.attribute_by_name('Face'), + 'Neck': PenguinStringCompiler.attribute_by_name('Neck'), + 'Body': PenguinStringCompiler.attribute_by_name('Body'), + 'Hand': PenguinStringCompiler.attribute_by_name('Name'), + 'Photo': PenguinStringCompiler.attribute_by_name('Photo') + })