This commit is contained in:
aozhiwei 2024-07-30 16:42:52 +08:00
parent b586ab8ec9
commit f9cc27e85c
2 changed files with 28 additions and 36 deletions

View File

@ -2,6 +2,7 @@
#include <a8/mutable_xobject.h>
#include <f8/app.h>
#include <f8/udplog.h>
#include "boxdrop.h"
@ -22,19 +23,6 @@ BoxDrop::BoxDrop(Room* room):room_(room)
void BoxDrop::Init()
{
if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) {
get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx
(SERVER_FRAME_RATE * 10,
[this] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
if (!room_->IsGameOver() && !room_->GetVictoryTeam()) {
RequestBoxNum();
}
}
},
&room_->xtimer_attacher_);
}
}
void BoxDrop::UnInit()
@ -66,34 +54,30 @@ void BoxDrop::Drop(int num, const glm::vec3& center)
void BoxDrop::OnBattleStart()
{
if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) {
get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx
(SERVER_FRAME_RATE * 10,
[this] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
if (!room_->IsGameOver() && !room_->GetVictoryTeam()) {
RequestAllocBoxNum();
}
}
},
&room_->xtimer_attacher_);
}
}
void BoxDrop::RequestBoxNum()
void BoxDrop::RequestAllocBoxNum()
{
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();
}*/
int nowtime = f8::App::Instance()->GetNowTime();
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());
url_params->SetVal("c", "Battle");
url_params->SetVal("a", "requestBoxNum");
url_params->SetVal("timestamp", a8::XValue(nowtime));
HttpProxy::Instance()->HttpGet
(
[]
@ -123,3 +107,8 @@ void BoxDrop::RequestBoxNum()
*url_params
);
}
void BoxDrop::RequestReturnBoxNum()
{
}

View File

@ -14,14 +14,17 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
void OnBattleStart();
void OnHeroDeadDrop(Hero* hero);
void OnObstacleDeadDrop(Obstacle* ob);
void RequestReturnBoxNum();
private:
void Drop(int num, const glm::vec3& center);
void RequestBoxNum();
void RequestAllocBoxNum();
private:
Room* room_ = nullptr;
a8::XTimerWp get_box_num_timer_;
int box_num_ = 0;
int alloc_box_num_ = 0;
bool returned_ = false;
};