From 0b854bbdf53ed22789ffa072f5ec1f83ceab1f05 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Sat, 8 Oct 2022 20:19:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=88=98=E6=96=97=E5=8E=86?= =?UTF-8?q?=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/gamedb.sql | 32 +++++++++++++++++++++++++++ webapp/models/BattleHistory.php | 31 ++++++++++++++++++++++++++ webapp/services/BattleDataService.php | 30 +++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 webapp/models/BattleHistory.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index a68c5015..396c3b11 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -641,4 +641,36 @@ CREATE TABLE `t_realtime_data` ( ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_battle_history` +-- + +DROP TABLE IF EXISTS `t_battle_history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_battle_history` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `battle_uniid` varchar(60) NOT NULL DEFAULT '' COMMENT '战斗记录唯一id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '用户 account_id', + `match_mode` int(11) NOT NULL DEFAULT '0' COMMENT '0: 匹配 pvp 1: 排位赛 2: pve', + `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 '团队排名', + `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', + `weapon1` int(11) NOT NULL DEFAULT '0' COMMENT '枪械1 id', + `weapon2` int(11) NOT NULL DEFAULT '0' COMMENT '枪械2 id', + `battle_end_time` int(11) NOT NULL DEFAULT '0' COMMENT '战斗结束时间', + `current_level_class` varchar(60) NOT NULL DEFAULT '0' COMMENT '当前用户段位', + `current_level_class_score` int(11) NOT NULL DEFAULT '0' COMMENT '当前用户排位分', + `level_class_score_chg` int(11) NOT NULL DEFAULT '0' COMMENT '排位分改变', + `pve_rank_score` int(11) NOT NULL DEFAULT '0' COMMENT 'pve冒险积分', + `pve_kill_boss` int(11) NOT NULL DEFAULT '0' COMMENT 'pve冒险是否击杀BOSS', + `battle_foreign_key` int(11) NOT NULL DEFAULT '0' COMMENT '结算外键', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_id_battle_uniid` (`account_id`, `battle_uniid`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + -- Dump completed on 2015-08-19 18:51:22 diff --git a/webapp/models/BattleHistory.php b/webapp/models/BattleHistory.php new file mode 100644 index 00000000..a009fc65 --- /dev/null +++ b/webapp/models/BattleHistory.php @@ -0,0 +1,31 @@ +_getSelfMysql(), + 't_battle_history', + $data + ); + } + + public static function getMyBattleHistory() + { + $row = SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_battle_history', + array( + 'account_id' => myself()->_getAccountId(), + ) + ); + return $row; + } + +} \ No newline at end of file diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index cb275452..bca0cdef 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -22,6 +22,7 @@ require_once('models/Hero.php'); require_once('models/Gun.php'); require_once('models/FragmentPool.php'); require_once('models/RealtimeData.php'); +require_once('models/BattleHistory.php'); require_once('services/RankActivityService.php'); require_once('services/FormulaService.php'); @@ -29,6 +30,7 @@ require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); require_once('services/LogService.php'); + use mt; use services; use phpcommon\SqlHelper; @@ -39,6 +41,7 @@ use models\Hero; use models\Gun; use models\RealtimeData; use models\FragmentPool; +use models\BattleHistory; use services\FormulaService; use services\LogService; @@ -133,6 +136,9 @@ class BattleDataService extends BaseService { $this->weapon2Dto['pve_ceg_uplimit'] : $this->weapon2Dto['pvp_ceg_uplimit']; } } + //录入战斗记录 + $this->saveBattleHistory(); + switch ($matchMode) { case self::MATCH_MODE_PVP: { @@ -167,6 +173,30 @@ class BattleDataService extends BaseService { } } + private function saveBattleHistory(){ + $user = myself()->_getOrmUserInfo(); + $data = array( + "battle_uniid" => getReqVal('battle_uniid', 0), + "account_id" => myself()->_getAccountId(), + "match_mode" => getReqVal('match_mode', 0), + "team_mode" => getReqVal('team_mode', 0), + "battle_rank" => getReqVal('ranked', 0), +// "team_rank" => 0, // 队伍排名 + "is_win" => getReqVal('pve_kill_boss', 0), + "kills" => getReqVal('kills', 0), + "hero_id" => getReqVal('hero_uniid', 0), + "weapon1" => getReqVal('weapon_uuid1', 0), + "weapon2" => getReqVal('weapon_uuid2', 0), + "battle_end_time" => myself()->_getNowTime(), + "current_level_class" => $user['rank'], + "current_level_class_score" => $user['score'], +// "level_class_score_chg" => 0, // 排位分改变 + "pve_rank_score" => getReqVal('pve_rank_score', 0), + "pve_kill_boss" => getReqVal('pve_kill_boss', 0), + ); + BattleHistory::add($data); + } + public function getReward() { return $this->reward;