From de605410cea431fe63e938558db88c8b85de9118 Mon Sep 17 00:00:00 2001 From: rsakeys Date: Tue, 3 Mar 2020 17:38:32 +0000 Subject: [PATCH] Add support for innocent items --- houdini.sql | 4 ++++ houdini/data/igloo.py | 1 + houdini/data/item.py | 1 + houdini/handlers/redemption/__init__.py | 9 ++++++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/houdini.sql b/houdini.sql index b240ff2..43f0b2f 100644 --- a/houdini.sql +++ b/houdini.sql @@ -11,6 +11,7 @@ CREATE TABLE item ( tour BOOLEAN NOT NULL DEFAULT FALSE, release_date DATE NOT NULL, treasure BOOLEAN NOT NULL DEFAULT FALSE, + innocent BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (id) ); @@ -29,6 +30,7 @@ COMMENT ON COLUMN item.epf IS 'Is EPF item?'; COMMENT ON COLUMN item.tour IS 'Gives tour status?'; COMMENT ON COLUMN item.release_date IS 'Release date of item'; COMMENT ON COLUMN item.treasure IS 'Is a treasure item?'; +COMMENT ON COLUMN item.innocent IS 'Is a innocent item?'; DROP TABLE IF EXISTS postcard; CREATE TABLE postcard ( @@ -87,6 +89,7 @@ CREATE TABLE furniture ( patched BOOLEAN NOT NULL DEFAULT FALSE, bait BOOLEAN NOT NULL DEFAULT FALSE, max_quantity SMALLINT NOT NULL DEFAULT 100, + innocent BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY(id) ); @@ -100,6 +103,7 @@ COMMENT ON COLUMN furniture.member IS 'Is member-only?'; COMMENT ON COLUMN furniture.patched IS 'Is furniture patched?'; COMMENT ON COLUMN furniture.bait IS 'Is furniture bait?'; COMMENT ON COLUMN furniture.max_quantity IS 'Max inventory quantity'; +COMMENT ON COLUMN furniture.innocent IS 'Is furniture innocent?'; DROP TABLE IF EXISTS flooring; CREATE TABLE flooring ( diff --git a/houdini/data/igloo.py b/houdini/data/igloo.py index 62ddde0..0882548 100644 --- a/houdini/data/igloo.py +++ b/houdini/data/igloo.py @@ -22,6 +22,7 @@ class Furniture(db.Model): patched = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) bait = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) max_quantity = db.Column(db.SmallInteger, nullable=False, server_default=db.text("100")) + innocent = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) class Igloo(db.Model): diff --git a/houdini/data/item.py b/houdini/data/item.py index d6ac177..ea6b53f 100644 --- a/houdini/data/item.py +++ b/houdini/data/item.py @@ -15,6 +15,7 @@ class Item(db.Model): tour = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) release_date = db.Column(db.Date, nullable=False, server_default=db.text("now()")) treasure = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) + innocent = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) def is_color(self): return self.type == 1 diff --git a/houdini/handlers/redemption/__init__.py b/houdini/handlers/redemption/__init__.py index 29ccf07..f73237e 100644 --- a/houdini/handlers/redemption/__init__.py +++ b/houdini/handlers/redemption/__init__.py @@ -64,8 +64,15 @@ async def handle_code(p, redemption_code: str): num_redeemed_codes = await PenguinRedemptionCode.join(RedemptionCode).count().where( (PenguinRedemptionCode.penguin_id == p.id) & (RedemptionCode.type == 'CATALOG') ).gino.scalar() - owned_ids = ','.join((str(item.item_id) for item in code.items if item.item_id in p.inventory and p.server.items[item.item_id].treasure)) + owned_ids = ','.join((str(item.id) for item in p.server.items.values() if item.treasure and item.id in p.inventory)) + p.tb_validation = True return await p.send_xt('rsc', 'treasurebook', 3, owned_ids, num_redeemed_codes) + if code.type == 'INNOCENT': + innocent_items = [item.id for item in p.server.items.values() if item.id in p.inventory and item.innocent] + innocent_furniture = [item.id for item in p.server.furniture.values() if item.id in p.furniture and item.innocent] + innocent_items = innocent_items + innocent_furniture + await p.send_xt('rsc', code.type, '', code.coins) +