|
|
|
@ -93,9 +93,10 @@ class Game(db.Model):
@@ -93,9 +93,10 @@ class Game(db.Model):
|
|
|
|
|
locations.append(player.last_location(self)) |
|
|
|
|
return locations |
|
|
|
|
|
|
|
|
|
def owned_by(self, player): |
|
|
|
|
'''given player is an owner of game''' |
|
|
|
|
return player in [gameplayer.player for gameplayer in self.game_players if gameplayer.role == Role.owner] |
|
|
|
|
def owned_by(self, player): |
|
|
|
|
# pylint: disable=not-an-iterable |
|
|
|
|
'''given player is an owner of game''' |
|
|
|
|
return player in [gameplayer.player for gameplayer in self.game_players if gameplayer.role == Role.owner] |
|
|
|
|
|
|
|
|
|
class Player(UserMixin, db.Model): |
|
|
|
|
""" !Always call set_auth_hash() after creating new instance! """ |
|
|
|
@ -182,11 +183,11 @@ class Player(UserMixin, db.Model):
@@ -182,11 +183,11 @@ class Player(UserMixin, db.Model):
|
|
|
|
|
return None |
|
|
|
|
return gameplayers[0].role |
|
|
|
|
|
|
|
|
|
def owns_game_played_by(self, player): |
|
|
|
|
'''self is an owner of a game the player participates in''' |
|
|
|
|
return self in [gameplayer.player for gameplayers in |
|
|
|
|
[game.game_players for game in player.games] |
|
|
|
|
for gameplayer in gameplayers if gameplayer.role == Role.owner] |
|
|
|
|
def owns_game_played_by(self, player): |
|
|
|
|
'''self is an owner of a game the player participates in''' |
|
|
|
|
return self in [gameplayer.player for gameplayers in |
|
|
|
|
[game.game_players for game in player.games] |
|
|
|
|
for gameplayer in gameplayers if gameplayer.role == Role.owner] |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def delete_orphans(): |
|
|
|
|