Fix betting timer

This commit is contained in:
Tracker-Friendly 2025-03-24 21:07:27 +00:00
parent 08aeae8335
commit 5cbb637890

10
main.go
View file

@ -244,11 +244,11 @@ func endBet() {
bettingOpen = false
question = ""
possibleAnswers = nil
timeToBet = 0
timeToBet = time.Unix(0, 0)
bets = nil
}
func startBet(q string, a []string, d time.Duration) {
func startBet(q string, a []string, d time.Time) {
bettingOpen = true
question = q
possibleAnswers = make(map[int]string)
@ -264,7 +264,7 @@ var (
bettingOpen bool
question string
possibleAnswers map[int]string
timeToBet time.Duration
timeToBet time.Time
bets map[string]Bet
)
@ -560,7 +560,7 @@ func main() {
possibleAnswers = append(possibleAnswers, answer.(string))
}
timeToBetFloat := data["timeToBet"].(float64)
timeToBet := time.Duration(timeToBetFloat) * time.Second
timeToBet := time.Now().Add(time.Duration(timeToBetFloat) * time.Second)
startBet(question, possibleAnswers, timeToBet)
@ -577,7 +577,7 @@ func main() {
c.JSON(200, gin.H{
"question": question,
"possible": possibleAnswersList,
"timeToBet": timeToBet.Seconds(),
"timeToBet": timeToBet.Unix(),
})
return
} else {