From d3b5d2c37fb5266cad910566e9e4b83bb73114c6 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Wed, 8 Jan 2025 02:00:21 +0100 Subject: [PATCH] Ohhhh --- internal/beerpong-elo.go | 8 +++++--- internal/elo.go | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/beerpong-elo.go b/internal/beerpong-elo.go index cf55c88..0f8c70b 100644 --- a/internal/beerpong-elo.go +++ b/internal/beerpong-elo.go @@ -17,14 +17,16 @@ func Start(config Config) { repo := repo.NewInMemoryRepo() - loadFromFile(repo, "./data.json") + controller := newController(repo) + + loadFromFile(controller, "./data.json") mux := web.CreateWebserver(repo) http.ListenAndServe(":8080", mux) } -func loadFromFile(repo repo.Repo, path string) error { +func loadFromFile(c Controller, path string) error { content, err := os.ReadFile(path) if err != nil { @@ -38,7 +40,7 @@ func loadFromFile(repo repo.Repo, path string) error { } for _, game := range payload { - repo.AddGame(game) + c.AddGame(game) } return nil diff --git a/internal/elo.go b/internal/elo.go index 7977572..ac1947f 100644 --- a/internal/elo.go +++ b/internal/elo.go @@ -1,7 +1,6 @@ package beerpongelo import ( - "fmt" "math" ) @@ -43,7 +42,6 @@ func NewRating(t0p0, t0p1, t1p0, t1p1 float64, score int) (float64, float64, flo } scoreMod := SCORE_SCALE * math.Log(math.Abs(float64(score))+SCORE_BIAS) / (math.Log(MAX_SCORE) + SCORE_BIAS) - fmt.Printf("%d: %f\n", score, scoreMod) newt0p0 := t0p0 + K*scoreMod*((st0*ct0p0)-(et0*ct0p0)) newt0p1 := t0p1 + K*scoreMod*((st0*ct0p1)-(et0*ct0p1))