mirror of
https://github.com/solero/houdini.git
synced 2025-10-26 18:12:00 +00:00
Survey handler module
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user