Exemplo n.º 1
0
def update_topN(c, g, n):
  if topN_count(c) >= n:
    if g['sc'] > lowest_highscore(c):
      query_do(c,'''DELETE FROM top_games
                          WHERE id = %s''',
               query_first(c, '''SELECT id FROM top_games
                                  ORDER BY sc LIMIT 1'''))
      insert_game(c, g, 'top_games')
      lowest_highscore.flush()
      dirty_pages('top-N', 'overview')
  else:
    insert_game(c, g, 'top_games')
    dirty_pages('top-N', 'overview')
    topN_count.flush()
Exemplo n.º 2
0
def update_topN(c, g, n):
    if topN_count(c) >= n:
        if g['sc'] > lowest_highscore(c):
            query_do(
                c, '''DELETE FROM top_games
                          WHERE id = %s''',
                query_first(
                    c, '''SELECT id FROM top_games
                                  ORDER BY sc LIMIT 1'''))
            insert_game(c, g, 'top_games')
            lowest_highscore.flush()
            dirty_pages('top-N', 'overview')
    else:
        insert_game(c, g, 'top_games')
        dirty_pages('top-N', 'overview')
        topN_count.flush()
Exemplo n.º 3
0
def update_topN(c, g, n):
  if topN_count(c) >= n:
    if g['sc'] > lowest_highscore(c):
      # note: for some reason this particular query is faster than just a simple
      # DELETE FROM ... ORDER BY query.
      query_do(c,'''DELETE FROM top_games
                          WHERE id = %s''',
               query_first(c, '''SELECT id FROM top_games
                                  ORDER BY sc LIMIT 1'''))
      insert_game(c, g, 'top_games')
      lowest_highscore.flush()
      dirty_pages('top-N', 'overview')
  else:
    insert_game(c, g, 'top_games')
    dirty_pages('top-N', 'overview')
    topN_count.flush()
Exemplo n.º 4
0
def update_player_streak(c, g):
  player = g['name']
  win = game_is_win(g)
  if not win:
    if player_streak_is_active(c, player):
      player_break_streak(c, player, g)
      player_streak_is_active.flush_key(player)
      dirty_pages('streaks', 'overview')
      dirty_player(player)
  else:
    if player_streak_is_active(c, player):
      player_extend_streak(c, player, g)
      dirty_pages('streaks', 'overview')
    elif player_won_last_game(c, player):
      player_create_streak(c, player, g)
      dirty_pages('streaks', 'overview')
      player_streak_is_active.flush_key(player)
Exemplo n.º 5
0
def update_player_streak(c, g):
    player = g['name']
    win = game_is_win(g)
    if not win:
        if player_streak_is_active(c, player):
            player_break_streak(c, player, g)
            player_streak_is_active.flush_key(player)
            dirty_pages('streaks', 'overview')
            dirty_player(player)
    else:
        if player_streak_is_active(c, player):
            player_extend_streak(c, player, g)
            dirty_pages('streaks', 'overview')
        elif player_won_last_game(c, player):
            player_create_streak(c, player, g)
            dirty_pages('streaks', 'overview')
            player_streak_is_active.flush_key(player)
Exemplo n.º 6
0
def update_wins_table(c, g):
  if game_is_win(g):
    dirty_pages('winners', 'fastest-wins-turns', 'fastest-wins-time',
                'overview')
    insert_game(c, g, 'wins')
Exemplo n.º 7
0
def update_wins_table(c, g):
    if game_is_win(g):
        dirty_pages('winners', 'fastest-wins-turns', 'fastest-wins-time',
                    'overview')
        insert_game(c, g, 'wins')
Exemplo n.º 8
0
 def update(self, g):
     if not game_is_win(g) or game_is_buggy(g):
         return
     dirty_pages('winners', 'fastest-wins-turns', 'fastest-wins-time',
                 'overview')
     self.games.append(g)