Compare commits

..

1 Commits

Author SHA1 Message Date
3e5b99e1a9
Improve Jeopardy cashout message
Print only a single message instead of one per winner to reduce chat
clutter.
Skip cashout to users who won less than the possible cashout value as
limited by the division value to avoid congratulating someone who only
gets 0.
Abort should a regression cause the logic to process an empty set of
finishers to prevent unexpected behavior.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-03 15:25:12 +02:00
2 changed files with 2 additions and 6 deletions

View File

@ -65,12 +65,8 @@ func NewWatDb() *WatDb {
func (w *WatDb) User(nick, host string, create bool) Player { func (w *WatDb) User(nick, host string, create bool) Player {
var player Player var player Player
query := "nick = ?"
if host != "" {
query = query + " or host = ?"
}
// Try and get a user // Try and get a user
if err := w.db.First(&player, query, nick, host).Error; err != nil && create { if err := w.db.First(&player, "nick = ? or host = ?", nick, host).Error; err != nil && create {
fmt.Printf("Creating user: %s\n", err.Error()) fmt.Printf("Creating user: %s\n", err.Error())
// No user, make another // No user, make another
player.Nick = nick player.Nick = nick

View File

@ -28,7 +28,7 @@ var unconscious = "wat, your hands fumble and fail you. try resting, weakling."
func NewWatGame(bot *WatBot, db *WatDb) *WatGame { func NewWatGame(bot *WatBot, db *WatDb) *WatGame {
g := WatGame{bot, db, Player{}, nil, nil, nil, nil, map[string]int{}} g := WatGame{bot, db, Player{}, nil, nil, nil, nil, map[string]int{}}
g.me = g.db.User(bot.Nick, "", true) g.me = g.db.User(bot.Nick, "amia8t89xfp8y.liberta.casa", true)
g.commands = map[string](func(*Player, []string) string){ g.commands = map[string](func(*Player, []string) string){
//"wat": g.megaWat, //"wat": g.megaWat,
"steroid": g.Steroid, "steroid": g.Steroid,