diff --git a/internal/game/game.go b/internal/game/game.go index d111a5f..33bda13 100644 --- a/internal/game/game.go +++ b/internal/game/game.go @@ -35,10 +35,8 @@ func NewPlant(username string, plant_kind string) error { tx.Commit() return nil } - func GiveItem(username string, items map[string]interface{}) error { db := database.DB - var stead map[string]interface{} err := db.Get(&stead, "SELECT inventory FROM Stead WHERE username=$1", username) if err != nil { @@ -72,6 +70,8 @@ func TakeItem(username string, items map[string]interface{}) error { var stead map[string]interface{} err := db.Get(&stead, "SELECT inventory FROM Stead WHERE username=$1", username) + log.Debug(stead) + if err != nil { return err } diff --git a/internal/handlers/hkgi.go b/internal/handlers/hkgi.go index abed83c..12abfd6 100644 --- a/internal/handlers/hkgi.go +++ b/internal/handlers/hkgi.go @@ -284,14 +284,14 @@ func Craft(c *fiber.Ctx) error { u := c.Locals("username").(string) var p models.Plant - err := db.Get(&p, "SELECT * FROM plant WHERE stead_owner=(SELECT id FROM stead WHERE username=$1) AND id=$2", u, cReq.PlantId) + err := db.Get(&p, "SELECT id,kind,xp,xp_multiplier,next_yield FROM plant WHERE stead_owner=(SELECT id FROM stead WHERE username=$1) AND id=$2", u, cReq.PlantId) if err != nil { return err } - recipe := manifest["plant_recipes"].(map[string]interface{})[p.Kind].([]map[string]interface{})[cReq.RecipeIndex] + recipe := manifest["plant_recipes"].(map[string]interface{})[p.Kind].([]interface{})[cReq.RecipeIndex].(map[string]interface{}) - if !(game.LvlFromXp(p.Xp) == recipe["xp"].(int)) { + if !(float64(game.LvlFromXp(p.Xp)) == recipe["lvl"].(float64)) { return &fiber.Error{ Code: fiber.ErrBadRequest.Code, Message: "come back when you're older, plant!",