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
@@ -38,6 +38,7 @@ func corsWrapper(next http.HandlerFunc) http.HandlerFunc {
|
||||
|
||||
func registerAPIRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("/api/status", corsWrapper(apiStatus))
|
||||
mux.HandleFunc("/api/technique", corsWrapper(apiTechnique))
|
||||
mux.HandleFunc("/api/freesr", corsWrapper(apiFreesrData))
|
||||
mux.HandleFunc("/api/freesr/avatars", corsWrapper(apiFreesrAvatars))
|
||||
mux.HandleFunc("/api/persistent", corsWrapper(apiPersistentData))
|
||||
@@ -605,7 +606,6 @@ func apiGachabaseFetch(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if targetURL == "" {
|
||||
writeJSON(w, map[string]any{"error": "missing url or id/type parameters", "status": 400})
|
||||
return
|
||||
@@ -833,5 +833,3 @@ func apiBattleReportReset(w http.ResponseWriter, r *http.Request) {
|
||||
"message": "Battle report cleared",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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})
|
||||
}
|
||||
@@ -218,21 +218,21 @@ type accountPayload struct {
|
||||
Retcode int `json:"retcode"`
|
||||
}
|
||||
|
||||
func standardAccount() map[string]any {
|
||||
func (a *appState) standardAccount() map[string]any {
|
||||
return map[string]any{
|
||||
"area_code": "**",
|
||||
"email": "ReversedRooms",
|
||||
"country": "RU",
|
||||
"is_email_verify": "1",
|
||||
"token": "mostsecuretokenever",
|
||||
"uid": "1337",
|
||||
"uid": fmt.Sprint(a.runtime.PlayerUID),
|
||||
}
|
||||
}
|
||||
|
||||
func loginReply(w http.ResponseWriter) {
|
||||
func (a *appState) loginReply(w http.ResponseWriter) {
|
||||
writeJSON(w, map[string]any{
|
||||
"data": map[string]any{
|
||||
"account": standardAccount(),
|
||||
"account": a.standardAccount(),
|
||||
"device_grant_required": false,
|
||||
"reactivate_required": false,
|
||||
"realperson_required": false,
|
||||
@@ -243,15 +243,15 @@ func loginReply(w http.ResponseWriter) {
|
||||
})
|
||||
}
|
||||
|
||||
func granterLoginReply(w http.ResponseWriter) {
|
||||
func (a *appState) granterLoginReply(w http.ResponseWriter) {
|
||||
writeJSON(w, map[string]any{
|
||||
"data": map[string]any{
|
||||
"account_type": 1,
|
||||
"combo_id": "1337",
|
||||
"combo_id": fmt.Sprint(a.runtime.PlayerUID),
|
||||
"combo_token": "9065ad8507d5a1991cb6fddacac5999b780bbd92",
|
||||
"data": `{"guest":false}`,
|
||||
"heartbeat": false,
|
||||
"open_id": "1337",
|
||||
"open_id": fmt.Sprint(a.runtime.PlayerUID),
|
||||
},
|
||||
"message": "OK",
|
||||
"retcode": 0,
|
||||
@@ -270,13 +270,13 @@ func riskyCheckReply(w http.ResponseWriter) {
|
||||
})
|
||||
}
|
||||
|
||||
func apnLoginReply(w http.ResponseWriter) {
|
||||
func (a *appState) apnLoginReply(w http.ResponseWriter) {
|
||||
writeJSON(w, map[string]any{
|
||||
"data": map[string]any{
|
||||
"token": map[string]any{"token": "mostsecuretokenever", "token_type": 1},
|
||||
"user_info": map[string]any{
|
||||
"aid": "1337",
|
||||
"mid": "1337",
|
||||
"aid": fmt.Sprint(a.runtime.PlayerUID),
|
||||
"mid": fmt.Sprint(a.runtime.PlayerUID),
|
||||
"is_email_verify": 1,
|
||||
"area_code": "**",
|
||||
"country": "US",
|
||||
@@ -289,13 +289,13 @@ func apnLoginReply(w http.ResponseWriter) {
|
||||
})
|
||||
}
|
||||
|
||||
func apnVerifyReply(w http.ResponseWriter) {
|
||||
func (a *appState) apnVerifyReply(w http.ResponseWriter) {
|
||||
writeJSON(w, map[string]any{
|
||||
"data": map[string]any{
|
||||
"tokens": []any{map[string]any{"token": "mostsecuretokenever", "token_type": 1}},
|
||||
"user_info": map[string]any{
|
||||
"aid": "1337",
|
||||
"mid": "1337",
|
||||
"aid": fmt.Sprint(a.runtime.PlayerUID),
|
||||
"mid": fmt.Sprint(a.runtime.PlayerUID),
|
||||
"is_email_verify": 1,
|
||||
"area_code": "**",
|
||||
"country": "US",
|
||||
@@ -361,12 +361,12 @@ func Listen() error {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/query_dispatch", func(w http.ResponseWriter, r *http.Request) { queryDispatch(w, r, runtime) })
|
||||
mux.HandleFunc("/query_gateway", queryGateway(state))
|
||||
mux.HandleFunc("/{product_name}/mdk/shield/api/login", func(w http.ResponseWriter, r *http.Request) { loginReply(w) })
|
||||
mux.HandleFunc("/{product_name}/mdk/shield/api/verify", func(w http.ResponseWriter, r *http.Request) { loginReply(w) })
|
||||
mux.HandleFunc("/{product_name}/combo/granter/login/v2/login", func(w http.ResponseWriter, r *http.Request) { granterLoginReply(w) })
|
||||
mux.HandleFunc("/{product_name}/mdk/shield/api/login", func(w http.ResponseWriter, r *http.Request) { state.loginReply(w) })
|
||||
mux.HandleFunc("/{product_name}/mdk/shield/api/verify", func(w http.ResponseWriter, r *http.Request) { state.loginReply(w) })
|
||||
mux.HandleFunc("/{product_name}/combo/granter/login/v2/login", func(w http.ResponseWriter, r *http.Request) { state.granterLoginReply(w) })
|
||||
mux.HandleFunc("/account/risky/api/check", func(w http.ResponseWriter, r *http.Request) { riskyCheckReply(w) })
|
||||
mux.HandleFunc("/account/ma-cn-passport/app/loginByPassword", func(w http.ResponseWriter, r *http.Request) { apnLoginReply(w) })
|
||||
mux.HandleFunc("/account/ma-cn-session/app/verify", func(w http.ResponseWriter, r *http.Request) { apnVerifyReply(w) })
|
||||
mux.HandleFunc("/account/ma-cn-passport/app/loginByPassword", func(w http.ResponseWriter, r *http.Request) { state.apnLoginReply(w) })
|
||||
mux.HandleFunc("/account/ma-cn-session/app/verify", func(w http.ResponseWriter, r *http.Request) { state.apnVerifyReply(w) })
|
||||
mux.HandleFunc("/srtools", corsWrapper(srToolsSave))
|
||||
registerAPIRoutes(mux)
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in new issue
Block a user