Fix: number of guesses
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
{{define "cardcounter"}}
|
||||
<div class="flex justify-center">
|
||||
<p>Blue cards left: {{.BlueCounter}} </p>
|
||||
<p>Red cards left: {{.RedCounter}} </p>
|
||||
<div class="flex justify-center space-x-2">
|
||||
<p class="text-blue-400">Blue cards left: {{.BlueCounter}} </p>
|
||||
<p class="text-red-400">Red cards left: {{.RedCounter}} </p>
|
||||
<hr>
|
||||
<p>Limit of cards to open: {{.ThisTurnLimit}} </p>
|
||||
<p>Opened this turn: {{.OpenedThisTurn}} </p>
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{define "room"}}
|
||||
<div id="interier" hx-get="/" hx-trigger="sse:roomupdate_{{.State.RoomID}}">
|
||||
<div id="interier" hx-get="/" hx-trigger="sse:roomupdate_{{.State.RoomID}}" class=space-y-2>
|
||||
<div id="meta">
|
||||
<p>Hello {{.State.Username}};</p>
|
||||
<p>Room created by {{.Room.CreatorName}};</p>
|
||||
|
@ -51,7 +51,6 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
color, exists := fi.Room.WCMap[word]
|
||||
log.Debug("got show-color request", "word", word, "color", color)
|
||||
if !exists {
|
||||
abortWithError(w, "word is not found")
|
||||
return
|
||||
@ -74,17 +73,20 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
// if opened card is of color of opp team, change turn
|
||||
oppositeColor := fi.Room.GetOppositeTeamColor()
|
||||
fi.Room.OpenedThisTurn++
|
||||
if fi.Room.ThisTurnLimit > 0 {
|
||||
if fi.Room.ThisTurnLimit >= fi.Room.OpenedThisTurn {
|
||||
// end turn
|
||||
fi.Room.TeamTurn = oppositeColor
|
||||
fi.Room.MimeDone = false
|
||||
fi.Room.OpenedThisTurn = 0
|
||||
fi.Room.ThisTurnLimit = 0
|
||||
}
|
||||
log.Debug("got show-color request", "word", word, "color", color,
|
||||
"limit", fi.Room.ThisTurnLimit, "opened", fi.Room.OpenedThisTurn,
|
||||
"team-turn", fi.Room.TeamTurn, "opposite-color", oppositeColor)
|
||||
if fi.Room.OpenedThisTurn >= fi.Room.ThisTurnLimit {
|
||||
log.Debug("reached limit", "room", fi.Room)
|
||||
// end turn
|
||||
fi.Room.TeamTurn = oppositeColor
|
||||
fi.Room.MimeDone = false
|
||||
fi.Room.OpenedThisTurn = 0
|
||||
fi.Room.ThisTurnLimit = 0
|
||||
}
|
||||
switch string(color) {
|
||||
case "black":
|
||||
log.Debug("opened black word", "room", fi.Room)
|
||||
// game over
|
||||
fi.Room.IsRunning = false
|
||||
fi.Room.IsOver = true
|
||||
@ -99,6 +101,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
fi.Room.ThisTurnLimit = 0
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
case "white", string(oppositeColor):
|
||||
log.Debug("opened opposite color word", "room", fi.Room, "opposite-color", oppositeColor)
|
||||
// end turn
|
||||
fi.Room.TeamTurn = oppositeColor
|
||||
fi.Room.MimeDone = false
|
||||
@ -116,8 +119,6 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
WordColor: models.WordColorBlue,
|
||||
Action: models.ActionTypeGameOver,
|
||||
}
|
||||
fi.Room.OpenedThisTurn = 0
|
||||
fi.Room.ThisTurnLimit = 0
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
}
|
||||
if fi.Room.RedCounter == 0 {
|
||||
@ -131,8 +132,6 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
WordColor: models.WordColorRed,
|
||||
Action: models.ActionTypeGameOver,
|
||||
}
|
||||
fi.Room.OpenedThisTurn = 0
|
||||
fi.Room.ThisTurnLimit = 0
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +269,11 @@ func HandleGiveClue(w http.ResponseWriter, r *http.Request) {
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
fi.Room.MimeDone = true
|
||||
fi.Room.ThisTurnLimit = uint8(guessLimitU64) + 1
|
||||
log.Debug("given clue", "clue", clue, "limit", guessLimitU64)
|
||||
if guessLimitU64 == 0 {
|
||||
fi.Room.ThisTurnLimit = 9
|
||||
}
|
||||
fi.Room.OpenedThisTurn = 0
|
||||
log.Debug("given clue", "clue", clue, "limit", fi.Room.ThisTurnLimit)
|
||||
notify(models.NotifyBacklogPrefix+fi.Room.ID, clue+num)
|
||||
notifyBotIfNeeded(fi)
|
||||
if err := saveFullInfo(fi); err != nil {
|
||||
|
@ -83,16 +83,34 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
|
||||
room.ActionHistory = append(room.ActionHistory, action)
|
||||
// if opened card is of color of opp team, change turn
|
||||
oppositeColor := room.GetOppositeTeamColor()
|
||||
if room.OpenedThisTurn >= room.ThisTurnLimit {
|
||||
// end turn
|
||||
room.TeamTurn = oppositeColor
|
||||
room.MimeDone = false
|
||||
room.OpenedThisTurn = 0
|
||||
room.ThisTurnLimit = 0
|
||||
}
|
||||
switch string(color) {
|
||||
case "black":
|
||||
// game over
|
||||
room.IsRunning = false
|
||||
room.IsOver = true
|
||||
room.TeamWon = oppositeColor
|
||||
room.OpenedThisTurn = 0
|
||||
room.ThisTurnLimit = 0
|
||||
action := models.Action{
|
||||
Actor: b.BotName,
|
||||
ActorColor: string(b.Team),
|
||||
WordColor: models.WordColorBlack,
|
||||
Action: models.ActionTypeGameOver,
|
||||
}
|
||||
room.ActionHistory = append(room.ActionHistory, action)
|
||||
case "white", string(oppositeColor):
|
||||
// end turn
|
||||
room.TeamTurn = oppositeColor
|
||||
room.MimeDone = false
|
||||
room.OpenedThisTurn = 0
|
||||
room.ThisTurnLimit = 0
|
||||
}
|
||||
// check if no cards left => game over
|
||||
if room.BlueCounter == 0 {
|
||||
@ -100,12 +118,30 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
|
||||
room.IsRunning = false
|
||||
room.IsOver = true
|
||||
room.TeamWon = "blue"
|
||||
room.OpenedThisTurn = 0
|
||||
room.ThisTurnLimit = 0
|
||||
action := models.Action{
|
||||
Actor: b.BotName,
|
||||
ActorColor: string(b.Team),
|
||||
WordColor: models.WordColorBlack,
|
||||
Action: models.ActionTypeGameOver,
|
||||
}
|
||||
room.ActionHistory = append(room.ActionHistory, action)
|
||||
}
|
||||
if room.RedCounter == 0 {
|
||||
// red won
|
||||
room.IsRunning = false
|
||||
room.IsOver = true
|
||||
room.TeamWon = "red"
|
||||
room.OpenedThisTurn = 0
|
||||
room.ThisTurnLimit = 0
|
||||
action := models.Action{
|
||||
Actor: b.BotName,
|
||||
ActorColor: string(b.Team),
|
||||
WordColor: models.WordColorBlack,
|
||||
Action: models.ActionTypeGameOver,
|
||||
}
|
||||
room.ActionHistory = append(room.ActionHistory, action)
|
||||
}
|
||||
if err := saveRoom(room); err != nil {
|
||||
b.log.Error("failed to save room", "room", room)
|
||||
|
@ -83,7 +83,6 @@ type Room struct {
|
||||
OpenedThisTurn uint8 // how many cards have been opened this turn
|
||||
WCMap map[string]WordColor
|
||||
BotMap map[string]BotPlayer // key is bot name
|
||||
Result uint8 // 0 for unknown; 1 is win for red; 2 if for blue;
|
||||
BlueCounter uint8
|
||||
RedCounter uint8
|
||||
RedTurn bool // false is blue turn
|
||||
@ -97,8 +96,7 @@ type Room struct {
|
||||
//
|
||||
Mark CardMark // card is marked
|
||||
// needed for debug
|
||||
LogJournal []string
|
||||
LastActionTS time.Time
|
||||
LogJournal []string
|
||||
}
|
||||
|
||||
func (r *Room) RemovePlayer(username string) {
|
||||
@ -240,9 +238,9 @@ func (r *Room) WhichBotToMove() string {
|
||||
|
||||
func (r *Room) GetOppositeTeamColor() UserTeam {
|
||||
switch r.TeamTurn {
|
||||
case "red":
|
||||
case UserTeamRed:
|
||||
return UserTeamBlue
|
||||
case "blue":
|
||||
case UserTeamBlue:
|
||||
return UserTeamRed
|
||||
}
|
||||
return UserTeamNone
|
||||
|
7
todos.md
7
todos.md
@ -20,6 +20,7 @@
|
||||
- clear indication that model (llm) is thinking / answered;
|
||||
- different files for each supported lang;
|
||||
- mark cards (instead of opening them (right click?);
|
||||
- on end of turn clear all the marks;
|
||||
|
||||
#### sse points
|
||||
- clue sse update;
|
||||
@ -40,11 +41,13 @@
|
||||
- if mime joins another role, he stays as mime (before game start); +
|
||||
- guesser llm makes up words, likely the prompt should be more clear; +
|
||||
- remove bot does not remove for player roles in the room; +
|
||||
- 0 should mean without limit;
|
||||
- guesser did not have same number of guesses (move ended after 1 guess); show how much guesses left on the page (red after blue); +
|
||||
- 0 should mean without limit; +
|
||||
- sse hangs / fails connection which causes to wait for cards to open a few seconds (on local machine) (did not reoccur so far);
|
||||
- invite link gets cutoff;
|
||||
- guesser did not have same number of guesses (move ended after 1 guess); show how much guesses left on the page (red after blue);
|
||||
- guesser bot no request after game restart;
|
||||
- remove join as mime button if there is a mime already on that team (rewrite teampew templ);
|
||||
- openrouter 429 errors;
|
||||
- there is a clue window for a mime before game started;
|
||||
- retry call to llm (if 400|429|4xx);
|
||||
- when llm guesses the word it is not removed from a pool of words making it keep guessing it;
|
||||
|
Reference in New Issue
Block a user