Save endgame progress, team presets, technique support and camera controls
This commit is contained in:
1 parent
a681affdb3
commit
639cef7d19
52 files changed
+11940
-766
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package sdkserver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"gac-hkrpg-go/internal/common"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GET is read-only. POST changes only the auto-food switch in persistent.
|
||||
func apiTechnique(w http.ResponseWriter, r *http.Request) {
|
||||
apiMu.Lock()
|
||||
defer apiMu.Unlock()
|
||||
data, err := common.LoadFreesrData()
|
||||
if err != nil {
|
||||
writeJSON(w, map[string]any{"status": 500, "error": err.Error()})
|
||||
return
|
||||
}
|
||||
switch r.Method {
|
||||
case http.MethodPost:
|
||||
var req struct {
|
||||
AutoFood *bool `json:"auto_food"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.AutoFood == nil {
|
||||
writeJSON(w, map[string]any{"status": 400, "error": "auto_food must be a boolean"})
|
||||
return
|
||||
}
|
||||
data.AutoTechniqueFood = req.AutoFood
|
||||
if err := data.SavePersistentChecked(); err != nil {
|
||||
writeJSON(w, map[string]any{"status": 500, "error": err.Error()})
|
||||
return
|
||||
}
|
||||
case http.MethodGet:
|
||||
default:
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
writeJSON(w, map[string]any{"status": 200, "auto_food": data.AutoTechniqueFood, "food_stock": data.TechniqueFoodStock})
|
||||
}
|
||||
Reference in new issue
Block a user