60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
|
|
namespace services;
|
|
require_once('models/ChipPage.php');
|
|
|
|
require_once('mt/StarLevel.php');
|
|
require_once('mt/EconomyAttribute.php');
|
|
|
|
use models\ChipPage;
|
|
use mt\EconomyAttribute;
|
|
use mt\Item;
|
|
use phpcommon\SqlHelper;
|
|
class ChipPageService extends BaseService
|
|
{
|
|
const MAX_CHIP_SLOT_NUM = 9;
|
|
const INIT_CHIP_PAGE_NUM = 3;
|
|
|
|
public function refreshSlotState($chipPageDb,$heroDb){
|
|
|
|
$itemMeta = Item::get($heroDb['hero_id']);
|
|
if (!$itemMeta){
|
|
return ;
|
|
}
|
|
$heroAtteMeta = EconomyAttribute::findByGrade($itemMeta['relationship'],$heroDb['quality']);
|
|
if (!$heroAtteMeta){
|
|
return ;
|
|
}
|
|
$chipSlot = explode("|",$heroAtteMeta['chipSlot']);
|
|
$slotArr = array();
|
|
if ($chipSlot[0] > 0){
|
|
for ($i=0;$i<$chipSlot[0];$i++){
|
|
array_push($slotArr,$i*3 +1 );
|
|
}
|
|
}
|
|
if ($chipSlot[1] > 0){
|
|
for ($i=0;$i<$chipSlot[1];$i++){
|
|
array_push($slotArr,$i*3 +2 );
|
|
}
|
|
}
|
|
if ($chipSlot[2] > 0){
|
|
for ($i=0;$i<$chipSlot[2];$i++){
|
|
array_push($slotArr,$i*3 +3 );
|
|
}
|
|
}
|
|
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
|
|
|
foreach ($data as &$val){
|
|
if ( in_array($val['slot_id'],$slotArr) ){
|
|
$val['state'] = 1;
|
|
}else{
|
|
$val['state'] = 0;
|
|
}
|
|
}
|
|
ChipPage::update($chipPageDb['hero_uniid'],array(
|
|
'data' => json_encode($data),
|
|
));
|
|
}
|
|
|
|
} |