add chip
This commit is contained in:
parent
7489d1e32f
commit
761fce24aa
15
doc/Chip.py
15
doc/Chip.py
@ -53,12 +53,13 @@ class Chip(object):
|
|||||||
'url': 'webapp/index.php?c=Chip&a=inlayChip',
|
'url': 'webapp/index.php?c=Chip&a=inlayChip',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['hero_id', '', '英雄idx'],
|
['type', '', '1 英雄;2 枪械'],
|
||||||
|
['unique_id', '', '英雄或枪械的唯一id'],
|
||||||
['token_id', '', '芯片token id'],
|
['token_id', '', '芯片token id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['!data', [_common.Hero()], '英雄加成信息']
|
['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例']
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
'name': 'demountChip',
|
'name': 'demountChip',
|
||||||
@ -67,12 +68,13 @@ class Chip(object):
|
|||||||
'url': 'webapp/index.php?c=Chip&a=demountChip',
|
'url': 'webapp/index.php?c=Chip&a=demountChip',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['hero_id', '', '英雄idx'],
|
['type', '', '1 英雄;2 枪械'],
|
||||||
|
['unique_id', '', '英雄或枪械的唯一id'],
|
||||||
['token_id', '', '芯片token id'],
|
['token_id', '', '芯片token id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['!data', [_common.Hero()], '英雄加成信息']
|
['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例']
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
'name': 'replaceChip',
|
'name': 'replaceChip',
|
||||||
@ -81,13 +83,14 @@ class Chip(object):
|
|||||||
'url': 'webapp/index.php?c=Chip&a=replaceChip',
|
'url': 'webapp/index.php?c=Chip&a=replaceChip',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['hero_id', '', '英雄idx'],
|
['type', '', '1 英雄;2 枪械'],
|
||||||
|
['unique_id', '', '英雄或枪械的唯一id'],
|
||||||
['token_id_new', '', '新芯片token id'],
|
['token_id_new', '', '新芯片token id'],
|
||||||
['token_id_old', '', '被替换的芯片token id'],
|
['token_id_old', '', '被替换的芯片token id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['!data', [_common.Hero()], '英雄加成信息']
|
['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例']
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
'name': 'aKeyInlayChip',
|
'name': 'aKeyInlayChip',
|
||||||
|
@ -265,6 +265,7 @@ CREATE TABLE `t_gun` (
|
|||||||
`last_pve_get_ceg_time` bigint NOT NULL DEFAULT '0' COMMENT '最后pve获取金币的时间',
|
`last_pve_get_ceg_time` bigint NOT NULL DEFAULT '0' COMMENT '最后pve获取金币的时间',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
`chip_ids` varchar(100) NOT NULL DEFAULT '0' COMMENT '已镶嵌的芯片idx组',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `token_id` (`token_id`),
|
UNIQUE KEY `token_id` (`token_id`),
|
||||||
KEY `account_id` (`account_id`)
|
KEY `account_id` (`account_id`)
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
require_once('models/Chip.php');
|
require_once('models/Chip.php');
|
||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
|
require_once('models/Gun.php');
|
||||||
require_once('mt/ChipAttr.php');
|
require_once('mt/ChipAttr.php');
|
||||||
require_once('mt/AttrHelper.php');
|
require_once('mt/AttrHelper.php');
|
||||||
require_once('services/FormulaService.php');
|
require_once('services/FormulaService.php');
|
||||||
|
|
||||||
use models\Chip;
|
use models\Chip;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
|
use models\Gun;
|
||||||
use services\NftService;
|
use services\NftService;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
@ -23,7 +25,9 @@ class ChipController extends BaseAuthedController
|
|||||||
$chipList = Chip::all($type);
|
$chipList = Chip::all($type);
|
||||||
$chipDtoList = array();
|
$chipDtoList = array();
|
||||||
foreach ($chipList as $item) {
|
foreach ($chipList as $item) {
|
||||||
array_push($chipDtoList, Chip::toDto($item));
|
if ($item['inlay_state'] == 0){
|
||||||
|
array_push($chipDtoList, Chip::toDto($item));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'data' => $chipDtoList,
|
'data' => $chipDtoList,
|
||||||
@ -40,7 +44,9 @@ class ChipController extends BaseAuthedController
|
|||||||
$chipList = Chip::all($type);
|
$chipList = Chip::all($type);
|
||||||
$chipDtoList = array();
|
$chipDtoList = array();
|
||||||
foreach ($chipList as $item) {
|
foreach ($chipList as $item) {
|
||||||
array_push($chipDtoList, Chip::toDto($item));
|
if ($item['inlay_state'] == 0){
|
||||||
|
array_push($chipDtoList, Chip::toDto($item));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$data = $this->_orderByChip($chipDtoList,$order);
|
$data = $this->_orderByChip($chipDtoList,$order);
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
@ -57,7 +63,7 @@ class ChipController extends BaseAuthedController
|
|||||||
$chipList = Chip::all($type);
|
$chipList = Chip::all($type);
|
||||||
$chipDtoList = array();
|
$chipDtoList = array();
|
||||||
foreach ($chipList as $item) {
|
foreach ($chipList as $item) {
|
||||||
if ($item['supper_state']==0 && $item['inlay_state']==0 && $item['state']==0){
|
if ($item['supper_state']==0 && $item['inlay_state']==0){
|
||||||
array_push($chipDtoList, Chip::toDto($item));
|
array_push($chipDtoList, Chip::toDto($item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,73 +73,110 @@ class ChipController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function inlayChip(){
|
public function inlayChip(){
|
||||||
$hero_id = trim(getReqVal('hero_id', 0));
|
$type = trim(getReqVal('type', 0));
|
||||||
|
$unique_id = trim(getReqVal('unique_id', 0));
|
||||||
$token_id = trim(getReqVal('token_id', 0));
|
$token_id = trim(getReqVal('token_id', 0));
|
||||||
if (! $token_id || ! $hero_id) {
|
if (!$type || ! $token_id || ! $unique_id) {
|
||||||
$this->_rspErr(1, 'Please enter instructions');
|
$this->_rspErr(1, 'Please enter instructions');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->_doInlay($hero_id,$token_id);
|
if ($type == 1){
|
||||||
$hero = $this->_inLayNewAttr($hero_id);
|
$this->_doInlayHero($unique_id,$token_id);
|
||||||
$chip_core = $this->_chipCore($hero_id);
|
$hero = $this->_inLayNewAttr($unique_id);
|
||||||
$hero['chip_core'] = $chip_core;
|
$chip_core = $this->_chipCore($unique_id,$type);
|
||||||
$this->_rspData(['data'=>$hero]);
|
$hero['chip_core'] = $chip_core;
|
||||||
|
$this->_rspData(['data'=>$hero]);
|
||||||
|
}else{
|
||||||
|
$this->_doInlayGun($unique_id,$token_id);
|
||||||
|
$gun = $this->_inLayNewAttrGun($unique_id);
|
||||||
|
$chip_core = $this->_chipCore($unique_id,$type);
|
||||||
|
$gun['chip_core'] = $chip_core;
|
||||||
|
$this->_rspData(['data'=>$gun]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function demountChip(){
|
public function demountChip(){
|
||||||
$hero_id = trim(getReqVal('hero_id', 0));
|
$type = trim(getReqVal('type', 0));
|
||||||
|
$unique_id = trim(getReqVal('unique_id', 0));
|
||||||
$token_id = trim(getReqVal('token_id', 0));
|
$token_id = trim(getReqVal('token_id', 0));
|
||||||
if (! $token_id || ! $hero_id) {
|
if (!$type || ! $token_id || ! $unique_id) {
|
||||||
$this->_rspErr(1, 'Please enter instructions');
|
$this->_rspErr(1, 'Please enter instructions');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->_doDemount($hero_id,$token_id);
|
if ($type == 1){
|
||||||
$hero = $this->_inLayNewAttr($hero_id);
|
$this->_doDemount($unique_id,$token_id);
|
||||||
$chip_core = $this->_chipCore($hero_id);
|
$hero = $this->_inLayNewAttr($unique_id);
|
||||||
$hero['chip_core'] = $chip_core;
|
$chip_core = $this->_chipCore($unique_id,$type);
|
||||||
$this->_rspData(['data'=>$hero]);
|
$hero['chip_core'] = $chip_core;
|
||||||
|
$this->_rspData(['data'=>$hero]);
|
||||||
|
}else{
|
||||||
|
$this->_doDemountGun($unique_id,$token_id);
|
||||||
|
$gun = $this->_inLayNewAttrGun($unique_id);
|
||||||
|
$chip_core = $this->_chipCore($unique_id,$type);
|
||||||
|
$gun['chip_core'] = $chip_core;
|
||||||
|
$this->_rspData(['data'=>$gun]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function replaceChip(){
|
public function replaceChip(){
|
||||||
$hero_id = trim(getReqVal('hero_id', 0));
|
$type = trim(getReqVal('type', 0));
|
||||||
|
$unique_id = trim(getReqVal('unique_id', 0));
|
||||||
$token_id_new = trim(getReqVal('token_id_new', 0));
|
$token_id_new = trim(getReqVal('token_id_new', 0));
|
||||||
$token_id_old = trim(getReqVal('token_id_old', 0));
|
$token_id_old = trim(getReqVal('token_id_old', 0));
|
||||||
if (! $token_id_new ||! $token_id_old || ! $hero_id) {
|
if (! $token_id_new ||! $token_id_old || ! $unique_id || !$type) {
|
||||||
$this->_rspErr(1, 'Please enter instructions');
|
$this->_rspErr(1, 'Please enter instructions');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->_doDemount($hero_id,$token_id_old);
|
if ($type == 1){
|
||||||
$this->_doInlay($hero_id,$token_id_new);
|
$this->_doDemount($unique_id,$token_id_old);
|
||||||
$hero = $this->_inLayNewAttr($hero_id);
|
$this->_doInlayHero($unique_id,$token_id_new);
|
||||||
$chip_core = $this->_chipCore($hero_id);
|
$hero = $this->_inLayNewAttr($unique_id);
|
||||||
$hero['chip_core'] = $chip_core;
|
$chip_core = $this->_chipCore($unique_id,$type);
|
||||||
$this->_rspData(['data'=>$hero]);
|
$hero['chip_core'] = $chip_core;
|
||||||
|
$this->_rspData(['data'=>$hero]);
|
||||||
|
}else{
|
||||||
|
$this->_doDemountGun($unique_id,$token_id_old);
|
||||||
|
$this->_doInlayGun($unique_id,$token_id_new);
|
||||||
|
$gun = $this->_inLayNewAttrGun($unique_id);
|
||||||
|
$chip_core = $this->_chipCore($unique_id,$type);
|
||||||
|
$gun['chip_core'] = $chip_core;
|
||||||
|
$this->_rspData(['data'=>$gun]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function aKeyInlayChip(){
|
public function aKeyInlayChip(){
|
||||||
$hero_id = trim(getReqVal('hero_id', 0));
|
$type = trim(getReqVal('type', 0));
|
||||||
if ( ! $hero_id) {
|
$unique_id = trim(getReqVal('unique_id', 0));
|
||||||
|
if ( ! $type || ! $unique_id) {
|
||||||
$this->_rspErr(1, 'Please enter instructions');
|
$this->_rspErr(1, 'Please enter instructions');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$hero = Hero::find($hero_id);
|
if ($type == 1){
|
||||||
if (! $hero){
|
$hero_or_gun = Hero::find($unique_id);
|
||||||
$this->_rspErr(1, 'Not enough hero');
|
}else{
|
||||||
|
$hero_or_gun = Gun::find($unique_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $hero_or_gun){
|
||||||
|
$this->_rspErr(1, 'Not enough hero or gun');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$limit = 0;
|
$limit = 0;
|
||||||
if (! $hero['chip_ids'] ){
|
if (! $hero_or_gun['chip_ids'] ){
|
||||||
$limit = 4;
|
$limit = 4;
|
||||||
}
|
}
|
||||||
if ($hero['chip_ids'] && !strpos($hero['chip_ids'], '|')){
|
if ($hero_or_gun['chip_ids'] && !strpos($hero_or_gun['chip_ids'], '|')){
|
||||||
$limit = 3;
|
$limit = 3;
|
||||||
}
|
}
|
||||||
if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){
|
if ($hero_or_gun['chip_ids'] && strpos($hero_or_gun['chip_ids'], '|')){
|
||||||
$chipIdsArr = explode('|',$hero['chip_ids']);
|
$chipIdsArr = explode('|',$hero_or_gun['chip_ids']);
|
||||||
$limit = 4-count($chipIdsArr);
|
$limit = 4-count($chipIdsArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$chipList = Chip::all(1);
|
$chipList = Chip::all($type);
|
||||||
if (! $chipList){
|
if (! $chipList){
|
||||||
$this->_rspErr(1, 'Not enough chip');
|
$this->_rspErr(1, 'Not enough chip');
|
||||||
return;
|
return;
|
||||||
@ -150,14 +193,23 @@ class ChipController extends BaseAuthedController
|
|||||||
$this->_rspErr(1, 'The chip slot is full');
|
$this->_rspErr(1, 'The chip slot is full');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach ($res as $val){
|
if ($type == 1){
|
||||||
$this->_doInlay($hero_id,$val['token_id']);
|
foreach ($res as $val){
|
||||||
|
$this->_doInlayHero($unique_id,$val['token_id']);
|
||||||
|
}
|
||||||
|
$hero_new = $this->_inLayNewAttr($unique_id);
|
||||||
|
$chip_core = $this->_chipCore($unique_id,$type);
|
||||||
|
$hero_new['chip_core'] = $chip_core;
|
||||||
|
$this->_rspData(['data'=>$hero_new]);
|
||||||
|
}else{
|
||||||
|
foreach ($res as $val){
|
||||||
|
$this->_doInlayGun($unique_id,$val['token_id']);
|
||||||
|
}
|
||||||
|
$gun_new = $this->_inLayNewAttrGun($unique_id);
|
||||||
|
$chip_core = $this->_chipCore($unique_id,$type);
|
||||||
|
$gun_new['chip_core'] = $chip_core;
|
||||||
|
$this->_rspData(['data'=>$gun_new]);
|
||||||
}
|
}
|
||||||
$hero_new = $this->_inLayNewAttr($hero_id);
|
|
||||||
$chip_core = $this->_chipCore($hero_id);
|
|
||||||
$hero_new['chip_core'] = $chip_core;
|
|
||||||
$this->_rspData(['data'=>$hero_new]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeSynthetic(){
|
public function beforeSynthetic(){
|
||||||
@ -172,7 +224,7 @@ class ChipController extends BaseAuthedController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($chip['chip_grade'] == 15){
|
if ($chip['chip_grade'] == 15){
|
||||||
$this->_rspErr(1, "Chip level upper limit");
|
$this->_rspErr(1, "Chip Lv upper limit");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$chip = Chip::toDto($chip);
|
$chip = Chip::toDto($chip);
|
||||||
@ -246,7 +298,7 @@ class ChipController extends BaseAuthedController
|
|||||||
//合成成功
|
//合成成功
|
||||||
$this->_upgraded($chip_main);
|
$this->_upgraded($chip_main);
|
||||||
$chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main));
|
$chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main));
|
||||||
$chip_new['strength_temporary'] = \services\FormulaService::getChipPhysicalStrengthValue($chip_new['chip_grade'],$chip_new['lucky_final']+$chip_new['lucky_temporary']);
|
$chip_new['strength_temporary'] = \services\FormulaService::getChipPhysicalStrengthValue($chip_new['chip_grade'],$chip_new['lucky_temporary']);
|
||||||
$this->_rspData(['data'=>$chip_new]);
|
$this->_rspData(['data'=>$chip_new]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,9 +311,9 @@ class ChipController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
$chip = Chip::getChipByTokenId($token_id);
|
$chip = Chip::getChipByTokenId($token_id);
|
||||||
$fieldsKv = [
|
$fieldsKv = [
|
||||||
'lucky_final'=>$chip['lucky_final']+$chip['lucky_temporary'],
|
'lucky_final'=>$chip['lucky_temporary'],
|
||||||
'lucky_temporary'=>0,
|
'lucky_temporary'=>0,
|
||||||
'strength' => \services\FormulaService::getChipPhysicalStrengthValue($chip['chip_grade'],$chip['lucky_final']+$chip['lucky_temporary'])
|
'strength' => \services\FormulaService::getChipPhysicalStrengthValue($chip['chip_grade'],$chip['lucky_temporary'])
|
||||||
];
|
];
|
||||||
Chip::update($chip['token_id'],$fieldsKv);
|
Chip::update($chip['token_id'],$fieldsKv);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
@ -304,7 +356,7 @@ class ChipController extends BaseAuthedController
|
|||||||
$chip = Chip::getChipByTokenId($token_id);
|
$chip = Chip::getChipByTokenId($token_id);
|
||||||
$upgrade_cost =\services\FormulaService::getChipUpgradeCost($chip['chip_grade']+1); //芯片升星价值
|
$upgrade_cost =\services\FormulaService::getChipUpgradeCost($chip['chip_grade']+1); //芯片升星价值
|
||||||
|
|
||||||
$chipList = Chip::all(1);
|
$chipList = Chip::all($chip['chip_type']);
|
||||||
$chipDtoList = array();
|
$chipDtoList = array();
|
||||||
foreach ($chipList as $item) {
|
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']==0 && $item['token_id'] != $token_id && $item['chip_grade'] <= $chip['chip_grade']){
|
||||||
@ -364,14 +416,7 @@ class ChipController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function _doInlayHero($hero_id,$token_id){
|
||||||
|
|
||||||
public function test(){
|
|
||||||
$chip = Chip::getChipByTokenId(1660629357);
|
|
||||||
print_r($chip);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function _doInlay($hero_id,$token_id){
|
|
||||||
$chip = Chip::getChipByTokenId($token_id);
|
$chip = Chip::getChipByTokenId($token_id);
|
||||||
$hero = Hero::find($hero_id);
|
$hero = Hero::find($hero_id);
|
||||||
if (! $chip || ! $hero){
|
if (! $chip || ! $hero){
|
||||||
@ -395,9 +440,33 @@ class ChipController extends BaseAuthedController
|
|||||||
Chip::updateChipInlayState($token_id,1);
|
Chip::updateChipInlayState($token_id,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _doDemount($hero_id,$token_id){
|
private function _doInlayGun($gun_id,$token_id){
|
||||||
$chip = Chip::getChipByTokenId($token_id);
|
$chip = Chip::getChipByTokenId($token_id);
|
||||||
$hero = Hero::find($hero_id);
|
$gun = Gun::find($gun_id);
|
||||||
|
if (! $chip || ! $gun){
|
||||||
|
$this->_rspErr(1, 'Not enough chip or gun');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (! $gun['chip_ids']){
|
||||||
|
$fieldsKv = ['chip_ids'=>$chip['idx']];
|
||||||
|
}
|
||||||
|
if ($gun['chip_ids'] && !strpos($gun['chip_ids'], '|')){
|
||||||
|
$chipIdsArr = [$gun['chip_ids']];
|
||||||
|
array_push($chipIdsArr,$chip['idx']);
|
||||||
|
$fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
|
||||||
|
}
|
||||||
|
if ($gun['chip_ids'] && strpos($gun['chip_ids'], '|')){
|
||||||
|
$chipIdsArr = explode('|',$gun['chip_ids']);
|
||||||
|
array_push($chipIdsArr,$chip['idx']);
|
||||||
|
$fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
|
||||||
|
}
|
||||||
|
Gun::update($gun_id,$fieldsKv);
|
||||||
|
Chip::updateChipInlayState($token_id,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _doDemount($unique_id,$token_id){
|
||||||
|
$chip = Chip::getChipByTokenId($token_id);
|
||||||
|
$hero = Hero::find($unique_id);
|
||||||
if (! $chip || ! $hero){
|
if (! $chip || ! $hero){
|
||||||
$this->_rspErr(1, 'Not enough chip or hero');
|
$this->_rspErr(1, 'Not enough chip or hero');
|
||||||
return;
|
return;
|
||||||
@ -406,9 +475,23 @@ class ChipController extends BaseAuthedController
|
|||||||
$k = array_search($chip['idx'],$chipIdsArr);
|
$k = array_search($chip['idx'],$chipIdsArr);
|
||||||
unset($chipIdsArr[$k]);
|
unset($chipIdsArr[$k]);
|
||||||
$fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
|
$fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
|
||||||
Hero::update($hero_id,$fieldsKv);
|
Hero::update($unique_id,$fieldsKv);
|
||||||
Chip::updateChipInlayState($token_id,0);
|
Chip::updateChipInlayState($token_id,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _doDemountGun($unique_id,$token_id){
|
||||||
|
$chip = Chip::getChipByTokenId($token_id);
|
||||||
|
$gun = Gun::find($unique_id);
|
||||||
|
if (! $chip || ! $gun){
|
||||||
|
$this->_rspErr(1, 'Not enough chip or gun');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$chipIdsArr = explode('|',$gun['chip_ids']);
|
||||||
|
$k = array_search($chip['idx'],$chipIdsArr);
|
||||||
|
unset($chipIdsArr[$k]);
|
||||||
|
$fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
|
||||||
|
Gun::update($unique_id,$fieldsKv);
|
||||||
|
Chip::updateChipInlayState($token_id,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _inLayNewAttr($hero_id){
|
private function _inLayNewAttr($hero_id){
|
||||||
@ -442,9 +525,45 @@ class ChipController extends BaseAuthedController
|
|||||||
return $hero;
|
return $hero;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _chipCore($hero_id){
|
private function _inLayNewAttrGun($gun_id){
|
||||||
|
$gun = Gun::find($gun_id);
|
||||||
|
if (! $gun){
|
||||||
|
$this->_rspErr(1, 'Not enough gun');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$chipAttr = [];
|
||||||
|
if (! $gun['chip_ids'] ){
|
||||||
|
return $gun;
|
||||||
|
}
|
||||||
|
if ($gun['chip_ids'] && !strpos($gun['chip_ids'], '|')){
|
||||||
|
$chip =Chip::toDto(Chip::getChipByIdx($gun['chip_ids']));
|
||||||
|
foreach ($chip['rand_attr'] as $val){
|
||||||
|
array_push($chipAttr,$val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($gun['chip_ids'] && strpos($gun['chip_ids'], '|')){
|
||||||
|
$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;
|
||||||
|
return $gun;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _chipCore($unique_id,$type){
|
||||||
$chipCore = [];
|
$chipCore = [];
|
||||||
$hero = Hero::find($hero_id);
|
if ($type==1){
|
||||||
|
$hero = Hero::find($unique_id);
|
||||||
|
}else{
|
||||||
|
$hero = Gun::find($unique_id);
|
||||||
|
}
|
||||||
|
|
||||||
if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){
|
if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){
|
||||||
$chipIdsArr = explode('|',$hero['chip_ids']);
|
$chipIdsArr = explode('|',$hero['chip_ids']);
|
||||||
if (count($chipIdsArr) == 4){
|
if (count($chipIdsArr) == 4){
|
||||||
@ -457,7 +576,7 @@ class ChipController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
$chipCoreList = getMetaTable('chipCore@chipCore.php');
|
$chipCoreList = getMetaTable('chipCore@chipCore.php');
|
||||||
foreach ($chipCoreList as $val){
|
foreach ($chipCoreList as $val){
|
||||||
if ($val['chip_core_type']==1 && $val['chip_core_lv']<=$min){
|
if ($val['chip_core_type']==$type && $val['chip_core_lv']<=$min){
|
||||||
array_push($chipCore,$val);
|
array_push($chipCore,$val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -521,9 +640,8 @@ class ChipController extends BaseAuthedController
|
|||||||
if ($new_grade == 3 || $new_grade == 5){
|
if ($new_grade == 3 || $new_grade == 5){
|
||||||
Chip::updateRandAttr($chip);
|
Chip::updateRandAttr($chip);
|
||||||
}
|
}
|
||||||
$lucky = \services\FormulaService::getChipLuckyValue($chip['chip_grade']);
|
$lucky = ltrim(\services\FormulaService::getChipLuckyValue($new_grade),'-') ;
|
||||||
$lucky_pro = \services\FormulaService::getChipLuckyValue($new_grade);
|
Chip::update($chip['token_id'],['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade]);
|
||||||
Chip::update($chip['token_id'],['lucky_temporary'=>$lucky_pro-$lucky, 'chip_grade'=>$new_grade]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _bestFun($upgrade_cost,$chip_param,$chip_param_out){
|
private function _bestFun($upgrade_cost,$chip_param,$chip_param_out){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user