1
This commit is contained in:
parent
1db06a84a1
commit
6ec964885f
@ -40,8 +40,151 @@
|
|||||||
const int kReviveTimeAdd = 12;
|
const int kReviveTimeAdd = 12;
|
||||||
const int kSkinNum = 4;
|
const int kSkinNum = 4;
|
||||||
|
|
||||||
void PlayerStats::Statement(Human* hum)
|
void PlayerStats::Statement(Human* sender)
|
||||||
{
|
{
|
||||||
|
auto topxFunc =
|
||||||
|
[sender] (std::function<int (Human*, Human*)> cmpFunc) -> double
|
||||||
|
{
|
||||||
|
std::vector<std::vector<Human*>> rank_list;
|
||||||
|
sender->room->TraverseHumanList
|
||||||
|
(a8::XParams(),
|
||||||
|
[cmpFunc, &rank_list] (Human* hum, a8::XParams& param) -> bool
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for (auto& list : rank_list) {
|
||||||
|
if (cmpFunc(list[0], hum) == 0) {
|
||||||
|
list.push_back(hum);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
rank_list.push_back(std::vector<Human*>({hum}));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
std::sort
|
||||||
|
(rank_list.begin(), rank_list.end(),
|
||||||
|
[cmpFunc] (std::vector<Human*>& a, std::vector<Human*>& b )
|
||||||
|
{
|
||||||
|
return cmpFunc(a[0], b[0]) > 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
int rank = rank_list.size();
|
||||||
|
for (int i = 0; i < rank_list.size(); ++i){
|
||||||
|
bool found = false;
|
||||||
|
for (Human* hum : rank_list[i]) {
|
||||||
|
if (hum == sender){
|
||||||
|
rank = i + 1;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double topx = (double)rank / rank_list.size();
|
||||||
|
return topx;
|
||||||
|
};
|
||||||
|
|
||||||
|
sender->stats.ranked_topx = (double)sender->stats.rank / sender->room->GetHumanNum();
|
||||||
|
sender->stats.kills_topx = topxFunc
|
||||||
|
(
|
||||||
|
[] (Human* a, Human* b) -> int
|
||||||
|
{
|
||||||
|
if (a->stats.kills == b->stats.kills) {
|
||||||
|
return 0;
|
||||||
|
} else if (a->stats.kills > b->stats.kills) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
sender->stats.hero_topx = topxFunc
|
||||||
|
(
|
||||||
|
[] (Human* a, Human* b) -> int
|
||||||
|
{
|
||||||
|
long long a_value = 0;
|
||||||
|
long long b_value = 0;
|
||||||
|
if (a->GetBattleContext()) {
|
||||||
|
int hero_lv = 0;
|
||||||
|
int quality = 0;
|
||||||
|
a->GetBattleContext()->GetHeroLvQualit(hero_lv, quality);
|
||||||
|
a_value = hero_lv + quality;
|
||||||
|
}
|
||||||
|
if (b->GetBattleContext()) {
|
||||||
|
int hero_lv = 0;
|
||||||
|
int quality = 0;
|
||||||
|
b->GetBattleContext()->GetHeroLvQualit(hero_lv, quality);
|
||||||
|
b_value = hero_lv + quality;
|
||||||
|
}
|
||||||
|
if (a_value == b_value) {
|
||||||
|
return 0;
|
||||||
|
} else if (a_value > b_value) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
sender->stats.weapon_topx = topxFunc
|
||||||
|
(
|
||||||
|
[] (Human* a, Human* b) -> int
|
||||||
|
{
|
||||||
|
long long a_value = 0;
|
||||||
|
long long b_value = 0;
|
||||||
|
if (a->GetBattleContext()) {
|
||||||
|
int weapon_lv = 0;
|
||||||
|
int quality = 0;
|
||||||
|
a->GetBattleContext()->GetWeaponLvQualit(weapon_lv, quality);
|
||||||
|
a_value = weapon_lv + quality;
|
||||||
|
}
|
||||||
|
if (b->GetBattleContext()) {
|
||||||
|
int weapon_lv = 0;
|
||||||
|
int quality = 0;
|
||||||
|
b->GetBattleContext()->GetWeaponLvQualit(weapon_lv, quality);
|
||||||
|
b_value = weapon_lv + quality;
|
||||||
|
}
|
||||||
|
if (a_value == b_value) {
|
||||||
|
return 0;
|
||||||
|
} else if (a_value > b_value) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
sender->stats.survival_topx = topxFunc
|
||||||
|
(
|
||||||
|
[] (Human* a, Human* b) -> int
|
||||||
|
{
|
||||||
|
if (a->dead && b->dead) {
|
||||||
|
if (a->dead_frameno == b->dead_frameno) {
|
||||||
|
return 0;
|
||||||
|
} else if (a->dead_frameno > b->dead_frameno) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!(a->dead && b->dead)) {
|
||||||
|
if (a->GetUniId() > b->GetUniId()) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!a->dead) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
statemented = 1;
|
statemented = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,3 +138,27 @@ void BattleDataContext::ApplyAttr(std::array<float, kHAT_End>& attr_abs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BattleDataContext::GetHeroLvQualit(int& hero_lv, int& quality)
|
||||||
|
{
|
||||||
|
hero_lv = 0;
|
||||||
|
quality = 0;
|
||||||
|
if (hero_uniid_) {
|
||||||
|
hero_lv = hero_dto->Get("hero_lv", 0).GetInt();
|
||||||
|
quality = hero_dto->Get("quality", 0).GetInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BattleDataContext::GetWeaponLvQualit(int& weapon_lv, int& quality)
|
||||||
|
{
|
||||||
|
weapon_lv = 0;
|
||||||
|
quality = 0;
|
||||||
|
if (weapon_uniid1_) {
|
||||||
|
weapon_lv += weapon_dto1->Get("gun_lv", 0).GetInt();
|
||||||
|
quality += weapon_dto1->Get("quality", 0).GetInt();
|
||||||
|
}
|
||||||
|
if (weapon_uniid2_) {
|
||||||
|
weapon_lv += weapon_dto2->Get("gun_lv", 0).GetInt();
|
||||||
|
quality += weapon_dto2->Get("quality", 0).GetInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -36,6 +36,9 @@ struct BattleDataContext
|
|||||||
float GetHeroAttrAbs(long long hero_uniid, int attr_id);
|
float GetHeroAttrAbs(long long hero_uniid, int attr_id);
|
||||||
float GetHeroAttrRate(long long hero_uniid, int attr_id);
|
float GetHeroAttrRate(long long hero_uniid, int attr_id);
|
||||||
|
|
||||||
|
void GetHeroLvQualit(int& hero_lv, int& quality);
|
||||||
|
void GetWeaponLvQualit(int& weapon_lv, int& quality);
|
||||||
|
|
||||||
float GetWeaponAttrAbs(long long weapon_uniid, int attr_id);
|
float GetWeaponAttrAbs(long long weapon_uniid, int attr_id);
|
||||||
float GetWeaponAttrRate(long long weapon_uniid, int attr_id);
|
float GetWeaponAttrRate(long long weapon_uniid, int attr_id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user