games package with data and page handlers for one and all
This commit is contained in:
parent
6d09f217e3
commit
e5afc16a04
1 changed files with 89 additions and 0 deletions
89
web/pages/games/games.go
Normal file
89
web/pages/games/games.go
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue