diff --git a/server/bin/gameserver/dev_config/setting.json b/server/bin/gameserver/dev_config/setting.json index 99befbb2..ec9bf879 100644 --- a/server/bin/gameserver/dev_config/setting.json +++ b/server/bin/gameserver/dev_config/setting.json @@ -1,3 +1,4 @@ { - "api_url": "https://game2006api-test.kingsome.cn/webapp/index.php" + "api_url": "https://game2006api-test.kingsome.cn/webapp/index.php", + "api_secret_key": "BIgDh5J%uUktooKxT!IM7#m$NtB51%la" } diff --git a/server/bin/gameserver/test_config/setting.json b/server/bin/gameserver/test_config/setting.json index 99befbb2..ec9bf879 100644 --- a/server/bin/gameserver/test_config/setting.json +++ b/server/bin/gameserver/test_config/setting.json @@ -1,3 +1,4 @@ { - "api_url": "https://game2006api-test.kingsome.cn/webapp/index.php" + "api_url": "https://game2006api-test.kingsome.cn/webapp/index.php", + "api_secret_key": "BIgDh5J%uUktooKxT!IM7#m$NtB51%la" } diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index a37cb12f..2a6f6438 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -76,7 +76,7 @@ void BoxDrop::RequestAllocBoxNum() int nowtime = f8::App::Instance()->GetNowTime(); auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Battle"); - url_params->SetVal("a", "requestBoxNum"); + url_params->SetVal("a", "requestAllocBoxNum"); url_params->SetVal("timestamp", a8::XValue(nowtime)); HttpProxy::Instance()->HttpGet ( @@ -110,5 +110,46 @@ void BoxDrop::RequestAllocBoxNum() void BoxDrop::RequestReturnBoxNum() { - + if (alloc_box_num_ <= 0) { + return; + } + if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { + if (returned_) { + return; + } + returned_ = true; + std::string url; + JsonDataMgr::Instance()->GetApiUrl(url); + auto url_params = a8::MutableXObject::CreateObject(); + url_params->SetVal("c", "Battle"); + url_params->SetVal("a", "requestReturnBoxNum"); + HttpProxy::Instance()->HttpGet + ( + [] + (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + { + if (ok) { + f8::UdpLog::Instance()->Info + ("GetBattleData ok %s", + { + rsp_obj->ToJsonStr() + }); + if (rsp_obj->GetType() != a8::XOT_OBJECT || + !rsp_obj->HasKey("errcode")) { + //cb(1, "", nullptr); + return; + } + } else { + f8::UdpLog::Instance()->Warning + ("GetCustomBattleData error %s", + { + "" + }); + //cb(1, "custom battle data error", nullptr); + } + }, + url.c_str(), + *url_params + ); + } } diff --git a/server/gameserver/jsondatamgr.cc b/server/gameserver/jsondatamgr.cc index 6e66988f..ae79b378 100644 --- a/server/gameserver/jsondatamgr.cc +++ b/server/gameserver/jsondatamgr.cc @@ -55,6 +55,7 @@ void JsonDataMgr::Init() if (setting_json_.GetType() == a8::XOT_OBJECT && setting_json_.HasKey("api_url")) { api_url_ = setting_json_.Get("api_url").GetString(); + api_secret_key_ = setting_json_.Get("api_secret_key").GetString(); } ip = GetConf()->At("ip")->AsXValue().GetString(); diff --git a/server/gameserver/jsondatamgr.h b/server/gameserver/jsondatamgr.h index 4304e34d..6fe48cce 100644 --- a/server/gameserver/jsondatamgr.h +++ b/server/gameserver/jsondatamgr.h @@ -21,11 +21,13 @@ public: std::string server_info; void GetApiUrl(std::string& url); + std::string GetApiSecretKey() { return api_secret_key_; }; void GetHttpGetProxyUrl(std::string& url); void GetHttpPostProxyUrl(std::string& url); private: std::string api_url_; + std::string api_secret_key_; private: std::string work_path_ = "../config";