Skip to content

julius-b/wordgame

Repository files navigation

WordGame

Cooperative wordgame @ hotbling.wtf

Status: WIP

Features

  • play solo or with up to 2 other team mates
  • etc.

Technology

This is a Kotlin Multiplatform project targeting Android, Web, Desktop, Server.

Code

Commands

  • wasmJs (dev): ./gradlew :composeApp:wasmJsBrowserDevelopmentRun
  • desktop (dev): ./gradlew :composeApp:run
    • jar: ./gradlew :composeApp:packageUberJarForCurrentOS && java -jar ./composeApp/build/compose/jars/wtf.hotbling.wordgame-linux-x64-1.0.0.jar
  • server (dev): ./gradlew :server:run
    • jar: ./gradlew :server:buildFatJar && (cd server && java -jar -Dio.ktor.development=true ./build/libs/server-all.jar)
    • combine with: ./gradlew wasmJsBrowserDevelopmentExecutableDistribution
  • prod run: ./gradlew clean wasmJsBrowserDistribution :server:publishImageToLocalRegistry && docker compose up -d
  • prod push: rsync -a --exclude build . [email protected]:~/code/wordgame

TODO

  • tests, esp. for subscription code
  • spectate mode (read-only)
  • login
  • streaks, friends & scoring system
  • profile pics
  • word definition, possibly via wiktionary (verify all marked as solved are in wiktionary offline db)
  • user-added words
  • server-side error handling, in routes & services
  • maybe: replace WS with SSE (since one-way)
  • full Android app (deeplink...)
  • auth :)
  • eliminate !! by capturing variables

Bash Client

Dev

export host=http://localhost:8080
export ws_host=ws://localhost:8080/ws

Prod

export host=https://hotbling.wtf
export ws_host=wss://hotbling.wtf/ws

Words Api

Random

curl "$host/api/v1/words/random"

Solution

curl "$host/api/v1/words/solution"

Accounts Api

Create

output=$(curl -s -X PUT --json '{"name":"Meow"}' "$host/api/v1/accounts")
echo "$output"
export account_id=$(jq -r '.data.id' <<< "$output")
echo "account_id: $account_id"

Update

output=$(curl -s -X PUT --json '{"id":"'$account_id'","name":"Cat"}' "$host/api/v1/accounts")
echo "$output"
export account_id=$(jq -r '.data.id' <<< "$output")
echo "account_id: $account_id"

Sessions Api

List

curl "$host/api/v1/sessions/by-account/$account_id"

Create

output=$(curl -s --json '{"account_id":"'$account_id'"}' "$host/api/v1/sessions")
echo "$output"
export session_id=$(jq -r '.data.id' <<< "$output")
echo "session_id: $session_id"

Connect (real-time)

websocat "$ws_host?Session=$session_id&Account=$account_id"

Guesses Api

Create

output=$(curl -s --json '{"session_id":"'$session_id'","account_id":"'$account_id'","txt":"hello"}' "$host/api/v1/guesses")
echo "$output"
export guess_id=$(jq -r '.data.id' <<< "$output")
echo "guess_id: $guess_id"