def test_single_game_winner_stats(self): stats = count_buys.DeckBuyStats() targ_name = 'moop' match_name = lambda g, name: name_merger.norm_name(name) == targ_name count_buys.accum_buy_stats([self.outpost_game], stats, match_name) count_buys.add_effectiveness(stats, stats) # Harem bought by both players cstats = stats[dominioncards.Harem] self.assertEquals(cstats.available.freq, 1) self.assertEquals(cstats.any_gained.freq, 1) self.assertEquals(cstats.effect_with().freq, 1) self.assertEquals(cstats.effect_without().freq, 0) self.assertEquals(cstats.effectiveness_gain.freq, 1) # Salvager only bought by winner cstats = stats[dominioncards.Salvager] self.assertEquals(cstats.available.freq, 1) self.assertEquals(cstats.any_gained.freq, 1) self.assertEquals(cstats.effect_with().freq, 1) self.assertEquals(cstats.effect_without().freq, 0) self.assertEquals(cstats.effectiveness_gain.freq, 1) # Potion only bought by loser cstats = stats[dominioncards.Potion] self.assertEquals(cstats.available.freq, 1) self.assertEquals(cstats.any_gained.freq, 0) self.assertEquals(cstats.effect_with().freq, 0) self.assertEquals(cstats.effect_without().freq, 1) self.assertEquals(cstats.effectiveness_gain.freq, 0) # Outpost only bought by loser cstats = stats[dominioncards.Outpost] self.assertEquals(cstats.available.freq, 1) self.assertEquals(cstats.any_gained.freq, 0) self.assertEquals(cstats.effect_with().freq, 0) self.assertEquals(cstats.effect_without().freq, 1) self.assertEquals(cstats.effectiveness_gain.freq, 0) # Workshop not bought by either player cstats = stats[dominioncards.Workshop] self.assertEquals(cstats.available.freq, 1) self.assertEquals(cstats.any_gained.freq, 0) self.assertEquals(cstats.effect_with().freq, 0) self.assertEquals(cstats.effect_without().freq, 1) self.assertEquals(cstats.effectiveness_gain.freq, 0) # Chapel not present in this game cstats = stats[dominioncards.Chapel] self.assertEquals(cstats.available.freq, 0) self.assertEquals(cstats.any_gained.freq, 0) self.assertEquals(cstats.effect_with().freq, 0) self.assertEquals(cstats.effect_without().freq, 0)
def GET(self): import count_buys web.header("Content-Type", "text/html; charset=utf-8") query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING'])) db = utils.get_mongo_database() stats = count_buys.DeckBuyStats() utils.read_object_from_db(stats, db.buys, '') player_buy_summary = None if 'player' in query_dict: targ_name = norm_name(query_dict['player']) games = map(game.Game, list(db.games.find({'players': targ_name}))) player_buy_summary = count_buys.DeckBuyStats() match_name = lambda g, name: norm_name(name) == targ_name count_buys.accum_buy_stats(games, player_buy_summary, match_name) count_buys.add_effectiveness(player_buy_summary, stats) render = web.template.render('', globals={'round': round}) return render.buy_template(stats, player_buy_summary)
def GET(self): import count_buys web.header("Content-Type", "text/html; charset=utf-8") query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING'])) db = utils.get_mongo_database() stats = count_buys.DeckBuyStats() utils.read_object_from_db(stats, db.buys, '') player_buy_summary = None if 'player' in query_dict: targ_name = NormName(query_dict['player']) games = map(game.Game, list(db.games.find({'players': targ_name}))) player_buy_summary = count_buys.DeckBuyStats() match_name = lambda g, name: NormName(name) == targ_name count_buys.accum_buy_stats(games, player_buy_summary, match_name) count_buys.add_effectiveness(player_buy_summary, stats) render = web.template.render('', globals={'round': round}) return render.buy_template(stats, player_buy_summary)