MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / apiAddCatchable

Method apiAddCatchable

modules/fishing/admin_api.go:42–63  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

40}
41
42func (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
65func (m *FishingModule) apiUpdateCatchable(r *http.Request) (int, bool, any) {
66 idStr := r.PathValue("id")

Callers

nothing calls this directly

Calls 2

nextCatchableIdMethod · 0.95
WriteStructMethod · 0.80

Tested by

no test coverage detected