added getting words

This commit is contained in:
Hazel Noack
2025-06-30 12:15:58 +02:00
parent 9d6700fa9a
commit 3f2f19943a
5 changed files with 104376 additions and 1 deletions

View File

@@ -4,10 +4,11 @@ import (
"net/http"
"gitea.elara.ws/Hazel/hangman/internal/game"
"gitea.elara.ws/Hazel/hangman/internal/words"
"github.com/labstack/echo/v4"
)
func CreateSession(c echo.Context) error {
s := game.NewSession()
s := game.NewSession(words.GetRandomWord())
return c.JSON(http.StatusOK, s)
}

104338
internal/words/dictionary.go Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
package words
import (
"math/rand/v2"
)
func GetRandomWord() string {
// https://stackoverflow.com/a/22876612/16804841
return Words[rand.IntN(len(Words))]
}