diff --git a/Bootstrap.py b/bootstrap.py similarity index 84% rename from Bootstrap.py rename to bootstrap.py index d43f980..9293360 100644 --- a/Bootstrap.py +++ b/bootstrap.py @@ -1,6 +1,6 @@ import asyncio import sys -from Houdini.HoudiniFactory import HoudiniFactory +from houdini.houdini import HoudiniFactory if __name__ == '__main__': if sys.platform == 'win32': diff --git a/Houdini/__init__.py b/houdini/__init__.py similarity index 100% rename from Houdini/__init__.py rename to houdini/__init__.py diff --git a/Houdini/Commands.py b/houdini/commands.py similarity index 91% rename from Houdini/Commands.py rename to houdini/commands.py index 05f057c..4f2d154 100644 --- a/Houdini/Commands.py +++ b/houdini/commands.py @@ -2,11 +2,11 @@ import inspect import config -from Houdini import Handlers -from Houdini import Plugins -from Houdini import ConflictResolution +from houdini import handlers +from houdini import plugins +from houdini import ConflictResolution -from Houdini.Converters import _ArgumentDeserializer, _listener +from houdini.converters import _ArgumentDeserializer, _listener class UnknownCommandException(Exception): @@ -55,12 +55,12 @@ def group(name=None, **kwargs): string_separator=' ', **kwargs) -cooldown = Handlers.cooldown -check = Handlers.check +cooldown = handlers.cooldown +check = handlers.check -player_attribute = Handlers.player_attribute -player_data_attribute = Handlers.player_data_attribute -player_in_room = Handlers.player_in_room +player_attribute = handlers.player_attribute +player_data_attribute = handlers.player_data_attribute +player_in_room = handlers.player_in_room def is_command(command_object): @@ -69,7 +69,7 @@ def is_command(command_object): def commands_from_plugin(commands, plugin): command_objects = inspect.getmembers(plugin, is_command) - if not isinstance(plugin, Plugins.IPlugin): + if not isinstance(plugin, plugins.IPlugin): raise TypeError('Commands can only be loaded from plugins') for command_name, command_object in command_objects: diff --git a/Houdini/Converters.py b/houdini/converters.py similarity index 96% rename from Houdini/Converters.py rename to houdini/converters.py index 401d5ae..4552da6 100644 --- a/Houdini/Converters.py +++ b/houdini/converters.py @@ -6,7 +6,7 @@ import itertools import inspect -from Houdini.Cooldown import CooldownError +from houdini.cooldown import CooldownError class ChecklistError(Exception): @@ -213,7 +213,7 @@ class ConnectedIglooConverter(IConverter): class RoomConverter(IConverter): - description = """Converts a room ID into a Houdini.Data.Room instance""" + description = """Converts a room ID into a houdini.data.Room instance""" async def convert(self, ctx): room_id = int(ctx.argument) @@ -224,7 +224,7 @@ class RoomConverter(IConverter): class ItemConverter(IConverter): - description = """Converts an item ID into a Houdini.Data.Item instance""" + description = """Converts an item ID into a houdini.data.Item instance""" async def convert(self, ctx): item_id = int(ctx.argument) @@ -235,7 +235,7 @@ class ItemConverter(IConverter): class IglooConverter(IConverter): - description = """Converts an igloo ID into a Houdini.Data.Igloo instance""" + description = """Converts an igloo ID into a houdini.data.Igloo instance""" async def convert(self, ctx): igloo_id = int(ctx.argument) @@ -246,7 +246,7 @@ class IglooConverter(IConverter): class FurnitureConverter(IConverter): - description = """Converts a furniture ID into a Houdini.Data.Furniture instance""" + description = """Converts a furniture ID into a houdini.data.Furniture instance""" async def convert(self, ctx): furniture_id = int(ctx.argument) @@ -257,7 +257,7 @@ class FurnitureConverter(IConverter): class FlooringConverter(IConverter): - description = """Converts a flooring ID into a Houdini.Data.Flooring instance""" + description = """Converts a flooring ID into a houdini.data.Flooring instance""" async def convert(self, ctx): flooring_id = int(ctx.argument) @@ -268,7 +268,7 @@ class FlooringConverter(IConverter): class StampConverter(IConverter): - description = """Converts a stamp ID into a Houdini.Data.Stamp instance""" + description = """Converts a stamp ID into a houdini.data.Stamp instance""" async def convert(self, ctx): stamp_id = int(ctx.argument) diff --git a/Houdini/Cooldown.py b/houdini/cooldown.py similarity index 100% rename from Houdini/Cooldown.py rename to houdini/cooldown.py diff --git a/Houdini/Crypto.py b/houdini/crypto.py similarity index 100% rename from Houdini/Crypto.py rename to houdini/crypto.py diff --git a/Houdini/Data/__init__.py b/houdini/data/__init__.py similarity index 100% rename from Houdini/Data/__init__.py rename to houdini/data/__init__.py diff --git a/Houdini/Data/Buddy.py b/houdini/data/buddy.py similarity index 98% rename from Houdini/Data/Buddy.py rename to houdini/data/buddy.py index 1ebdc98..d5bdf33 100644 --- a/Houdini/Data/Buddy.py +++ b/houdini/data/buddy.py @@ -1,4 +1,4 @@ -from Houdini.Data import db +from houdini.data import db class BuddyList(db.Model): diff --git a/Houdini/Data/Dance.py b/houdini/data/dance.py similarity index 92% rename from Houdini/Data/Dance.py rename to houdini/data/dance.py index 539970b..2f2af5a 100644 --- a/Houdini/Data/Dance.py +++ b/houdini/data/dance.py @@ -1,4 +1,4 @@ -from Houdini.Data import db +from houdini.data import db class DanceSong(db.Model): diff --git a/Houdini/Data/Igloo.py b/houdini/data/igloo.py similarity index 97% rename from Houdini/Data/Igloo.py rename to houdini/data/igloo.py index ac18b7c..5688fae 100644 --- a/Houdini/Data/Igloo.py +++ b/houdini/data/igloo.py @@ -1,5 +1,5 @@ -from Houdini.Data import db, BaseCrumbsCollection -from Houdini.Data.Penguin import PenguinIgloo, PenguinLocation, PenguinFurniture +from houdini.data import db, BaseCrumbsCollection +from houdini.data.penguin import PenguinIgloo, PenguinLocation, PenguinFurniture class Flooring(db.Model): diff --git a/Houdini/Data/Item.py b/houdini/data/item.py similarity index 77% rename from Houdini/Data/Item.py rename to houdini/data/item.py index a5a7d50..bf6b094 100644 --- a/Houdini/Data/Item.py +++ b/houdini/data/item.py @@ -1,5 +1,5 @@ -from Houdini.Data import db, BaseCrumbsCollection -from Houdini.Data.Penguin import PenguinItem +from houdini.data import db, BaseCrumbsCollection +from houdini.data.penguin import PenguinItem class Item(db.Model): @@ -19,6 +19,6 @@ class Item(db.Model): class ItemCrumbsCollection(BaseCrumbsCollection): - def __init__(self, model=Item, key='ID', inventory_model=PenguinItem, inventory_id=None): - super().__init__(model=model, key=key, inventory_model=inventory_model, + def __init__(self, inventory_id=None): + super().__init__(model=Item, key='ID', inventory_model=PenguinItem, inventory_id=inventory_id) diff --git a/Houdini/Data/Mail.py b/houdini/data/mail.py similarity index 85% rename from Houdini/Data/Mail.py rename to houdini/data/mail.py index 68864da..40d0372 100644 --- a/Houdini/Data/Mail.py +++ b/houdini/data/mail.py @@ -1,5 +1,5 @@ -from Houdini.Data import db, BaseCrumbsCollection -from Houdini.Data.Penguin import PenguinPostcard +from houdini.data import db, BaseCrumbsCollection +from houdini.data.penguin import PenguinPostcard class Postcard(db.Model): diff --git a/Houdini/Data/Moderator.py b/houdini/data/moderator.py similarity index 98% rename from Houdini/Data/Moderator.py rename to houdini/data/moderator.py index cae997a..54ad136 100644 --- a/Houdini/Data/Moderator.py +++ b/houdini/data/moderator.py @@ -1,4 +1,4 @@ -from Houdini.Data import db +from houdini.data import db class Ban(db.Model): diff --git a/Houdini/Data/Music.py b/houdini/data/music.py similarity index 97% rename from Houdini/Data/Music.py rename to houdini/data/music.py index 1d368d9..99f8dd1 100644 --- a/Houdini/Data/Music.py +++ b/houdini/data/music.py @@ -1,4 +1,4 @@ -from Houdini.Data import db +from houdini.data import db class PenguinTrack(db.Model): diff --git a/Houdini/Data/Ninja.py b/houdini/data/ninja.py similarity index 90% rename from Houdini/Data/Ninja.py rename to houdini/data/ninja.py index 9af7dcd..6bcb8cb 100644 --- a/Houdini/Data/Ninja.py +++ b/houdini/data/ninja.py @@ -1,5 +1,5 @@ -from Houdini.Data import db, BaseCrumbsCollection -from Houdini.Data.Penguin import PenguinCard +from houdini.data import db, BaseCrumbsCollection +from houdini.data.penguin import PenguinCard class Card(db.Model): diff --git a/Houdini/Data/Penguin.py b/houdini/data/penguin.py similarity index 95% rename from Houdini/Data/Penguin.py rename to houdini/data/penguin.py index 509ca04..3db744f 100644 --- a/Houdini/Data/Penguin.py +++ b/houdini/data/penguin.py @@ -1,4 +1,4 @@ -from Houdini.Data import db +from houdini.data import db class Penguin(db.Model): @@ -71,6 +71,11 @@ class Penguin(db.Model): return int('{}{}0{}{}{}{}'.format(self.ApprovalRu * 1, self.ApprovalDe * 1, self.ApprovalEs * 1, self.ApprovalFr * 1, self.ApprovalPt * 1, self.ApprovalEn * 1), 2) + @property + def rejection(self): + return int('{}{}0{}{}{}{}'.format(self.RejectionRu * 1, self.RejectionDe * 1, self.RejectionEs * 1, + self.RejectionFr * 1, self.RejectionPt * 1, self.RejectionEn * 1), 2) + class ActivationKey(db.Model): __tablename__ = 'activation_key' @@ -233,6 +238,13 @@ class PenguinPuffleItem(db.Model): Quantity = db.Column(db.SmallInteger, nullable=False) +class PenguinPermission(db.Model): + __tablename__ = 'penguin_permission' + + PenguinID = db.Column(db.ForeignKey(u'penguin.ID', ondelete=u'CASCADE', onupdate=u'CASCADE'), primary_key=True) + PermissionID = db.Column(db.ForeignKey(u'permission.ID', ondelete=u'CASCADE', onupdate=u'CASCADE'), nullable=False) + + class Login(db.Model): __tablename__ = 'login' diff --git a/Houdini/Data/Pet.py b/houdini/data/pet.py similarity index 97% rename from Houdini/Data/Pet.py rename to houdini/data/pet.py index 778f0d0..2b778fe 100644 --- a/Houdini/Data/Pet.py +++ b/houdini/data/pet.py @@ -1,5 +1,5 @@ -from Houdini.Data import db, BaseCrumbsCollection -from Houdini.Data.Penguin import PenguinPuffle, PenguinPuffleItem +from houdini.data import db, BaseCrumbsCollection +from houdini.data.penguin import PenguinPuffle, PenguinPuffleItem class Puffle(db.Model): diff --git a/Houdini/Data/Redemption.py b/houdini/data/redemption.py similarity index 99% rename from Houdini/Data/Redemption.py rename to houdini/data/redemption.py index 9ae124a..b6937af 100644 --- a/Houdini/Data/Redemption.py +++ b/houdini/data/redemption.py @@ -1,4 +1,4 @@ -from Houdini.Data import db +from houdini.data import db class RedemptionBook(db.Model): diff --git a/Houdini/Data/Room.py b/houdini/data/room.py similarity index 99% rename from Houdini/Data/Room.py rename to houdini/data/room.py index 1907749..8ac1921 100644 --- a/Houdini/Data/Room.py +++ b/houdini/data/room.py @@ -1,4 +1,4 @@ -from Houdini.Data import db, BaseCrumbsCollection +from houdini.data import db, BaseCrumbsCollection class Room(db.Model): diff --git a/Houdini/Data/Stamp.py b/houdini/data/stamp.py similarity index 95% rename from Houdini/Data/Stamp.py rename to houdini/data/stamp.py index 972531e..ac3fe5d 100644 --- a/Houdini/Data/Stamp.py +++ b/houdini/data/stamp.py @@ -1,5 +1,5 @@ -from Houdini.Data import db, BaseCrumbsCollection -from Houdini.Data.Penguin import PenguinStamp +from houdini.data import db, BaseCrumbsCollection +from houdini.data.penguin import PenguinStamp class Stamp(db.Model): diff --git a/Houdini/Events/__init__.py b/houdini/events/__init__.py similarity index 100% rename from Houdini/Events/__init__.py rename to houdini/events/__init__.py diff --git a/Houdini/Events/HandlerFileEvent.py b/houdini/events/handler_file_event.py similarity index 95% rename from Houdini/Events/HandlerFileEvent.py rename to houdini/events/handler_file_event.py index c3b6934..952f6e7 100644 --- a/Houdini/Events/HandlerFileEvent.py +++ b/houdini/events/handler_file_event.py @@ -3,8 +3,8 @@ import importlib import copy from watchdog.events import FileSystemEventHandler -from Houdini.Handlers import listeners_from_module, remove_handlers_by_module -from Houdini.Events import evaluate_handler_file_event +from houdini.handlers import listeners_from_module, remove_handlers_by_module +from houdini.events import evaluate_handler_file_event class HandlerFileEventHandler(FileSystemEventHandler): diff --git a/Houdini/Events/PluginFileEvent.py b/houdini/events/plugin_file_event.py similarity index 98% rename from Houdini/Events/PluginFileEvent.py rename to houdini/events/plugin_file_event.py index d939bf6..68308fd 100644 --- a/Houdini/Events/PluginFileEvent.py +++ b/houdini/events/plugin_file_event.py @@ -5,7 +5,7 @@ import copy import asyncio from watchdog.events import FileSystemEventHandler -from Houdini.Events import evaluate_handler_file_event +from houdini.events import evaluate_handler_file_event class PluginFileEventHandler(FileSystemEventHandler): diff --git a/Houdini/Handlers/__init__.py b/houdini/handlers/__init__.py similarity index 97% rename from Houdini/Handlers/__init__.py rename to houdini/handlers/__init__.py index c8d32bc..fa8be9b 100644 --- a/Houdini/Handlers/__init__.py +++ b/houdini/handlers/__init__.py @@ -4,10 +4,10 @@ import os import itertools from types import FunctionType -from Houdini.Converters import _listener, _ArgumentDeserializer, get_converter, do_conversion, _ConverterContext +from houdini.converters import _listener, _ArgumentDeserializer, get_converter, do_conversion, _ConverterContext -from Houdini.Cooldown import _Cooldown, _CooldownMapping, BucketType -from Houdini import Plugins +from houdini.cooldown import _Cooldown, _CooldownMapping, BucketType +from houdini import plugins class AuthorityError(Exception): @@ -132,7 +132,7 @@ def is_listener(listener): def listeners_from_module(xt_listeners, xml_listeners, module): listener_objects = inspect.getmembers(module, is_listener) for listener_name, listener_object in listener_objects: - if isinstance(module, Plugins.IPlugin): + if isinstance(module, plugins.IPlugin): listener_object.instance = module listener_collection = xt_listeners if type(listener_object) == _XTListener else xml_listeners diff --git a/Houdini/Handlers/Games/Ninja/__init__.py b/houdini/handlers/games/__init__.py similarity index 100% rename from Houdini/Handlers/Games/Ninja/__init__.py rename to houdini/handlers/games/__init__.py diff --git a/Houdini/Handlers/Games/Dance.py b/houdini/handlers/games/dance.py similarity index 100% rename from Houdini/Handlers/Games/Dance.py rename to houdini/handlers/games/dance.py diff --git a/Houdini/Handlers/Games/FindFour.py b/houdini/handlers/games/four.py similarity index 100% rename from Houdini/Handlers/Games/FindFour.py rename to houdini/handlers/games/four.py diff --git a/Houdini/Handlers/Games/Mancala.py b/houdini/handlers/games/mancala.py similarity index 100% rename from Houdini/Handlers/Games/Mancala.py rename to houdini/handlers/games/mancala.py diff --git a/Houdini/Handlers/Games/MatchMaking.py b/houdini/handlers/games/match.py similarity index 100% rename from Houdini/Handlers/Games/MatchMaking.py rename to houdini/handlers/games/match.py diff --git a/Houdini/Handlers/Games/__init__.py b/houdini/handlers/games/ninja/__init__.py similarity index 100% rename from Houdini/Handlers/Games/__init__.py rename to houdini/handlers/games/ninja/__init__.py diff --git a/Houdini/Handlers/Games/Ninja/CardFire.py b/houdini/handlers/games/ninja/card.py similarity index 100% rename from Houdini/Handlers/Games/Ninja/CardFire.py rename to houdini/handlers/games/ninja/card.py diff --git a/Houdini/Handlers/Games/Ninja/CardJitsu.py b/houdini/handlers/games/ninja/fire.py similarity index 100% rename from Houdini/Handlers/Games/Ninja/CardJitsu.py rename to houdini/handlers/games/ninja/fire.py diff --git a/Houdini/Handlers/Games/Ninja/CardWater.py b/houdini/handlers/games/ninja/water.py similarity index 100% rename from Houdini/Handlers/Games/Ninja/CardWater.py rename to houdini/handlers/games/ninja/water.py diff --git a/Houdini/Handlers/Games/SledRace.py b/houdini/handlers/games/sled.py similarity index 100% rename from Houdini/Handlers/Games/SledRace.py rename to houdini/handlers/games/sled.py diff --git a/Houdini/Handlers/Games/TreasureHunt.py b/houdini/handlers/games/treasure.py similarity index 100% rename from Houdini/Handlers/Games/TreasureHunt.py rename to houdini/handlers/games/treasure.py diff --git a/Houdini/Handlers/Login/__init__.py b/houdini/handlers/login/__init__.py similarity index 61% rename from Houdini/Handlers/Login/__init__.py rename to houdini/handlers/login/__init__.py index ef40775..e7b0d11 100644 --- a/Houdini/Handlers/Login/__init__.py +++ b/houdini/handlers/login/__init__.py @@ -1,10 +1,10 @@ -from Houdini import Handlers -from Houdini.Handlers import XMLPacket -from Houdini.Converters import VersionChkConverter +from houdini import handlers +from houdini.handlers import XMLPacket +from houdini.converters import VersionChkConverter -@Handlers.handler(XMLPacket('verChk')) -@Handlers.allow_once() +@handlers.handler(XMLPacket('verChk')) +@handlers.allow_once() async def handle_version_check(p, version: VersionChkConverter): if not version == 153: await p.send_xml({'body': {'action': 'apiKO', 'r': '0'}}) @@ -13,7 +13,7 @@ async def handle_version_check(p, version: VersionChkConverter): await p.send_xml({'body': {'action': 'apiOK', 'r': '0'}}) -@Handlers.handler(XMLPacket('rndK')) -@Handlers.allow_once() +@handlers.handler(XMLPacket('rndK')) +@handlers.allow_once() async def handle_random_key(p, data): await p.send_xml({'body': {'action': 'rndK', 'r': '-1'}, 'k': 'houdini'}) diff --git a/Houdini/Handlers/Login/Login.py b/houdini/handlers/login/login.py similarity index 82% rename from Houdini/Handlers/Login/Login.py rename to houdini/handlers/login/login.py index ce7b5d2..6244a40 100644 --- a/Houdini/Handlers/Login/Login.py +++ b/houdini/handlers/login/login.py @@ -1,10 +1,10 @@ -from Houdini import Handlers -from Houdini.Handlers import XMLPacket, Login -from Houdini.Converters import CredentialsConverter -from Houdini.Data.Penguin import Penguin -from Houdini.Data.Buddy import BuddyList -from Houdini.Data.Moderator import Ban -from Houdini.Crypto import Crypto +from houdini import handlers +from houdini.handlers import XMLPacket, login +from houdini.converters import CredentialsConverter +from houdini.data.penguin import Penguin +from houdini.data.buddy import BuddyList +from houdini.data.moderator import Ban +from houdini.crypto import Crypto import asyncio import bcrypt @@ -15,8 +15,8 @@ import config from datetime import datetime -@Handlers.handler(XMLPacket('login')) -@Handlers.allow_once() +@handlers.handler(XMLPacket('login')) +@handlers.allow_once() async def handle_login(p, credentials: CredentialsConverter): loop = asyncio.get_event_loop() @@ -97,7 +97,8 @@ async def handle_login(p, credentials: CredentialsConverter): for server_name, server_config in servers_config.items(): if server_config['World']: server_population = await p.server.redis.get('{}.population'.format(server_name)) - server_population = int(server_population) / (server_config['Capacity'] / 6) if server_population else 0 + server_population = (7 if int(server_population) == server_config['Capacity'] \ + else int(server_population) / (server_config['Capacity'] / 6)) if server_population else 0 server_players = await p.server.redis.smembers('{}.players'.format(server_name)) @@ -113,8 +114,9 @@ async def handle_login(p, credentials: CredentialsConverter): buddy_worlds.append(server_config['Id']) break - raw_login_data = '|'.join([str(data.ID), str(data.ID), data.Username, login_key, str(data.approval), '1']) - await p.send_xt('l', raw_login_data, confirmation_hash, 'friendsKey', '|'.join(world_populations), data.Email) + raw_login_data = '|'.join([str(data.ID), str(data.ID), data.Username, login_key, str(data.approval), + str(data.rejection)]) + await p.send_xt('l', raw_login_data, confirmation_hash, '', '|'.join(world_populations), '|'.join(buddy_worlds), data.Email) -handle_version_check = Login.handle_version_check -handle_random_key = Login.handle_random_key +handle_version_check = login.handle_version_check +handle_random_key = login.handle_random_key diff --git a/Houdini/Handlers/Play/__init__.py b/houdini/handlers/play/__init__.py similarity index 100% rename from Houdini/Handlers/Play/__init__.py rename to houdini/handlers/play/__init__.py diff --git a/Houdini/Handlers/Login/World.py b/houdini/handlers/play/buddy.py similarity index 100% rename from Houdini/Handlers/Login/World.py rename to houdini/handlers/play/buddy.py diff --git a/Houdini/Handlers/Play/Buddy.py b/houdini/handlers/play/epf.py similarity index 100% rename from Houdini/Handlers/Play/Buddy.py rename to houdini/handlers/play/epf.py diff --git a/Houdini/Handlers/Play/EPF.py b/houdini/handlers/play/igloo.py similarity index 100% rename from Houdini/Handlers/Play/EPF.py rename to houdini/handlers/play/igloo.py diff --git a/Houdini/Handlers/Play/Igloo.py b/houdini/handlers/play/ignore.py similarity index 100% rename from Houdini/Handlers/Play/Igloo.py rename to houdini/handlers/play/ignore.py diff --git a/Houdini/Handlers/Play/Ignore.py b/houdini/handlers/play/item.py similarity index 100% rename from Houdini/Handlers/Play/Ignore.py rename to houdini/handlers/play/item.py diff --git a/Houdini/Handlers/Play/Item.py b/houdini/handlers/play/mail.py similarity index 100% rename from Houdini/Handlers/Play/Item.py rename to houdini/handlers/play/mail.py diff --git a/Houdini/Handlers/Play/Mail.py b/houdini/handlers/play/moderation.py similarity index 100% rename from Houdini/Handlers/Play/Mail.py rename to houdini/handlers/play/moderation.py diff --git a/Houdini/Handlers/Play/Moderation.py b/houdini/handlers/play/music.py similarity index 100% rename from Houdini/Handlers/Play/Moderation.py rename to houdini/handlers/play/music.py diff --git a/Houdini/Handlers/Play/Music.py b/houdini/handlers/play/navigation.py similarity index 100% rename from Houdini/Handlers/Play/Music.py rename to houdini/handlers/play/navigation.py diff --git a/Houdini/Handlers/Play/Navigation.py b/houdini/handlers/play/ninja.py similarity index 100% rename from Houdini/Handlers/Play/Navigation.py rename to houdini/handlers/play/ninja.py diff --git a/Houdini/Handlers/Play/Ninja.py b/houdini/handlers/play/pet.py similarity index 100% rename from Houdini/Handlers/Play/Ninja.py rename to houdini/handlers/play/pet.py diff --git a/Houdini/Handlers/Play/Pet.py b/houdini/handlers/play/player.py similarity index 100% rename from Houdini/Handlers/Play/Pet.py rename to houdini/handlers/play/player.py diff --git a/Houdini/Handlers/Play/Player.py b/houdini/handlers/play/room.py similarity index 100% rename from Houdini/Handlers/Play/Player.py rename to houdini/handlers/play/room.py diff --git a/Houdini/Handlers/Play/Room.py b/houdini/handlers/play/setting.py similarity index 100% rename from Houdini/Handlers/Play/Room.py rename to houdini/handlers/play/setting.py diff --git a/Houdini/Handlers/Play/Setting.py b/houdini/handlers/play/stampbook.py similarity index 100% rename from Houdini/Handlers/Play/Setting.py rename to houdini/handlers/play/stampbook.py diff --git a/Houdini/Handlers/Play/Stampbook.py b/houdini/handlers/play/toy.py similarity index 100% rename from Houdini/Handlers/Play/Stampbook.py rename to houdini/handlers/play/toy.py diff --git a/Houdini/Handlers/Play/Toy.py b/houdini/handlers/redemption/__init__.py similarity index 100% rename from Houdini/Handlers/Play/Toy.py rename to houdini/handlers/redemption/__init__.py diff --git a/Houdini/HoudiniFactory.py b/houdini/houdini.py similarity index 86% rename from Houdini/HoudiniFactory.py rename to houdini/houdini.py index 191e7d8..dd6591a 100644 --- a/Houdini/HoudiniFactory.py +++ b/houdini/houdini.py @@ -4,9 +4,9 @@ import sys import pkgutil import importlib -from Houdini.Spheniscidae import Spheniscidae -from Houdini.Penguin import Penguin -from Houdini import PenguinStringCompiler +from houdini.spheniscidae import Spheniscidae +from houdini.penguin import Penguin +from houdini import PenguinStringCompiler import config from aiologger import Logger @@ -20,15 +20,17 @@ import aioredis from aiocache import SimpleMemoryCache from watchdog.observers import Observer -from Houdini.Data import db -from Houdini.Data.Item import ItemCrumbsCollection -from Houdini.Data.Igloo import IglooCrumbsCollection, FurnitureCrumbsCollection, \ +from houdini.data import db +from houdini.data.item import ItemCrumbsCollection +from houdini.data.igloo import IglooCrumbsCollection, FurnitureCrumbsCollection, \ LocationCrumbsCollection, FlooringCrumbsCollection -from Houdini.Data.Room import RoomCrumbsCollection -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 +from houdini.data.room import RoomCrumbsCollection +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 + +from houdini.data.permission import PermissionCrumbsCollection try: import uvloop @@ -36,14 +38,14 @@ try: except ImportError: uvloop = None -import Houdini.Handlers -from Houdini.Handlers import listeners_from_module, remove_handlers_by_module -from Houdini.Events.HandlerFileEvent import HandlerFileEventHandler -from Houdini.Events.PluginFileEvent import PluginFileEventHandler +import houdini.handlers +from houdini.handlers import listeners_from_module, remove_handlers_by_module +from houdini.events.handler_file_event import HandlerFileEventHandler +from houdini.events.plugin_file_event import PluginFileEventHandler -from Houdini.Commands import commands_from_plugin +from houdini.commands import commands_from_plugin -import Houdini.Plugins as Plugins +import houdini.plugins as plugins class HoudiniFactory: @@ -103,7 +105,7 @@ class HoudiniFactory: os.mkdir(errors_log_directory) if sys.platform != 'win32': - self.logger = Logger(name='Houdini') + self.logger = Logger(name='houdini') universal_handler = AsyncTimedRotatingFileHandler( filename=self.server_config['Logging']['General'], backup_count=3, @@ -112,7 +114,7 @@ class HoudiniFactory: error_handler = AsyncFileHandler(filename=self.server_config['Logging']['Errors']) console_handler = AsyncStreamHandler(stream=sys.stdout) else: - self.logger = logging.getLogger('Houdini') + self.logger = logging.getLogger('houdini') universal_handler = RotatingFileHandler(self.server_config['Logging']['General'], maxBytes=2097152, backupCount=3, encoding='utf-8') @@ -142,7 +144,7 @@ class HoudiniFactory: self.config.database['Address'], self.config.database['Name'])) - self.logger.info('Houdini module instantiated') + self.logger.info('houdini module instantiated') self.redis = await aioredis.create_redis_pool('redis://{}:{}'.format( self.config.redis['Address'], self.config.redis['Port']), @@ -161,10 +163,10 @@ class HoudiniFactory: 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.load_handler_modules(exclude_load='houdini.Handlers.Login.Login') self.logger.info('World server started') else: - self.load_handler_modules('Houdini.Handlers.Login.Login') + self.load_handler_modules('houdini.Handlers.Login.Login') self.logger.info('Login server started') self.items = await ItemCrumbsCollection.get_collection() @@ -203,8 +205,8 @@ class HoudiniFactory: self.puffle_items = await PuffleItemCrumbsCollection.get_collection() self.logger.info('Loaded {} puffle care items'.format(len(self.puffle_items))) - handlers_path = './Houdini{}Handlers'.format(os.path.sep) - plugins_path = './Houdini{}Plugins'.format(os.path.sep) + handlers_path = './houdini{}handlers'.format(os.path.sep) + plugins_path = './houdini{}plugins'.format(os.path.sep) self.configure_observers([handlers_path, HandlerFileEventHandler], [plugins_path, PluginFileEventHandler]) @@ -216,7 +218,7 @@ class HoudiniFactory: await self.server.serve_forever() async def load_plugins(self): - for plugin_package in self.get_package_modules(Plugins): + for plugin_package in self.get_package_modules(plugins): await self.load_plugin(plugin_package) async def load_plugin(self, plugin): @@ -227,7 +229,7 @@ class HoudiniFactory: plugin_object = getattr(plugin_module, plugin_class)(self) - if isinstance(plugin_object, Plugins.IPlugin): + if isinstance(plugin_object, plugins.IPlugin): self.plugins[plugin_class] = plugin_object listeners_from_module(self.xt_listeners, self.xml_listeners, plugin_object) @@ -251,7 +253,7 @@ class HoudiniFactory: await client_object.run() def load_handler_modules(self, strict_load=None, exclude_load=None): - for handler_module in self.get_package_modules(Houdini.Handlers): + for handler_module in self.get_package_modules(houdini.handlers): if not (strict_load and handler_module not in strict_load or exclude_load and handler_module in exclude_load): if handler_module not in sys.modules.keys(): module = importlib.import_module(handler_module) @@ -269,7 +271,7 @@ class HoudiniFactory: subpackage_object = importlib.import_module(full_module_name, package=package.__path__) subpackage_object_directory = dir(subpackage_object) - if Plugins.IPlugin.__name__ in subpackage_object_directory: + if plugins.IPlugin.__name__ in subpackage_object_directory: package_modules.append((subpackage_object, module_name)) continue diff --git a/Houdini/Penguin.py b/houdini/penguin.py similarity index 96% rename from Houdini/Penguin.py rename to houdini/penguin.py index 85ff190..07a1b04 100644 --- a/Houdini/Penguin.py +++ b/houdini/penguin.py @@ -1,4 +1,4 @@ -from Houdini.Spheniscidae import Spheniscidae +from houdini.spheniscidae import Spheniscidae class Penguin(Spheniscidae): diff --git a/Houdini/Plugins/__init__.py b/houdini/plugins/__init__.py similarity index 100% rename from Houdini/Plugins/__init__.py rename to houdini/plugins/__init__.py diff --git a/Houdini/Spheniscidae.py b/houdini/spheniscidae.py similarity index 96% rename from Houdini/Spheniscidae.py rename to houdini/spheniscidae.py index a312dc7..e908aca 100644 --- a/Houdini/Spheniscidae.py +++ b/houdini/spheniscidae.py @@ -1,5 +1,5 @@ -from Houdini import Handlers -from Houdini.Handlers import XMLPacket, XTPacket +from houdini import handlers +from houdini.handlers import XMLPacket, XTPacket from asyncio import IncompleteReadError @@ -85,7 +85,7 @@ class Spheniscidae: packet_id = parsed_data[2] packet = XTPacket(packet_id) - if Handlers.listener_exists(self.server.xt_listeners, self.server.xml_listeners, packet): + if handlers.listener_exists(self.server.xt_listeners, self.server.xml_listeners, packet): xt_listeners = self.server.xt_listeners[packet] packet_data = parsed_data[4:] @@ -111,7 +111,7 @@ class Spheniscidae: action = body_tag.get('action') packet = XMLPacket(action) - if Handlers.listener_exists(self.server.xt_listeners, self.server.xml_listeners, packet): + if handlers.listener_exists(self.server.xt_listeners, self.server.xml_listeners, packet): xml_listeners = self.server.xml_listeners[packet] for listener in xml_listeners: