(r *http.Request)
| 40 | } |
| 41 | |
| 42 | func (m *FishingModule) apiAddCatchable(r *http.Request) (int, bool, any) { |
| 43 | var body CatchableItem |
| 44 | if err := json.NewDecoder(r.Body).Decode(&body); err != nil { |
| 45 | return http.StatusBadRequest, false, map[string]string{"error": "malformed request body: " + err.Error()} |
| 46 | } |
| 47 | |
| 48 | if body.ItemId < 1 { |
| 49 | return http.StatusBadRequest, false, map[string]string{"error": "itemid is required"} |
| 50 | } |
| 51 | if body.ChanceToCatch < 1 || body.ChanceToCatch > 100 { |
| 52 | return http.StatusBadRequest, false, map[string]string{"error": "chancetocatch must be between 1 and 100"} |
| 53 | } |
| 54 | |
| 55 | body.ID = m.nextCatchableId() |
| 56 | m.cfg.Catchables = append(m.cfg.Catchables, body) |
| 57 | |
| 58 | if err := m.plug.WriteStruct(configKey, m.cfg); err != nil { |
| 59 | return http.StatusInternalServerError, false, map[string]string{"error": "failed to save: " + err.Error()} |
| 60 | } |
| 61 | |
| 62 | return http.StatusOK, true, body |
| 63 | } |
| 64 | |
| 65 | func (m *FishingModule) apiUpdateCatchable(r *http.Request) (int, bool, any) { |
| 66 | idStr := r.PathValue("id") |
nothing calls this directly
no test coverage detected