diff --git a/doc/Other.py b/doc/Other.py new file mode 100644 index 00000000..0237f738 --- /dev/null +++ b/doc/Other.py @@ -0,0 +1,27 @@ +import _common + +class Other(object): + + def __init__(self): + self.apis = [ + { + 'name': 'tag', + 'desc': '红点提示', + 'group': 'Other', + 'url': 'webapp/index.php?c=Other&a=tag', + 'params': [ + _common.ReqHead(), + ['param', '0', '1:任务 2:碎片'], + ], + 'response': [ + _common.RspHead(), + ['!data', [ + ['mission',0,'任务: 1 提示, 0 不提示'], + ['piece',[ + ['hero',0,'英雄碎片: 1 提示, 0 不提示'], + ['gun',0,'枪械碎片: 1 提示, 0 不提示'], + ],'碎片'] + ], '提示信息'], + ] + } + ] \ No newline at end of file diff --git a/doc/User.py b/doc/User.py index bd72ce5c..757ba360 100644 --- a/doc/User.py +++ b/doc/User.py @@ -165,5 +165,17 @@ class User(object): _common.RspHead(), ['property_chg', _common.PropertyChg(), '属性变更'], ] + },{ + 'name': 'getFreeItemList', + 'desc': '获取免费英雄和武器列表', + 'group': 'User', + 'url': 'webapp/index.php?c=User&a=getFreeItemList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!data', [], '列表'], + ] }, ] diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index cfd3da09..a4d68224 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -58,6 +58,15 @@ class BaseAuthedController extends BaseController { public function _handlePre() { +// if (SERVER_ENV == _ONLINE) { +// if (getReqVal('client_uuid', '') != '499af8a0-a1bc-0b0e-dc79-a42cb3f103dc') { +// if ((getReqVal('c', '') != 'Battle')) { +// phpcommon\sendError(1001, 'session expiration'); +// die(); +// } +// } +// } + $this->accountId = getReqVal('account_id', ''); $this->sessionId = getReqVal('session_id', ''); if (!phpcommon\isValidSessionId($this->accountId, diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 316feccf..7376f0fa 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -53,8 +53,9 @@ class BaseController { public function _getZid() { $net = getReqVal('_net', ''); - $zid = $net && strlen($net) > 3 ? $net[2] : 3; - return ($zid >= 1 && $zid <= 8) ? $zid : 3; + $values = explode('-', $net); + $zid = $values[1]; + return substr($zid, 1); } public function _rspErr($errcode, $errmsg) diff --git a/webapp/controller/OtherController.class.php b/webapp/controller/OtherController.class.php new file mode 100644 index 00000000..32614cc3 --- /dev/null +++ b/webapp/controller/OtherController.class.php @@ -0,0 +1,58 @@ + 0, + 'piece' => array(), + ); + switch ($param){ + case self::MISSION : { + $userInfo = $this->_safeGetOrmUserInfo(); + $currRankSeasonMeta = mt\RankSeason::getCurrentSeason(); + $seasonDb = Season::find($currRankSeasonMeta['id']); + $missionService = new services\MissionService(); + $missionService->init($userInfo, $seasonDb);; + $missionMetaList = mt\Task::getCustomTypeMetaList(1, $missionService); + $missionHash = Mission::allToHash(); + foreach ($missionMetaList as $missionMeta) { + $missionDb = getXVal($missionHash, $missionMeta['id'], null); + $missionDto = $missionService->getMissionDto('', '', $missionDb, $missionMeta); + if ($missionDto['state'] == Mission::RECEIVEABLE_STATE){ + $req['mission'] = 1; + break; + } + } + } + break; + case self::PIECE : { + $req['piece'] = Fragment::isSatisfy(); + } + break; + default:{ + $req = array( + 'mission' => 0, + 'piece' => array(), + ); + } + } + $this->_rspData(array( + 'data'=>$req + )); + } +} diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 343caf1d..a42a0478 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -150,6 +150,7 @@ class UserController extends BaseAuthedController { $this->_addItems($addItems, $awardService, $propertyChgService); } + private function loginCheck($userInfo) { $seasonService = new services\SeasonService(); @@ -706,6 +707,21 @@ class UserController extends BaseAuthedController { ]); } + public function getFreeItemList(){ + $data = array(); + $heroParam = mt\Parameter::getListValue('free_hero_list'); + $gunParam = mt\Parameter::getListValue('free_weapon_list'); + if ($heroParam){ + $data['hero'] = $heroParam; + } + if ($gunParam){ + $data['gun'] = $gunParam; + } + $this->_rspData([ + 'data'=>$data + ]); + } + public function selectFreeItem(){ $hero_id = getReqVal('hero_id', ''); $gun_id = getReqVal('gun_id', ''); diff --git a/webapp/models/Fragment.php b/webapp/models/Fragment.php index 88ab16db..f552a593 100644 --- a/webapp/models/Fragment.php +++ b/webapp/models/Fragment.php @@ -79,5 +79,88 @@ class Fragment extends BaseModel return $dto; } + public static function getList($type=null){ + $itemList = array(); + $fragmentItem = self::getFragmentItem(); + $list1 = $fragmentItem['all']; + $list2 = $fragmentItem['hero']; + $list3 = $fragmentItem['gun']; + switch ($type){ + case 1:{ + Bag::getItemList(function ($row) use(&$itemList,$list2) { + if (in_array($row['item_id'],$list2) && $row['item_num'] > 0) { + array_push($itemList, $row); + } + }); + } + break; + case 2:{ + Bag::getItemList(function ($row) use(&$itemList,$list3) { + if (in_array($row['item_id'],$list3) && $row['item_num'] > 0) { + array_push($itemList, $row); + } + }); + } + break; + default:{ + Bag::getItemList(function ($row) use(&$itemList,$list1) { + if (in_array($row['item_id'],$list1) && $row['item_num'] > 0) { + array_push($itemList, $row); + } + }); + } + } + return $itemList; + } + + public static function getFragmentItem(){ + $itemMetas = mt\Item::getMetaListByType(mt\Item::FRAGMENT_TYPE); + $list1 = array(); + $list2 = array(); + $list3 = array(); + foreach ($itemMetas as $meta ){ + array_push($list1,$meta['id']); + if ($meta['sub_type'] == mt\Item::HERO_FRAGMENT_SUBTYPE){ + array_push($list2,$meta['id']); + }else if ($meta['sub_type'] == mt\Item::GUN_FRAGMENT_SUBTYPE){ + array_push($list3,$meta['id']); + } + } + return array( + 'all'=>$list1, + 'hero'=>$list2, + 'gun'=>$list3, + ); + } + + public static function isSatisfy(){ + $data = array( + 'hero' => 0, + 'gun' => 0, + ); + $heroFragmentList = self::getList(1); + $heroFragmentListPro = array(); + foreach ($heroFragmentList as $value){ + array_push($heroFragmentListPro,$value['item_id']); + } + $fragmentItem = self::getFragmentItem(); + $heroFragmentItem = $fragmentItem['hero']; + $heroDiff = array_diff($heroFragmentItem,$heroFragmentListPro); + if (empty($heroDiff)){ + $data['hero'] = 1; + } + $gunFragmentList = self::getList(2); + $gunFragmentListPro = array(); + foreach ($gunFragmentList as $value){ + array_push($gunFragmentListPro,$value['item_id']); + } + $gunFragmentItem = $fragmentItem['gun']; + $gunDiff = array_diff($gunFragmentItem,$gunFragmentListPro); + if (empty($gunDiff)){ + $data['gun'] = 1; + } + return $data; + } + } diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index 425d3311..162684dd 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -358,7 +358,7 @@ class FormulaService extends BaseService { // ROUND(1-($weaponTopX*100/10-1)/9,2) * 0.02; //表现分=f(个人存活时间排名TopX/4)*50%+f(队伍排名TopY)*50% f(TopX) = ROUND(1-(X-1)/9,2) - $expreScore = (ROUND(1-($ranked-1)/9,2)/4)*0.5+ROUND(1-($teamRank-1)/9,2)*0.5; + $expreScore = (ROUND(1-($ranked/4-1)/9,2))*0.5+ROUND(1-($teamRank-1)/9,2)*0.5; //不同段位的及格分 = ROUND(1-(大段位排名-1)/(MAX(10)-1),2) $topRanking = mt\Rank::getRankById($userDb['rank'])?mt\Rank::getRankById($userDb['rank'])['rank_order']:0; //************** rankRank 参数表获取 ************