This commit is contained in:
hujiabin 2022-11-04 14:24:23 +08:00
parent 5ea7b3376c
commit 2ac2470be8
5 changed files with 116 additions and 73 deletions

View File

@ -186,7 +186,7 @@ class BagController extends BaseAuthedController {
$errMsg = 'Parameter error name length must not be less than 3';
return;
}
if (mb_strlen($name, 'utf8') > 16) {
if (mb_strlen($name, 'utf8') > 12) {
$errCode = 5;
$errMsg = 'Parameter error name length must not be greater than 16';
return;

View File

@ -26,18 +26,22 @@ class ChipController extends BaseAuthedController
{
public function chipList()
{
$type = getReqVal('type','');
if (! $type){
$this->_rspErr(1,'Please enter instructions');
return ;
}
$chipList = Chip::all($type);
$chipDtoList = array();
foreach ($chipList as $item) {
array_push($chipDtoList, Chip::toDto($item));
}
// $type = getReqVal('type','');
// if (! $type){
// $this->_rspErr(1,'Please enter instructions');
// return ;
// }
// $chipList = Chip::all($type);
// $chipDtoList = array();
// foreach ($chipList as $item) {
// array_push($chipDtoList, Chip::toDto($item));
// }
$chipList = array();
Chip::getChipList(function ($row) use(&$chipList){
array_push($chipList, Chip::toDto($row));
});
$this->_rspData(array(
'data' => $chipDtoList,
'data' => $chipList,
));
}

View File

@ -461,7 +461,7 @@ class GunController extends BaseAuthedController {
}
public function receive(){
$this->_rspOk();return;
$type = getReqVal('type', 0);
$gunUniId = getReqVal('gun_uniid', 0);
$gunDb = Gun::find($gunUniId);
@ -537,6 +537,7 @@ class GunController extends BaseAuthedController {
break;
case 2:
{
$this->_rspOk();return;
$idx = 0;
$found = false;
for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {

View File

@ -228,7 +228,7 @@ class HeroController extends BaseAuthedController {
public function receive()
{
$this->_rspOk();return;
$type = getReqVal('type', 0);
$heroUniId = getReqVal('hero_uniid', 0);
$heroDb = Hero::find($heroUniId);
@ -322,6 +322,7 @@ class HeroController extends BaseAuthedController {
break;
case 2:
{
$this->_rspOk();return;
$idx = 0;
$found = false;
for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {

View File

@ -30,43 +30,74 @@ class Chip extends BaseModel
public static function getChipList($cb)
{
// SqlHelper::ormSelect(
// myself()->_getSelfMysql(),
// 't_chip',
// array(
// 'account_id' => myself()->_getAccountId()
// ),
// function ($row) use($cb) {
// $cb($row);
// }
// );
// foreach (NftService::getChips(myself()->_getOpenId()) as $nftDb) {
// if (! $nftDb['deleted']){
// $row = SqlHelper::ormSelectOne(
// myself()->_getSelfMysql(),
// 't_chip',
// array(
// 'token_id' => $nftDb['token_id'],
// )
// );
// if (!$row) {
// $itemMeta = mt\Item::get($nftDb['item_id']);
// if ($itemMeta) {
// self::addChip($nftDb['item_id'], $nftDb['token_id']);
// $row = SqlHelper::ormSelectOne(
// myself()->_getSelfMysql(),
// 't_chip',
// array(
// 'token_id' => $nftDb['token_id'],
// )
// );
// }
// }
// if ($row) {
// $cb($row);
// }
// }
// }
$sql = "select * from t_nft1155 where owner_address=:owner_address and token_id>10000000 and balance>0";
$whereKv =array(
'owner_address' => myself()->_getOpenId(),
);
foreach (myself()->_getMarketMysql()->execQuery($sql,$whereKv) as $nftDb) {
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_chip',
array(
'token_id' => $nftDb['token_id'],
)
);
if ($row){
if (! $row['activate']){
self::activateChip($row);
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_chip',
array(
'token_id' => $nftDb['token_id'],
)
);
$cb($row);
}else{
$cb($row);
}
}
}
}
private static function activateChip($row){
if (myself()->_isVirtualItem($row['item_id'])) {
return;
}
if ($row['item_num'] <= 0) {
return;
}
$itemMeta = mt\Item::get($row['item_id']);
if (!$itemMeta) {
return;
}
$randAttr = array();
if (mt\Item::isRoleChipItem($itemMeta)) {
$randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$row['chip_grade']);
}
if (mt\Item::isGunChipItem($itemMeta)) {
$randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$row['chip_grade']);
}
if ($row['chip_grade'] >= 5){
$lucky = ltrim(\services\FormulaService::getChipLuckyValue($row['chip_grade']),'-') ;
$fieldsKv = array(
'supper_state'=>1,
'lucky_temporary'=>$lucky,
'chip_type' => $itemMeta['sub_type'],
'rand_attr' => json_encode($randAttr),
'activate' => 1,
'modifytime' => myself()->_getNowTime()
);
}else{
$fieldsKv = array(
'chip_type' => $itemMeta['sub_type'],
'rand_attr' => json_encode($randAttr),
'activate' => 1,
'modifytime' => myself()->_getNowTime()
);
}
self::update($row['token_id'],$fieldsKv);
}
public static function toDto($row)
@ -85,7 +116,7 @@ class Chip extends BaseModel
'attr_id' => $attr['attr_id'],
'type' => 2,
'val' => $attr['lv'.$row['chip_grade']]*$val['attr_pool_number'],
'val' => strval($attr['lv'.$row['chip_grade']]*$val['attr_pool_number']),
// 'chip_name' => $attr['chip_name'],
'chip_type' => $attr['chip_type'],
'attr_num' => $attr['lv'.$row['chip_grade']],
@ -102,30 +133,36 @@ class Chip extends BaseModel
}
public static function belongsToWhere($row){
if ($row['chip_type'] == 1){
$heroDb = array();
Hero::getHeroList(function ($hero) use ($row,&$heroDb) {
if ($hero['chip_ids'] && strstr($hero['chip_ids']."|",strval($row['idx']."|")) ){
$heroDb = $hero;
switch ($row['chip_type']){
case 1:{
$heroDb = array();
Hero::getHeroList(function ($hero) use ($row,&$heroDb) {
if ($hero['chip_ids'] && strstr($hero['chip_ids']."|",strval($row['idx']."|")) ){
$heroDb = $hero;
}
});
if($heroDb){
return $heroDb['hero_id'];
}else{
return 0;
}
});
if($heroDb){
return $heroDb['hero_id'];
}else{
return 0;
}
}
if ($row['chip_type'] == 2){
$gunDb = array();
Gun::getGunList(function ($gun) use($row,&$gunDb) {
if ($gun['chip_ids'] && strstr($gun['chip_ids']."|",strval($row['idx']."|")) ){
$gunDb = $gun;
break;
case 2:{
$gunDb = array();
Gun::getGunList(function ($gun) use($row,&$gunDb) {
if ($gun['chip_ids'] && strstr($gun['chip_ids']."|",strval($row['idx']."|")) ){
$gunDb = $gun;
}
});
if($gunDb){
return $gunDb['gun_id'];
}else{
return 0;
}
});
if($gunDb){
return $gunDb['gun_id'];
}else{
}
break;
default:{
return 0;
}
}