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
|
||||
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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue