358 lines
16 KiB
PHP
358 lines
16 KiB
PHP
<?php
|
||
|
||
namespace services;
|
||
|
||
require_once('mt/AttrHelper.php');
|
||
require_once('mt/Item.php');
|
||
require_once('mt/FormulaPvp.php');
|
||
require_once('mt/HeroQuality.php');
|
||
require_once('mt/GunQuality.php');
|
||
|
||
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)
|
||
{
|
||
//PVP角色NFT每日获得极限*(50%*[每局排名TopX%对应比例]+25%*[每局PK人数排名TopX%对应比例]+15%*[每局英雄属性排名TopX%对应比例]+5%*[每局武器属性排名TopX%对应比例]+5%*[每局存活时间排名TopX%对应比例])
|
||
$upLimit = $heroDto['ceg_uplimit'];
|
||
$rankedTopX= getXVal($params, 'ranked_topx');
|
||
$killsTopX = getXVal($params, 'kills_topx');
|
||
$heroTopX = getXVal($params, 'hero_topx');
|
||
$weaponTopX = getXVal($params, 'weapon_topx');
|
||
$survivalTopX = getXVal($params, 'survival_topx');
|
||
$meta = mt\FormulaPvp::getByRanked($rankedTopX);
|
||
if (!$meta) {
|
||
return 0;
|
||
}
|
||
$ceg = $upLimit *
|
||
(
|
||
(0.5 * $rankedTopX * $meta['ranked_topx']) +
|
||
(0.25 * $killsTopX * $meta['kills_topx']) +
|
||
(0.15 * $heroTopX * $meta['hero_topx']) +
|
||
(0.5 * $weaponTopX * $meta['weapon_topx']) +
|
||
(0.5 * $survivalTopX * $meta['survival_topx'])
|
||
);
|
||
return round($ceg);
|
||
}
|
||
|
||
public static function calcHeroPveCeg($heroDb, $uplimit)
|
||
{
|
||
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)
|
||
{
|
||
//PVP武器NFT每日获得极限*(50%*[每局排名TopX%对应比例]+25%*[每局PK人数排名TopX%对应比例]+15%*[每局英雄属性排名TopX%对应比例]+5%*[每局武器属性排名TopX%对应比例]+5%*[每局存活时间排名TopX%对应比例])
|
||
$upLimit = $weaponDto['ceg_uplimit'];
|
||
$rankedTopX= getXVal($params, 'ranked_topx');
|
||
$killsTopX = getXVal($params, 'kills_topx');
|
||
$heroTopX = getXVal($params, 'hero_topx');
|
||
$weaponTopX = getXVal($params, 'weapon_topx');
|
||
$survivalTopX = getXVal($params, 'survival_topx');
|
||
$meta = mt\FormulaPvp::getByRanked($rankedTopX);
|
||
if (!$meta) {
|
||
return 0;
|
||
}
|
||
$ceg = $upLimit *
|
||
(
|
||
(0.5 * $rankedTopX * $meta['ranked_topx']) +
|
||
(0.25 * $killsTopX * $meta['kills_topx']) +
|
||
(0.15 * $heroTopX * $meta['hero_topx']) +
|
||
(0.5 * $weaponTopX * $meta['weapon_topx']) +
|
||
(0.5 * $survivalTopX * $meta['survival_topx'])
|
||
);
|
||
return round($ceg);
|
||
}
|
||
|
||
public static function calcWeaponPveCeg($weaponDb)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
public static function getHeroPvpTiliTotalValue($heroDb)
|
||
{
|
||
//ROUND((0.0241*角色NFT阶数^3-0.5675*角色NFT阶数^2+7.1798*角色NFT阶数+2.4114)+(0.0161*角色幸运值^3-1.2943*角色幸运值^2+36.5664*角色幸运值-336.144),0)+系统参数
|
||
$sysParam = 0;
|
||
$lucky = 0;
|
||
$upLimit = round(
|
||
(
|
||
0.0241*pow($heroDb['quality'],3) -
|
||
0.5675*pow($heroDb['quality'],2) +
|
||
7.1798*$heroDb['quality'] +
|
||
2.4114
|
||
) +
|
||
(
|
||
0.0161*pow($lucky, 3) -
|
||
1.2943*pow($lucky, 2) +
|
||
36.5664*$lucky -
|
||
336.144
|
||
)
|
||
) + $sysParam;
|
||
return $upLimit;
|
||
}
|
||
|
||
public static function getHeroPveTiliTotalValue($heroDb)
|
||
{
|
||
//ROUND((0.0563*角色NFT阶数^3-1.3243*角色NFT阶数^2+16.753*角色NFT阶数+5.6266)+(0.0375*角色幸运值^3-3.02*角色幸运值^2+85.3217*角色幸运值-784.3361),0)+系统参数
|
||
$sysParam = 0;
|
||
$lucky = 0;
|
||
$upLimit = round(
|
||
(
|
||
0.0563*pow($heroDb['quality'],3) -
|
||
1.3243*pow($heroDb['quality'],2) +
|
||
16.753*$heroDb['quality'] +
|
||
5.6266
|
||
) +
|
||
(
|
||
0.0375*pow($lucky, 3) -
|
||
3.02*pow($lucky, 2) +
|
||
85.3217*$lucky -
|
||
784.3361
|
||
)
|
||
) + $sysParam;
|
||
return $upLimit;
|
||
}
|
||
|
||
public static function getWeaponPvpDurabilityTotalValue($weaponDb)
|
||
{
|
||
//ROUND((0.0067*武器NFT阶数^3-0.1558*武器NFT阶数^2+1.9758*武器NFT阶数+0.8033)+(0.0044*武器幸运值^3-0.3564*武器幸运值^2+10.0625*武器幸运值-92.3784),0)+系统参数
|
||
$sysParam = 0;
|
||
$lucky = 0;
|
||
$upLimit = round(
|
||
(
|
||
0.0067*pow($heroDb['quality'],3) -
|
||
0.1558*pow($heroDb['quality'],2) +
|
||
1.9758*$heroDb['quality'] +
|
||
0.8033
|
||
) +
|
||
(
|
||
0.0044*pow($lucky, 3) -
|
||
0.3564*pow($lucky, 2) +
|
||
10.0625*$lucky -
|
||
92.3784
|
||
)
|
||
) + $sysParam;
|
||
return $upLimit;
|
||
}
|
||
|
||
public static function getWeaponPveDurabilityTotalValue($weaponDb)
|
||
{
|
||
//ROUND((0.0155*武器NFT阶数^3-0.3637*武器NFT阶数^2+4.6102*武器NFT阶数+1.8745)+(0.0104*武器幸运值^3-0.8315*武器幸运值^2+23.4792*武器幸运值-215.5496),0)+系统参数
|
||
$sysParam = 0;
|
||
$lucky = 0;
|
||
$upLimit = round(
|
||
(
|
||
0.0155*pow($heroDb['quality'],3) -
|
||
0.3637*pow($heroDb['quality'],2) +
|
||
4.6102*$heroDb['quality'] +
|
||
1.8745
|
||
) +
|
||
(
|
||
0.0104*pow($lucky, 3) -
|
||
0.8315*pow($lucky, 2) +
|
||
23.4792*$lucky -
|
||
215.5496
|
||
)
|
||
) + $sysParam;
|
||
return $upLimit;
|
||
}
|
||
|
||
public static function calcHeroPvpTiliConsume($heroDb)
|
||
{
|
||
//ROUND((最大角色体力值-当前剩余体力值)*(PVP角色体力总价值+PVE角色体力总价值)/最大角色体力值,0)
|
||
$heroMeta = mt\Item::get($heroDb['hero_id']);
|
||
if (!$heroMeta) {
|
||
return 0;
|
||
}
|
||
$cost = round(
|
||
($heroMeta['init_tili'] - $heroDb['hero_tili']) *
|
||
(1) /
|
||
$heroMeta['init_tili']
|
||
);
|
||
return $cost;
|
||
}
|
||
|
||
public static function calcWeaponPvpDurabilityConsume($weaponDb)
|
||
{
|
||
//ROUND((最大武器耐久度-当前剩余耐久度)*(PVP武器耐久度总价值+PVE武器耐久度总价值)/最大武器耐久度,0)
|
||
return 0;
|
||
}
|
||
|
||
//CEG折扣比率
|
||
public static function CEG_Discount_Rate(){
|
||
//CEG_Discount_Rate=ROUND(CEG_Dynamic_Index /( CEG_Dynamic_Price / CEG_Base_Price),3)
|
||
return 1;
|
||
}
|
||
|
||
//英雄芯片劳力值
|
||
public static function Hero_Chip_Labor_Value(){
|
||
return 1;
|
||
}
|
||
|
||
//武器芯片劳力值
|
||
public static function Weapon_Chip_Labor_Value(){
|
||
return 1;
|
||
}
|
||
|
||
//芯片升星累计成本
|
||
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::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::CEG_Discount_Rate();
|
||
|
||
}
|
||
|
||
//芯片升星成本
|
||
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::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 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 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);
|
||
}
|
||
|
||
//每日枪械芯片体力值衰减百分比
|
||
public static function Weapon_Chip_DA_Value($grand){
|
||
//Weapon_Chip_DA_Value=MAX(0,ROUND((Chip_Payback_Period-Chip_Attenuation_Parameter*Weapon_Chip_Labor_Value)/((1-Chip_Attenuation_Parameter/2)* Chip_Payback_Period^2)/ROUND(1+0.04*武器芯片星数,3),4))*(1+0.1*ROUND(SIN(Weapon_Chip_Labor_Value),2))
|
||
$num = max(0,round((self::Chip_Payback_Period($grand)-self::Chip_Attenuation_Parameter($grand)*self::Weapon_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::Weapon_Chip_Labor_Value()),2));
|
||
return round($num,5);
|
||
}
|
||
|
||
//芯片升级MINT费用
|
||
public static function Chip_Need_Mint_Cost($grand){
|
||
// 芯片升星累计MINT成本=(SIGN(chip星级>=5)*SIGN(chip星级<=10)*ROUND(91*chip星级*(chip星级-6.06)/100+1000/100,0)*100+SIGN(chip星级>=11)*SIGN(chip星级<=15)*ROUND(364.29*chip星级*(chip星级-17.847)/100+33446/100,0)*100)*CEG_Discount_Rate
|
||
return ($grand>=5?1:0)*($grand<=10?1:0)*round(91*$grand*($grand-6.06)/100+1000/100,0)*100+($grand>=11?1:0)*($grand<=15?1:0)*round(364.29*$grand*($grand-17.847)/100+33446/100,0)*100*self::CEG_Discount_Rate();
|
||
}
|
||
|
||
//芯片NFT拆卸MINT费用
|
||
public static function Chip_Demount_Mint($tili){
|
||
return round($tili*10*self::CEG_Discount_Rate());
|
||
}
|
||
|
||
|
||
}
|