added getting words
This commit is contained in:
@@ -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
104338
internal/words/dictionary.go
Normal file
File diff suppressed because it is too large
Load Diff
10
internal/words/get_words.go
Normal file
10
internal/words/get_words.go
Normal 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))]
|
||||
}
|
||||
Reference in New Issue
Block a user