Go binary/server for helping run/build sessions for the Maze Rats TTRPG
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

67 lines
1.9 KiB

package handlers
import (
"mazeratsgen/internal/dice"
"mazeratsgen/internal/tables"
"net/http"
"time"
)
// @Summary Generate a spell
// @Tags magic
// @Produce application/json, text/plain
// @Method GET
// @Router /api/generate/spell [get]
// @Success 200
func GenSpell(w http.ResponseWriter, r *http.Request) {
t := tables.MagicTable{Roller: dice.NewRoller(time.Now().UnixNano())}
WriteResponse(w, r, t.Generate(), t.Template())
}
// @Summary Generate a mutation
// @Tags magic
// @Produce application/json, text/plain
// @Method GET
// @Router /api/generate/mutation [get]
// @Success 200
func GenMutation(w http.ResponseWriter, r *http.Request) {
t := tables.MagicTable{Roller: dice.NewRoller(time.Now().UnixNano())}
mutation := t.Mutation(t.Roller.TableRoll())
WriteResponse(w, r, mutation, "{{.}}")
}
// @Summary Generate a insanity
// @Tags magic
// @Produce application/json, text/plain
// @Method GET
// @Router /api/generate/insanity [get]
// @Success 200
func GenInsanity(w http.ResponseWriter, r *http.Request) {
t := tables.MagicTable{Roller: dice.NewRoller(time.Now().UnixNano())}
i := t.Insanity(t.Roller.TableRoll())
WriteResponse(w, r, i, "{{.}}")
}
// @Summary Generate a catastrophe
// @Tags magic
// @Produce application/json, text/plain
// @Method GET
// @Router /api/generate/catastrophe [get]
// @Success 200
func GenCatastrophe(w http.ResponseWriter, r *http.Request) {
t := tables.MagicTable{Roller: dice.NewRoller(time.Now().UnixNano())}
c := t.Catastrophe(t.Roller.TableRoll())
WriteResponse(w, r, c, "{{.}}")
}
// @Summary Generate a catastrophe
// @Tags magic
// @Produce application/json, text/plain
// @Method GET
// @Router /api/generate/catastrophe [get]
// @Success 200
func GenCatastophe(w http.ResponseWriter, r *http.Request) {
t := tables.MagicTable{Roller: dice.NewRoller(time.Now().UnixNano())}
c := t.Catastrophe(t.Roller.TableRoll())
WriteResponse(w, r, c, "{{.}}")
}