diff --git a/components/login.html b/components/login.html index 184a9b0..28ef7a7 100644 --- a/components/login.html +++ b/components/login.html @@ -1,19 +1,21 @@ {{define "login"}}
-
+
- +
- +
this name looks available
- - + +
+ +
- +
diff --git a/handlers/timer.go b/handlers/timer.go index 7807439..41bd8ed 100644 --- a/handlers/timer.go +++ b/handlers/timer.go @@ -23,7 +23,7 @@ func StartTurnTimer(roomID string, timeLeft uint32) { if err := repo.RoomUpdate(context.Background(), room); err != nil { logger.Error("failed to save room", "error", err) } - notify(models.NotifyTurnTimerPrefix+room.ID, strconv.FormatUint(uint64(room.Settings.RoundTime), 10)) + // notify(models.NotifyTurnTimerPrefix+room.ID, strconv.FormatUint(uint64(room.Settings.RoundTime), 10)) notifyBotIfNeeded(room) } @@ -31,7 +31,7 @@ func StartTurnTimer(roomID string, timeLeft uint32) { notify(models.NotifyTurnTimerPrefix+roomID, strconv.FormatUint(uint64(currentLeft), 10)) } - timer.StartTurnTimer(context.Background(), roomID, timeLeft, onTurnEnd, onTick, logger) + timer.StartTurnTimer(context.Background(), roomID, int32(timeLeft), onTurnEnd, onTick, logger) } func StopTurnTimer(roomID string) { diff --git a/llmapi/parser.go b/llmapi/parser.go index 625ee04..40e69b1 100644 --- a/llmapi/parser.go +++ b/llmapi/parser.go @@ -173,6 +173,7 @@ func (p *openRouterParser) MakePayload(prompt string) io.Reader { model := models[int(p.modelIndex)%len(models)] strPayload := fmt.Sprintf(`{ "model": "%s", + "max_tokens": 300, "messages": [ { "role": "user", diff --git a/llmapi/timer.go b/llmapi/timer.go index 5c1d30c..7f493a7 100644 --- a/llmapi/timer.go +++ b/llmapi/timer.go @@ -24,10 +24,10 @@ func (b *Bot) StartTurnTimer(timeLeft uint32) { if err := repos.RP.RoomUpdate(context.Background(), room); err != nil { logger.Error("failed to save room", "error", err) } - broker.Notifier.Notifier <- broker.NotificationEvent{ - EventName: models.NotifyTurnTimerPrefix + room.ID, - Payload: strconv.FormatUint(uint64(room.Settings.RoundTime), 10), - } + // broker.Notifier.Notifier <- broker.NotificationEvent{ + // EventName: models.NotifyTurnTimerPrefix + room.ID, + // Payload: strconv.FormatUint(uint64(room.Settings.RoundTime), 10), + // } // notifyBotIfNeeded(room) if botName := room.WhichBotToMove(); botName != "" { SignalChanMap[botName] <- true @@ -41,7 +41,7 @@ func (b *Bot) StartTurnTimer(timeLeft uint32) { } } - timer.StartTurnTimer(context.Background(), b.RoomID, timeLeft, onTurnEnd, onTick, logger) + timer.StartTurnTimer(context.Background(), b.RoomID, int32(timeLeft), onTurnEnd, onTick, logger) } func (b *Bot) StopTurnTimer() { diff --git a/timer/timer.go b/timer/timer.go index c44312a..1969a5b 100644 --- a/timer/timer.go +++ b/timer/timer.go @@ -14,12 +14,12 @@ type TurnEndCallback func(ctx context.Context, roomID string) type TickCallback func(ctx context.Context, roomID string, timeLeft uint32) type RoomTimer struct { - ticker *time.Ticker - done chan bool - roomID string + ticker *time.Ticker + done chan bool + roomID string onTurnEnd TurnEndCallback - onTick TickCallback - log *slog.Logger + onTick TickCallback + log *slog.Logger } var ( @@ -28,7 +28,7 @@ var ( ) // StartTurnTimer initializes and starts a new turn timer for a given room. -func StartTurnTimer(ctx context.Context, roomID string, timeLeft uint32, onTurnEnd TurnEndCallback, onTick TickCallback, logger *slog.Logger) { +func StartTurnTimer(ctx context.Context, roomID string, timeLeft int32, onTurnEnd TurnEndCallback, onTick TickCallback, logger *slog.Logger) { mu.Lock() defer mu.Unlock() @@ -39,14 +39,14 @@ func StartTurnTimer(ctx context.Context, roomID string, timeLeft uint32, onTurnE ticker := time.NewTicker(1 * time.Second) done := make(chan bool) - + rt := &RoomTimer{ - ticker: ticker, - done: done, - roomID: roomID, + ticker: ticker, + done: done, + roomID: roomID, onTurnEnd: onTurnEnd, - onTick: onTick, - log: logger, + onTick: onTick, + log: logger, } timers[roomID] = rt @@ -62,7 +62,7 @@ func StartTurnTimer(ctx context.Context, roomID string, timeLeft uint32, onTurnE StopTurnTimer(roomID) return } - rt.onTick(ctx, roomID, currentLeft) + rt.onTick(ctx, roomID, uint32(currentLeft)) currentLeft-- } } diff --git a/todos.md b/todos.md index a86e3cf..3c77117 100644 --- a/todos.md +++ b/todos.md @@ -94,3 +94,7 @@ - lose/win game; then exit room (while being the creator), then press to stats -> cannot find session in db, although cookie in place and session in db; + - exit endpoints delets player from db; + - timer end did not update the page; + +- timers conflict; stop timers; +- clue snatching; +- llm resp token amount limit;