This commit is contained in:
aozhiwei 2024-07-30 15:59:36 +08:00
parent d4beb8537a
commit b586ab8ec9
2 changed files with 63 additions and 0 deletions

View File

@ -1,9 +1,15 @@
#include "precompile.h"
#include <a8/mutable_xobject.h>
#include <f8/udplog.h>
#include "boxdrop.h"
#include "room.h"
#include "hero.h"
#include "obstacle.h"
#include "httpproxy.h"
#include "jsondatamgr.h"
#include "mt/MapMode.h"
@ -23,6 +29,7 @@ void BoxDrop::Init()
{
if (a8::TIMER_EXEC_EVENT == event) {
if (!room_->IsGameOver() && !room_->GetVictoryTeam()) {
RequestBoxNum();
}
}
},
@ -61,3 +68,58 @@ void BoxDrop::OnBattleStart()
{
}
void BoxDrop::RequestBoxNum()
{
std::string url;
JsonDataMgr::Instance()->GetApiUrl(url);
/*
if (custom_room_type == CUSTOM_ROOM_CUSTOM) {
if (url.find('?') != std::string::npos) {
url += "&c=Battle&a=getCustomBattleDataNew";
} else {
url += "?&c=Battle&a=getCustomBattleDataNew";
}
} else if (custom_room_type == CUSTOM_ROOM_NORMAL) {
if (url.find('?') != std::string::npos) {
url += "&c=Battle&a=getNormalBattleData";
} else {
url += "?&c=Battle&a=getNormalBattleData";
}
} else {
A8_ABORT();
}*/
auto url_params = a8::MutableXObject::CreateObject();
//url_params->SetVal("account_id", join_msg->account_id());
//url_params->SetVal("session_id", join_msg->session_id());
url_params->SetVal("version", 1);
//url_params->SetVal("__POST", join_msg->payload_data());
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
);
}

View File

@ -18,6 +18,7 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
private:
void Drop(int num, const glm::vec3& center);
void RequestBoxNum();
private:
Room* room_ = nullptr;