From 5b8157a0369fe8c3022e6520625408d06d61e30e Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 24 Aug 2022 16:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8B=B1=E9=9B=84=E5=92=8C?= =?UTF-8?q?=E6=9E=AA=E6=A2=B0=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Chip.py | 13 ++++++ doc/Gun.py | 14 +++++++ doc/Hero.py | 14 +++++++ doc/_common.py | 8 +++- sql/gamedb.sql | 3 +- webapp/controller/ChipController.class.php | 45 +++++++++++++------- webapp/controller/GunController.class.php | 45 ++++++++++++++++++++ webapp/controller/HeroController.class.php | 48 ++++++++++++++++++++++ webapp/services/FormulaService.php | 39 ++++++++++++++++-- 9 files changed, 208 insertions(+), 21 deletions(-) diff --git a/doc/Chip.py b/doc/Chip.py index e6c3b4b0..9ecfb6de 100644 --- a/doc/Chip.py +++ b/doc/Chip.py @@ -198,6 +198,19 @@ class Chip(object): ['token_ids', '', '芯片token id 例如:token_id1 token_id2 token_id3'], ], '芯片信息'] ] + },{ + 'name': 'lockChip', + 'desc': '芯片加锁', + 'group': 'Chip', + 'url': 'webapp/index.php?c=Chip&a=lockChip', + 'params': [ + _common.ReqHead(), + ['token_id', '', '芯片token id'], + ['state', '', '1 加锁 ;0 释放锁'], + ], + 'response': [ + _common.RspHead() + ] }, diff --git a/doc/Gun.py b/doc/Gun.py index dffce062..18ee217c 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -89,4 +89,18 @@ class Gun(object): ['property_chg', _common.PropertyChg(), '属性变更'], ] }, + { + 'name': 'gunDetails', + 'desc': '武器详情', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=gunDetails', + 'params': [ + _common.ReqHead(), + ['unique_id', 0, '枪械唯一id'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.Gun()], '枪械信息'] + ] + }, ] diff --git a/doc/Hero.py b/doc/Hero.py index 1d1ad8c3..624e7806 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -150,4 +150,18 @@ class Hero(object): ['new_hero', _common.Hero(), '英雄-新'], ] }, + { + 'name': 'heroDetails', + 'desc': '英雄详情', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=heroDetails', + 'params': [ + _common.ReqHead(), + ['unique_id', 0, '英雄唯一id'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.Hero()], '英雄信息'] + ] + }, ] diff --git a/doc/_common.py b/doc/_common.py index 355dea7b..a81c9268 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -87,6 +87,8 @@ class Gun(object): ['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'], ['unlock_lefttime', 0, '解锁剩余时间(单位秒)'], ['trade_locktime', 0, '出售锁定时间(升级或者升阶完成后触发),单位秒,只锁交易,其他的操作仍可进行'], + ['chip_ids', '', '镶嵌的芯片主键id组'], + ['!chip_core', [ChipCore()], '核心加成'], ] class GunSkin(object): @@ -232,6 +234,7 @@ class Hero(object): ['def', 0, '防御'], ['advanced_count', 0, '进阶次数'], ['lukcy', 0, '幸运'], + ['chip_ids', '', '镶嵌的芯片主键id组'], ['!chip_core', [ChipCore()], '核心加成'], ] @@ -668,9 +671,10 @@ class Chip(object): ['supper_state', 0, '是否锁定:0 正常;1 锁住'], ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了'], ['!rand_attr', [ChipAttr()], '属性'], - ['lucky_temporary', '', '升级成功所需增加的幸运值'], + ['lucky_temporary', '', '升级成功后的幸运值'], ['lucky_final', '', '最终幸运值'], - ['strength', '', '最终体力值'], + ['strength_max', '', '最大体力值'], + ['strength', '', '前一天体力值'], ['strength_temporary', '', '升级成功所得出的总体力值'], ] diff --git a/sql/gamedb.sql b/sql/gamedb.sql index eda8259a..8657af66 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -229,7 +229,8 @@ CREATE TABLE `t_chip` ( `last_get_gold_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后获取金币的时间', `lucky_temporary` varchar(10) NOT NULL DEFAULT '0' COMMENT '临时幸运值', `lucky_final` varchar(10) NOT NULL DEFAULT '0' COMMENT '最终幸运值', - `strength` varchar(10) NOT NULL DEFAULT '0' COMMENT '体力值', + `strength_max` varchar(10) NOT NULL DEFAULT '0' COMMENT '最大体力值', + `strength` varchar(10) NOT NULL DEFAULT '0' COMMENT '前一天体力值', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index 90f9cc1f..c8ab9af4 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -244,8 +244,6 @@ class ChipController extends BaseAuthedController $this->_rspErr(1, 'Please enter instructions'); return; } - - $chip_main = Chip::getChipByTokenId($token_ids[0]); $chip_param = Chip::getChipByTokenId($token_ids[1]); if ($chip_param['supper_state'] == 1 || $chip_param['inlay_state'] == 1 || $chip_param['state'] == -1){ @@ -256,14 +254,8 @@ class ChipController extends BaseAuthedController $this->_rspErr(1, "The selected material is too high grade"); return; } - if ($chip_param['state']){ - Chip::update($token_ids[1],['state'=>0]); - $cost = 0; - }else{ - Chip::update($token_ids[1],['state'=>1]); - $cost = \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']); - } - $this->_rspData(['data'=>$cost]); + $cost = \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']); + $this->_rspData(['data'=>$cost]); } public function syntheticChip(){ @@ -294,7 +286,7 @@ class ChipController extends BaseAuthedController //合成成功 $this->_upgraded($chip_main); $chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main)); - $chip_new['strength_temporary'] = \services\FormulaService::getChipPhysicalStrengthValue($chip_new['chip_grade'],$chip_new['lucky_temporary']); + $chip_new['strength_temporary'] = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip_new['chip_grade'],$chip_new['lucky_temporary']); $this->_rspData(['data'=>$chip_new]); } } @@ -306,10 +298,13 @@ class ChipController extends BaseAuthedController return; } $chip = Chip::getChipByTokenId($token_id); + $strength_max = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$chip['lucky_temporary']); $fieldsKv = [ + 'supper_state' => 0, 'lucky_final'=>$chip['lucky_temporary'], 'lucky_temporary'=>0, - 'strength' => \services\FormulaService::getChipPhysicalStrengthValue($chip['chip_grade'],$chip['lucky_temporary']) + 'strength_max' => $strength_max, + 'strength' => $strength_max ]; Chip::update($chip['token_id'],$fieldsKv); $this->_rspOk(); @@ -323,6 +318,7 @@ class ChipController extends BaseAuthedController } $chip = Chip::getChipByTokenId($token_id); $fieldsKv = [ + 'supper_state' => 0, 'lucky_temporary'=>0, ]; Chip::update($chip['token_id'],$fieldsKv); @@ -355,7 +351,7 @@ class ChipController extends BaseAuthedController $chipList = Chip::all($chip['chip_type']); $chipDtoList = array(); foreach ($chipList as $item) { - if ($item['supper_state']==0 && $item['inlay_state']==0 && $item['state']==0 && $item['token_id'] != $token_id && $item['chip_grade'] <= $chip['chip_grade']){ + if ($item['supper_state']==0 && $item['inlay_state']==0 && $item['state']!=-1 && $item['token_id'] != $token_id && $item['chip_grade'] <= $chip['chip_grade']){ array_push($chipDtoList, $item); } }; @@ -411,6 +407,21 @@ class ChipController extends BaseAuthedController $this->_rspData(['data'=>['cost'=>$cumulative_cost,'token_ids'=>implode(' ',$token_id_arr)]]); } + public function lockChip(){ + $token_id = trim(getReqVal('token_id', 0)); + $state = trim(getReqVal('state', 0)); + if (! $token_id){ + $this->_rspErr(1, 'Please enter instructions'); + return; + } + if ($state == 1){ + Chip::update($token_id,['state'=>-1]); + }else{ + Chip::update($token_id,['state'=>0]); + } + $this->_rspOk(); + } + private function _doInlayHero($hero_id,$token_id){ $chip = Chip::getChipByTokenId($token_id); @@ -628,8 +639,14 @@ class ChipController extends BaseAuthedController if ($new_grade == 3 || $new_grade == 5){ Chip::updateRandAttr($chip); } + $lucky = ltrim(\services\FormulaService::getChipLuckyValue($new_grade),'-') ; - Chip::update($chip['token_id'],['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade]); + if ($new_grade>=5){ + $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade,'supper_state'=>1]; + }else{ + $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade]; + } + Chip::update($chip['token_id'],$where); } private function _bestFun($upgrade_cost,$chip_param,$chip_param_out){ diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index 071d87b2..4769e831 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -10,6 +10,7 @@ require_once('models/GunTalent.php'); require_once('models/User.php'); require_once('models/Gun.php'); require_once('models/Bag.php'); +require_once('models/Chip.php'); require_once('services/PropertyChgService.php'); @@ -19,6 +20,7 @@ use models\GunTalent; use models\User; use models\Gun; use models\Bag; +use models\Chip; class GunController extends BaseAuthedController { @@ -40,6 +42,49 @@ class GunController extends BaseAuthedController { )); } + public function gunDetails(){ + $unique_id = trim(getReqVal('unique_id', 0)); + if ( ! $unique_id) { + $this->_rspErr(1, 'Please enter instructions'); + return; + } + $chipAttr = []; + $gun = Gun::find($unique_id); + $chipIdsArr = explode('|',$gun['chip_ids']); + foreach ($chipIdsArr as $val){ + $chip = Chip::toDto(Chip::getChipByIdx($val)); + foreach ($chip['rand_attr'] as $v){ + array_push($chipAttr,$v); + } + } + $gun_attr = emptyReplace(json_decode($gun['rand_attr'], true), array()); + \mt\AttrHelper::mergeAttr($gun_attr,$chipAttr); + $gun['rand_attr'] = $gun_attr; + $chipCore = []; + if (count($chipIdsArr) == 4){ + $min = 15; + foreach ($chipIdsArr as $val){ + $chip = Chip::getChipByIdx($val); + if ($chip['chip_grade']<$min){ + $min = $chip['chip_grade']; + } + } + $chipCoreList = getMetaTable('chipCore@chipCore.php'); + foreach ($chipCoreList as $val){ + if ($val['chip_core_type']==2 && $val['chip_core_lv']<=$min){ + array_push($chipCore,$val); + } + } + $gun['chip_core'] = $chipCore; + }else{ + $gun['chip_core'] = []; + } + + $this->_rspData(array( + 'data' => $gun + )); + } + public function talentList() { $talentList = array(); diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index c5c3fcaa..7dd6249a 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -12,15 +12,19 @@ require_once('mt/Parameter.php'); require_once('models/Hero.php'); require_once('models/Bag.php'); require_once('models/HeroSkin.php'); +require_once('models/Chip.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); require_once('services/RankActivityService.php'); + + use phpcommon\SqlHelper; use models\Hero; use models\Bag; use models\HeroSkin; +use models\Chip; class HeroController extends BaseAuthedController { @@ -35,6 +39,50 @@ class HeroController extends BaseAuthedController { )); } + public function heroDetails() + { + $unique_id = trim(getReqVal('unique_id', 0)); + if ( ! $unique_id) { + $this->_rspErr(1, 'Please enter instructions'); + return; + } + $chipAttr = []; + $hero = Hero::find($unique_id); + $chipIdsArr = explode('|',$hero['chip_ids']); + foreach ($chipIdsArr as $val){ + $chip = Chip::toDto(Chip::getChipByIdx($val)); + foreach ($chip['rand_attr'] as $v){ + array_push($chipAttr,$v); + } + } + $hero_attr = emptyReplace(json_decode($hero['rand_attr'], true), array()); + \mt\AttrHelper::mergeAttr($hero_attr,$chipAttr); + $hero['rand_attr'] = $hero_attr; + $chipCore = []; + if (count($chipIdsArr) == 4){ + $min = 15; + foreach ($chipIdsArr as $val){ + $chip = Chip::getChipByIdx($val); + if ($chip['chip_grade']<$min){ + $min = $chip['chip_grade']; + } + } + $chipCoreList = getMetaTable('chipCore@chipCore.php'); + foreach ($chipCoreList as $val){ + if ($val['chip_core_type']==1 && $val['chip_core_lv']<=$min){ + array_push($chipCore,$val); + } + } + $hero['chip_core'] = $chipCore; + }else{ + $hero['chip_core'] = []; + } + + $this->_rspData(array( + 'data' => $hero + )); + } + public function skinList() { $skinList = array(); diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index 1d05a507..1f258905 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -271,7 +271,7 @@ class FormulaService extends BaseService { return 0; } - public static function getCegDiscountRate(){ + public static function CEG_Discount_Rate(){ //CEG_Discount_Rate=ROUND(CEG_Dynamic_Index /( CEG_Dynamic_Price / CEG_Base_Price),3) return 1; } @@ -279,7 +279,7 @@ class FormulaService extends BaseService { //芯片升星累计成本 public static function getChipCumulativeCost($grade){ //( SIGN(芯片星级<6)*(15*芯片星级*(芯片星级-1)+10)+SIGN(芯片星级>5)*SIGN(芯片星级<10)*(80*(芯片星级-4)*( 芯片星级-3)+50) +SIGN(芯片星级>9)*SIGN(芯片星级<14)*(370*(芯片星级-8)*( 芯片星级-7)*(2*芯片星级-15)/6+80*(芯片星级-8)+2100) +SIGN(芯片星级>13)*SIGN(芯片星级<16)*(600*(芯片星级-8)*(芯片星级-7)*(2*芯片星级-15)/6-14000)) *CEG_Discount_Rate - return (($grade<6?1:0)*(15*$grade*($grade-1)+10)+($grade>5?1:0)*($grade<10?1:0)*(80*($grade-4)*( $grade-3)+50) +($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*( $grade-7)*(2*$grade-15)/6+80*($grade-8)+2100) +($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-7)*(2*$grade-15)/6-14000)) *self::getCegDiscountRate(); + return (($grade<6?1:0)*(15*$grade*($grade-1)+10)+($grade>5?1:0)*($grade<10?1:0)*(80*($grade-4)*( $grade-3)+50) +($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*( $grade-7)*(2*$grade-15)/6+80*($grade-8)+2100) +($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-7)*(2*$grade-15)/6-14000)) *self::CEG_Discount_Rate(); //( SIGN(芯片星级<6)*((15*芯片星级+10)*(芯片星级-1)+10)+SIGN(芯片星级>5)*SIGN(芯片星级<10)*(80*(芯片星级-4)*( 芯片星级-3)+90) +SIGN(芯片星级>9)*SIGN(芯片星级<14)*(370*(芯片星级-8)*( 芯片星级-7)*(2*芯片星级-15)/6+80*(芯片星级-8)+2140) +SIGN(芯片星级>13)*SIGN(芯片星级<16)*(600*(芯片星级-8)*(芯片星级-7)*(2*芯片星级-15)/6-13960)) *CEG_Discount_Rate /* return (($grade<6?1:0)*((15*$grade+10)*($grade-1)+10)+($grade>5?1:0)*($grade<10?1:0)*(80*($grade-4)*($grade-3)+90)+($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*($grade-7)*(2*$grade-15)/6+80*($grade-8)+2140)+($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-7)*(2*$grade-15)/6-13960))*self::getCegDiscountRate();*/ @@ -289,18 +289,49 @@ class FormulaService extends BaseService { //芯片升星成本 public static function getChipUpgradeCost($grade){ //(SIGN(芯片星级=1)*10+SIGN(芯片星级<6)*SIGN(芯片星级>1)*(30*(芯片星级-1))+SIGN(芯片星级>5)*SIGN(芯片星级<10)*(160*(芯片星级-4))-SIGN(芯片星级=6)*100+SIGN(芯片星级>9)*SIGN(芯片星级<14)*(370*(芯片星级-8)^2+80)+SIGN(芯片星级=10)*100 +SIGN(芯片星级>13)*SIGN(芯片星级<16)*(600*(芯片星级-8)^2)-SIGN(芯片星级=14)*3850) *CEG_Discount_Rate - return (($grade==1?1:0)*10+($grade<6?1:0)*($grade>1?1:0)*(30*($grade-1))+($grade>5?1:0)*($grade<10?1:0)*(160*($grade-4))-($grade==6?1:0)*100+($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*($grade-8)+80)+($grade==10?1:0)*100+($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-8))-($grade==14?1:0)*3850)*self::getCegDiscountRate(); + return (($grade==1?1:0)*10+($grade<6?1:0)*($grade>1?1:0)*(30*($grade-1))+($grade>5?1:0)*($grade<10?1:0)*(160*($grade-4))-($grade==6?1:0)*100+($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*($grade-8)+80)+($grade==10?1:0)*100+($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-8))-($grade==14?1:0)*3850)*self::CEG_Discount_Rate(); } + //芯片幸运值 public static function getChipLuckyValue($grade){ //芯片幸运值=SIGN(芯片星数>4)*ROUND( 0.00419*芯片星数^5-0.0705*芯片星数^4 +0.24*芯片星数^3 +8.5*芯片星数^2-39.9*芯片星数+38,1) 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 getChipPhysicalStrengthValue($grade,$lucky){ + //芯片体力值 + 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)); } + //英雄芯片劳力值 + public static function Hero_Chip_Labor_Value(){ + return 1; + } + + //武器芯片劳力值 + public static function Weapon_Chip_Labor_Value(){ + return 1; + } + + //芯片回本周期(参数单位:天) + public static function Chip_Payback_Period($grade){ + //ROUND( -0.0095*芯片星数^3+0.0942*芯片星数^2+5.8425*芯片星数+24.7,0) + return round(-0.0095*pow($grade,3)+0.0942*pow($grade,2)+5.8425*$grade+24.7,0); + } + + //芯片衰减参数 + public static function Chip_Attenuation_Parameter($grade){ + //ROUND(-0.0000507*芯片星数^3+0.0024*芯片星数^2-0.0512*芯片星数+0.785,4) + return round(-0.0000507*pow($grade,3)+0.0024*pow($grade,2)-0.0512*$grade+0.785,4); + } + + public static function Hero_Chip_PSA_Value($grand){ + //Hero_Chip_PSA_Value=MAX(0,ROUND((Chip_Payback_Period-Chip_Attenuation_Parameter* Hero_Chip_Labor_Value)/((1-Chip_Attenuation_Parameter /2)* Chip_Payback_Period ^2)/ROUND(1+0.04*英雄芯片星数,3),4))*(1+0.1*ROUND(SIN(Hero_Chip_Labor_Value),2)) + $num = max(0,round((self::Chip_Payback_Period($grand)-self::Chip_Attenuation_Parameter($grand)*self::Hero_Chip_Labor_Value())/((1-self::Chip_Attenuation_Parameter($grand)/2)*pow(self::Chip_Payback_Period($grand),2))/round(1+0.04*$grand,3),4))*(1+0.1*round(sin(self::Hero_Chip_Labor_Value()),2)); + return round($num,5); + } + + }