def update_game(self, game: Game): self.__hyperlink.update_hyperlink(game.name) self.__map_size.update_size(game.width, game.height) self.__player_count.update_counter(game.count, game.limit) self.__rate.update_value(game.rate) self.__delete_button.config( state=tk.NORMAL if game.deletable() else tk.DISABLED) self.__game = game
def DoGet(self): # By loading and storing each player, we're updating the player for any # schema changes. # This will not work once we have more than 1000 records, but it's fine for now. for player in Player.all(): player.put() for game in Game.all(): game.put() self.render_to_response("update_schema.html")
def DoGet(self): for game in Game.all(): logging.info('Checking if game %s is on the new schema' % game) if (not game.winner) and hasattr(game, 'player_1_score') and hasattr(game, 'player_2_score'): logging.info('Updating Game %s to new schema' % game) if game.player_1_score > game.player_2_score: game.winner = game.player_1 else: game.winner = game.player_2 game.put() self.render_to_response("update_schema.html")
def update(self): if self.__response: if self.__response.done(): if 'games' in self.__response.data: raw_games = sort_games(self.__response.data['games']) games = [] for game in raw_games: games.append(Game.from_json_dict(game)) self.__game_list.update_game_list(games) self.__response = self.__client.get_games() self.after(1000, self.update)
def DoGet(self): logging.info('Calculating ELO rankings') # Reset ranks for player in Player.all(): player.rank = elo.INITIAL_RANK player.put() # Calculate ranks for games in ascending order, since the order matters for ELO for game in Game.all_completed_asc(): logging.info('Updating rankings based on game completed at %s: %s' % (game.completed_date, game)) elo.update_ranks(game) game.player_1.put() game.player_2.put() self.render_to_response("calculate_elo_rankings.html")
def start_new_game(): global running_game running_game = Game()
import random from lib.helper import quit_game, remove_empty_cells, accumulate_neighbours from lib.models import Cell, Game running_game = Game() def start_new_game(): global running_game running_game = Game() def add_random_number(): """ Add a random number to an empty place in the game """ empty_cells = [] for row in running_game.game_matrix: for cell in row: if cell.empty: empty_cells.append(cell) count = len(empty_cells) if count == 0: quit_game("No more valid places!") random_cell = empty_cells[random.randint(0, count - 1)] choices = [2, 2, 4] random_cell.value = choices[random.randint(0, len(choices)-1)] def move_cells(row):