This commit is contained in:
aozhiwei 2024-05-13 19:11:30 +08:00
commit 2a0e20b733
13 changed files with 260 additions and 6 deletions

View File

@ -20,8 +20,31 @@ class OutAppNft(object):
['!nfts', [NftInfo()], 'nft列表'], ['!nfts', [NftInfo()], 'nft列表'],
] ]
}, },
{
'name': 'getWebInfo',
'desc': 'web信息',
'group': 'OutAppNft',
'url': 'webapp/index.php?c=OutAppNft&a=getWebInfo',
'params': [
['channel', '', 'channel'],
['openId', 0, 'openId'],
],
'response': [
_common.RspHead(),
['info', WebInfo(), 'info'],
]
},
] ]
class WebInfo(object):
def __init__(self):
self.fields = [
['loginVal', 0, '今日登录状态 1:登录 0:未登录'],
['battleTimes', '', '战斗次数'],
['winTimes', 0, '胜利次数'],
['kills', 0, '击杀数'],
['getGoldVal', 0, '获得金币数'],
]
class NftInfo(object): class NftInfo(object):

View File

@ -1729,3 +1729,21 @@ CREATE TABLE `t_global_data` (
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),
UNIQUE KEY `name` (`name`) UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Table structure for table `t_sub_user_bind`
--
DROP TABLE IF EXISTS `t_sub_user_bind`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_sub_user_bind` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`org_account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '初始账号id',
`cur_account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '最新账号id',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `org_account_id` (`org_account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View File

@ -0,0 +1,16 @@
begin;
CREATE TABLE `t_sub_user_bind` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`org_account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '初始账号id',
`cur_account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '最新账号id',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `org_account_id` (`org_account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
insert into version (version) values(2024050801);
commit;

View File

@ -9,6 +9,7 @@ define('LAST_SESSION_KEY', 'last_session:');
define('MATCH_CURRENT_TEAM_KEY', 'match:current_team:'); define('MATCH_CURRENT_TEAM_KEY', 'match:current_team:');
define('MATCH_OK_KEY', 'match:ok:'); define('MATCH_OK_KEY', 'match:ok:');
define('DEC_BATTLE_TICKET', 'battle_ticket:'); define('DEC_BATTLE_TICKET', 'battle_ticket:');
define('LAST_ACTIVE_TIME', 'last_active_time:');
define('V_ITEM_GOLD', 10001); //金币 define('V_ITEM_GOLD', 10001); //金币
define('V_ITEM_GOLDS', 10017); //金堆 define('V_ITEM_GOLDS', 10017); //金堆
@ -69,6 +70,7 @@ define('TN_DAILY_BUY_LEVEL_STATE', 9018);
define('TN_DAILY_RESET_HERO_LEVEL_STATE', 9019); define('TN_DAILY_RESET_HERO_LEVEL_STATE', 9019);
define('TN_DAILY_REFRESH_MISSION_TIMES', 9020); define('TN_DAILY_REFRESH_MISSION_TIMES', 9020);
define('TN_DAILY_GOLD_MODE_BATTLE_TIMES', 9021); define('TN_DAILY_GOLD_MODE_BATTLE_TIMES', 9021);
define('TN_DAILY_GATHER_GOLD', 9022);
define('TN_WEEKLY_BEGIN', 10001); define('TN_WEEKLY_BEGIN', 10001);
define('TN_WEEKLY_ACTIVE', 10002); define('TN_WEEKLY_ACTIVE', 10002);

View File

@ -376,6 +376,15 @@ class BagController extends BaseAuthedController {
} }
private function openBattleBox($itemDb,$itemMeta,$itemNum){ private function openBattleBox($itemDb,$itemMeta,$itemNum){
$costItems = mt\Item::getUseCostItems($itemMeta);
if (count($costItems) > 0){
$lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
return;
}
}
$lootMeta = mt\LootConfig::find($itemMeta['loot']); $lootMeta = mt\LootConfig::find($itemMeta['loot']);
if ($lootMeta['isAffected']){ if ($lootMeta['isAffected']){
// $lucky = Hero::getAccountLucky(myself()->_getAddress()); // $lucky = Hero::getAccountLucky(myself()->_getAddress());
@ -393,6 +402,9 @@ class BagController extends BaseAuthedController {
}else{ }else{
$items = \services\LootService::dropOutItem($itemMeta['loot']); $items = \services\LootService::dropOutItem($itemMeta['loot']);
} }
if (count($costItems) > 0){
$this->_decItems($costItems);
}
$this->_decItems(array( $this->_decItems(array(
array( array(
'item_id' => $itemMeta['id'], 'item_id' => $itemMeta['id'],

View File

@ -96,11 +96,11 @@ class BaseAuthedController extends BaseController {
die(); die();
} }
} }
$r = $this->_getRedis($this->_getAccountId());
if (!(getReqVal('c', '') == 'User' && getReqVal('a', '') == 'login')) { if (!(getReqVal('c', '') == 'User' && getReqVal('a', '') == 'login')) {
if ((getReqVal('c', '') == 'Battle')) { if ((getReqVal('c', '') == 'Battle')) {
return; return;
} }
$r = $this->_getRedis($this->_getAccountId());
$sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId()); $sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId());
// error_log('SERVER_ENV:' . SERVER_ENV . '_DEBUG:' . _DEBUG); // error_log('SERVER_ENV:' . SERVER_ENV . '_DEBUG:' . _DEBUG);
if (SERVER_ENV != _DEBUG) if (SERVER_ENV != _DEBUG)
@ -116,9 +116,8 @@ class BaseAuthedController extends BaseController {
die(); die();
} }
} }
} }
$this->updateActive($r);
/*if (SERVER_ENV == _ONLINE) { /*if (SERVER_ENV == _ONLINE) {
if (phpcommon\cmpVersion(getReqVal('_version', ''), '0.2.0') > 0) { if (phpcommon\cmpVersion(getReqVal('_version', ''), '0.2.0') > 0) {
if (!$this->isWhiteList() || myself()->_getChannel() != BC_CHANNEL) { if (!$this->isWhiteList() || myself()->_getChannel() != BC_CHANNEL) {
@ -129,7 +128,15 @@ class BaseAuthedController extends BaseController {
}*/ }*/
} }
protected function updateActive($r)
{
$lastActiveTime = $r->get(LAST_ACTIVE_TIME . $this->_getAccountId());
//第一次登录或者跨天更新最后活跃时间
if (empty($lastActiveTime) ||
$lastActiveTime < $this->_getNowDaySeconds()) {
$r->setNxPx(LAST_ACTIVE_TIME . $this->_getAccountId(), $this->_getNowTime(), 1000 * 3600 * 24);
}
}
protected function updateSession($accountId, $sessionId) protected function updateSession($accountId, $sessionId)
{ {

View File

@ -247,4 +247,34 @@ class BaseController {
return $ret; return $ret;
} }
public function _getGameId() {
return 2006;
}
public function _isSubAccountId($accountId) {
$str_list = explode('_', $accountId);
if (count($str_list) < 4) {
return false;
}
$channel = $str_list[0];
$gameId = $str_list[1];
if ($channel != BC_POLY_CHANNEL) {
return false;
}
if ($gameId != $this->_getGameId()) {
return false;
}
return $str_list[2][0] == 's';
}
public function _getShortAccountId($accountId) {
if (!$this->_isSubAccountId($accountId)) {
return $accountId;
}
//
$str_list = explode('_', $accountId);
unset($str_list[2]);
return implode("_",$str_list);
}
} }

View File

@ -1,8 +1,10 @@
<?php <?php
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
require_once('models/Nft.php'); require_once('models/Nft.php');
require_once('models/User.php');
use models\Nft; use models\Nft;
use models\User;
class OutAppNftController extends BaseController { class OutAppNftController extends BaseController {
public function getNftList(){ public function getNftList(){
@ -38,5 +40,87 @@ class OutAppNftController extends BaseController {
)); ));
} }
public function getWebInfo(){
$channel = getReqVal('channel', '');
$openId = getReqVal('openId', '');
$accountId = BC_POLY_CHANNEL.'_'.$this->_getGameId().'_'.$channel.'_'.$openId;
$userDb = User::find($accountId);
if (!$userDb){
$this->_rspErr(1, 'user not found');
return;
}
$info = array(
'loginVal' => 0,
'battleTimes' => 0,
'winTimes' => 0,
'kills' => 0,
'getGoldVal' => 0,
);
$accountBindDb = SqlHelper::ormSelectOne(
myself()->_getMysql($openId),
't_sub_user_bind',
array(
'org_account_id' => $accountId,
)
);
$accountId = $accountBindDb ? $accountBindDb['cur_account_id'] : $accountId ;
$redis = $this->_getRedis($accountId);
$lastActiveTime = $redis->get(LAST_ACTIVE_TIME . $accountId);
if (!empty($lastActiveTime) && $lastActiveTime > myself()->_getNowDaySeconds()){
$info['loginVal'] = 1;
}
// $loginDyn = SqlHelper::ormSelectOne(
// myself()->_getMysql($openId),
// 't_dyndata',
// array(
// 'account_id' => $accountId,
// 'x' => TN_DAILY_LOGINS,
// 'y' => 0,
// )
// );
// if ($loginDyn){
// $info['loginVal'] = $loginDyn['val'];
// if (myself()->_getDaySeconds($loginDyn['modifytime']) < myself()->_getNowDaySeconds()) {
// $info['loginVal'] = 0;
// }
// }
$battleDb = SqlHelper::ormSelectOne(
myself()->_getMysql($openId),
't_battle',
array(
'account_id' => $accountId,
)
);
if ($battleDb){
$hisBattleData = json_decode($battleDb['battle_data'], true);
$todayBattleData = getXVal($hisBattleData, 'today_data', array());
if (myself()->_getDaySeconds(getXVal($todayBattleData, 'modifytime', 0)) == myself()->_getNowDaySeconds()) {
$info['battleTimes'] = getXVal($todayBattleData, "total_battle_times", 0);
$info['winTimes'] = getXVal($todayBattleData, "total_special_win_times", 0);
$info['kills'] = getXVal($todayBattleData, "total_kills_times", 0);
}
}
$getGoldDyn = SqlHelper::ormSelectOne(
myself()->_getMysql($openId),
't_dyndata',
array(
'account_id' => $accountId,
'x' => TN_DAILY_GATHER_GOLD,
'y' => 0,
)
);
if ($getGoldDyn){
$info['getGoldVal'] = $getGoldDyn['val'];
if (myself()->_getDaySeconds($getGoldDyn['modifytime']) < myself()->_getNowDaySeconds()) {
$info['getGoldVal'] = 0;
}
}
$this->_rspData(array(
'info' => $info,
));
}
} }

View File

@ -72,6 +72,7 @@ class UserController extends BaseAuthedController {
$userInfo['address'] = $this->_getOpenId(); $userInfo['address'] = $this->_getOpenId();
} }
$this->_updateLastSeason($userInfo); $this->_updateLastSeason($userInfo);
$this->_updateSubUserAccount();
$this->_sign(); $this->_sign();
$event = array( $event = array(
'ID' => 'luck', 'ID' => 'luck',
@ -1168,6 +1169,29 @@ class UserController extends BaseAuthedController {
} }
} }
private function _updateSubUserAccount() {
if ($this->_getChannel() == BC_POLY_CHANNEL) {
$shortAccountId = $this->_getShortAccountId(myself()->_getAccountId());
SqlHelper::upsert
($this->_getSelfMysql(),
't_sub_user_bind',
array(
'org_account_id' => $shortAccountId
),
array(
'cur_account_id' => myself()->_getAccountId(),
'modifytime' => myself()->_getNowTime(),
),
array(
'org_account_id' => $shortAccountId,
'cur_account_id' => myself()->_getAccountId(),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
}
private function _sign(){ private function _sign(){
//用户是否有签到记录 //用户是否有签到记录
if (SignLog::isSignRecord()){ if (SignLog::isSignRecord()){

View File

@ -383,7 +383,7 @@ class FormulaService extends BaseService {
//胜负率=1-(排名-1)/(最大排名-1) //胜负率=1-(排名-1)/(最大排名-1)
// $ranked = getXVal($params, 'pvp_personal_rank'); // $ranked = getXVal($params, 'pvp_personal_rank');
// $teamRank = min(getXVal($params, 'pvp_team_rank'),10); // $teamRank = min(getXVal($params, 'pvp_team_rank'),10);
$maxRanked = mt\Parameter::getVal('rank_order_max',40); //************** parameter 参数表获取 ************ $maxRanked = mt\Parameter::getVal('rank_order_max',8); //************** parameter 参数表获取 ************
$winRate = 1-($ranked-1)/($maxRanked-1); $winRate = 1-($ranked-1)/($maxRanked-1);
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400)) //总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
$winRateSum = $winningPro; $winRateSum = $winningPro;
@ -401,7 +401,7 @@ class FormulaService extends BaseService {
//一个玩家的赛后积分 = 赛前积分+K/2*(MAX(胜负率-0.5,0))+K/2*(表现分-段位要求的及格分) 新 //一个玩家的赛后积分 = 赛前积分+K/2*(MAX(胜负率-0.5,0))+K/2*(表现分-段位要求的及格分) 新
$kArr = explode('|',mt\Parameter::getVal('rank_k',0)); //************** parameter 参数表获取 ************ $kArr = explode('|',mt\Parameter::getVal('rank_k',0)); //************** parameter 参数表获取 ************
$K = $kArr[$rankMeta['rank_order2']-1]; $K = $kArr[$rankMeta['rank_order2']-1];
$battleAfterScore = $userDb['score'] + $K/2 * max(($winRate-0.5),0) + ($K/2) * ($expreScore-$askedScore); $battleAfterScore = $userDb['score'] + $K * max(($winRate-$winningPro),0);
return round($battleAfterScore); return round($battleAfterScore);
} }

View File

@ -221,6 +221,7 @@ class RoomBattleDataService extends BaseService {
"item_id" => V_ITEM_GOLD, "item_id" => V_ITEM_GOLD,
"item_num" => floor($gold), "item_num" => floor($gold),
)); ));
myself()->_incDailyV(TN_DAILY_GATHER_GOLD,0,floor($gold));
} }
} }
@ -240,6 +241,10 @@ class RoomBattleDataService extends BaseService {
public function _calBattleScore($battleInfo){ public function _calBattleScore($battleInfo){
$paramMeta = mt\Parameter::getVal('performance_score_range',0); $paramMeta = mt\Parameter::getVal('performance_score_range',0);
$paramMetaMoba = mt\Parameter::getVal('performance_score_weight_4V4',0);
$paramMetaPvp = mt\Parameter::getVal('performance_score_weight_BR',0);
$weightMoba = explode("|",$paramMetaMoba);
$weightPvp = explode("|",$paramMetaPvp);
$scoreParam = explode("|",$paramMeta); $scoreParam = explode("|",$paramMeta);
if (count($scoreParam) < 2){ if (count($scoreParam) < 2){
error_log('Parameter table error'); error_log('Parameter table error');
@ -284,10 +289,24 @@ class RoomBattleDataService extends BaseService {
} }
switch ($room_mode){ switch ($room_mode){
case self::ROOM_MODE_PVP: { case self::ROOM_MODE_PVP: {
if (count($weightPvp) == 5){
$killSco *= $weightPvp[0];
$assistSco *= $weightPvp[1];
$damageSco *= $weightPvp[2];
$recoverSco *= $weightPvp[3];
$aliveSco *= $weightPvp[4];
}
$battleScore = round($killSco + $assistSco + $damageSco + $recoverSco + $aliveSco , 2); $battleScore = round($killSco + $assistSco + $damageSco + $recoverSco + $aliveSco , 2);
} }
break; break;
case self::ROOM_MODE_MOBA :{ case self::ROOM_MODE_MOBA :{
if (count($weightMoba) == 5){
$killSco *= $weightMoba[0];
$assistSco *= $weightMoba[1];
$damageSco *= $weightMoba[2];
$recoverSco *= $weightMoba[3];
$levelSco *= $weightMoba[4];
}
$battleScore = round($killSco + $assistSco + $damageSco + $recoverSco + $levelSco , 2); $battleScore = round($killSco + $assistSco + $damageSco + $recoverSco + $levelSco , 2);
} }
break; break;

View File

@ -467,7 +467,21 @@ class TameBattleDataService extends BaseService {
'modifytime' => myself()->_getNowTime() 'modifytime' => myself()->_getNowTime()
); );
} }
if (!isset($hisBattleData['today_data'])) {
$hisBattleData['today_data'] = array(
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
);
}
if (myself()->_getDaySeconds($hisBattleData['today_data']['modifytime']) <
myself()->_getNowDaySeconds()) {
$hisBattleData['today_data'] = array(
'createtime' => $hisBattleData['today_data']['createtime'],
'modifytime' => myself()->_getNowTime()
);
}
$this->apply($hisBattleData['moba_data']); $this->apply($hisBattleData['moba_data']);
$this->apply($hisBattleData['today_data']);
Battle::add(json_encode($hisBattleData)); Battle::add(json_encode($hisBattleData));
} }
@ -530,6 +544,7 @@ class TameBattleDataService extends BaseService {
$data = array( $data = array(
"battle_uuid" => $battleUuid, "battle_uuid" => $battleUuid,
"map_mode_id" => getXVal($this->allInfo,'map_mode_id', 0), "map_mode_id" => getXVal($this->allInfo,'map_mode_id', 0),
"map_id" => getXVal($this->allInfo,'map_id', 0),
"map_mode" => getXVal($this->allInfo,'map_mode', 0), "map_mode" => getXVal($this->allInfo,'map_mode', 0),
"room_mode" => getXVal($this->allInfo,'room_mode', 0), "room_mode" => getXVal($this->allInfo,'room_mode', 0),
"pvp_mode" => $pvp_mode, "pvp_mode" => $pvp_mode,
@ -1085,11 +1100,15 @@ class TameBattleDataService extends BaseService {
//排名 //排名
$ranked = getXVal($this->battleInfo,'pvp_team_rank', 0); $ranked = getXVal($this->battleInfo,'pvp_team_rank', 0);
$mapMode = getXVal($this->allInfo,'map_mode', 0);
if ($ranked == 1) { if ($ranked == 1) {
//吃鸡次数 //吃鸡次数
$this->incValue($battleData, 'total_win_times', 1); $this->incValue($battleData, 'total_win_times', 1);
//地图吃鸡数 //地图吃鸡数
$this->incValue($battleData['total_map_win_times'], $mapId, 1); $this->incValue($battleData['total_map_win_times'], $mapId, 1);
if ($mapMode== mt\MapMode::RANKING_MODE || $mapMode == mt\MapMode::BET_MODE){
$this->incValue($battleData, "total_special_win_times", 1);
}
} }
if ($ranked <= 3 && $ranked>0){ if ($ranked <= 3 && $ranked>0){
//排名前十 总次数 //排名前十 总次数