diff --git a/.gitignore b/.gitignore index 4fdbbab..58a1751 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ _testmain.go /fyne-cross /kqb-scoreboard.app +/kqb-scoreboard.exe # This file includes artifacts of Go build that should not be checked in. # For files created by specific development environment (e.g. editor), # use alternative ways to exclude files from git. diff --git a/main.go b/main.go index 2aaea6a..111d0db 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,7 @@ type Stats struct { var h Team = Team{"Blue Team", PlaceholderImage, 1, 1, Stats{1, 1, 1, 1}} var a Team = Team{"Gold Team", PlaceholderImage, 1, 1, Stats{1, 1, 1, 1}} -var s Scoreboard = Scoreboard{&h, &a, 0, 0, 0, 0} +var s Scoreboard = Scoreboard{&h, &a, 0, 0, 0, 0, []ScoreboardSet{}} var logoPath string var FyneApp fyne.App diff --git a/scoreboard.go b/scoreboard.go index 11f193c..fd4d36e 100644 --- a/scoreboard.go +++ b/scoreboard.go @@ -10,12 +10,23 @@ type Scoreboard struct { AwayMaps int HomeGames int AwayGames int + // BlueBerries int + // GoldBerries int + // BlueEggs int + // GoldEggs int + Sets []ScoreboardSet +} + +type ScoreboardSet struct { + Away int + Home int } // IncrementHome accounts for when the home team wins a map func (s *Scoreboard) IncrementHome() { s.HomeMaps++ if s.HomeMaps == 3 { + s.Sets = append(s.Sets, ScoreboardSet{Away: s.AwayMaps, Home: s.HomeMaps}) s.HomeMaps = 0 s.AwayMaps = 0 s.HomeGames++ @@ -35,6 +46,7 @@ func (s *Scoreboard) DecrementHome() { func (s *Scoreboard) IncrementAway() { s.AwayMaps++ if s.AwayMaps == 3 { + s.Sets = append(s.Sets, ScoreboardSet{Away: s.AwayMaps, Home: s.HomeMaps}) s.HomeMaps = 0 s.AwayMaps = 0 s.AwayGames++ diff --git a/static/index.html b/static/index.html index 96204c5..2019614 100644 --- a/static/index.html +++ b/static/index.html @@ -60,19 +60,35 @@ document.getElementById("away-img").src = data.Away.Img } updateMapCSS(data) - if (data.HomeGames >= 3) { - document.getElementById("home-winner").classList.add("winner-background") - } else { - if(document.getElementById("home-winner").classList.contains("winner-background")) { - document.getElementById("home-winner").classList.remove("winner-background") - } + // if (data.HomeGames >= 3) { + // document.getElementById("home-winner").classList.add("winner-background") + // } else { + // if(document.getElementById("home-winner").classList.contains("winner-background")) { + // document.getElementById("home-winner").classList.remove("winner-background") + // } + // } + // if (data.AwayGames >= 3) { + // document.getElementById("away-winner").classList.add("winner-background") + // } else { + // if(document.getElementById("away-winner").classList.contains("winner-background")) { + // document.getElementById("away-winner").classList.remove("winner-background") + // } + // } + let homeRow = document.getElementById("home-row") + let awayRow = document.getElementById("away-row") + let x = homeRow.cells.length + let y = awayRow.cells.length + for(let i = x-1; i>0 ; i--) { + homeRow.deleteCell(i) } - if (data.AwayGames >= 3) { - document.getElementById("away-winner").classList.add("winner-background") - } else { - if(document.getElementById("away-winner").classList.contains("winner-background")) { - document.getElementById("away-winner").classList.remove("winner-background") - } + for(let j = y-1; j>0 ; j--) { + awayRow.deleteCell(j) + } + for(let [idx,set] of data.Sets.entries()) { + let homeCell = homeRow.insertCell(-1) + let awayCell = awayRow.insertCell(-1) + homeCell.innerText = set.Home + awayCell.innerText = set.Away } } function DarkModeToggle() { @@ -252,6 +268,16 @@
A | +
H | +