mirror of
https://github.com/solero/houdini.git
synced 2024-11-09 20:58:20 +00:00
New player quest database models
This commit is contained in:
parent
006d55934b
commit
f5f041b9f2
103
houdini.sql
103
houdini.sql
@ -327,6 +327,90 @@ COMMENT ON TABLE puffle_treasure_puffle_item IS 'Puffle digging treasure puffle
|
||||
COMMENT ON COLUMN puffle_treasure_puffle_item.puffle_id IS 'Puffle type ID';
|
||||
COMMENT ON COLUMN puffle_treasure_puffle_item.puffle_item_id IS 'Puffle care item ID';
|
||||
|
||||
DROP TABLE IF EXISTS quest;
|
||||
CREATE TABLE quest (
|
||||
id SERIAL,
|
||||
name VARCHAR(30) NOT NULL,
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE quest IS 'Player map quests';
|
||||
|
||||
COMMENT ON COLUMN quest.id IS 'Unique quest ID';
|
||||
COMMENT ON COLUMN quest.name IS 'Short name of quest';
|
||||
|
||||
DROP TABLE IF EXISTS quest_award_item;
|
||||
CREATE TABLE quest_award_item (
|
||||
quest_id INT NOT NULL,
|
||||
item_id INT NOT NULL,
|
||||
PRIMARY KEY (quest_id, item_id),
|
||||
CONSTRAINT quest_award_item_ibfk_1 FOREIGN KEY (quest_id) REFERENCES quest (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT quest_award_item_ibfk_2 FOREIGN KEY (item_id) REFERENCES item (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN quest_award_item.quest_id IS 'Quest ID';
|
||||
COMMENT ON COLUMN quest_award_item.item_id IS 'Clothing item ID';
|
||||
|
||||
DROP TABLE IF EXISTS quest_award_furniture;
|
||||
CREATE TABLE quest_award_furniture (
|
||||
quest_id INT NOT NULL,
|
||||
furniture_id INT NOT NULL,
|
||||
quantity SMALLINT NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (quest_id, furniture_id),
|
||||
CONSTRAINT quest_award_furniture_ibfk_1 FOREIGN KEY (quest_id) REFERENCES quest (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT quest_award_furniture_ibfk_2 FOREIGN KEY (furniture_id) REFERENCES furniture (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN quest_award_furniture.quest_id IS 'Quest ID';
|
||||
COMMENT ON COLUMN quest_award_furniture.item_id IS 'Furniture item ID';
|
||||
|
||||
DROP TABLE IF EXISTS quest_award_puffle_item;
|
||||
CREATE TABLE quest_award_puffle_item (
|
||||
quest_id INT NOT NULL,
|
||||
puffle_item_id INT NOT NULL,
|
||||
quantity SMALLINT NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (quest_id, puffle_item_id),
|
||||
CONSTRAINT quest_award_puffle_item_ibfk_1 FOREIGN KEY (quest_id) REFERENCES quest (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT quest_award_puffle_item_ibfk_2 FOREIGN KEY (puffle_item_id) REFERENCES puffle_item (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN quest_award_puffle_item.quest_id IS 'Quest ID';
|
||||
COMMENT ON COLUMN quest_award_puffle_item.item_id IS 'Puffle care item ID';
|
||||
|
||||
DROP TABLE IF EXISTS quest_task;
|
||||
CREATE TABLE quest_task (
|
||||
id SERIAL NOT NULL,
|
||||
quest_id INT NOT NULL,
|
||||
description VARCHAR(50) NOT NULL,
|
||||
room_id INT DEFAULT NULL,
|
||||
data VARCHAR(50) DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
CONSTRAINT quest_task_ibfk_1 FOREIGN KEY (quest_id) REFERENCES quest (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT quest_task_ibfk_2 FOREIGN KEY (room_id) REFERENCES room (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
COMMENT ON TABLE quest_task IS 'Player map quest tasks';
|
||||
|
||||
COMMENT ON COLUMN quest_task.task_id IS 'Unique task ID';
|
||||
COMMENT ON COLUMN quest_task.quest_id IS 'Task quest ID';
|
||||
COMMENT ON COLUMN quest_task.description IS 'Description of task';
|
||||
COMMENT ON COLUMN quest_task.room_id IS 'Room ID for completion';
|
||||
|
||||
DROP TABLE IF EXISTS penguin_quest_task;
|
||||
CREATE TABLE penguin_quest_task (
|
||||
task_id INT NOT NULL,
|
||||
penguin_id INT NOT NULL,
|
||||
complete BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY (task_id, penguin_id),
|
||||
CONSTRAINT penguin_quest_task_ibfk_1 FOREIGN KEY (task_id) REFERENCES quest_task (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT penguin_quest_task_ibfk_2 FOREIGN KEY (penguin_id) REFERENCES penguin (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
COMMENT ON TABLE penguin_quest_task IS 'Completed quest tasks';
|
||||
|
||||
COMMENT ON COLUMN penguin_quest_task.task_id IS 'Completed task ID';
|
||||
COMMENT ON COLUMN penguin_quest_task.penguin_id IS 'Task penguin ID';
|
||||
|
||||
DROP TABLE IF EXISTS dance_song;
|
||||
CREATE TABLE dance_song (
|
||||
id INT NOT NULL,
|
||||
@ -421,6 +505,11 @@ CREATE TABLE penguin (
|
||||
rainbow_adoptability SMALLINT NOT NULL DEFAULT 0,
|
||||
has_dug BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
nuggets SMALLINT NOT NULL DEFAULT 0,
|
||||
opened_playercard BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
special_wave BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
special_dance BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
special_snowball BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
map_category SMALLINT NOT NULL DEFAULT 0,
|
||||
status_field INT NOT NULL DEFAULT 0,
|
||||
timer_active BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
timer_start TIME NOT NULL DEFAULT '00:00:00',
|
||||
@ -506,6 +595,8 @@ COMMENT ON COLUMN penguin.water_matches_won IS 'JitsuWater matces won';
|
||||
COMMENT ON COLUMN penguin.rainbow_adoptability IS 'Rainbow puffle adoptability status';
|
||||
COMMENT ON COLUMN penguin.has_dug IS 'Puffle digging boolean';
|
||||
COMMENT ON COLUMN penguin.nuggets IS 'Golden puffle nuggets';
|
||||
COMMENT ON COLUMN penguin.opened_playercard IS 'Has player opened playercard?';
|
||||
COMMENT ON COLUMN penguin.map_category IS 'Currently selected map category';
|
||||
COMMENT ON COLUMN penguin.status_field IS 'New player status field';
|
||||
COMMENT ON COLUMN penguin.timer_active IS 'Is egg-timer active?';
|
||||
COMMENT ON COLUMN penguin.timer_start IS 'Egg-timer start time';
|
||||
@ -1254,6 +1345,18 @@ COMMENT ON COLUMN penguin_membership.penguin_id IS 'Penguin ID of membership';
|
||||
COMMENT ON COLUMN penguin_membership.start IS 'Start time of membership';
|
||||
COMMENT ON COLUMN penguin_membership.expires IS 'End time of membership';
|
||||
|
||||
INSERT INTO quest (id, name) VALUES (1, 'shopping');
|
||||
INSERT INTO quest (id, name) VALUES (2, 'puffle');
|
||||
INSERT INTO quest (id, name) VALUES (3, 'igloo');
|
||||
|
||||
INSERT INTO quest_award_item (quest_id, item_id) VALUES (1, 24023);
|
||||
INSERT INTO quest_award_furniture (quest_id, furniture_id) VALUES (3, 2166);
|
||||
INSERT INTO quest_award_puffle_item (quest_id, puffle_item_id) VALUES (2, 146);
|
||||
|
||||
INSERT INTO quest_task (quest_id, description, room_id) VALUES (1, 'Visit the Clothes Shop', 130);
|
||||
INSERT INTO quest_task (quest_id, description, room_id) VALUES (2, 'Visit the Pet Shop', 310);
|
||||
INSERT INTO quest_task (quest_id, description) VALUES (3, 'Visit your Igloo');
|
||||
|
||||
INSERT INTO item (id, name, type, cost, member, bait, patched, epf, tour, release_date) VALUES
|
||||
(1, 'Blue', 1, 20, FALSE, FALSE, FALSE, FALSE, FALSE, now()),
|
||||
(2, 'Green', 1, 20, FALSE, FALSE, FALSE, FALSE, FALSE, now()),
|
||||
|
@ -4,7 +4,8 @@ from houdini.data import db
|
||||
|
||||
from houdini.data.permission import PermissionCrumbsCollection
|
||||
from houdini.data.item import ItemCrumbsCollection
|
||||
from houdini.data.igloo import IglooCrumbsCollection, FlooringCrumbsCollection, LocationCrumbsCollection
|
||||
from houdini.data.igloo import IglooCrumbsCollection, FurnitureCrumbsCollection, FlooringCrumbsCollection, \
|
||||
LocationCrumbsCollection
|
||||
from houdini.data.stamp import StampCrumbsCollection
|
||||
from houdini.data.ninja import CardCrumbsCollection
|
||||
from houdini.data.mail import PostcardCrumbsCollection
|
||||
@ -60,6 +61,11 @@ class Penguin(db.Model):
|
||||
rainbow_adoptability = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
|
||||
has_dug = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
nuggets = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
|
||||
opened_playercard = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
special_wave = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
special_dance = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
special_snowball = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
map_category = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
|
||||
status_field = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
|
||||
timer_active = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
timer_start = db.Column(db.Time, nullable=False, server_default=db.text("'00:00:00'::time without time zone"))
|
||||
|
124
houdini/data/quest.py
Normal file
124
houdini/data/quest.py
Normal file
@ -0,0 +1,124 @@
|
||||
from houdini.data import db
|
||||
|
||||
|
||||
class Quest(db.Model):
|
||||
__tablename__ = 'quest'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, server_default=db.text("nextval('\"quest_id_seq\"'::regclass)"))
|
||||
name = db.Column(db.String(50), nullable=False, unique=True)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self._tasks = set()
|
||||
|
||||
self._items = set()
|
||||
self._furniture = set()
|
||||
self._pet = set()
|
||||
|
||||
self._complete = set()
|
||||
self._in_progress = set()
|
||||
|
||||
@property
|
||||
def items(self):
|
||||
return self._items
|
||||
|
||||
@property
|
||||
def furniture(self):
|
||||
return self._furniture
|
||||
|
||||
@property
|
||||
def pet(self):
|
||||
return self._pet
|
||||
|
||||
@property
|
||||
def complete(self):
|
||||
return self._complete
|
||||
|
||||
@property
|
||||
def in_progress(self):
|
||||
return self._in_progress
|
||||
|
||||
@property
|
||||
def awards(self):
|
||||
return self._items.union(self._furniture.union(self._pet))
|
||||
|
||||
@property
|
||||
def tasks(self):
|
||||
return self._tasks
|
||||
|
||||
@items.setter
|
||||
def items(self, child):
|
||||
if isinstance(child, QuestAwardItem):
|
||||
self._items.add(child)
|
||||
|
||||
@furniture.setter
|
||||
def furniture(self, child):
|
||||
if isinstance(child, QuestAwardFurniture):
|
||||
self._furniture.add(child)
|
||||
|
||||
@pet.setter
|
||||
def pet(self, child):
|
||||
if isinstance(child, QuestAwardPuffleItem):
|
||||
self._pet.add(child)
|
||||
|
||||
@tasks.setter
|
||||
def tasks(self, child):
|
||||
if isinstance(child, QuestTask):
|
||||
self._tasks.add(child)
|
||||
|
||||
@complete.setter
|
||||
def complete(self, child):
|
||||
if isinstance(child, PenguinQuestTask):
|
||||
if child.complete:
|
||||
self._complete.add(child.task_id)
|
||||
else:
|
||||
self._in_progress.add(child.task_id)
|
||||
|
||||
|
||||
class QuestAwardItem(db.Model):
|
||||
__tablename__ = 'quest_award_item'
|
||||
|
||||
quest_id = db.Column(db.ForeignKey('quest.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 QuestAwardFurniture(db.Model):
|
||||
__tablename__ = 'quest_award_furniture'
|
||||
|
||||
quest_id = db.Column(db.ForeignKey('quest.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 QuestAwardPuffleItem(db.Model):
|
||||
__tablename__ = 'quest_award_puffle_item'
|
||||
|
||||
quest_id = db.Column(db.ForeignKey('quest.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
|
||||
nullable=False)
|
||||
puffle_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, server_default=db.text("1"))
|
||||
|
||||
|
||||
class QuestTask(db.Model):
|
||||
__tablename__ = 'quest_task'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, server_default=db.text("nextval('\"quest_id_seq\"'::regclass)"))
|
||||
quest_id = db.Column(db.ForeignKey('quest.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
|
||||
description = db.Column(db.String(50), nullable=False)
|
||||
room_id = db.Column(db.ForeignKey('room.id', ondelete='CASCADE', onupdate='CASCADE'))
|
||||
data = db.Column(db.String(50))
|
||||
|
||||
|
||||
class PenguinQuestTask(db.Model):
|
||||
__tablename__ = 'penguin_quest_task'
|
||||
|
||||
task_id = db.Column(db.ForeignKey('quest_task.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False,
|
||||
primary_key=True)
|
||||
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False,
|
||||
primary_key=True)
|
||||
complete = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
Loading…
Reference in New Issue
Block a user