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

Method apiGetConfig

modules/automission/admin_api.go:107–157  ·  view source on GitHub ↗

apiGetConfig handles GET /admin/api/v1/automission-config.

(r *http.Request)

Source from the content-addressed store, hash-verified

105
106// apiGetConfig handles GET /admin/api/v1/automission-config.
107func (m *AutoMissionModule) apiGetConfig(r *http.Request) (int, bool, any) {
108 cc := m.loadComplexConfig()
109
110 // Merge scalar keys from the overlay config so the response is complete.
111 type fullConfig struct {
112 RestockPeriod string `json:"RestockPeriod"`
113 MaxMissions any `json:"MaxMissions"`
114 EscortTimeLimit string `json:"EscortTimeLimit"`
115 complexConfig
116 }
117
118 fc := fullConfig{
119 RestockPeriod: m.restockPeriod(),
120 EscortTimeLimit: m.escortTimeLimit(),
121 complexConfig: cc,
122 }
123
124 if v := m.plug.Config.Get("MaxMissions"); v != nil {
125 fc.MaxMissions = v
126 } else {
127 fc.MaxMissions = 6
128 }
129
130 // Seed reward pools from overlay defaults if plugin storage is empty.
131 if len(cc.KillMobEasyRewards) == 0 {
132 fc.KillMobEasyRewards = overlayRewards(m, "KillMobEasyRewards")
133 }
134 if len(cc.KillMobHardRewards) == 0 {
135 fc.KillMobHardRewards = overlayRewards(m, "KillMobHardRewards")
136 }
137 if len(cc.FindItemEasyRewards) == 0 {
138 fc.FindItemEasyRewards = overlayRewards(m, "FindItemEasyRewards")
139 }
140 if len(cc.FindItemHardRewards) == 0 {
141 fc.FindItemHardRewards = overlayRewards(m, "FindItemHardRewards")
142 }
143 if len(cc.ExploreEasyRewards) == 0 {
144 fc.ExploreEasyRewards = overlayRewards(m, "ExploreEasyRewards")
145 }
146 if len(cc.ExploreHardRewards) == 0 {
147 fc.ExploreHardRewards = overlayRewards(m, "ExploreHardRewards")
148 }
149 if len(cc.EscortEasyRewards) == 0 {
150 fc.EscortEasyRewards = overlayRewards(m, "EscortEasyRewards")
151 }
152 if len(cc.EscortHardRewards) == 0 {
153 fc.EscortHardRewards = overlayRewards(m, "EscortHardRewards")
154 }
155
156 return http.StatusOK, true, fc
157}
158
159// apiPatchConfig handles PATCH /admin/api/v1/automission-config.
160func (m *AutoMissionModule) apiPatchConfig(r *http.Request) (int, bool, any) {

Callers

nothing calls this directly

Calls 5

loadComplexConfigMethod · 0.95
restockPeriodMethod · 0.95
escortTimeLimitMethod · 0.95
overlayRewardsFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected