Compare commits
No commits in common. "master" and "dev" have entirely different histories.
@ -6,20 +6,6 @@ class Battle(object):
|
||||
|
||||
def __init__(self):
|
||||
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 = [
|
||||
{
|
||||
@ -31,8 +17,6 @@ class Battle(object):
|
||||
['map_id', 0, '地图id'],
|
||||
['map_tpl_name', '', '地图模板名'],
|
||||
['room_uuid', 0, '房间唯一id'],
|
||||
['room_mode', 0, '房间模式 0:吃鸡模式 1:匹配赛模式'],
|
||||
['hero_id', 0, '英雄id'],
|
||||
['map_name', '', '地图名'],
|
||||
['team_mode', 0, '队伍模式 0:单人 1:组队'],
|
||||
['game_time', 0, '游戏时间'],
|
||||
@ -58,7 +42,7 @@ class Battle(object):
|
||||
|
||||
['rank_score', 0, '排位积分'],
|
||||
#['pass_score', 0, '通行证积分'],
|
||||
['items', 0, '道具id:道具数量|'],
|
||||
['items', 0, '道具|分割'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
|
@ -3,7 +3,7 @@
|
||||
class ReqHead(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
self.params = [
|
||||
['account_id', '', '账号id'],
|
||||
['session_id', '', '会话id'],
|
||||
]
|
||||
@ -101,7 +101,6 @@ class Hero(object):
|
||||
self.fields = [
|
||||
['hero_id', 0, '英雄id'],
|
||||
['hero_lv', 0, '英雄等级'],
|
||||
['hero_tili', 0, '英雄体力'],
|
||||
['skin_id', 0, '英雄皮肤id'],
|
||||
['skill_lv1', 0, '必杀技等级'],
|
||||
['skill_lv2', 0, '躲避技能等级'],
|
||||
|
@ -68,7 +68,6 @@ CREATE TABLE `t_hero` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_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',
|
||||
`hero_lv` int(11) NOT NULL DEFAULT '0' COMMENT '英雄等级',
|
||||
`hero_exp` int(11) NOT NULL DEFAULT '0' COMMENT '英雄等级',
|
||||
@ -238,7 +237,6 @@ CREATE TABLE `t_battle` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`battle_data` mediumblob COMMENT 'battle_data',
|
||||
`kills_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '击杀修改时间',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Drop.php');
|
||||
|
||||
require_once('models/Bag.php');
|
||||
|
||||
@ -55,24 +54,22 @@ class BagController extends BaseAuthedController {
|
||||
$this->_rspErr(2, '配置表错误');
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['type'] == mt\Item::FUNC_TYPE) {
|
||||
switch ($itemMeta['sub_type']) {
|
||||
case mt\Item::FUNC_RENAME_CARD_SUBTYPE:
|
||||
{
|
||||
$this->renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$this->_rspErr(4, '该道具功能暂未实现');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if ($itemMeta['type'] == mt\Item::GIFT_PACKAGE_TYPE) {
|
||||
$this->openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);
|
||||
} else {
|
||||
if ($itemMeta['type'] != mt\Item::FUNC_TYPE) {
|
||||
$this->_rspErr(3, '该道具为不可使用道具');
|
||||
return;
|
||||
}
|
||||
switch ($itemMeta['sub_type']) {
|
||||
case mt\Item::FUNC_RENAME_CARD_SUBTYPE:
|
||||
{
|
||||
$this->renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$this->_rspErr(4, '该道具功能暂未实现');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,36 +174,4 @@ 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(),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,13 +6,6 @@ use phpcommon\SqlHelper;
|
||||
|
||||
class BattleController extends BaseAuthedController {
|
||||
|
||||
public function preBattleCheck()
|
||||
{
|
||||
$this->_rspData(array(
|
||||
'pre_battle_payload' => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function battleReport()
|
||||
{
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
|
@ -32,9 +32,6 @@ class GMController extends BaseAuthedController {
|
||||
'.additem' => function () use($params) {
|
||||
$this->addItem($params);
|
||||
},
|
||||
'.addtili' => function () use($params) {
|
||||
$this->addTili($params);
|
||||
},
|
||||
'.getsystime' => function () use($params) {
|
||||
$this->getSysTime($params);
|
||||
},
|
||||
@ -56,7 +53,6 @@ class GMController extends BaseAuthedController {
|
||||
$this->_rspData(array(
|
||||
'text' => <<<END
|
||||
.additem 道具id 道具数量 //添加道具
|
||||
.addtili 英雄id 体力值 //添加英雄体力
|
||||
.getsystime //获取服务器时间
|
||||
.setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00
|
||||
END
|
||||
@ -82,21 +78,6 @@ 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)
|
||||
{
|
||||
$sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime());
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Drop.php');
|
||||
require_once('mt/Task.php');
|
||||
require_once('mt/Season.php');
|
||||
@ -97,7 +96,7 @@ class MissionController extends BaseAuthedController {
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'current_active_value' => $this->_getV(TN_ACTIVE, 0),
|
||||
'max_active_value' => mt\Parameter::getVal('max_activity', 0),
|
||||
'max_active_value' => 0,
|
||||
'mission_list1' => $missionDtoList1,
|
||||
'mission_list2' => $missionDtoList2
|
||||
));
|
||||
|
@ -25,8 +25,8 @@ class ToolsController extends BaseController {
|
||||
$tables = $conn->execQueryAsArray('show tables;');
|
||||
foreach ($tables as $table) {
|
||||
$tblName = $table[0];
|
||||
$conn->execScript("DROP TABLE {$tblName};",
|
||||
array());
|
||||
$conn->execScript("DELETE FROM {$tblName};",
|
||||
arary());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,8 +142,7 @@ class UserController extends BaseAuthedController {
|
||||
'head_frame' => $headFrame,
|
||||
'level' => 1,
|
||||
'exp' => 0,
|
||||
'rank' => $initRankMeta ? $initRankMeta['rank'] : 1,
|
||||
'history_best_rank' => $initRankMeta ? $initRankMeta['rank'] : 1,
|
||||
'rank' => $initRankMeta ? $initRankMeta['rank'] : 0,
|
||||
'score' => $initRankMeta ? $initRankMeta['min_score'] : 0,
|
||||
'head_id' => $headId,
|
||||
'hero_id' => $heroId,
|
||||
@ -379,26 +378,6 @@ class UserController extends BaseAuthedController {
|
||||
'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(
|
||||
'info' => $userDto
|
||||
));
|
||||
|
@ -43,7 +43,7 @@ class Battle extends BaseModel {
|
||||
|
||||
public static function update($fieldsKv)
|
||||
{
|
||||
SqlHelper::update
|
||||
SqlHelper::upsert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_battle',
|
||||
array(
|
||||
|
@ -160,8 +160,8 @@ class DynData extends BaseModel {
|
||||
{
|
||||
$key = self::calcKey($x, $y);
|
||||
if (self::$dynData) {
|
||||
if (isset(self::$dynData[$key])) {
|
||||
return self::$dynData[$key];
|
||||
if (isset($dynData[$key])) {
|
||||
return $dynData[$key];
|
||||
} else {
|
||||
return array(
|
||||
'val' => $defVal,
|
||||
|
@ -28,7 +28,6 @@ class Hero extends BaseModel {
|
||||
return array(
|
||||
'hero_id' => $row['hero_id'],
|
||||
'hero_lv' => $row['hero_lv'],
|
||||
'hero_tili' => $row['hero_tili'],
|
||||
'skin_id' => $row['skin_id'],
|
||||
'skill_lv1' => $row['skill_lv1'],
|
||||
'skill_lv2' => $row['skill_lv2'],
|
||||
@ -39,7 +38,6 @@ class Hero extends BaseModel {
|
||||
|
||||
public static function addHero($heroMeta)
|
||||
{
|
||||
$realHeroMeta = mt\Hero::get($heroMeta['id']);
|
||||
SqlHelper::upsert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero',
|
||||
@ -53,7 +51,6 @@ class Hero extends BaseModel {
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'hero_id' => $heroMeta['id'],
|
||||
'hero_lv' => 1,
|
||||
'hero_tili' => getXVal($realHeroMeta, 'tili', 10000),
|
||||
#'skin_id' => $defSkin,
|
||||
'skill_lv1' => 1,
|
||||
'skill_lv2' => 1,
|
||||
@ -103,17 +100,4 @@ 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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -169,20 +169,6 @@ class Item {
|
||||
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)
|
||||
{
|
||||
return in_array($type, array(
|
||||
|
@ -6,19 +6,14 @@ require_once('mt/Item.php');
|
||||
require_once('mt/Equip.php');
|
||||
require_once('mt/Season.php');
|
||||
require_once('mt/Rank.php');
|
||||
require_once('mt/Parameter.php');
|
||||
|
||||
require_once('models/Season.php');
|
||||
require_once('models/Battle.php');
|
||||
require_once('models/Bag.php');
|
||||
require_once('models/Hero.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Season;
|
||||
use models\Battle;
|
||||
use models\Bag;
|
||||
use models\Hero;
|
||||
|
||||
class BattleDataService extends BaseService {
|
||||
|
||||
@ -26,17 +21,10 @@ class BattleDataService extends BaseService {
|
||||
|
||||
public function updateBattleData()
|
||||
{
|
||||
error_log(json_encode($_REQUEST));
|
||||
error_log('updateBattleData1');
|
||||
if (!$this->decCost()) {
|
||||
return;
|
||||
}
|
||||
error_log('updateBattleData2');
|
||||
$this->currSeasonMeta = mt\Season::getCurrentSeason();
|
||||
if (!$this->currSeasonMeta) {
|
||||
return;
|
||||
}
|
||||
error_log('updateBattleData3');
|
||||
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
||||
if (!$this->seasonDb) {
|
||||
Season::add($this->currSeasonMeta['id']);
|
||||
@ -45,7 +33,6 @@ class BattleDataService extends BaseService {
|
||||
if (!$this->seasonDb) {
|
||||
return;
|
||||
}
|
||||
error_log('updateBattleData4');
|
||||
$this->updateScore();
|
||||
$hisBattleData = Battle::getMyBattleData();
|
||||
if (!isset($hisBattleData)) {
|
||||
@ -112,7 +99,6 @@ class BattleDataService extends BaseService {
|
||||
'battle_data' => json_encode($seasonBattleData),
|
||||
)
|
||||
);
|
||||
$this->addItems();
|
||||
}
|
||||
|
||||
private function apply(&$battleData)
|
||||
@ -269,67 +255,30 @@ class BattleDataService extends BaseService {
|
||||
|
||||
private function updateScore()
|
||||
{
|
||||
if (getReqVal('room_mode', 0) == 0) {
|
||||
$userInfo = myself()->_getOrmUserInfo();
|
||||
$rankScore = getReqVal('rank_score', 0);
|
||||
if ($rankScore > 0) {
|
||||
$newRank = $userInfo['rank'];
|
||||
$newScore = $userInfo['score'];
|
||||
mt\Rank::calcNewRankAndScore($userInfo['rank'], $userInfo['score'], $newRank, $newScore, $rankScore);
|
||||
if ($newRank >= $userInfo['rank'] && $newScore != $userInfo['score']) {
|
||||
myself()->_updateUserInfo(array(
|
||||
'rank' => $newRank,
|
||||
'score' => $newScore,
|
||||
'history_best_rank' => max($userInfo['rank'], $newRank),
|
||||
'score_modifytime' => myself()->_getNowTime(),
|
||||
'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
|
||||
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
|
||||
));
|
||||
Season::update($this->currSeasonMeta['id'], array(
|
||||
'rank' => $newRank,
|
||||
'score' => $newScore,
|
||||
'history_best_rank' => max($userInfo['rank'], $newRank),
|
||||
'score_modifytime' => myself()->_getNowTime(),
|
||||
'score_modifytime' => myself()->_getNowTime(),
|
||||
'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);
|
||||
}
|
||||
$userInfo = myself()->_getOrmUserInfo();
|
||||
$rankScore = getReqVal('rank_score', 0);
|
||||
if ($rankScore > 0) {
|
||||
$newRank = $userInfo['rank'];
|
||||
$newScore = $userInfo['score'];
|
||||
mt\Rank::calcNewRankAndScore($userInfo['rank'], $userInfo['score'], $newRank, $newScore, $rankScore);
|
||||
if ($newRank >= $userInfo['rank'] && $newScore != $userInfo['score']) {
|
||||
myself()->_updateUserInfo(array(
|
||||
'rank' => $newRank,
|
||||
'score' => $newScore,
|
||||
'history_best_rank' => max($userInfo['rank'], $newRank),
|
||||
'score_modifytime' => myself()->_getNowTime(),
|
||||
'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
|
||||
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
|
||||
));
|
||||
Season::update($this->currSeasonMeta['id'], array(
|
||||
'rank' => $newRank,
|
||||
'score' => $newScore,
|
||||
'history_best_rank' => max($userInfo['rank'], $newRank),
|
||||
'score_modifytime' => myself()->_getNowTime(),
|
||||
'score_modifytime' => myself()->_getNowTime(),
|
||||
'best_rank_modifytime' => $newRank > $userInfo['rank'] ?
|
||||
myself()->_getNowTime() : $userInfo['best_rank_modifytime'],
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user