Add support for innocent items

This commit is contained in:
rsakeys 2020-03-03 17:38:32 +00:00
parent 3deba275fe
commit de605410ce
4 changed files with 14 additions and 1 deletions

View File

@ -11,6 +11,7 @@ CREATE TABLE item (
tour BOOLEAN NOT NULL DEFAULT FALSE, tour BOOLEAN NOT NULL DEFAULT FALSE,
release_date DATE NOT NULL, release_date DATE NOT NULL,
treasure BOOLEAN NOT NULL DEFAULT FALSE, treasure BOOLEAN NOT NULL DEFAULT FALSE,
innocent BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (id) 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.tour IS 'Gives tour status?';
COMMENT ON COLUMN item.release_date IS 'Release date of item'; 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.treasure IS 'Is a treasure item?';
COMMENT ON COLUMN item.innocent IS 'Is a innocent item?';
DROP TABLE IF EXISTS postcard; DROP TABLE IF EXISTS postcard;
CREATE TABLE postcard ( CREATE TABLE postcard (
@ -87,6 +89,7 @@ CREATE TABLE furniture (
patched BOOLEAN NOT NULL DEFAULT FALSE, patched BOOLEAN NOT NULL DEFAULT FALSE,
bait BOOLEAN NOT NULL DEFAULT FALSE, bait BOOLEAN NOT NULL DEFAULT FALSE,
max_quantity SMALLINT NOT NULL DEFAULT 100, max_quantity SMALLINT NOT NULL DEFAULT 100,
innocent BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY(id) 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.patched IS 'Is furniture patched?';
COMMENT ON COLUMN furniture.bait IS 'Is furniture bait?'; COMMENT ON COLUMN furniture.bait IS 'Is furniture bait?';
COMMENT ON COLUMN furniture.max_quantity IS 'Max inventory quantity'; COMMENT ON COLUMN furniture.max_quantity IS 'Max inventory quantity';
COMMENT ON COLUMN furniture.innocent IS 'Is furniture innocent?';
DROP TABLE IF EXISTS flooring; DROP TABLE IF EXISTS flooring;
CREATE TABLE flooring ( CREATE TABLE flooring (

View File

@ -22,6 +22,7 @@ class Furniture(db.Model):
patched = db.Column(db.Boolean, nullable=False, server_default=db.text("false")) patched = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
bait = 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")) 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): class Igloo(db.Model):

View File

@ -15,6 +15,7 @@ class Item(db.Model):
tour = 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()")) 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")) 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): def is_color(self):
return self.type == 1 return self.type == 1

View File

@ -64,8 +64,15 @@ async def handle_code(p, redemption_code: str):
num_redeemed_codes = await PenguinRedemptionCode.join(RedemptionCode).count().where( num_redeemed_codes = await PenguinRedemptionCode.join(RedemptionCode).count().where(
(PenguinRedemptionCode.penguin_id == p.id) & (RedemptionCode.type == 'CATALOG') (PenguinRedemptionCode.penguin_id == p.id) & (RedemptionCode.type == 'CATALOG')
).gino.scalar() ).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) 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) await p.send_xt('rsc', code.type, '', code.coins)