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.
68 lines
1.9 KiB
68 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())}
|
|
s := t.Spell(t.Roller.TableRoll())
|
|
WriteResponse(w, r, s, "{{.}}")
|
|
}
|
|
|
|
// @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())}
|
|
m := t.Mutation(t.Roller.TableRoll())
|
|
WriteResponse(w, r, m, "{{.}}")
|
|
}
|
|
|
|
// @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, "{{.}}")
|
|
}
|
|
|