コード例 #1
0
ファイル: foosbot_test.go プロジェクト: alevinval/foosbot
func benchmarkStoreState(b *testing.B, c *foosbot.Context) {
	b.ResetTimer()
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		c.Store()
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: alevinval/foosbot
func statsCommand(ctx *foosbot.Context, statement *parsing.StatStatement) string {
	stats, err := ctx.ExecuteStats(*statement)
	if err != nil {
		return err.Error()
	}
	return ctx.ReportStats(stats)
}
コード例 #3
0
ファイル: foosbot_test.go プロジェクト: alevinval/foosbot
func benchmarkLoadState(b *testing.B, c *foosbot.Context) {
	b.ResetTimer()
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		c.Reset()
		c.Load()
	}
}
コード例 #4
0
ファイル: main.go プロジェクト: alevinval/foosbot
func addMatchCommand(ctx *foosbot.Context, statement *parsing.MatchStatement) string {
	err := ctx.ExecuteMatch(*statement)
	if err != nil {
		panic(err)
	}
	total := statement.TeamOneScore + statement.TeamTwoScore
	return fmt.Sprintf("%d matches registered to history.", total)
}
コード例 #5
0
ファイル: foosbot_test.go プロジェクト: alevinval/foosbot
func addMatches(c *foosbot.Context, outcomes []*foosbot.Outcome) {
	for k := 0; k < len(outcomes); k++ {
		c.AddMatchWithOutcome(outcomes[k])
	}
}
コード例 #6
0
ファイル: main.go プロジェクト: alevinval/foosbot
func getLeaderboard(ctx *foosbot.Context) string {
	stats := ctx.PlayersStatsFromMatches(10, 10)
	response := ctx.ReportLeaderBoard(stats)
	return response
}
コード例 #7
0
ファイル: main.go プロジェクト: alevinval/foosbot
func backup(c *foosbot.Context) {
	for {
		time.Sleep(1 * time.Hour)
		c.Store()
	}
}