151 lines
4.6 KiB
PHP
151 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace services;
|
|
|
|
/*
|
|
数据结构:
|
|
{
|
|
"total_battle_times": 0,
|
|
"total_single_battle_times": 0,
|
|
"total_team_battle_times": 0,
|
|
"single_battle_rank": 0,
|
|
"team_battle_rank": 0,
|
|
"total_win_times": 0,
|
|
"total_kills_times": 0,
|
|
"max_kills_times": 0,
|
|
"total_damage_out":0,
|
|
"max_damage_out": 0,
|
|
"total_damage_in": 0,
|
|
"max_damage_in": 0,
|
|
"total_recover_hp": 0,
|
|
"max_recover_hp": 0,
|
|
"total_alive_time": 0,
|
|
"max_alive_time": 0,
|
|
"rescue_teammate_times": 0,
|
|
"diving_times": 0,
|
|
"open_airdrop_times": 0,
|
|
"use_medicine_times": 0,
|
|
"destory_car_times": 0,
|
|
"use_camouflage_times": 0,
|
|
"use_skill_times": 0,
|
|
"ride_car_move_distance": 0,
|
|
"ride_car_kills": 0,
|
|
"max_hero_skill_lv": 0,
|
|
"weapon_type_data": {
|
|
"${equip_type}_${equip_subtype}":
|
|
{
|
|
"kills": 1,
|
|
"damage_out": 1,
|
|
"obtain_count": 1,
|
|
}
|
|
},
|
|
"weapon_slot_data": {
|
|
"${slot}":
|
|
{
|
|
"use_times": 1,
|
|
}
|
|
},
|
|
"hero_data": {
|
|
"${hero_id}":
|
|
{
|
|
"skinll_lv": 1,
|
|
"weapon_lv": 1,
|
|
}
|
|
},
|
|
"createtime": 0,
|
|
"modifytime": 0,
|
|
}
|
|
涉及的表:
|
|
t_battle.data
|
|
t_season.data
|
|
{
|
|
"daily_data": {},
|
|
"weekly_data": {
|
|
1: {}
|
|
}
|
|
}
|
|
*/
|
|
|
|
class BattleDataService extends BaseService {
|
|
|
|
private $seasonDb = array();
|
|
private $hisBattleData = array();
|
|
|
|
public function updateBattleData()
|
|
{
|
|
|
|
}
|
|
|
|
private function apply(&$battleData)
|
|
{
|
|
$this->incValue($battleData, 'total_battle_times', 1);
|
|
if (getReqVal('team_mode', 0) == 0) {
|
|
$this->incValue($battleData, 'total_single_battle_times', 1);
|
|
$this->minValue($battleData, 'single_battle_rank', getReqVal('ranked', 0));
|
|
} else {
|
|
$this->minValue($battleData, 'team_battle_rank', getReqVal('ranked', 0));
|
|
$this->incValue($battleData, 'total_team_battle_times', 1);
|
|
}
|
|
if (getReqVal('ranked', 0) == 1) {
|
|
$this->incValue($battleData, 'total_win_times', 1);
|
|
}
|
|
$kills = getReqVal('kills', 0);
|
|
if ($kills > 0) {
|
|
$this->incValue($battleData, 'total_kills_times', $kills);
|
|
$this->maxValue($battleData, 'max_kills_times', $kills);
|
|
}
|
|
$damageOut = getReqVal('damage_out', 0);
|
|
if ($damageOut > 0) {
|
|
$this->incValue($battleData, 'total_damage_out', $damageOut);
|
|
$this->maxValue($battleData, 'max_damage_out', $damageOut);
|
|
}
|
|
$damageIn = getReqVal('damage_in', 0);
|
|
if ($damageIn > 0) {
|
|
$this->incValue($battleData, 'total_damage_in', $damageIn);
|
|
$this->maxValue($battleData, 'max_damage_in', $damageIn);
|
|
}
|
|
$recoverHp = getReqVal('recover_hp', 0);
|
|
if ($recoverHp > 0) {
|
|
$this->incValue($battleData, 'total_recover_hp', $recoverHp);
|
|
$this->maxValue($battleData, 'max_recover_hp', $recoverHp);
|
|
}
|
|
$aliveTime = getReqVal('alive_time', 0);
|
|
if ($aliveTime > 0) {
|
|
$this->incValue($battleData, 'total_alive_time', $aliveTime);
|
|
$this->maxValue($battleData, 'max_alive_time', $aliveTime);
|
|
}
|
|
$this->incValue($battleData, 'rescue_teammate_times', getReqVal('rescue_teammate_times', 0));
|
|
$this->incValue($battleData, 'diving_times', getReqVal('diving_times', 0));
|
|
$this->incValue($battleData, 'open_airdrop_times', getReqVal('open_airdrop_times', 0));
|
|
$this->incValue($battleData, 'use_medicine_times', getReqVal('use_medicine_times', 0));
|
|
$this->incValue($battleData, 'destory_car_times', getReqVal('destory_car_times', 0));
|
|
$this->incValue($battleData, 'use_camouflage_times', getReqVal('use_camouflage_times', 0));
|
|
$this->incValue($battleData, 'use_skill_times', getReqVal('use_skill_times', 0));
|
|
$this->incValue($battleData, 'ride_car_move_distance', getReqVal('ride_car_move_distance', 0));
|
|
$this->incValue($battleData, 'ride_car_kills', getReqVal('ride_car_kills', 0));
|
|
$this->maxValue($battleData, 'max_single_battle_hero_lv', getReqVal('max_single_battle_hero_lv', 0));
|
|
if (!isset($battleData['createtime'])) {
|
|
$battleData['createtime'] = myself()->_getNowTime();
|
|
}
|
|
$battleData['modifytime'] = myself()->_getNowTime();
|
|
}
|
|
|
|
private function incValue(&$battleData, $key, $val)
|
|
{
|
|
if ($val > 0) {
|
|
$battleData[$key] = getXVal($battleData, $key, 0) + $val;
|
|
}
|
|
}
|
|
|
|
private function minValue(&$battleData, $key, $val)
|
|
{
|
|
$battleData[$key] = min(getXVal($battleData, $key, 0), $val);
|
|
}
|
|
|
|
private function maxValue(&$battleData, $key, $val)
|
|
{
|
|
$battleData[$key] = max(getXVal($battleData, $key, 0), $val);
|
|
}
|
|
|
|
}
|