2019-01-15 00:57:48 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-10-15 18:51:46 +08:00
|
|
|
db = lambda _=None: None
|
|
|
|
setattr(db, 'close', lambda _=None: None)
|
|
|
|
|
2019-01-15 00:57:48 +08:00
|
|
|
pool = dict()
|
|
|
|
|
|
|
|
class Player():
|
2019-10-15 18:51:46 +08:00
|
|
|
def __init__(self, user_id, mines, death, wins,
|
|
|
|
restricted_until, immunity_cards, permission):
|
2019-01-15 00:57:48 +08:00
|
|
|
self.user_id = user_id
|
|
|
|
self.mines = mines
|
|
|
|
self.death = death
|
|
|
|
self.wins = wins
|
|
|
|
self.restricted_until = restricted_until
|
|
|
|
self.immunity_cards = immunity_cards
|
2019-10-15 18:51:46 +08:00
|
|
|
self.permission = permission
|
2019-01-15 00:57:48 +08:00
|
|
|
|
|
|
|
def get_player(user_id):
|
|
|
|
player = pool.get(user_id, None)
|
|
|
|
if player is None:
|
|
|
|
player = Player(user_id=user_id, mines=0, death=0, wins=0,
|
2019-10-15 18:51:46 +08:00
|
|
|
restricted_until=0, immunity_cards=0, permission=0)
|
2019-01-15 00:57:48 +08:00
|
|
|
pool[user_id] = player
|
|
|
|
return player
|
|
|
|
else:
|
|
|
|
return player
|