mirror of
https://github.com/solero/houdini.git
synced 2024-11-08 12:18:20 +00:00
CJ Snow handlers
Implement CJSnow handlers
This commit is contained in:
commit
ccf10f2412
@ -562,9 +562,14 @@ CREATE TABLE penguin (
|
||||
fire_ninja_progress SMALLINT NOT NULL DEFAULT 0,
|
||||
water_ninja_rank SMALLINT NOT NULL DEFAULT 0,
|
||||
water_ninja_progress SMALLINT NOT NULL DEFAULT 0,
|
||||
snow_ninja_rank SMALLINT NOT NULL DEFAULT 0,
|
||||
snow_ninja_progress SMALLINT NOT NULL DEFAULT 0,
|
||||
ninja_matches_won INT NOT NULL DEFAULT 0,
|
||||
fire_matches_won INT NOT NULL DEFAULT 0,
|
||||
water_matches_won INT NOT NULL DEFAULT 0,
|
||||
snow_progress_fire_wins INT NOT NULL DEFAULT 0,
|
||||
snow_progress_water_wins INT NOT NULL DEFAULT 0,
|
||||
snow_progress_snow_wins INT NOT NULL DEFAULT 0,
|
||||
rainbow_adoptability BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
has_dug BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
puffle_handler BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
@ -49,6 +49,8 @@ class Penguin(db.Model):
|
||||
fire_ninja_progress = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
|
||||
water_ninja_rank = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
|
||||
water_ninja_progress = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
|
||||
snow_ninja_progress = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
|
||||
snow_ninja_rank = db.Column(db.SmallInteger, nullable=False, server_default=db.text("0"))
|
||||
ninja_matches_won = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
|
||||
fire_matches_won = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
|
||||
water_matches_won = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
|
||||
@ -80,6 +82,7 @@ class Penguin(db.Model):
|
||||
rejection_es = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
rejection_de = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
rejection_ru = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.inventory = None
|
||||
|
@ -72,6 +72,10 @@ async def handle_get_puck(p):
|
||||
@handlers.handler(XTPacket('zo', ext='z'))
|
||||
@handlers.cooldown(10, callback=game_over_cooling)
|
||||
async def handle_get_game_over(p, score: int):
|
||||
# If the room is Card Jitsu Snow, it this should do nothing
|
||||
if p.room.id == 996:
|
||||
return
|
||||
|
||||
if p.room.game and not p.waddle and not p.table:
|
||||
coins_earned = determine_coins_earned(p, score)
|
||||
if await determine_coins_overdose(p, coins_earned):
|
||||
|
17
houdini/handlers/games/ninja/snow.py
Normal file
17
houdini/handlers/games/ninja/snow.py
Normal file
@ -0,0 +1,17 @@
|
||||
from houdini.handlers import XTPacket
|
||||
from houdini import handlers
|
||||
from houdini.data.item import PenguinItemCollection
|
||||
from houdini.data.stamp import PenguinStampCollection
|
||||
from houdini.handlers.play.stampbook import get_player_stamps_string
|
||||
|
||||
@handlers.handler(XTPacket('i#ngi'))
|
||||
@handlers.cooldown(5)
|
||||
async def ninja_get_inventory(self, p):
|
||||
p.inventory = await PenguinItemCollection.get_collection(p.id)
|
||||
await p.send_xt('gi', *p.inventory.keys())
|
||||
|
||||
@handlers.handler(XTPacket('st#ngps'))
|
||||
@handlers.cooldown(5)
|
||||
async def ninja_get_penguin_stamps(self, p):
|
||||
p.stamps = await PenguinStampCollection.get_collection(p.id)
|
||||
await p.send_xt('gps', p.id, await get_player_stamps_string(p, p.id))
|
@ -4,17 +4,12 @@ from houdini.data.penguin import Penguin
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('ni', 'gnr'))
|
||||
@handlers.cooldown(2)
|
||||
async def handle_get_ninja_ranks(p, penguin_id: int):
|
||||
if penguin_id in p.server.penguins_by_id:
|
||||
penguin = p.server.penguins_by_id[penguin_id]
|
||||
ninja_rank, fire_ninja_rank, water_ninja_rank = \
|
||||
penguin.ninja_rank, penguin.fire_ninja_rank, penguin.water_ninja_rank
|
||||
else:
|
||||
ninja_rank, fire_ninja_rank, water_ninja_rank = await Penguin.select(
|
||||
'ninja_rank', 'fire_ninja_rank', 'water_ninja_rank'
|
||||
).where(Penguin.id == penguin_id).gino.first()
|
||||
await p.send_xt('gnr', p.id, ninja_rank, fire_ninja_rank, water_ninja_rank, 0)
|
||||
|
||||
ninja_rank, fire_ninja_rank, water_ninja_rank, snow_ninja_rank = await Penguin.select(
|
||||
'ninja_rank', 'fire_ninja_rank', 'water_ninja_rank', 'snow_ninja_rank'
|
||||
).where(Penguin.id == penguin_id).gino.first()
|
||||
await p.send_xt('gnr', p.id, ninja_rank, fire_ninja_rank, water_ninja_rank, snow_ninja_rank)
|
||||
|
||||
@handlers.handler(XTPacket('ni', 'gnl'))
|
||||
async def handle_get_ninja_level(p):
|
||||
@ -32,8 +27,13 @@ async def handle_get_water_level(p):
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('ni', 'gsl'))
|
||||
@handlers.cooldown(1)
|
||||
async def handle_get_snow_level(p):
|
||||
await p.send_xt('gsl', 0, 0, 24)
|
||||
# Snow ninja data should be taken from the database, not memory
|
||||
snow_ninja_rank, snow_ninja_progress = await Penguin.select(
|
||||
'snow_ninja_rank', 'snow_ninja_progress'
|
||||
).where(Penguin.id == p.id).gino.first()
|
||||
await p.send_xt('gsl', snow_ninja_rank, snow_ninja_progress, 24)
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('ni', 'gcd'))
|
||||
|
@ -12,3 +12,11 @@ async def handle_get_coin_reward(p):
|
||||
coins = random.choice([1, 2, 5, 10, 20, 50, 100])
|
||||
await p.update(coins=Penguin.coins + coins).apply()
|
||||
await p.send_xt('cdu', coins, p.coins)
|
||||
|
||||
@handlers.handler(XTPacket('r', 'gtc'))
|
||||
@handlers.cooldown(1)
|
||||
async def handle_get_coins(p):
|
||||
# Fetch coins from the database
|
||||
p.coins, = await Penguin.select('coins').where(Penguin.id == p.id).gino.first()
|
||||
await p.send_xt("gtc", p.coins)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user