mirror of
https://github.com/solero/houdini.git
synced 2024-11-10 05:08:19 +00:00
Toy book handlers
Experimental: players who open newspapers will persist after changing rooms.
This commit is contained in:
parent
a6e1d05a52
commit
337c2048cd
@ -38,6 +38,8 @@ class Room(db.Model):
|
||||
|
||||
self.penguins.remove(p)
|
||||
p.room = None
|
||||
p.frame = 1
|
||||
p.toy = None
|
||||
|
||||
async def get_string(self):
|
||||
return '%'.join([await p.string for p in self.penguins])
|
||||
|
@ -102,6 +102,7 @@ async def handle_pbsm_finish(p):
|
||||
async def handle_set_player_position(p, x: int, y: int):
|
||||
p.x, p.y = x, y
|
||||
p.frame = 1
|
||||
p.toy = None
|
||||
await p.room.send_xt('sp', p.data.id, x, y)
|
||||
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
from houdini import handlers, ClientType
|
||||
from houdini.handlers import XTPacket
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('t', 'at'))
|
||||
async def handle_open_book(p, toy_id: int):
|
||||
p.toy = toy_id
|
||||
await p.room.send_xt('at', p.data.id, toy_id)
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('t', 'rt'))
|
||||
async def handle_close_book(p):
|
||||
p.toy = None
|
||||
await p.room.send_xt('rt', p.data.id)
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('j', 'jr'), client=ClientType.Legacy)
|
||||
async def handle_join_room_toy(p):
|
||||
for penguin in p.room.penguins:
|
||||
if penguin.toy is not None:
|
||||
await p.send_xt('at', penguin.data.id, penguin.toy)
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('j', 'crl'), client=ClientType.Vanilla)
|
||||
@handlers.depends_on_packet(XTPacket('j', 'jr'))
|
||||
async def handle_client_room_loaded_toy(p):
|
||||
for penguin in p.room.penguins:
|
||||
if penguin.toy is not None:
|
||||
await p.send_xt('at', penguin.data.id, penguin.toy)
|
@ -5,7 +5,7 @@ from houdini.spheniscidae import Spheniscidae
|
||||
|
||||
class Penguin(Spheniscidae):
|
||||
|
||||
__slots__ = ['x', 'y', 'frame', 'room', 'waddle', 'table', 'data', 'muted',
|
||||
__slots__ = ['x', 'y', 'frame', 'toy', 'room', 'waddle', 'table',
|
||||
'login_key', 'member', 'membership_days', 'avatar',
|
||||
'walking_puffle', 'permissions', 'active_quests']
|
||||
|
||||
@ -14,6 +14,7 @@ class Penguin(Spheniscidae):
|
||||
|
||||
self.x, self.y = (0, 0)
|
||||
self.frame = 1
|
||||
self.toy = None
|
||||
self.room = None
|
||||
self.waddle = None
|
||||
self.table = None
|
||||
|
Loading…
Reference in New Issue
Block a user