mirror of
https://github.com/solero/houdini.git
synced 2024-11-24 14:37:22 +00:00
Survey handler module
This commit is contained in:
parent
79a5c43a66
commit
fed5cf01ec
21
houdini.sql
21
houdini.sql
@ -932,6 +932,7 @@ CREATE TABLE penguin_igloo_room (
|
||||
music SMALLINT NOT NULL DEFAULT 0,
|
||||
location INT NOT NULL,
|
||||
locked BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
competition BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY (id),
|
||||
CONSTRAINT igloo_room_ibfk_1 FOREIGN KEY (penguin_id) REFERENCES penguin (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT igloo_room_ibfk_2 FOREIGN KEY (type) REFERENCES igloo (id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
@ -949,6 +950,7 @@ COMMENT ON COLUMN penguin_igloo_room.type IS 'Igloo type ID';
|
||||
COMMENT ON COLUMN penguin_igloo_room.flooring IS 'Igloo flooring ID';
|
||||
COMMENT ON COLUMN penguin_igloo_room.music IS 'Igloo music ID';
|
||||
COMMENT ON COLUMN penguin_igloo_room.locked IS 'Is igloo locked?';
|
||||
COMMENT ON COLUMN penguin_igloo_room.competition IS 'Is entered in competition?';
|
||||
|
||||
DROP TABLE IF EXISTS igloo_like;
|
||||
CREATE TABLE igloo_like (
|
||||
@ -1121,6 +1123,25 @@ COMMENT ON COLUMN login.date IS 'Login date';
|
||||
COMMENT ON COLUMN login.ip_hash IS 'Connection IP address';
|
||||
COMMENT ON COLUMN login.minutes_played IS 'Minutes played for session';
|
||||
|
||||
DROP TABLE IF EXISTS cfc_donation;
|
||||
CREATE TABLE cfc_donation (
|
||||
penguin_id INT NOT NULL,
|
||||
coins INT NOT NULL,
|
||||
charity SMALLINT NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (penguin_id, charity, date),
|
||||
CONSTRAINT cfc_donation_ibfk_1 FOREIGN KEY (penguin_id) REFERENCES penguin (id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
ALTER TABLE cfc_donation ALTER COLUMN date SET DEFAULT now();
|
||||
|
||||
COMMENT ON TABLE cfc_donation IS 'CFC charity donations';
|
||||
|
||||
COMMENT ON COLUMN cfc_donation.penguin_id IS 'Donator penguin ID';
|
||||
COMMENT ON COLUMN cfc_donation.coins IS 'Donation coin amount';
|
||||
COMMENT ON COLUMN cfc_donation.charity IS 'Donation charity or cause';
|
||||
COMMENT ON COLUMN cfc_donation.date IS 'Date of donation';
|
||||
|
||||
DROP TABLE IF EXISTS penguin_postcard;
|
||||
CREATE TABLE penguin_postcard (
|
||||
id SERIAL,
|
||||
|
@ -165,3 +165,12 @@ class EpfComMessage(db.Model):
|
||||
message = db.Column(db.Text, nullable=False)
|
||||
character_id = db.Column(db.ForeignKey('character.id', ondelete='RESTRICT', onupdate='CASCADE'), nullable=False)
|
||||
date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()"))
|
||||
|
||||
|
||||
class CfcDonation(db.Model):
|
||||
__tablename__ = 'cfc_donation'
|
||||
|
||||
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
|
||||
coins = db.Column(db.Integer, nullable=False)
|
||||
charity = db.Column(db.Integer, nullable=False)
|
||||
date = db.Column(db.DateTime, nullable=False, server_default=db.text("now()"))
|
||||
|
@ -150,7 +150,8 @@ class PenguinIglooRoom(db.Model, RoomMixin):
|
||||
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"))
|
||||
locked = db.Column(db.Boolean, nullable=False, server_default=db.text("true"))
|
||||
competition = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
|
||||
internal_id = 2000
|
||||
name = 'Igloo'
|
||||
|
17
houdini/handlers/play/survey.py
Normal file
17
houdini/handlers/play/survey.py
Normal file
@ -0,0 +1,17 @@
|
||||
from houdini import handlers
|
||||
from houdini.handlers import XTPacket
|
||||
from houdini.data.penguin import CfcDonation
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('e', 'dc'))
|
||||
async def handle_donate_to_charity(p, charity: int, coins: int):
|
||||
if p.coins >= coins and 0 <= charity <= 4:
|
||||
await p.update(coins=p.coins-coins).apply()
|
||||
await CfcDonation.create(penguin_id=p.id, coins=coins, charity=charity)
|
||||
await p.send_xt('dc', p.coins)
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('e', 'sig'))
|
||||
async def handle_igloo_contest_entry(p):
|
||||
if p.room.igloo and p.room.penguin_id == p.id and not p.room.competition:
|
||||
await p.room.update(competition=True).apply()
|
Loading…
Reference in New Issue
Block a user