From 5249ce02a50d7471389c90fb7c355881b54e7e81 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 7 Jun 2019 00:40:32 +0100 Subject: [PATCH] Move all inventory table models to their respective module --- houdini/data/igloo.py | 38 ++++++++- houdini/data/item.py | 10 ++- houdini/data/mail.py | 19 ++++- houdini/data/ninja.py | 13 ++- houdini/data/penguin.py | 160 ------------------------------------- houdini/data/permission.py | 8 +- houdini/data/pet.py | 54 ++++++++++++- houdini/data/redemption.py | 10 +++ houdini/data/room.py | 13 +++ houdini/data/stamp.py | 11 ++- 10 files changed, 166 insertions(+), 170 deletions(-) diff --git a/houdini/data/igloo.py b/houdini/data/igloo.py index d60c522..4908959 100644 --- a/houdini/data/igloo.py +++ b/houdini/data/igloo.py @@ -1,5 +1,4 @@ from houdini.data import db, BaseCrumbsCollection -from houdini.data.penguin import PenguinIgloo, PenguinLocation, PenguinFurniture, PenguinFlooring class Flooring(db.Model): @@ -69,6 +68,43 @@ class Location(db.Model): patched = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) +class PenguinIgloo(db.Model): + __tablename__ = 'penguin_igloo' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + igloo_id = db.Column(db.ForeignKey('igloo.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + + +class PenguinLocation(db.Model): + __tablename__ = 'penguin_location' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + location_id = db.Column(db.ForeignKey('location.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + + +class PenguinFurniture(db.Model): + __tablename__ = 'penguin_furniture' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + furniture_id = db.Column(db.ForeignKey('furniture.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1")) + + +class PenguinFlooring(db.Model): + __tablename__ = 'penguin_flooring' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + flooring_id = db.Column(db.ForeignKey('flooring.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + + class IglooCrumbsCollection(BaseCrumbsCollection): def __init__(self, inventory_id=None): diff --git a/houdini/data/item.py b/houdini/data/item.py index ed99336..be44ff3 100644 --- a/houdini/data/item.py +++ b/houdini/data/item.py @@ -1,5 +1,4 @@ from houdini.data import db, BaseCrumbsCollection -from houdini.data.penguin import PenguinItem class Item(db.Model): @@ -17,6 +16,15 @@ class Item(db.Model): release_date = db.Column(db.Date, nullable=False, server_default=db.text("now()")) +class PenguinItem(db.Model): + __tablename__ = 'penguin_item' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), + primary_key=True, nullable=False) + item_id = db.Column(db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'), + primary_key=True, nullable=False) + + class ItemCrumbsCollection(BaseCrumbsCollection): def __init__(self, inventory_id=None): diff --git a/houdini/data/mail.py b/houdini/data/mail.py index a9dee9b..af9daf3 100644 --- a/houdini/data/mail.py +++ b/houdini/data/mail.py @@ -1,5 +1,4 @@ from houdini.data import db, BaseCrumbsCollection -from houdini.data.penguin import PenguinPostcard class Postcard(db.Model): @@ -11,12 +10,26 @@ class Postcard(db.Model): enabled = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) +class PenguinPostcard(db.Model): + __tablename__ = 'penguin_postcard' + + id = db.Column(db.Integer, primary_key=True, + server_default=db.text("nextval('\"penguin_postcard_id_seq\"'::regclass)")) + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False, + index=True) + sender_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), index=True) + postcard_id = db.Column(db.ForeignKey('postcard.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) + send_date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()")) + details = db.Column(db.String(255), nullable=False, server_default=db.text("''::character varying")) + has_read = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) + + class PostcardCrumbsCollection(BaseCrumbsCollection): def __init__(self, inventory_id=None): super().__init__(model=Postcard, key='id', inventory_model=PenguinPostcard, - inventory_key='recipient_id', - inventory_value='postcard_id', + inventory_key='penguin_id', + inventory_value='id', inventory_id=inventory_id) diff --git a/houdini/data/ninja.py b/houdini/data/ninja.py index 2efdc74..00ddcb2 100644 --- a/houdini/data/ninja.py +++ b/houdini/data/ninja.py @@ -1,5 +1,4 @@ from houdini.data import db, BaseCrumbsCollection -from houdini.data.penguin import PenguinCard class Card(db.Model): @@ -15,10 +14,22 @@ class Card(db.Model): description = db.Column(db.String(255), nullable=False, server_default=db.text("''::character varying")) +class PenguinCard(db.Model): + __tablename__ = 'penguin_card' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False, index=True) + card_id = db.Column(db.ForeignKey('card.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1")) + + class CardCrumbsCollection(BaseCrumbsCollection): def __init__(self, inventory_id=None): super().__init__(model=Card, key='id', + inventory_key='penguin_id', + inventory_value='card_id', inventory_model=PenguinCard, inventory_id=inventory_id) diff --git a/houdini/data/penguin.py b/houdini/data/penguin.py index 0f2efd0..e2bf7c1 100644 --- a/houdini/data/penguin.py +++ b/houdini/data/penguin.py @@ -88,64 +88,6 @@ class ActivationKey(db.Model): activation_key = db.Column(db.CHAR(255), primary_key=True, nullable=False) -class PuffleQuest(db.Model): - __tablename__ = 'puffle_quest' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - task_id = db.Column(db.SmallInteger, primary_key=True, nullable=False) - completion_date = db.Column(db.DateTime) - item_collected = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) - coins_collected = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) - - -class PenguinIgloo(db.Model): - __tablename__ = 'penguin_igloo' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - igloo_id = db.Column(db.ForeignKey('igloo.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - - -class PenguinItem(db.Model): - __tablename__ = 'penguin_item' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), - primary_key=True, nullable=False) - item_id = db.Column(db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'), - primary_key=True, nullable=False) - - -class PenguinLocation(db.Model): - __tablename__ = 'penguin_location' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - location_id = db.Column(db.ForeignKey('location.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - - -class PenguinStamp(db.Model): - __tablename__ = 'penguin_stamp' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - stamp_id = db.Column(db.ForeignKey('stamp.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - recent = db.Column(db.Boolean, nullable=False, server_default=db.text("true")) - - -class PenguinRedemption(db.Model): - __tablename__ = 'penguin_redemption' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - code_id = db.Column(db.ForeignKey('redemption_code.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False, index=True) - book_id = db.Column(db.ForeignKey('redemption_book.id', ondelete='CASCADE', onupdate='CASCADE'), index=True) - - class PenguinMembership(db.Model): __tablename__ = 'penguin_membership' @@ -155,108 +97,6 @@ class PenguinMembership(db.Model): expires = db.Column(db.DateTime, primary_key=True, nullable=False) -class PenguinPostcard(db.Model): - __tablename__ = 'penguin_postcard' - - id = db.Column(db.Integer, primary_key=True, - server_default=db.text("nextval('\"penguin_postcard_id_seq\"'::regclass)")) - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False, - index=True) - sender_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), index=True) - postcard_id = db.Column(db.ForeignKey('postcard.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) - send_date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()")) - details = db.Column(db.String(255), nullable=False, server_default=db.text("''::character varying")) - has_read = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) - - -class PenguinIglooRoom(db.Model): - __tablename__ = 'penguin_igloo_room' - - id = db.Column(db.Integer, primary_key=True, - server_default=db.text("nextval('\"penguin_igloo_room_id_seq\"'::regclass)")) - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) - type = db.Column(db.ForeignKey('igloo.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) - flooring = db.Column(db.ForeignKey('flooring.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) - music = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0")) - location = db.Column(db.ForeignKey('location.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) - locked = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) - - -class PenguinLaunchGame(db.Model): - __tablename__ = 'penguin_launch_game' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - level = db.Column(db.SmallInteger, primary_key=True, nullable=False, server_default=db.text("0")) - puffle_os = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0")) - best_time = db.Column(db.SmallInteger, nullable=False, server_default=db.text("600")) - turbo = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) - - -class PenguinCard(db.Model): - __tablename__ = 'penguin_card' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False, index=True) - card_id = db.Column(db.ForeignKey('card.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1")) - - -class PenguinFurniture(db.Model): - __tablename__ = 'penguin_furniture' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - furniture_id = db.Column(db.ForeignKey('furniture.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1")) - - -class PenguinFlooring(db.Model): - __tablename__ = 'penguin_flooring' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - flooring_id = db.Column(db.ForeignKey('flooring.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - - -class PenguinPuffle(db.Model): - __tablename__ = 'penguin_puffle' - - id = db.Column(db.Integer, primary_key=True, - server_default=db.text("nextval('\"penguin_puffle_id_seq\"'::regclass)")) - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) - puffle_id = db.Column(db.ForeignKey('puffle.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) - name = db.Column(db.String(16), nullable=False) - adoption_date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()")) - food = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) - play = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) - rest = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) - clean = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) - walking = db.Column(db.Boolean, server_default=db.text("false")) - hat = db.Column(db.ForeignKey('puffle_item.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) - backyard = db.Column(db.Boolean, server_default=db.text("false")) - has_dug = db.Column(db.Boolean, server_default=db.text("false")) - - -class PenguinPuffleItem(db.Model): - __tablename__ = 'penguin_puffle_item' - - penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, - nullable=False) - item_id = db.Column(db.Integer, primary_key=True, nullable=False) - quantity = db.Column(db.SmallInteger, nullable=False) - - -class PenguinPermission(db.Model): - __tablename__ = 'penguin_permission' - - penguin_id = db.Column(db.ForeignKey(u'penguin.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), primary_key=True) - permission_id = 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/permission.py b/houdini/data/permission.py index b8d221c..64b7d2f 100644 --- a/houdini/data/permission.py +++ b/houdini/data/permission.py @@ -1,5 +1,4 @@ from houdini.data import db, BaseCrumbsCollection -from houdini.data.penguin import PenguinPermission class Permission(db.Model): @@ -10,6 +9,13 @@ class Permission(db.Model): enabled = db.Column(db.Boolean, nullable=False, server_default=db.text("true")) +class PenguinPermission(db.Model): + __tablename__ = 'penguin_permission' + + penguin_id = db.Column(db.ForeignKey(u'penguin.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), primary_key=True) + permission_id = db.Column(db.ForeignKey(u'permission.id', ondelete=u'CASCADE', onupdate=u'CASCADE'), nullable=False) + + class PermissionCrumbsCollection(BaseCrumbsCollection): def __init__(self, inventory_id=None): diff --git a/houdini/data/pet.py b/houdini/data/pet.py index 42a0c42..78b79dd 100644 --- a/houdini/data/pet.py +++ b/houdini/data/pet.py @@ -1,5 +1,4 @@ from houdini.data import db, BaseCrumbsCollection -from houdini.data.penguin import PenguinPuffle, PenguinPuffleItem class Puffle(db.Model): @@ -60,6 +59,57 @@ class PuffleTreasurePuffleItem(db.Model): primary_key=True, nullable=False) +class PuffleQuest(db.Model): + __tablename__ = 'puffle_quest' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + task_id = db.Column(db.SmallInteger, primary_key=True, nullable=False) + completion_date = db.Column(db.DateTime) + item_collected = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) + coins_collected = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) + + +class PenguinPuffle(db.Model): + __tablename__ = 'penguin_puffle' + + id = db.Column(db.Integer, primary_key=True, + server_default=db.text("nextval('\"penguin_puffle_id_seq\"'::regclass)")) + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) + puffle_id = db.Column(db.ForeignKey('puffle.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) + name = db.Column(db.String(16), nullable=False) + adoption_date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()")) + food = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) + play = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) + rest = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) + clean = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) + walking = db.Column(db.Boolean, server_default=db.text("false")) + hat = db.Column(db.ForeignKey('puffle_item.id', ondelete='CASCADE', onupdate='CASCADE')) + backyard = db.Column(db.Boolean, server_default=db.text("false")) + has_dug = db.Column(db.Boolean, server_default=db.text("false")) + + +class PenguinPuffleItem(db.Model): + __tablename__ = 'penguin_puffle_item' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + item_id = db.Column(db.ForeignKey('puffle_item.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + quantity = db.Column(db.SmallInteger, nullable=False) + + +class PenguinLaunchGame(db.Model): + __tablename__ = 'penguin_launch_game' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + level = db.Column(db.SmallInteger, primary_key=True, nullable=False, server_default=db.text("0")) + puffle_os = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0")) + best_time = db.Column(db.SmallInteger, nullable=False, server_default=db.text("600")) + turbo = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) + + class PuffleCrumbsCollection(BaseCrumbsCollection): def __init__(self, inventory_id=None): @@ -67,7 +117,7 @@ class PuffleCrumbsCollection(BaseCrumbsCollection): key='id', inventory_model=PenguinPuffle, inventory_key='penguin_id', - inventory_value='puffle_id', + inventory_value='id', inventory_id=inventory_id) diff --git a/houdini/data/redemption.py b/houdini/data/redemption.py index 3b888c4..5015db7 100644 --- a/houdini/data/redemption.py +++ b/houdini/data/redemption.py @@ -92,3 +92,13 @@ class RedemptionAwardPuffleItem(db.Model): nullable=False) puffle_item_id = db.Column(db.ForeignKey('puffle_item.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, nullable=False) + + +class PenguinRedemption(db.Model): + __tablename__ = 'penguin_redemption' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + code_id = db.Column(db.ForeignKey('redemption_code.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False, index=True) + book_id = db.Column(db.ForeignKey('redemption_book.id', ondelete='CASCADE', onupdate='CASCADE'), index=True) diff --git a/houdini/data/room.py b/houdini/data/room.py index e1e0e5e..18a7c3e 100644 --- a/houdini/data/room.py +++ b/houdini/data/room.py @@ -47,6 +47,19 @@ class Room(db.Model): await penguin.send_xt(*data) +class PenguinIglooRoom(db.Model): + __tablename__ = 'penguin_igloo_room' + + id = db.Column(db.Integer, primary_key=True, + server_default=db.text("nextval('\"penguin_igloo_room_id_seq\"'::regclass)")) + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) + type = db.Column(db.ForeignKey('igloo.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) + flooring = db.Column(db.ForeignKey('flooring.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) + music = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0")) + location = db.Column(db.ForeignKey('location.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) + locked = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) + + class RoomTable(db.Model): __tablename__ = 'room_table' diff --git a/houdini/data/stamp.py b/houdini/data/stamp.py index 931a6f6..b90661a 100644 --- a/houdini/data/stamp.py +++ b/houdini/data/stamp.py @@ -1,5 +1,4 @@ from houdini.data import db, BaseCrumbsCollection -from houdini.data.penguin import PenguinStamp class Stamp(db.Model): @@ -36,6 +35,16 @@ class CoverStamp(db.Model): depth = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0")) +class PenguinStamp(db.Model): + __tablename__ = 'penguin_stamp' + + penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + stamp_id = db.Column(db.ForeignKey('stamp.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, + nullable=False) + recent = db.Column(db.Boolean, nullable=False, server_default=db.text("true")) + + class StampCrumbsCollection(BaseCrumbsCollection): def __init__(self, inventory_id=None):