Update GaCy-GO
This commit is contained in:
1 parent
da8a32f60d
commit
0cbe460e49
345 files changed
+98202
-77559
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package sdkserver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"gac-hkrpg-go/internal/common"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func apiAhaHelp(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodPost {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
if r.Method == http.MethodPost {
|
||||
var body map[string]json.RawMessage
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
http.Error(w, "invalid JSON", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
raw, ok := body["level"]
|
||||
var level *uint32
|
||||
if !ok || json.Unmarshal(raw, &level) != nil {
|
||||
http.Error(w, "level must be null or an unsigned integer", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if err := common.SaveAhaHelpLevel(level); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
levels, err := common.LoadAhaHelpLevels()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
selected, err := common.ReadAhaHelpLevel()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
data, err := common.LoadFreesrData()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
writeJSON(w, map[string]any{"status": 200, "level": selected, "levels": levels, "legacy_enabled": data.BattleConfig.EnableInvasionSupport})
|
||||
}
|
||||
Reference in new issue
Block a user