def __init__(self, id, name=None, email=None, password=None): self.id = id self.name = name self.email = email self.password = password self.created = datetime.datetime.now() self.updated = self.created self.money = MoneyPlayer(player_id=self.id) self.counters = CountersPlayer(player_id=self.id) self.achievements = PlayerAchievements(player_id=self.id)
counetrs_player_1 = CountersPlayer(1, 4030, 1212, 15) counetrs_player_2 = CountersPlayer(2, 400, 12, 5) counetrs_player_3 = CountersPlayer(3, 10000, 1222, 6) counetrs_player_1.save_to_db() counetrs_player_2.save_to_db() counetrs_player_3.save_to_db() achievements_player_1 = PlayerAchievements(1, 1) achievements_player_2 = PlayerAchievements(2, 4) achievements_player_3 = PlayerAchievements(3, 4) achievements_player_1.save_to_db() achievements_player_2.save_to_db() achievements_player_3.save_to_db() money_player_1 = MoneyPlayer(1) money_player_2 = MoneyPlayer(2) money_player_3 = MoneyPlayer(3) money_player_1.save_to_db() money_player_2.save_to_db() money_player_3.save_to_db() player1 = Player(1) player1.load_from_db('*****@*****.**') print(player1) print('player={}, money={}, counters={}'.format(player1.name, player1.get_money_player(), player1.get_counters_player())) player2 = Player(2) player2.load_from_db('*****@*****.**') print(player2)