Compare commits

...

11 Commits
dev ... master

Author SHA1 Message Date
aozhiwei
9bf025c219 1 2021-12-30 15:41:31 +08:00
azw
5ffa3dc400 1 2021-12-24 14:49:15 +08:00
azw
a37bcd8ac6 1 2021-12-24 14:47:20 +08:00
aozhiwei
9432aa8235 修复英雄体力问题 2021-12-23 15:17:07 +08:00
aozhiwei
a9da94e47c 1 2021-12-23 10:44:09 +08:00
aozhiwei
862639ce6e 添加任务活跃 2021-12-23 10:27:15 +08:00
aozhiwei
3c825b7034 1 2021-12-22 10:42:24 +08:00
aozhiwei
94e1621905 1 2021-12-20 17:18:12 +08:00
aozhiwei
d4f1ab0c9b 1 2021-12-20 17:17:58 +08:00
aozhiwei
2f0cf183ff 1 2021-12-20 13:41:34 +08:00
aozhiwei
c5486b4c1b 1 2021-12-20 12:12:15 +08:00
14 changed files with 231 additions and 48 deletions

View File

@ -6,6 +6,20 @@ class Battle(object):
def __init__(self): def __init__(self):
self.apis = [ self.apis = [
{
'method': 'POST',
'name': 'preBattleCheck',
'desc': '战前检查把CMJoin协议打包成json格式放到http body里参考gamelog处理方式(在发CMJoin之前发如果errcode!=0则提示错误并且不再发CMJoin相当于进入失败)',
'group': 'Battle',
'url': 'webapp/index.php?c=Battle&a=preBattleCheck',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['pre_battle_payload', '', '透传给战斗的CMJoin.pre_battle_payload(该信息里携带了战斗服需要校验的信息,防止客户端伪造数据)']
]
},
] ]
self.internalApis = [ self.internalApis = [
{ {
@ -17,6 +31,8 @@ class Battle(object):
['map_id', 0, '地图id'], ['map_id', 0, '地图id'],
['map_tpl_name', '', '地图模板名'], ['map_tpl_name', '', '地图模板名'],
['room_uuid', 0, '房间唯一id'], ['room_uuid', 0, '房间唯一id'],
['room_mode', 0, '房间模式 0:吃鸡模式 1:匹配赛模式'],
['hero_id', 0, '英雄id'],
['map_name', '', '地图名'], ['map_name', '', '地图名'],
['team_mode', 0, '队伍模式 0:单人 1组队'], ['team_mode', 0, '队伍模式 0:单人 1组队'],
['game_time', 0, '游戏时间'], ['game_time', 0, '游戏时间'],
@ -42,7 +58,7 @@ class Battle(object):
['rank_score', 0, '排位积分'], ['rank_score', 0, '排位积分'],
#['pass_score', 0, '通行证积分'], #['pass_score', 0, '通行证积分'],
['items', 0, '道具|分割'], ['items', 0, '道具id:道具数量|'],
], ],
'response': [ 'response': [
_common.RspHead(), _common.RspHead(),

View File

@ -3,7 +3,7 @@
class ReqHead(object): class ReqHead(object):
def __init__(self): def __init__(self):
self.params = [ self.fields = [
['account_id', '', '账号id'], ['account_id', '', '账号id'],
['session_id', '', '会话id'], ['session_id', '', '会话id'],
] ]
@ -101,6 +101,7 @@ class Hero(object):
self.fields = [ self.fields = [
['hero_id', 0, '英雄id'], ['hero_id', 0, '英雄id'],
['hero_lv', 0, '英雄等级'], ['hero_lv', 0, '英雄等级'],
['hero_tili', 0, '英雄体力'],
['skin_id', 0, '英雄皮肤id'], ['skin_id', 0, '英雄皮肤id'],
['skill_lv1', 0, '必杀技等级'], ['skill_lv1', 0, '必杀技等级'],
['skill_lv2', 0, '躲避技能等级'], ['skill_lv2', 0, '躲避技能等级'],

View File

@ -68,6 +68,7 @@ CREATE TABLE `t_hero` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id', `account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
`hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id', `hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id',
`hero_tili` int(11) NOT NULL DEFAULT '0' COMMENT '英雄体力',
`skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '皮肤id', `skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '皮肤id',
`hero_lv` int(11) NOT NULL DEFAULT '0' COMMENT '英雄等级', `hero_lv` int(11) NOT NULL DEFAULT '0' COMMENT '英雄等级',
`hero_exp` int(11) NOT NULL DEFAULT '0' COMMENT '英雄等级', `hero_exp` int(11) NOT NULL DEFAULT '0' COMMENT '英雄等级',
@ -237,6 +238,7 @@ CREATE TABLE `t_battle` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
`battle_data` mediumblob COMMENT 'battle_data', `battle_data` mediumblob COMMENT 'battle_data',
`kills_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '击杀修改时间',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),

View File

@ -2,6 +2,7 @@
require_once('mt/Parameter.php'); require_once('mt/Parameter.php');
require_once('mt/Item.php'); require_once('mt/Item.php');
require_once('mt/Drop.php');
require_once('models/Bag.php'); require_once('models/Bag.php');
@ -54,22 +55,24 @@ class BagController extends BaseAuthedController {
$this->_rspErr(2, '配置表错误'); $this->_rspErr(2, '配置表错误');
return; return;
} }
if ($itemMeta['type'] != mt\Item::FUNC_TYPE) { if ($itemMeta['type'] == mt\Item::FUNC_TYPE) {
$this->_rspErr(3, '该道具为不可使用道具'); switch ($itemMeta['sub_type']) {
return; case mt\Item::FUNC_RENAME_CARD_SUBTYPE:
} {
switch ($itemMeta['sub_type']) { $this->renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);
case mt\Item::FUNC_RENAME_CARD_SUBTYPE: }
{ break;
$this->renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); default:
} {
break; $this->_rspErr(4, '该道具功能暂未实现');
default: return;
{ }
break;
}
} else if ($itemMeta['type'] == mt\Item::GIFT_PACKAGE_TYPE) {
$this->openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);
} else {
$this->_rspErr(4, '该道具功能暂未实现'); $this->_rspErr(4, '该道具功能暂未实现');
return;
}
break;
} }
} }
@ -174,4 +177,36 @@ class BagController extends BaseAuthedController {
)); ));
} }
private function openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3)
{
$dropMeta = mt\Drop::get($itemMeta['drop']);
if (!$dropMeta) {
$this->_rspErr(1, '配置表错误');
return;
}
$costItems = mt\Item::getUseCostItems($itemMeta);
error_log(json_encode($costItems));
$lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
return;
}
$this->_decItems($costItems);
$this->_decItems(array(
array(
'item_id' => $itemMeta['id'],
'item_num' => 1
)
));
$this->_scatterDrop('gift_package:' . $itemMeta['id'],
$dropMeta,
$this->awardService,
$this->propertyChgService);
$this->propertyChgService->addBagChg();
$this->_rspData(array(
'award' => $this->awardService->toDto(),
'property_chg' => $this->propertyChgService->toDto(),
));
}
} }

View File

@ -6,6 +6,13 @@ use phpcommon\SqlHelper;
class BattleController extends BaseAuthedController { class BattleController extends BaseAuthedController {
public function preBattleCheck()
{
$this->_rspData(array(
'pre_battle_payload' => ''
));
}
public function battleReport() public function battleReport()
{ {
$userInfo = $this->_getOrmUserInfo(); $userInfo = $this->_getOrmUserInfo();

View File

@ -32,6 +32,9 @@ class GMController extends BaseAuthedController {
'.additem' => function () use($params) { '.additem' => function () use($params) {
$this->addItem($params); $this->addItem($params);
}, },
'.addtili' => function () use($params) {
$this->addTili($params);
},
'.getsystime' => function () use($params) { '.getsystime' => function () use($params) {
$this->getSysTime($params); $this->getSysTime($params);
}, },
@ -53,6 +56,7 @@ class GMController extends BaseAuthedController {
$this->_rspData(array( $this->_rspData(array(
'text' => <<<END 'text' => <<<END
.additem 道具id 道具数量 //添加道具 .additem 道具id 道具数量 //添加道具
.addtili 英雄id 体力值 //添加英雄体力
.getsystime //获取服务器时间 .getsystime //获取服务器时间
.setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00 .setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00
END END
@ -78,6 +82,21 @@ END
)); ));
} }
private function addTili($params)
{
$heroId = getXVal($params, 0, 0);
$tili = getXVal($params, 1, 0);
Hero::update($heroId, array(
'hero_tili' => "hero_tili + ${tili}"
));
$propertyChgService->addHeroChg();
$this->_rspData(array(
'text' => '添加道具成功',
'award' => $awardService->toDto(),
'property_chg' => $propertyChgService->toDto(),
));
}
private function getSysTime($params) private function getSysTime($params)
{ {
$sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime()); $sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime());

View File

@ -1,5 +1,6 @@
<?php <?php
require_once('mt/Parameter.php');
require_once('mt/Drop.php'); require_once('mt/Drop.php');
require_once('mt/Task.php'); require_once('mt/Task.php');
require_once('mt/Season.php'); require_once('mt/Season.php');
@ -96,7 +97,7 @@ class MissionController extends BaseAuthedController {
} }
$this->_rspData(array( $this->_rspData(array(
'current_active_value' => $this->_getV(TN_ACTIVE, 0), 'current_active_value' => $this->_getV(TN_ACTIVE, 0),
'max_active_value' => 0, 'max_active_value' => mt\Parameter::getVal('max_activity', 0),
'mission_list1' => $missionDtoList1, 'mission_list1' => $missionDtoList1,
'mission_list2' => $missionDtoList2 'mission_list2' => $missionDtoList2
)); ));

View File

@ -25,8 +25,8 @@ class ToolsController extends BaseController {
$tables = $conn->execQueryAsArray('show tables;'); $tables = $conn->execQueryAsArray('show tables;');
foreach ($tables as $table) { foreach ($tables as $table) {
$tblName = $table[0]; $tblName = $table[0];
$conn->execScript("DELETE FROM {$tblName};", $conn->execScript("DROP TABLE {$tblName};",
arary()); array());
} }
} }
} }

View File

@ -142,7 +142,8 @@ class UserController extends BaseAuthedController {
'head_frame' => $headFrame, 'head_frame' => $headFrame,
'level' => 1, 'level' => 1,
'exp' => 0, 'exp' => 0,
'rank' => $initRankMeta ? $initRankMeta['rank'] : 0, 'rank' => $initRankMeta ? $initRankMeta['rank'] : 1,
'history_best_rank' => $initRankMeta ? $initRankMeta['rank'] : 1,
'score' => $initRankMeta ? $initRankMeta['min_score'] : 0, 'score' => $initRankMeta ? $initRankMeta['min_score'] : 0,
'head_id' => $headId, 'head_id' => $headId,
'hero_id' => $heroId, 'hero_id' => $heroId,
@ -378,6 +379,26 @@ class UserController extends BaseAuthedController {
'star_win' => min(100, $starWin), 'star_win' => min(100, $starWin),
)); ));
} }
if (count($userDto['history_seasons']) <= 0) {
$currSeasonMeta = mt\Season::getCurrentSeason();
array_push($userDto['history_seasons'],
array(
'season_id' => $currSeasonMeta['id'],
'total_kills' => 0,
'game_times' => 0,
'win_times' => 0,
'win_rate' => 0,
'max_kills' => 0,
'avg_kills' => 0,
'max_damage_out' => 0,
'avg_damage_out' => 0,
'star_kills' => min(100, 0),
'star_damage' => min(100, 0),
'star_alive' => min(100, 0),
'star_recover' => min(100, 0),
'star_win' => min(100, 0),
));
}
$this->_rspData(array( $this->_rspData(array(
'info' => $userDto 'info' => $userDto
)); ));

View File

@ -43,7 +43,7 @@ class Battle extends BaseModel {
public static function update($fieldsKv) public static function update($fieldsKv)
{ {
SqlHelper::upsert SqlHelper::update
(myself()->_getSelfMysql(), (myself()->_getSelfMysql(),
't_battle', 't_battle',
array( array(

View File

@ -160,8 +160,8 @@ class DynData extends BaseModel {
{ {
$key = self::calcKey($x, $y); $key = self::calcKey($x, $y);
if (self::$dynData) { if (self::$dynData) {
if (isset($dynData[$key])) { if (isset(self::$dynData[$key])) {
return $dynData[$key]; return self::$dynData[$key];
} else { } else {
return array( return array(
'val' => $defVal, 'val' => $defVal,

View File

@ -28,6 +28,7 @@ class Hero extends BaseModel {
return array( return array(
'hero_id' => $row['hero_id'], 'hero_id' => $row['hero_id'],
'hero_lv' => $row['hero_lv'], 'hero_lv' => $row['hero_lv'],
'hero_tili' => $row['hero_tili'],
'skin_id' => $row['skin_id'], 'skin_id' => $row['skin_id'],
'skill_lv1' => $row['skill_lv1'], 'skill_lv1' => $row['skill_lv1'],
'skill_lv2' => $row['skill_lv2'], 'skill_lv2' => $row['skill_lv2'],
@ -38,6 +39,7 @@ class Hero extends BaseModel {
public static function addHero($heroMeta) public static function addHero($heroMeta)
{ {
$realHeroMeta = mt\Hero::get($heroMeta['id']);
SqlHelper::upsert( SqlHelper::upsert(
myself()->_getSelfMysql(), myself()->_getSelfMysql(),
't_hero', 't_hero',
@ -51,6 +53,7 @@ class Hero extends BaseModel {
'account_id' => myself()->_getAccountId(), 'account_id' => myself()->_getAccountId(),
'hero_id' => $heroMeta['id'], 'hero_id' => $heroMeta['id'],
'hero_lv' => 1, 'hero_lv' => 1,
'hero_tili' => getXVal($realHeroMeta, 'tili', 10000),
#'skin_id' => $defSkin, #'skin_id' => $defSkin,
'skill_lv1' => 1, 'skill_lv1' => 1,
'skill_lv2' => 1, 'skill_lv2' => 1,
@ -100,4 +103,17 @@ class Hero extends BaseModel {
); );
} }
public static function update($heroId, $fieldsKv)
{
SqlHelper::update
(myself()->_getSelfMysql(),
't_hero',
array(
'account_id' => myself()->_getAccountId(),
'hero_id' => $heroId,
),
$fieldsKv
);
}
} }

View File

@ -169,6 +169,20 @@ class Item {
return $costItems; return $costItems;
} }
public static function getUseCostItems($itemMeta)
{
$costItems = array();
foreach (splitStr2($itemMeta['use_cost']) as $arr) {
if (count($arr) >= 2) {
array_push($costItems, array(
'item_id' => $arr[0],
'item_num' => $arr[1]
));
}
}
return $costItems;
}
public static function isBagItem($type, $subType) public static function isBagItem($type, $subType)
{ {
return in_array($type, array( return in_array($type, array(

View File

@ -6,14 +6,19 @@ require_once('mt/Item.php');
require_once('mt/Equip.php'); require_once('mt/Equip.php');
require_once('mt/Season.php'); require_once('mt/Season.php');
require_once('mt/Rank.php'); require_once('mt/Rank.php');
require_once('mt/Parameter.php');
require_once('models/Season.php'); require_once('models/Season.php');
require_once('models/Battle.php'); require_once('models/Battle.php');
require_once('models/Bag.php');
require_once('models/Hero.php');
use mt; use mt;
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\Season; use models\Season;
use models\Battle; use models\Battle;
use models\Bag;
use models\Hero;
class BattleDataService extends BaseService { class BattleDataService extends BaseService {
@ -21,10 +26,17 @@ class BattleDataService extends BaseService {
public function updateBattleData() public function updateBattleData()
{ {
error_log(json_encode($_REQUEST));
error_log('updateBattleData1');
if (!$this->decCost()) {
return;
}
error_log('updateBattleData2');
$this->currSeasonMeta = mt\Season::getCurrentSeason(); $this->currSeasonMeta = mt\Season::getCurrentSeason();
if (!$this->currSeasonMeta) { if (!$this->currSeasonMeta) {
return; return;
} }
error_log('updateBattleData3');
$this->seasonDb = Season::find($this->currSeasonMeta['id']); $this->seasonDb = Season::find($this->currSeasonMeta['id']);
if (!$this->seasonDb) { if (!$this->seasonDb) {
Season::add($this->currSeasonMeta['id']); Season::add($this->currSeasonMeta['id']);
@ -33,6 +45,7 @@ class BattleDataService extends BaseService {
if (!$this->seasonDb) { if (!$this->seasonDb) {
return; return;
} }
error_log('updateBattleData4');
$this->updateScore(); $this->updateScore();
$hisBattleData = Battle::getMyBattleData(); $hisBattleData = Battle::getMyBattleData();
if (!isset($hisBattleData)) { if (!isset($hisBattleData)) {
@ -99,6 +112,7 @@ class BattleDataService extends BaseService {
'battle_data' => json_encode($seasonBattleData), 'battle_data' => json_encode($seasonBattleData),
) )
); );
$this->addItems();
} }
private function apply(&$battleData) private function apply(&$battleData)
@ -255,30 +269,67 @@ class BattleDataService extends BaseService {
private function updateScore() private function updateScore()
{ {
$userInfo = myself()->_getOrmUserInfo(); if (getReqVal('room_mode', 0) == 0) {
$rankScore = getReqVal('rank_score', 0); $userInfo = myself()->_getOrmUserInfo();
if ($rankScore > 0) { $rankScore = getReqVal('rank_score', 0);
$newRank = $userInfo['rank']; if ($rankScore > 0) {
$newScore = $userInfo['score']; $newRank = $userInfo['rank'];
mt\Rank::calcNewRankAndScore($userInfo['rank'], $userInfo['score'], $newRank, $newScore, $rankScore); $newScore = $userInfo['score'];
if ($newRank >= $userInfo['rank'] && $newScore != $userInfo['score']) { mt\Rank::calcNewRankAndScore($userInfo['rank'], $userInfo['score'], $newRank, $newScore, $rankScore);
myself()->_updateUserInfo(array( if ($newRank >= $userInfo['rank'] && $newScore != $userInfo['score']) {
'rank' => $newRank, myself()->_updateUserInfo(array(
'score' => $newScore, 'rank' => $newRank,
'history_best_rank' => max($userInfo['rank'], $newRank), 'score' => $newScore,
'score_modifytime' => myself()->_getNowTime(), 'history_best_rank' => max($userInfo['rank'], $newRank),
'best_rank_modifytime' => $newRank > $userInfo['rank'] ? 'score_modifytime' => myself()->_getNowTime(),
myself()->_getNowTime() : $userInfo['best_rank_modifytime'], 'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
)); myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
Season::update($this->currSeasonMeta['id'], array( ));
'rank' => $newRank, Season::update($this->currSeasonMeta['id'], array(
'score' => $newScore, 'rank' => $newRank,
'history_best_rank' => max($userInfo['rank'], $newRank), 'score' => $newScore,
'score_modifytime' => myself()->_getNowTime(), 'history_best_rank' => max($userInfo['rank'], $newRank),
'score_modifytime' => myself()->_getNowTime(), 'score_modifytime' => myself()->_getNowTime(),
'best_rank_modifytime' => $newRank > $userInfo['rank'] ? 'score_modifytime' => myself()->_getNowTime(),
myself()->_getNowTime() : $userInfo['best_rank_modifytime'], 'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
)); myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
));
}
}
}
}
private function decCost()
{
$heroDb = Hero::find(getReqVal('hero_id', 0));
if (!$heroDb) {
return false;
}
$costTili = mt\Parameter::getVal('cost_fatigue', 0);
if ($heroDb['hero_tili'] < $costTili) {
return false;
}
Hero::update($heroDb['hero_id'], array(
'hero_tili' => function () use($costTili) {
return "GREATEST(0, hero_tili - ${costTili})";
}
));
return true;
}
private function addItems()
{
$tmpStrs1 = explode('|', getReqVal('items', ''));
error_log('addItems ' . getReqVal('items', ''));
foreach ($tmpStrs1 as $tmpStr) {
$tmpStrs2 = explode(':', $tmpStr);
if (count($tmpStrs2) >= 2) {
$itemId = $tmpStrs2[0];
$itemNum = $tmpStrs2[1];
$itemMeta = mt\Item::get($itemId);
if ($itemMeta) {
Bag::addItem($itemId, $itemNum);
}
} }
} }
} }