1
This commit is contained in:
parent
5e662854ee
commit
20aaec0787
@ -4,10 +4,11 @@ require_once('models/Chip.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Nft.php');
|
||||
require_once('mt/ChipAttr.php');
|
||||
require_once('services/FormulaService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('phpcommon/tglog.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
|
||||
|
||||
@ -15,10 +16,10 @@ use models\Chip;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\User;
|
||||
use models\Nft;
|
||||
use services\FormulaService;
|
||||
use services\NftService;
|
||||
use services\LogService;
|
||||
use phpcommon\SqlHelper;
|
||||
use phpcommon\TGLog;
|
||||
|
||||
class ChipController extends BaseAuthedController
|
||||
{
|
||||
@ -144,6 +145,7 @@ class ChipController extends BaseAuthedController
|
||||
if (!$this->_doDemount($unique_id,$token_id)){
|
||||
return;
|
||||
}
|
||||
$this->_writeLog($token_id); //埋点
|
||||
$hero = Hero::toDto(Hero::find($unique_id));
|
||||
$propertyChgService->addHeroChg();
|
||||
$this->_rspData([
|
||||
@ -154,6 +156,7 @@ class ChipController extends BaseAuthedController
|
||||
if (! $this->_doDemountGun($unique_id,$token_id)){
|
||||
return;
|
||||
}
|
||||
$this->_writeLog($token_id); //埋点
|
||||
$gun = Gun::toDto(Gun::find($unique_id));
|
||||
$propertyChgService->addGunChg();
|
||||
$this->_rspData([
|
||||
@ -179,6 +182,7 @@ class ChipController extends BaseAuthedController
|
||||
if (! $this->_doDemount($unique_id,$token_id_old)){
|
||||
return;
|
||||
}
|
||||
$this->_writeLog($token_id_old); //埋点
|
||||
if (! $this->_doInlayHero($unique_id,$token_id_new)){
|
||||
return;
|
||||
}
|
||||
@ -192,6 +196,7 @@ class ChipController extends BaseAuthedController
|
||||
if (! $this->_doDemountGun($unique_id,$token_id_old)){
|
||||
return;
|
||||
}
|
||||
$this->_writeLog($token_id_old); //埋点
|
||||
if (! $this->_doInlayGun($unique_id,$token_id_new)){
|
||||
return;
|
||||
}
|
||||
@ -328,11 +333,11 @@ class ChipController extends BaseAuthedController
|
||||
|
||||
public function syntheticChip(){
|
||||
$token_id_main = trim(getReqVal('token_id_main', 0));
|
||||
$token_id_param = explode(' ',getReqVal('token_id_param', 0));
|
||||
if (! $token_id_main || count($token_id_param)<=0 ) {
|
||||
$this->_rspErr(1, 'Please enter instructions');
|
||||
return;
|
||||
}
|
||||
$token_id_param = array_filter(explode(' ',getReqVal('token_id_param', 0)));
|
||||
// if (! $token_id_main || count($token_id_param)<=0 ) {
|
||||
// $this->_rspErr(1, 'Please enter instructions token_id_param');
|
||||
// return;
|
||||
// }
|
||||
$chip_main = Chip::getChipByTokenId($token_id_main);
|
||||
$upgrade_cost = \services\FormulaService::getChipUpgradeCost($chip_main['chip_grade']+1);
|
||||
if ($upgrade_cost==0){
|
||||
@ -343,19 +348,28 @@ class ChipController extends BaseAuthedController
|
||||
foreach ($token_id_param as $val){
|
||||
$chip_param = Chip::getChipByTokenId($val);
|
||||
$cumulative_cost += \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']);
|
||||
Chip::deleteChip(['token_id'=>$val]);
|
||||
// Chip::deleteChip(['token_id'=>$val]);
|
||||
}
|
||||
$this->_rspData([
|
||||
'state' => 0,
|
||||
'data' => [
|
||||
'main'=>$token_id_main,
|
||||
'param'=>$token_id_param,
|
||||
'main_cost'=>$upgrade_cost,
|
||||
'param_cost'=>$cumulative_cost,
|
||||
],
|
||||
]);return;
|
||||
$num = round(round(($cumulative_cost/$upgrade_cost),5)*10000);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addChip();
|
||||
if ($num<rand(1,10000)){
|
||||
if ($num<rand(1,10000)){ echo 'NO';die;
|
||||
//合成失败
|
||||
$this->_rspData([
|
||||
'state' => 0,
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
]);
|
||||
return;
|
||||
}else{
|
||||
}else{echo 'OK';die;
|
||||
//合成成功
|
||||
$this->_upgraded($chip_main);
|
||||
$chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main));
|
||||
@ -548,7 +562,7 @@ class ChipController extends BaseAuthedController
|
||||
// $this->_rspOk();
|
||||
// $a = mt\Parameter::getByName('CEG_Parameter');
|
||||
$a =FormulaService::Hero_Parts_Synthetic_Cost();
|
||||
print_r($a);
|
||||
print_r($_SERVER);
|
||||
}
|
||||
|
||||
|
||||
@ -835,4 +849,25 @@ class ChipController extends BaseAuthedController
|
||||
}
|
||||
}
|
||||
|
||||
private function _writeLog($token_id){
|
||||
$userDb = User::find($this->_getAccountId());
|
||||
$chipDb = Chip::getChipByTokenId($token_id);
|
||||
$nftDb = Nft::getNft($token_id);
|
||||
{
|
||||
$itemMeta = \mt\Item::get($nftDb['item_id']);
|
||||
$nft = array(
|
||||
'id' => $itemMeta['id'],
|
||||
'name' => $itemMeta['name'],
|
||||
'type' => '芯片NFT',
|
||||
'level' => $chipDb['chip_grade'],
|
||||
'createtime' => $nftDb['createtime'],
|
||||
'is_ceg' => 1,
|
||||
);
|
||||
$event = array(
|
||||
'name' => LogService::CHIP_DEMOUNT,
|
||||
);
|
||||
// LogService::jsonContentToLog($userDb,$nft,$event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
10
webapp/services/LogService.php
Normal file
10
webapp/services/LogService.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace services;
|
||||
|
||||
|
||||
class LogService
|
||||
{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user