diff --git a/doc/_common.py b/doc/_common.py index 79dc4e5c..ee732c56 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -82,6 +82,7 @@ class Gun(object): ['gun_lv', 0, '枪等级'], ['quality', 0, '品阶'], ['durability', 0, '耐久'], + ['durability_max', 0, '最大耐久'], ['ceg_uplimit', 0, 'ceg今天获取上限'], ['!attr_base', [Attr()], '枪械基础属性'], ['!attr_pro', [Attr()], '枪械升级升阶加成属性'], @@ -91,8 +92,14 @@ class Gun(object): ['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'], ['unlock_lefttime', 0, '解锁剩余时间(单位秒)'], ['trade_locktime', 0, '出售锁定时间(升级或者升阶完成后触发),单位秒,只锁交易,其他的操作仍可进行'], + ['current_pvp_get_ceg', 0, '当前pvp获取的ceg数量'], + ['current_pve_get_ceg', 0, '当前pve获取的ceg数量'], + ['last_pvp_get_ceg_time', 0, '最后一次获取pvp获取ceg时间'], + ['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'], ['chip_ids', '', '镶嵌的芯片主键id组'], ['!chip_core', [ChipCore()], '芯片核心加成'], + ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'], + ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'], ['offer_reward_state', 0, '是否悬赏中'], ] @@ -218,13 +225,12 @@ class Hero(object): ['hero_id', 0, '英雄id'], ['hero_lv', 0, '英雄等级'], ['hero_tili', 0, '英雄体力'], + ['hero_tili_max', 0, '英雄最大体力'], ['state', 0, '0:已购买 1:体验中'], ['skin_id', 0, '英雄皮肤id'], ['quality', 0, '品阶'], ['skill_lv1', 0, '主动技能等级'], ['skill_lv2', 0, '被动技能等级'], - ['ceg_uplimit', 0, 'ceg今天获取上限'], - ['pve_ceg_uplimit', 0, 'pve ceg今天获取上限'], ['!attr_base', [Attr()], '英雄基础属性'], ['!attr_pro', [Attr()], '英雄升级升阶提升属性'], ['!attr_skill', [Attr()], '英雄技能提升属性'], @@ -233,9 +239,9 @@ class Hero(object): ['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'], ['unlock_lefttime', 0, '解锁剩余时间(单位秒)'], ['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'], - ['today_get_gold', 0, '今天pvp获取的ceg数量'], - ['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'], - ['last_get_gold_time', 0, '今天pvp获取的ceg数量'], + ['current_pvp_get_ceg', 0, '当前pvp获取的ceg数量'], + ['current_pve_get_ceg', 0, '当前pve获取的ceg数量'], + ['last_pvp_get_ceg_time', 0, '最后一次获取pvp获取ceg时间'], ['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'], ['unlock_trade_time', 0, '出售解锁utc时间(升级或者升阶完成后触发),只锁交易,其他的操作仍可进行,和lock_type无关是独立的锁!!!'], ['advanced_count', 0, '进阶次数'], @@ -244,7 +250,10 @@ class Hero(object): ['skill_points', '', '技能点'], ['!chip_core', [ChipCore()], '芯片核心加成'], ['!skill_common', [], '通用属性'], + ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'], + ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'], ['offer_reward_state', 0, '是否悬赏中'], + ] class LevelingHero(object): diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 67426b21..e18387ac 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -133,7 +133,7 @@ CREATE TABLE `t_hero` ( `token_id` varchar(60) COMMENT 'token_id', `account_id` varchar(60) COMMENT 'account_id', `hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id', - `hero_tili` int(11) NOT NULL DEFAULT '0' COMMENT '英雄体力', + `hero_tili` varchar(25) NOT NULL DEFAULT '0' COMMENT '英雄体力', `state` int(11) NOT NULL DEFAULT '0' COMMENT '0:已购买 1:体验中', `skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '皮肤id', `hero_lv` int(11) NOT NULL DEFAULT '0' COMMENT '英雄等级', @@ -282,7 +282,7 @@ CREATE TABLE `t_gun` ( `lock_type` int(11) NOT NULL DEFAULT '0' COMMENT '0:无锁 1:升级 2:升阶', `unlock_time` int(11) NOT NULL DEFAULT '0' COMMENT '解锁时间', `unlock_trade_time` int(11) NOT NULL DEFAULT '0' COMMENT '出售解锁时间', - `durability` int(11) NOT NULL DEFAULT '0' COMMENT '耐久', + `durability` varchar(25) NOT NULL DEFAULT '0' COMMENT '耐久', `rand_attr` mediumblob COMMENT '随机属性', `today_get_gold` bigint NOT NULL DEFAULT '0' COMMENT '金币', `last_get_gold_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后获取金币的时间', diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index 06131cfd..9b33d810 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -13,6 +13,7 @@ use models\Chip; use models\Hero; use models\Gun; use models\User; +use services\FormulaService; use services\NftService; use phpcommon\SqlHelper; use phpcommon\TGLog; @@ -473,12 +474,18 @@ class ChipController extends BaseAuthedController // }else{ // $Chip_PSA_Value= \services\FormulaService::Weapon_Chip_DA_Value($chip['chip_grade']); // } -// $tili = $chip['strength']-$chip['strength_max']*$Chip_PSA_Value; +// $tili = $chip['strength']-$chip['strength_max']*$Chip_PSA_Value; //错误公式 // Chip::update($chip['token_id'],['strength'=>$tili]); // } // $this->_rspOk(); - +// $lucky = FormulaService::getChipLuckyValue(6); +// echo FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength(6,$lucky); +// echo FormulaService::Hero_Chip_PSA_Value(6); +// $lucky = FormulaService::Hero_Advanced_Lucky_Value(3); +// echo FormulaService::Hero_NFT_Maximum_Physical_Strength(3,$lucky); + echo FormulaService::Weapon_Advanced_Lucky_Value(1); +// echo FormulaService::Hero_NFT_Maximum_Physical_Strength(1,$lucky); } diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 2bdc9ee1..3e1ea77b 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -4,12 +4,16 @@ namespace models; require_once('services/NftService.php'); +require_once('services/FormulaService.php'); + require_once('mt/Item.php'); require_once('mt/ChipAttr.php'); + use mt; use phpcommon\SqlHelper; use services\NftService; +use services\FormulaService; class Chip extends BaseModel { @@ -264,4 +268,34 @@ class Chip extends BaseModel return $data; } + public static function getChipMaxStrength($chip_ids,$type){ + $MaxStrength = 0; + if (! $chip_ids) { + return $MaxStrength; + } + $chipIdsArr = explode('|',$chip_ids); + switch ($type){ + case 1:{ + foreach ($chipIdsArr as $val){ + $chip = self::getChipByIdx($val); + $lucky = FormulaService::getChipLuckyValue($chip['chip_grade']); + $MaxStrength+=FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$lucky)*FormulaService::Hero_Chip_PSA_Value($chip['chip_grade']); + } + } + break; + case 2:{ + foreach ($chipIdsArr as $val){ + $chip = self::getChipByIdx($val); + $lucky = FormulaService::getChipLuckyValue($chip['chip_grade']); + $MaxStrength+=FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$lucky)*FormulaService::Weapon_Chip_DA_Value($chip['chip_grade']); + } + } + break; + default:{ + $MaxStrength = 0; + } + } + return $MaxStrength; + } + } \ No newline at end of file diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 8be30c73..1eef16a0 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -186,9 +186,9 @@ class Gun extends BaseModel { 'attr_chip' => Chip::getChipAttr($row['chip_ids'])['attr_chip'], 'chip_core' => Chip::getChipAttr($row['chip_ids'])['chip_core'], 'try_count' => $row['try_count'], - 'today_get_gold' => $todayGetGold, - 'last_get_gold_time' => $lastGetGoldTime, - 'today_pve_get_ceg' => $todayPveGetCeg, + 'current_pvp_get_ceg' => $todayGetGold, + 'last_pvp_get_ceg_time' => $lastGetGoldTime, + 'current_pve_get_ceg' => $todayPveGetCeg, 'last_pve_get_ceg_time' => $lastPveGetCegTime, 'lock_type' => $lockType, 'unlock_time' => $unlockTime, @@ -196,12 +196,12 @@ class Gun extends BaseModel { $unlockTime - myself()->_getNowTime()), 'unlock_trade_time' => $row['unlock_trade_time'], 'chip_ids' => $row['chip_ids'], + 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],2)), //计算ceg上限所需参数 'offer_reward_state' => 0, ); - $dto['ceg_uplimit'] = FormulaService::getWeaponPvpDailyCegUpLimit($dto); - $dto['raw_pve_ceg_uplimit'] = - FormulaService::getWeaponPveDailyCegUpLimit($dto); - $dto['pve_ceg_uplimit'] = round($dto['raw_pve_ceg_uplimit'] * 0.9); + $dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3)); + $dto['pvp_ceg_uplimit'] = FormulaService::getWeaponPvpDailyCegUpLimit($dto); + $dto['pve_ceg_uplimit'] = FormulaService::getWeaponPveDailyCegUpLimit($dto); return $dto; } @@ -237,7 +237,7 @@ class Gun extends BaseModel { 'gun_lv' => 1, 'quality' => 1, 'state' => self::GETED_STATE, - 'durability' => $gunMeta['init_durability'] ? $gunMeta['init_durability'] : 0, + 'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)), 'rand_attr' => json_encode($randAttr), 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index ef624ae4..2091089b 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -187,9 +187,6 @@ class Hero extends BaseModel { 'quality' => $row['quality'], 'skill_lv1' => $row['skill_lv1'], 'skill_lv2' => $row['skill_lv2'], - 'ceg_uplimit' => 0, - 'pve_ceg_uplimit' => 0, - 'raw_pve_ceg_uplimit' => 0, 'attr_base' => $baseAttr, 'attr_pro' => $attrPro, 'attr_skill' => $attr_skill, @@ -200,22 +197,24 @@ class Hero extends BaseModel { 'unlock_time' => $unlockTime, 'unlock_lefttime' => max(0, $unlockTime - myself()->_getNowTime()), - 'today_get_gold' => $todayGetGold, - 'last_get_gold_time' => $lastGetGoldTime, - 'today_pve_get_ceg' => $todayPveGetCeg, + 'current_pvp_get_ceg' => $todayGetGold, + 'last_pvp_get_ceg_time' => $lastGetGoldTime, + 'current_pve_get_ceg' => $todayPveGetCeg, 'last_pve_get_ceg_time' => $lastPveGetCegTime, 'unlock_trade_time' => $row['unlock_trade_time'], 'advanced_count' => $row['advanced_count'], 'lucky' => $heroLucky, 'chip_ids' => $row['chip_ids'], + 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],1)), //计算ceg上限所需参数 'skill_common' => $skill_common, 'skill_points' => $row['skill_points'], 'offer_reward_state' => 0, ); - $dto['ceg_uplimit'] = FormulaService::getHeroPvpDailyCegUpLimit($dto); - $dto['raw_pve_ceg_uplimit'] = - FormulaService::getHeroPveDailyCegUpLimit($dto); - $dto['pve_ceg_uplimit'] = round($dto['raw_pve_ceg_uplimit'] * 0.9); + $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3)); + $dto['pvp_ceg_uplimit'] = strval(FormulaService::getHeroPvpDailyCegUpLimit($dto)); + $dto['pve_ceg_uplimit'] = strval(FormulaService::getHeroPveDailyCegUpLimit($dto)); + + return $dto; } @@ -245,7 +244,7 @@ class Hero extends BaseModel { 'hero_id' => $heroMeta['id'], 'hero_lv' => 1, 'quality' => 1, - 'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0, + 'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)), 'state' => self::GETED_STATE, 'skill_lv1' => 1, 'skill_lv2' => 1, @@ -253,7 +252,7 @@ class Hero extends BaseModel { 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, 'unlock_trade_time' => 0, - 'skill_points' => 100, + 'skill_points' => 0, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() ); diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index 0d4f67ea..60327d7a 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -12,51 +12,7 @@ use mt; class FormulaService extends BaseService { - public static function getHeroPvpDailyCegUpLimit($heroDb) - { - //ROUND((0.0402*角色NFT阶数^3-0.9459*角色NFT阶数^2+11.9664*角色NFT阶数+4.01892)+(0.0268*角色幸运值^3-2.15712*角色幸运值^2+60.944*角色幸运值-560.24),0)+系统参数 - $sysParam = 0; - $qualityMeta = mt\HeroQuality::getByQuality($heroDb['quality']); - $lucky = $qualityMeta ? $qualityMeta['lucky'] : 0; - $upLimit = round( - ( - 0.0402*pow($heroDb['quality'],3) - - 0.9459*pow($heroDb['quality'],2) + - 11.9664*$heroDb['quality'] + - 4.01892 - ) + - ( - 0.0268*pow($lucky, 3) - - 2.15712*pow($lucky, 2) + - 60.944*$lucky - - 560.24 - ) - ) + $sysParam; - return $upLimit; - } - public static function getHeroPveDailyCegUpLimit($heroDb) - { - //ROUND((0.0938*角色NFT阶数^3-2.2071*角色NFT阶数^2+27.9216*角色NFT阶数+9.3776)+(0.0625*角色幸运值^3-5.0334*角色幸运值^2+142.2028*角色幸运值-1307.2268),0)+系统参数 - $sysParam = 0; - $qualityMeta = mt\HeroQuality::getByQuality($heroDb['quality']); - $lucky = $qualityMeta ? $qualityMeta['lucky'] : 0; - $upLimit = round( - ( - 0.0938*pow($heroDb['quality'],3) - - 2.2071*pow($heroDb['quality'],2) + - 27.9216*$heroDb['quality'] + - 9.3776 - ) + - ( - 0.0625*pow($lucky, 3) - - 5.0334*pow($lucky, 2) + - 142.2028*$lucky - - 1307.2268 - ) - ) + $sysParam; - return $upLimit; - } public static function calcHeroPvpCeg($heroDto, $params) { @@ -87,51 +43,7 @@ class FormulaService extends BaseService { return 0; } - public static function getWeaponPvpDailyCegUpLimit($weaponDb) - { - //ROUND((0.0111*武器NFT阶数^3-0.25974*武器NFT阶数^2+3.29292*武器NFT阶数+1.3389)+(0.0074*武器幸运值^3-0.59396*武器幸运值^2+16.7708*武器幸运值-153.964),0)+系统参数 - $sysParam = 0; - $qualityMeta = mt\GunQuality::getByQuality($weaponDb['quality']); - $lucky = $qualityMeta ? $qualityMeta['lucky'] : 0; - $upLimit = round( - ( - 0.0111*pow($weaponDb['quality'],3) - - 0.25974*pow($weaponDb['quality'],2) + - 3.29292*$weaponDb['quality'] + - 1.3389 - ) + - ( - 0.0074*pow($lucky, 3) - - 0.59396*pow($lucky, 2) + - 16.7708*$lucky - - 153.964 - ) - ) + $sysParam; - return $upLimit; - } - public static function getWeaponPveDailyCegUpLimit($weaponDb) - { - //ROUND((0.0259*武器NFT阶数^3-0.6061*武器NFT阶数^2+7.6836*武器NFT阶数+3.1241)+(0.0174*武器幸运值^3-1.3859*武器幸运值^2+39.132*武器幸运值-359.2493),0)+系统参数 - $sysParam = 0; - $qualityMeta = mt\GunQuality::getByQuality($weaponDb['quality']); - $lucky = $qualityMeta ? $qualityMeta['lucky'] : 0; - $upLimit = round( - ( - 0.0259*pow($weaponDb['quality'],3) - - 0.6061*pow($weaponDb['quality'],2) + - 7.6836*$weaponDb['quality'] + - 3.1241 - ) + - ( - 0.0174*pow($lucky, 3) - - 1.3859*pow($lucky, 2) + - 39.132*$lucky - - 359.2493 - ) - ) + $sysParam; - return $upLimit; - } public static function calcWeaponPvpCeg($weaponDto, $params) { @@ -271,6 +183,52 @@ class FormulaService extends BaseService { return 0; } + /** + -------------------------------------------------新公式----------------------------------------------------------- + */ + + + //每天英雄NFT获得CEG上限值 + public static function Hero_Max_CEG($heroDb){ + //Hero_Max_CEG=((SIGN(英雄NFT阶数=1)*Hero_NFT_Maximum_Physical_Strength+SIGN(英雄NFT阶数>1)*Hero_Fixed_Physical_Strength)*Hero_PSA_Value+Hero_Chip_NFT_Maximum_Physical_Strength*Hero_PSA_Value)*10*CEG_Discount_Rate + return ((($heroDb['quality']==1?1:0)*self::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroDb['lucky'])+($heroDb['quality']>1?1:0)*$heroDb['hero_tili'])*self::Hero_PSA_Value($heroDb['quality'])+$heroDb['chip_strength_sum'])*10*self::CEG_Discount_Rate(); + } + + //英雄PVP收益上限 + public static function getHeroPvpDailyCegUpLimit($heroDb) + { + //Hero_Max_CEG *60% + return self::Hero_Max_CEG($heroDb)*0.6; + } + + //英雄PVE收益上限 + public static function getHeroPveDailyCegUpLimit($heroDb) + { + //Hero_Max_CEG *35% + return self::Hero_Max_CEG($heroDb)*0.35; + } + + //每天枪械NFT获得CEG上限值 + public static function Weapon_Max_CEG($weaponDb){ + //Weapon_Max_CEG=((SIGN(武器NFT阶数=1)*Weapon_NFT_Maximum_Durability+SIGN(武器NFT阶数>1)*Weapon_Fixed_Durability)*Weapon_DA_Value+Weapon_Chip_NFT_Maximum_Durability*Weapon_Chip_DA_Value)*10*CEG_Discount_Rate + return ((($weaponDb['quality']==1?1:0)*self::Weapon_NFT_Maximum_Durability($weaponDb['quality'],$weaponDb['lucky'])+($weaponDb['quality']>1?1:0)*$weaponDb['durability'])*self::Weapon_DA_Value($weaponDb['quality'])+$weaponDb['chip_strength_sum'])*10*self::CEG_Discount_Rate(); + + } + + //枪械PVP收益上限 + public static function getWeaponPvpDailyCegUpLimit($weaponDb) + { + //Weapon_Max_CEG *60% + return self::Weapon_Max_CEG($weaponDb)*0.6; + } + + //枪械PVE收益上限 + public static function getWeaponPveDailyCegUpLimit($weaponDb) + { + //Weapon_Max_CEG *35% + return self::Weapon_Max_CEG($weaponDb)*0.35; + } + //CEG折扣比率 public static function CEG_Discount_Rate(){ //CEG_Discount_Rate=ROUND(CEG_Dynamic_Index /( CEG_Dynamic_Price / CEG_Base_Price),3) @@ -326,7 +284,7 @@ class FormulaService extends BaseService { return ($grade>4?1:0)*round(0.00419*pow($grade,5)-0.0705*pow($grade,4)+0.24*pow($grade,3)+8.5*pow($grade,2)-39.9*$grade+38,1); } - //芯片体力值 + //芯片体力值(英雄芯片和枪械芯片一样的) public static function Hero_Chip_NFT_Maximum_Physical_Strength($grade,$lucky){ //芯片体力值(命名:Hero_Chip_NFT_Maximum_Physical_Strength) = SIGN(英雄芯片NFT星数>4)*( 英雄芯片NFT幸运值*ROUND(1+0.04*英雄芯片NFT星数,3)) return ($grade>4?1:0)*($lucky*round(1+0.04*$grade,3));