site/web/pages/games/games.go

89 lines
1.3 KiB
Go

package games
import (
"net/http"
"dofdev/tem"
"github.com/gorilla/mux"
)
type Game struct {
Name string
Desc string
Notes string
}
var Games = map[string]Game{
"silo": {
Name: "stretch silo",
Desc: "a stretch cursor 360 missile defense game",
Notes: `start with air raid sirens
and shouted commands
shilouttes in the night
(fight or flight - adrenaline)
walk into futuristic vector battlestation
(step up buckle down)
overview of your silos and what you are protecting
missiles fly in
(take responsibility)
*ref typhon missile system`,
},
"snake": {
Name: "snake in a box",
Desc: "vr snake zencore",
Notes: `cute happy go lucky eating stuff
older and bigger
and have to deal with your past choices`,
},
"vien": {
Name: "vien",
Desc: "hordiculture",
},
}
func Handler(w http.ResponseWriter, r *http.Request) {
data := struct {
Games map[string]Game
}{
Games: Games,
}
tem.Render(
w, r,
"games.html",
"games",
"dof driven games",
data,
)
}
func GameHandler(w http.ResponseWriter, r *http.Request) {
hash := mux.Vars(r)["hash"]
game, ok := Games[hash]
if !ok {
w.WriteHeader(http.StatusNotFound)
return
}
data := struct {
Hash string
Game Game
}{
Hash: hash,
Game: game,
}
tem.Render(
w, r,
"game.html",
game.Name,
game.Desc,
data,
)
}