update pause/unpause

This commit is contained in:
shoopea
2021-11-08 14:27:49 +08:00
parent 7db13a764c
commit 9a1ba7e7f2
2 changed files with 18 additions and 14 deletions

24
bot.go
View File

@@ -78,15 +78,17 @@ func botPause(m *tb.Message) {
if co, ok := srv.Status.Companies[cc.CompanyID]; ok {
if clt, ok2 := srv.Status.Clients[co.ClientID]; ok2 {
clt.Paused = true
if !srv.Status.Paused {
srv.Pause()
} else {
bot.SendChat(bot.Config.ChatID, "Game already paused.")
}
return
}
}
}
}
if !srv.Status.Paused {
srv.Pause()
} else {
bot.SendChat(bot.Config.ChatID, "Game already paused.")
}
bot.SendChat(bot.Config.ChatID, "You are not playing and cannot pause the game.")
return
}
@@ -97,15 +99,17 @@ func botUnpause(m *tb.Message) {
if co, ok := srv.Status.Companies[cc.CompanyID]; ok {
if clt, ok2 := srv.Status.Clients[co.ClientID]; ok2 {
clt.Paused = false
if !srv.NeedPause() {
srv.Unpause()
} else {
bot.SendChat(bot.Config.ChatID, fmt.Sprintf("Cannot unpause : %s", srv.NeedPauseReason()))
}
return
}
}
}
}
if !srv.NeedPause() {
srv.Unpause()
} else {
bot.SendChat(bot.Config.ChatID, fmt.Sprintf("Cannot unpause : %s", srv.NeedPauseReason()))
}
bot.SendChat(bot.Config.ChatID, "You are not playing and cannot unpause the game.")
return
}