Private
Public Access
1
0

fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 6m49s

This commit is contained in:
Sebastian Unterschütz
2026-03-22 18:46:54 +01:00
parent 656f279a89
commit 6d0d31824e
6 changed files with 265 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ package main
import (
"crypto/rand"
"encoding/hex"
"fmt"
"io/ioutil"
"log"
"strings"
@@ -61,3 +62,19 @@ func (g *Game) savePlayerName(name string) {
log.Printf("💾 Spielername gespeichert: %s", name)
}
}
func (g *Game) loadHighscore() int {
const hsFile = "highscore.txt"
if data, err := ioutil.ReadFile(hsFile); err == nil {
var score int
if _, err2 := fmt.Sscanf(strings.TrimSpace(string(data)), "%d", &score); err2 == nil {
return score
}
}
return 0
}
func (g *Game) saveHighscore(score int) {
const hsFile = "highscore.txt"
ioutil.WriteFile(hsFile, []byte(fmt.Sprintf("%d", score)), 0644)
}