From e94993a71fbfd822bdb92efb4de20354f29955e7 Mon Sep 17 00:00:00 2001 From: rsakeys Date: Mon, 2 Mar 2020 20:41:43 +0000 Subject: [PATCH] Add support for treasure items --- houdini.sql | 2 ++ houdini/data/item.py | 1 + houdini/handlers/redemption/__init__.py | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/houdini.sql b/houdini.sql index 5754ead..b240ff2 100644 --- a/houdini.sql +++ b/houdini.sql @@ -10,6 +10,7 @@ CREATE TABLE item ( epf BOOLEAN NOT NULL DEFAULT FALSE, tour BOOLEAN NOT NULL DEFAULT FALSE, release_date DATE NOT NULL, + treasure BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (id) ); @@ -27,6 +28,7 @@ COMMENT ON COLUMN item.patched IS 'Is item patched?'; 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?'; DROP TABLE IF EXISTS postcard; CREATE TABLE postcard ( diff --git a/houdini/data/item.py b/houdini/data/item.py index e708e23..d6ac177 100644 --- a/houdini/data/item.py +++ b/houdini/data/item.py @@ -14,6 +14,7 @@ class Item(db.Model): epf = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) 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")) def is_color(self): return self.type == 1 diff --git a/houdini/handlers/redemption/__init__.py b/houdini/handlers/redemption/__init__.py index b791e72..29ccf07 100644 --- a/houdini/handlers/redemption/__init__.py +++ b/houdini/handlers/redemption/__init__.py @@ -61,8 +61,11 @@ async def handle_code(p, redemption_code: str): return await p.send_error(726) if code.type == 'CATALOG': - owned_ids = ','.join((item.item_id for item in code.items if item.item_id in p.inventory)) - return await p.send_xt('rsc', 'treasurebook', 3, owned_ids, 0) + 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)) + return await p.send_xt('rsc', 'treasurebook', 3, owned_ids, num_redeemed_codes) await p.send_xt('rsc', code.type, '', code.coins)