reta final, so falta a parte do obs studio agora
This commit is contained in:
@@ -98,6 +98,8 @@ func main() {
|
||||
e.POST("login", login, timeoutMiddleware, rateLimit)
|
||||
e.GET("login", badreq)
|
||||
e.GET("player", player_data)
|
||||
e.GET("player/info/:id", player_info)
|
||||
e.GET("player/info*", player_info)
|
||||
e.GET("player/inv", inv_get)
|
||||
e.POST("player/inv", inv_add)
|
||||
e.GET("player/inv/del/:id", inv_del)
|
||||
|
||||
@@ -190,6 +190,50 @@ func roll_get(c echo.Context) error {
|
||||
})
|
||||
}
|
||||
|
||||
func player_info(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
|
||||
if anyEmpty(id) {
|
||||
return jsonError(c, http.StatusBadRequest, "você precisa passar a id do usuario.")
|
||||
}
|
||||
|
||||
var foto, nome, vida, descricao string
|
||||
var conhecimento, level, idade, vd, vdm, destreza, inteligencia, forca, constituicao, carisma, inventario int64
|
||||
var altura float64
|
||||
|
||||
err := db.QueryRow(`SELECT foto, nome, conhecimento, level, idade, altura, vida, vida_maxima,
|
||||
destresa, inteligencia, força, constituição, cárisma, inventario, descrição
|
||||
FROM players WHERE id=? LIMIT 1;`, id).
|
||||
Scan(&foto, &nome, &conhecimento, &level, &idade, &altura, &vd, &vdm,
|
||||
&destreza, &inteligencia, &forca, &constituicao, &carisma, &inventario, &descricao)
|
||||
|
||||
if err != nil {
|
||||
return jsonError(c, http.StatusBadRequest, "Algo deu errado ao carregar informações do player")
|
||||
}
|
||||
|
||||
vida = fmt.Sprintf("%v/%v", vd, vdm)
|
||||
porcentagem := (float64(vd) / float64(vdm)) * 100
|
||||
|
||||
return c.JSON(http.StatusOK, resp_json{
|
||||
Status: "Success",
|
||||
Foto: foto,
|
||||
PlayerName: nome,
|
||||
Conhecimento: &conhecimento,
|
||||
Level: &level,
|
||||
Idade: &idade,
|
||||
Altura: &altura,
|
||||
Vida: vida,
|
||||
VidaPorcentagem: &porcentagem,
|
||||
Destresa: &destreza,
|
||||
Inteligencia: &inteligencia,
|
||||
Força: &forca,
|
||||
Constituição: &constituicao,
|
||||
Cárisma: &carisma,
|
||||
Inventario: &inventario,
|
||||
Descrição: descricao,
|
||||
})
|
||||
}
|
||||
|
||||
func player_data(c echo.Context) error {
|
||||
session, err := requireSession(c)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user