mirror of
https://github.com/solero/houdini.git
synced 2024-11-21 21:17:21 +00:00
Blackhole room support
This commit is contained in:
parent
beee263e88
commit
f2924d9a54
@ -116,7 +116,14 @@ class Room(db.Model, RoomMixin):
|
||||
RoomMixin.__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.blackhole_penguins = {}
|
||||
|
||||
async def add_penguin(self, p):
|
||||
if self.blackhole and p.is_vanilla_client:
|
||||
self.blackhole_penguins[p.id] = p.room
|
||||
p.room = self
|
||||
return await p.send_xt('jnbhg', self.id)
|
||||
|
||||
await RoomMixin.add_penguin(self, p)
|
||||
|
||||
if self.game:
|
||||
@ -127,6 +134,13 @@ class Room(db.Model, RoomMixin):
|
||||
await p.send_xt('jr', self.id, await self.get_string())
|
||||
await self.send_xt('ap', await p.string)
|
||||
|
||||
async def remove_penguin(self, p):
|
||||
await RoomMixin.remove_penguin(self, p)
|
||||
|
||||
async def leave_blackhole(self, p):
|
||||
if p.id in self.blackhole_penguins and p.is_vanilla_client:
|
||||
p.room = self.blackhole_penguins.pop(p.id)
|
||||
|
||||
|
||||
class PenguinIglooRoom(db.Model, RoomMixin):
|
||||
__tablename__ = 'penguin_igloo_room'
|
||||
|
8
houdini/handlers/play/blackhole.py
Normal file
8
houdini/handlers/play/blackhole.py
Normal file
@ -0,0 +1,8 @@
|
||||
from houdini import handlers
|
||||
from houdini.handlers import XTPacket
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('bh', 'lnbhg'))
|
||||
async def handle_leave_non_blackhole_game(p):
|
||||
if p.room.blackhole:
|
||||
await p.room.leave_blackhole(p)
|
Loading…
Reference in New Issue
Block a user