mirror of
https://github.com/solero/houdini.git
synced 2024-11-09 12:48:20 +00:00
Give waddles a "temporary" option
Passing `temporary=true` into a waddle will cause it to destroy itself when all players have left
This commit is contained in:
parent
18d26a5f5a
commit
48dde7a0ee
@ -268,13 +268,13 @@ class RoomWaddle(db.Model):
|
||||
game = db.Column(db.String(20), nullable=False)
|
||||
|
||||
GameClassMapping = {
|
||||
'sled': SledRacingLogic
|
||||
self.temporary = kwargs.pop('temporary', False)
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.penguins = []
|
||||
self.logic = None
|
||||
self.room = None
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
async def add_penguin(self, p):
|
||||
if not self.penguins:
|
||||
@ -293,6 +293,9 @@ class RoomWaddle(db.Model):
|
||||
|
||||
await self.reset()
|
||||
|
||||
if self.temporary:
|
||||
del p.server.rooms[self.room_id].waddles[self.id]
|
||||
|
||||
async def remove_penguin(self, p):
|
||||
seat_id = self.get_seat_id(p)
|
||||
self.penguins[seat_id] = None
|
||||
@ -300,6 +303,9 @@ class RoomWaddle(db.Model):
|
||||
|
||||
p.waddle = None
|
||||
|
||||
if self.temporary and self.penguins.count(None) == self.seats:
|
||||
del p.server.rooms[self.room_id].waddles[self.id]
|
||||
|
||||
async def reset(self):
|
||||
for seat_id, penguin in enumerate(self.penguins):
|
||||
if penguin:
|
||||
|
Loading…
Reference in New Issue
Block a user