Fix: last clue; give clue mime input

This commit is contained in:
Grail Finder
2025-09-14 21:16:57 +03:00
parent d076bd1348
commit f61de5645d
2 changed files with 15 additions and 6 deletions

View File

@@ -67,7 +67,7 @@
{{if .Room.IsRunning}}
{{if and (eq .State.Role "guesser") (eq .State.Team .Room.TeamTurn) (.Room.MimeDone)}}
<button hx-get="/end-turn" hx-target="#room" class="bg-amber-100 text-black px-4 py-2 rounded">End Turn</button>
{{else if and (eq .State.Role "mime") (not .Room.MimeDone)}}
{{else if and (eq .State.Role "mime") (not .Room.MimeDone) (eq .State.Team .Room.TeamTurn)}}
{{template "mimeclue"}}
{{end}}
{{end}}

View File

@@ -228,11 +228,20 @@ func (r *Room) FetchLastClue() (*Action, error) {
}
func (r *Room) FetchLastClueWord() string {
if len(r.ActionHistory) > 1 {
if strings.EqualFold(r.ActionHistory[0].Action, ActionTypeGameStarted) {
for i := len(r.ActionHistory) - 1; i >= 0; i-- {
if r.ActionHistory[i].Action == string(ActionTypeClue) {
return r.ActionHistory[i].Word
}
}
}
}
for i := 0; i <= len(r.ActionHistory)-1; i++ {
if r.ActionHistory[i].Action == string(ActionTypeClue) {
return r.ActionHistory[i].Word
}
}
return ""
}