Fix betting timer
This commit is contained in:
parent
08aeae8335
commit
5cbb637890
1 changed files with 5 additions and 5 deletions
10
main.go
10
main.go
|
@ -244,11 +244,11 @@ func endBet() {
|
||||||
bettingOpen = false
|
bettingOpen = false
|
||||||
question = ""
|
question = ""
|
||||||
possibleAnswers = nil
|
possibleAnswers = nil
|
||||||
timeToBet = 0
|
timeToBet = time.Unix(0, 0)
|
||||||
bets = nil
|
bets = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func startBet(q string, a []string, d time.Duration) {
|
func startBet(q string, a []string, d time.Time) {
|
||||||
bettingOpen = true
|
bettingOpen = true
|
||||||
question = q
|
question = q
|
||||||
possibleAnswers = make(map[int]string)
|
possibleAnswers = make(map[int]string)
|
||||||
|
@ -264,7 +264,7 @@ var (
|
||||||
bettingOpen bool
|
bettingOpen bool
|
||||||
question string
|
question string
|
||||||
possibleAnswers map[int]string
|
possibleAnswers map[int]string
|
||||||
timeToBet time.Duration
|
timeToBet time.Time
|
||||||
bets map[string]Bet
|
bets map[string]Bet
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ func main() {
|
||||||
possibleAnswers = append(possibleAnswers, answer.(string))
|
possibleAnswers = append(possibleAnswers, answer.(string))
|
||||||
}
|
}
|
||||||
timeToBetFloat := data["timeToBet"].(float64)
|
timeToBetFloat := data["timeToBet"].(float64)
|
||||||
timeToBet := time.Duration(timeToBetFloat) * time.Second
|
timeToBet := time.Now().Add(time.Duration(timeToBetFloat) * time.Second)
|
||||||
|
|
||||||
startBet(question, possibleAnswers, timeToBet)
|
startBet(question, possibleAnswers, timeToBet)
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ func main() {
|
||||||
c.JSON(200, gin.H{
|
c.JSON(200, gin.H{
|
||||||
"question": question,
|
"question": question,
|
||||||
"possible": possibleAnswersList,
|
"possible": possibleAnswersList,
|
||||||
"timeToBet": timeToBet.Seconds(),
|
"timeToBet": timeToBet.Unix(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue