diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 9f657746..0ddc35c1 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -693,6 +693,8 @@ CREATE TABLE `t_battle_history` ( `team_mode` int(11) NOT NULL DEFAULT '0' COMMENT '队伍模式 0:单人 1:组队', `battle_rank` int(11) NOT NULL DEFAULT '0' COMMENT '战斗排名', `team_rank` int(11) NOT NULL DEFAULT '0' COMMENT '团队排名', + `team_kills` int(11) NOT NULL DEFAULT '0' COMMENT '团队击杀数', + `gold` int(11) NOT NULL DEFAULT '0' COMMENT 'gold获得数', `is_win` int(11) NOT NULL DEFAULT '0' COMMENT 'pve冒险是否胜利', `kills` int(11) NOT NULL DEFAULT '0' COMMENT '击杀数', `hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄 id', diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 1945f021..f5a83dff 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -41,6 +41,7 @@ define('TN_DAILY_END', 9011); define('TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM', 9012); define('TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM', 9013); define('TN_DAILY_COMPLETE_TASK_NUM', 9014); +define('TN_DAILY_USED_GOLD_NUM', 9015); define('TN_WEEKLY_BEGIN', 10001); define('TN_WEEKLY_ACTIVE', 10002); diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 3fad6430..e99f64be 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -307,6 +307,7 @@ class BaseAuthedController extends BaseController { return "consume_gold + ${itemNum}"; } )); + $this->_incDailyV(TN_DAILY_USED_GOLD_NUM, 0, $itemNum); } break; case V_ITEM_DIAMOND: diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 9b2a0b69..27bc1984 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -112,8 +112,12 @@ class BattleController extends BaseAuthedController { $this->_rspData($data); } public function test(){ - $a = myself()->_getDailyV(TN_DAILY_ACTIVE, 0); - print_r($a); +// echo "当前时间=>" . time() . '|' . date('Y-m-d H:i:s',time()) ; +// echo "当天时间=>" . $this->_getDaySeconds(time()) . '|' . date('Y-m-d H:i:s',$this->_getDaySeconds(time())); +// echo "下一天时间=>" . ($this->_getDaySeconds(time())+3600*24) . '|' . date('Y-m-d H:i:s',$this->_getDaySeconds(time())+3600*24); +// echo "当周时间=>" . $this->_getMondaySeconds() . '|' . date('Y-m-d H:i:s',$this->_getMondaySeconds()); +// echo "下周时间=>" . ($this->_getMondaySeconds() + 7*24*3600) . '|' . date('Y-m-d H:i:s',$this->_getMondaySeconds() + 7*24*3600); + echo $this->_getDailyV(TN_DAILY_ACTIVE, 0); } /* @@ -224,7 +228,7 @@ class BattleController extends BaseAuthedController { } } } - array_push($data['members'], $info);error_log("PresetInfo---".json_encode($data)); + array_push($data['members'], $info); myself()->_rspData($data); } diff --git a/webapp/controller/MissionController.class.php b/webapp/controller/MissionController.class.php index e411b115..ec9558ba 100644 --- a/webapp/controller/MissionController.class.php +++ b/webapp/controller/MissionController.class.php @@ -102,8 +102,8 @@ class MissionController extends BaseAuthedController { // $specMissionDto['state'] = 9636; // } $this->_rspData(array( - 'current_day_active_value' => min($this->_getV(TN_DAILY_ACTIVE, 0), mt\Parameter::getVal('activeness_limit', 0)), - 'current_week_active_value' => min($this->_getV(TN_WEEKLY_ACTIVE, 0), mt\Parameter::getVal('max_weekly', 0)), + 'current_day_active_value' => min($this->_getDailyV(TN_DAILY_ACTIVE, 0), mt\Parameter::getVal('activeness_limit', 0)), + 'current_week_active_value' => min($this->_getWeeklyV(TN_WEEKLY_ACTIVE, 0), mt\Parameter::getVal('max_weekly', 0)), 'day_active_limit' => mt\Parameter::getVal('activeness_limit', 0), 'week_active_limit' => mt\Parameter::getVal('max_weekly', 0), 'mission_list1' => $missionDtoList1, diff --git a/webapp/models/BattleHistory.php b/webapp/models/BattleHistory.php index ec4de40e..bde219e6 100644 --- a/webapp/models/BattleHistory.php +++ b/webapp/models/BattleHistory.php @@ -99,4 +99,27 @@ class BattleHistory extends BaseModel return $data; } + public static function findByAccount($account,$battleUid){ + return SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_battle_history', + array( + 'account_id' => $account, + 'battle_uniid' => $battleUid, + ) + ); + } + + public static function updateField($account,$battleUid,$field){ + return SqlHelper::update( + myself()->_getSelfMysql(), + 't_battle_history', + array( + 'account_id' => $account, + 'battle_uniid' => $battleUid, + ), + $field + ); + } + } \ No newline at end of file diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index e81cf290..458694d9 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -450,9 +450,9 @@ class Hero extends BaseModel { public static function gainGoldPvp($heroDto, $addGold) { - $newGold = min($heroDto['pvp_ceg_uplimit'], - $heroDto['current_pvp_get_ceg'] + $addGold); - $finalyAddGold = max(0, $newGold - $heroDto['current_pvp_get_ceg']); + $newGold = min($heroDto['gold_uplimit'], + $heroDto['current_get_gold'] + $addGold); + $finalyAddGold = max(0, $newGold - $heroDto['current_get_gold']); if ($finalyAddGold > 0) { self::update($heroDto['hero_uniid'], array( diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 7d61743e..6fc5e899 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -68,6 +68,7 @@ class BattleDataService extends BaseService { public $teamList = array(); private $seasonDb = array(); + private $userinfo = array(); private $heroDto = null; private $heroMeta = null; private $weapon1Dto = null; @@ -82,8 +83,8 @@ class BattleDataService extends BaseService { 'curr_ceg' => 0, ), 'total_ceg' => 0, + 'is_settlement' => 0, 'items' => array(), - 'lvInfo' => array() ); private $rankActivityService = null; private $pveGeminiMeta = null; @@ -101,6 +102,12 @@ class BattleDataService extends BaseService { error_log(json_encode($_REQUEST)); $matchMode = getReqVal('match_mode', 0); { + $userDb = User::find(getReqVal('account_id', 0)); + if(!$userDb){ + return false; + } + $this->userinfo = User::toSimple($userDb); + $heroDb = Hero::find(getReqVal('hero_uniid', 0)); if (!$heroDb) { return false; @@ -114,8 +121,7 @@ class BattleDataService extends BaseService { return false; } $this->reward['hero']['hero_uniid'] = $this->heroDto['hero_uniid']; - $this->reward['hero']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ? - $this->heroDto['pve_ceg_uplimit'] : $this->heroDto['pvp_ceg_uplimit']; + $this->reward['hero']['ceg_uplimit'] = $this->heroDto['gold_uplimit']; } @@ -127,7 +133,7 @@ class BattleDataService extends BaseService { { //匹配赛模式 $this->updatePvpData(); - $this->rewardCegPvp(); +// $this->rewardCegPvp(); myself()->_incDailyV(TN_DAILY_PVP_BATTLE_TIMES, 0, 1); } break; @@ -196,13 +202,19 @@ class BattleDataService extends BaseService { } $match_mode = 1; } + $gold = 0; + if (getReqVal('is_team_statemented', 0) == 1){ + $gold = FormulaService::calcHeroPvpGold($this->heroDto, $_REQUEST,$user); + } $data = array( "battle_uniid" => getReqVal('battle_uuid', 0), "account_id" => myself()->_getAccountId(), "match_mode" => $match_mode, "team_mode" => getReqVal('team_mode', 0), "battle_rank" => getReqVal('ranked', 0), -// "team_rank" => 0, // 队伍排名 + "team_rank" => getReqVal('team_rank', 0), // 队伍排名 + "team_kills" => getReqVal('team_kills', 0), // 队伍击杀数 + "gold" => $gold, // 队伍击杀数 "is_win" => getReqVal('pve_kill_boss', 0), "kills" => getReqVal('kills', 0), "hero_id" => getReqVal('hero_uniid', 0), @@ -559,6 +571,38 @@ class BattleDataService extends BaseService { return $winningPro; } + private function _settlementMyTeamGold(){ + $team_id = getReqVal('team_id', 0); + $battleUid = getReqVal('battle_uuid', 0); + $myTeam = array(); + foreach ($this->teamList as $team){ + if ($team['team_id'] == $team_id){ + $myTeam = $team['members']; + } + } + foreach ($myTeam as $member){ + if (!empty($member['account_id'])){ + $user = User::find($member['account_id']); + if ($member['account_id'] != myself()->_getAccountId()){ + $battleDb = BattleHistory::findByAccount($member['account_id'],$battleUid); + if ($battleDb){ + $heroDto = Hero::toDto(Hero::find($battleDb['hero_id'])); + $heroPvpGold = FormulaService::calcHeroPvpGold($heroDto, $_REQUEST,$user); + $heroPvpGold = Hero::gainGoldPvp($heroDto, $heroPvpGold); + BattleHistory::updateField($member['account_id'],$battleUid, + array( + 'gold' => $heroPvpGold, + 'team_rank' => getReqVal('team_rank', 0), + 'team_kills' => getReqVal('team_kills', 0), + )); + //给该用户 add gold + + } + } + } + } + } + private function rewardGold($heroDto) { $heroMeta = mt\Item::get($heroDto['hero_id']); @@ -925,6 +969,46 @@ class BattleDataService extends BaseService { } + private function rewardGoldPvp() + { + $this->_settlementMyTeamGold(); + $heroPvpGold = FormulaService::calcHeroPvpGold($this->heroDto, $_REQUEST,$this->userinfo); + error_log(json_encode(array( + 'heroPvpGold' => $heroPvpGold, + ))); + if ($heroPvpGold > 0) { + $heroPvpGold = Hero::gainGoldPvp($this->heroDto, $heroPvpGold); + { + //埋点 + $log_param = [ + 'battle_uniid' => getReqVal('battle_uniid', 0), + 'match_mode' => getReqVal('match_mode', 0), + 'room_uuid' => getReqVal('room_uuid', 0), + ]; + $event = [ + 'name' => LogService::BATTLE_AWARD_PVP, + 'val' => $heroPvpGold + ]; + LogService::productCEG($event,$this->heroDto,$log_param); + } + + $this->reward['hero']['curr_gold'] = '' . ($this->heroDto['current_get_gold'] + $heroPvpGold); + $this->reward['hero']['obtain_gold'] = '' . ($this->heroDto['current_get_gold'] + $heroPvpGold); + $this->reward['total_gold'] += $heroPvpGold; + } + + $this->reward['total_gold'] .= ''; + error_log(json_encode(array( + 'new_heroPvpGold' => $heroPvpGold, + ))); + $gold = $heroPvpGold; + error_log('updateBattleData1'); + $this->rankActivityService->updateBattleData($gold); + if ($gold > 0) { + myself()->_addVirtualItem(V_ITEM_GOLD, $gold); + } + } + private function rewardCegPvp() { { @@ -958,8 +1042,8 @@ class BattleDataService extends BaseService { LogService::productCEG($event,$this->heroDto,$log_param); } - $this->reward['hero']['curr_ceg'] = '' . ($this->heroDto['current_pvp_get_ceg'] + $heroPvpCeg); - $this->reward['hero']['obtain_ceg'] = '' . ($this->heroDto['current_pvp_get_ceg'] + $heroPvpCeg); + $this->reward['hero']['curr_ceg'] = '' . ($this->heroDto['current_get_gold'] + $heroPvpCeg); + $this->reward['hero']['obtain_ceg'] = '' . ($this->heroDto['current_get_gold'] + $heroPvpCeg); $this->reward['total_ceg'] += $heroPvpCeg; } @@ -975,66 +1059,6 @@ class BattleDataService extends BaseService { } } - private function _addNftActive($nftDb,$type){ - if (!$nftDb){ - return ; - } - switch ($type){ - case Nft::HERO_TYPE: - { - $data = array( - 'uniid' => $nftDb['hero_uniid'], - 'token_id' => $nftDb['token_id'], - 'token_type' => Nft::HERO_TYPE, - ); - NftActive::upsert($data); - if ($nftDb['chip_ids']){ - $chip_ids = explode("|",$nftDb['chip_ids']); - if (count($chip_ids)>0){ - foreach ($chip_ids as $chip_id){ - $chipDb = Chip::getChipByIdx($chip_id); - self::_addNftActive($chipDb,Nft::CHIP_TYPE); - } - } - } - } - break; - case Nft::EQUIP_TYPE: - { - $data = array( - 'uniid' => $nftDb['gun_uniid'], - 'token_id' => $nftDb['token_id'], - 'token_type' => Nft::EQUIP_TYPE, - ); - NftActive::upsert($data); - if ($nftDb['chip_ids']){ - $chip_ids = explode("|",$nftDb['chip_ids']); - if (count($chip_ids)>0){ - foreach ($chip_ids as $chip_id){ - $chipDb = Chip::getChipByIdx($chip_id); - self::_addNftActive($chipDb,Nft::CHIP_TYPE); - } - } - } - } - break; - case Nft::CHIP_TYPE: - { - $data = array( - 'uniid' => $nftDb['idx'], - 'token_id' => $nftDb['token_id'], - 'token_type' => Nft::CHIP_TYPE, - ); - NftActive::upsert($data); - } - break; - default: - { - - } - } - } - private function rewardCegPve() { $log_param = [ diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index fc25f7d3..44283641 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -17,11 +17,18 @@ use mt; class FormulaService extends BaseService { - public static function calcHeroPvpGold($heroDto, $params) + public static function calcHeroPvpGold($heroDto, $params,$user) { -// GOLD = Min(英雄每天gold上限*10%,标准值) * (f(队伍排名) + g(队伍击杀数)) // f(队伍排名) = round(1-(队伍排名-1)/10 ,1) + $teamRank = getXVal($params, 'team_rank'); + $f = round(1-($teamRank-1)/10,1); // g(队伍击杀数)= Min(队伍击杀数*0.1 ,2) + $teamKills = getXVal($params, 'team_kills'); + $g = min($teamKills*0.1,2); +// GOLD = Min(英雄每天gold上限*10%,标准值) * (f(队伍排名) + g(队伍击杀数)) + $rank = $user['rank']?$user['rank']:1; + $rankMeta = mt\Rank::getRankById($rank); + return min($heroDto['gold_uplimit']*0.1,$rankMeta['gold_base']) * ($f+$g); } public static function calcHeroPvpCeg($heroDto, $params) diff --git a/webapp/services/MissionService.php b/webapp/services/MissionService.php index 09b47e6a..5f6b8cb5 100644 --- a/webapp/services/MissionService.php +++ b/webapp/services/MissionService.php @@ -332,7 +332,7 @@ class MissionService extends BaseService { case mt\Task::CONSUME_GOLD_COND: { //消耗X个金币 - $missionDto['current'] = $this->userInfo['consume_gold']; + $missionDto['current'] = myself()->_getDailyV(TN_DAILY_USED_GOLD_NUM, 0);; } break; case mt\Task::BATTLE_RANK_COND: