1
This commit is contained in:
parent
c0a0d28474
commit
2a0048ab32
@ -7,61 +7,13 @@ class ChipPage(object):
|
||||
def __init__(self):
|
||||
self.apis = [
|
||||
{
|
||||
'name': 'chipPageList',
|
||||
'desc': '铭文页列表',
|
||||
'group': 'ChipPage',
|
||||
'url': 'webapp/index.php?c=ChipPage&a=chipPageList',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!data', [_common.ChipPageList()], '页列表']
|
||||
]
|
||||
},{
|
||||
'name': 'showPageInfo',
|
||||
'desc': '铭文页信息',
|
||||
'name': 'showChipPage',
|
||||
'desc': '铭文信息',
|
||||
'group': 'ChipPage',
|
||||
'url': 'webapp/index.php?c=ChipPage&a=showPageInfo',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['page', '', '页id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!data', [_common.ChipPage()], '页信息']
|
||||
]
|
||||
},{
|
||||
'name': 'setChipPage',
|
||||
'desc': '设置铭文页',
|
||||
'group': 'ChipPage',
|
||||
'url': 'webapp/index.php?c=ChipPage&a=setChipPage',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['page', '', '页id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},{
|
||||
'name': 'addChipPage',
|
||||
'desc': '添加铭文页',
|
||||
'group': 'ChipPage',
|
||||
'url': 'webapp/index.php?c=ChipPage&a=addChipPage',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},{
|
||||
'name': 'rename',
|
||||
'desc': '修改页名',
|
||||
'group': 'ChipPage',
|
||||
'url': 'webapp/index.php?c=ChipPage&a=rename',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['page', '', '页id'],
|
||||
['hero_unnid', '', '英雄唯一id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
@ -74,9 +26,9 @@ class ChipPage(object):
|
||||
'url': 'webapp/index.php?c=ChipPage&a=useChip',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['page', '', '页id'],
|
||||
['hero_unnid', '', '英雄唯一id'],
|
||||
['slot_id', '', '卡槽id'],
|
||||
['unique_id', '', '芯片idx'],
|
||||
['chip_unnid', '', '芯片唯一id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
@ -89,7 +41,7 @@ class ChipPage(object):
|
||||
'url': 'webapp/index.php?c=ChipPage&a=removeChipOne',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['page', '', '页id'],
|
||||
['hero_unnid', '', '英雄唯一id'],
|
||||
['slot_id', '', '卡槽id'],
|
||||
],
|
||||
'response': [
|
||||
@ -103,7 +55,7 @@ class ChipPage(object):
|
||||
'url': 'webapp/index.php?c=ChipPage&a=removeChipAll',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['page', '', '页id'],
|
||||
['hero_unnid', '', '英雄唯一id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
|
@ -1064,24 +1064,12 @@ class Emoji(object):
|
||||
['state', 0, '1:使用 0:未使用'],
|
||||
]
|
||||
|
||||
class ChipPageList(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['idx', 0, 'idx'],
|
||||
['account_id', 0, 'account_id'],
|
||||
['page_id', 0, '页id'],
|
||||
['page_name', '', '页名'],
|
||||
['createtime', 0, '创建时间'],
|
||||
]
|
||||
|
||||
class ChipPage(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['idx', 0, 'idx'],
|
||||
['page_id', 0, '页id'],
|
||||
['page_name', '', '页名'],
|
||||
['hero_uniid', 0, '英雄唯一id'],
|
||||
['!data', [ChipPageSlot()], '卡槽信息'],
|
||||
['!attr', [Attr()], '属性信息'],
|
||||
]
|
||||
@ -1092,7 +1080,8 @@ class ChipPageSlot(object):
|
||||
self.fields = [
|
||||
['slot_id', 0, '卡槽id'],
|
||||
['state', 0, '0:未解锁 1:已解锁'],
|
||||
['chip_id', '', '芯片idx'],
|
||||
['chip_id', '', '芯片唯一id'],
|
||||
['item_id', '', '芯片itemId'],
|
||||
]
|
||||
|
||||
class HeroPreset(object):
|
||||
|
11
sql/gamedb2006_migrate_240201_01.sql
Normal file
11
sql/gamedb2006_migrate_240201_01.sql
Normal file
@ -0,0 +1,11 @@
|
||||
begin;
|
||||
|
||||
alter table t_chip_page add column `hero_uniid` int(11) NOT NULL DEFAULT '0' COMMENT '英雄唯一id';
|
||||
alter table t_chip_page drop column page_name;
|
||||
alter table t_chip_page drop column page_id;
|
||||
alter table t_chip_page drop index account_page_id;
|
||||
alter table t_chip_page add UNIQUE KEY `hero_uniid` (`hero_uniid`);
|
||||
|
||||
insert into version (version) values(2024020101);
|
||||
|
||||
commit;
|
@ -275,7 +275,7 @@ class BattleController extends BaseAuthedController {
|
||||
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
||||
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['presetInfo']['chip_page']);
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['hero_uniId']);
|
||||
$info['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||
$info['honor_info'] = $userPresetInfo['honor_info'];
|
||||
$battleDb = Battle::find($account_id);
|
||||
@ -394,7 +394,7 @@ class BattleController extends BaseAuthedController {
|
||||
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
||||
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['presetInfo']['chip_page']);
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['hero_uniId']);
|
||||
$info['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||
$info['honor_info'] = $userPresetInfo['honor_info'];
|
||||
$battleDb = Battle::find($accountId);
|
||||
@ -497,7 +497,7 @@ class BattleController extends BaseAuthedController {
|
||||
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
||||
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['presetInfo']['chip_page']);
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['hero_uniId']);
|
||||
$info['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||
$info['honor_info'] = $userPresetInfo['honor_info'];
|
||||
$battleDb = Battle::find($accountId);
|
||||
|
@ -2,108 +2,32 @@
|
||||
require_once('mt/StarLevel.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/ChipPage.php');
|
||||
require_once('models/HeroPreset.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('services/ChipPageService.php');
|
||||
|
||||
use models\Chip;
|
||||
use models\ChipPage;
|
||||
use models\HeroPreset;
|
||||
use models\Hero;
|
||||
use services\ChipPageService;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class ChipPageController extends BaseAuthedController
|
||||
{
|
||||
public function chipPageList(){
|
||||
$obj = new services\ChipPageService();
|
||||
$obj->initChipPage();
|
||||
|
||||
$list =array();
|
||||
ChipPage::getList(function ($row) use(&$list){
|
||||
array_push($list, ChipPage::toDto($row));
|
||||
});
|
||||
$this->_rspData(array(
|
||||
'data' => $list,
|
||||
));
|
||||
}
|
||||
|
||||
public function showPageInfo(){
|
||||
$page = getReqVal('page',1);
|
||||
$chipPageDb = ChipPage::find($page);
|
||||
public function showChipPage(){
|
||||
$heroUid = getReqVal('hero_unnid',0);
|
||||
$heroDb = Hero::find($heroUid);
|
||||
if (!$heroDb){
|
||||
$this->_rspErr(1,'param error');
|
||||
return ;
|
||||
}
|
||||
$chipPageDb = ChipPage::find($heroUid);
|
||||
if (!$chipPageDb){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
return ;
|
||||
ChipPage::addChipPage($heroUid);
|
||||
$chipPageDb = ChipPage::find($heroUid);
|
||||
}
|
||||
$obj = new services\ChipPageService();
|
||||
$obj->refreshSlotState($chipPageDb);
|
||||
$chipPageDb = ChipPage::find($page);
|
||||
$chipPageDto = ChipPage::toDtoInfo($chipPageDb);
|
||||
$this->_rspData(array(
|
||||
'data' => $chipPageDto,
|
||||
));
|
||||
}
|
||||
|
||||
public function setChipPage(){
|
||||
$page = getReqVal('page',1);
|
||||
$chipPageDb = ChipPage::find($page);
|
||||
if (!$chipPageDb){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
return ;
|
||||
}
|
||||
$userDb = $this->_getOrmUserInfo();
|
||||
$hero_uid = $userDb['hero_id'];
|
||||
$preset = HeroPreset::getHeroPreset($hero_uid);
|
||||
HeroPreset::upsertPreset($hero_uid,$preset['skill_id'],$page,0,0);
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function addChipPage(){
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
$count = ChipPage::getCount();
|
||||
switch ($count){
|
||||
case 3 : {
|
||||
// if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_PAGE1_MATCH_LIMIT){
|
||||
if ($userInfo['star_num'] < \mt\StarLevel::STAR_NUM_CHIP_PAGE1_MATCH_LIMIT){
|
||||
$this->_rspErr(1,'Not agreed terms');
|
||||
return ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4 : {
|
||||
// if ($userInfo['level'] < \mt\LevelUp::USER_LEVEL_CHIP_PAGE2_MATCH_LIMIT){
|
||||
if ($userInfo['star_num'] < \mt\StarLevel::STAR_NUM_CHIP_PAGE2_MATCH_LIMIT){
|
||||
$this->_rspErr(1,'Not agreed terms');
|
||||
return ;
|
||||
}
|
||||
};
|
||||
break;
|
||||
case 5 : {
|
||||
$this->_rspErr(1,'Maximum');
|
||||
return ;
|
||||
}
|
||||
}
|
||||
ChipPage::addChipPage();
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function rename(){
|
||||
$page = getReqVal('page',0);
|
||||
$chipPageDb = ChipPage::find($page);
|
||||
if (! $chipPageDb ){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
return ;
|
||||
}
|
||||
$name = getReqVal('name','');
|
||||
if (mb_strlen($name) < 3) {
|
||||
$this->_rspErr(1,'Parameter error name length must not be less than 3');
|
||||
return;
|
||||
}
|
||||
if (mb_strlen($name, 'utf8') > 12) {
|
||||
$this->_rspErr(1,'Parameter error name length must not be greater than 12');
|
||||
return;
|
||||
}
|
||||
ChipPage::update($page,array(
|
||||
'page_name' => $name
|
||||
));
|
||||
$chipPageService = new services\ChipPageService();
|
||||
$chipPageService->refreshSlotState($chipPageDb);
|
||||
$chipPageDto = ChipPage::toDtoInfo($chipPageDb);
|
||||
$this->_rspData(array(
|
||||
'data' => $chipPageDto,
|
||||
@ -111,14 +35,14 @@ class ChipPageController extends BaseAuthedController
|
||||
}
|
||||
|
||||
public function useChip(){
|
||||
$page = getReqVal('page',0);
|
||||
$hero_unnid = getReqVal('hero_unnid',0);
|
||||
$slotId = getReqVal('slot_id',0);
|
||||
$uniqueId = getReqVal('unique_id',0);
|
||||
if (!$page || !$slotId || !$uniqueId){
|
||||
$chip_unnid = getReqVal('chip_unnid',0);
|
||||
if (!$hero_unnid || !$slotId || !$chip_unnid){
|
||||
$this->_rspErr(1, 'Missing parameter');
|
||||
return ;
|
||||
}
|
||||
$chipPageDb = ChipPage::find($page);
|
||||
$chipPageDb = ChipPage::find($hero_unnid);
|
||||
if (!$chipPageDb){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
return ;
|
||||
@ -132,13 +56,13 @@ class ChipPageController extends BaseAuthedController
|
||||
$this->_rspErr(1,'Unlocked state');
|
||||
return ;
|
||||
}
|
||||
$chipDb = Chip::find($uniqueId);
|
||||
$chipDb = Chip::find($chip_unnid);
|
||||
if (! $chipDb){
|
||||
$this->_rspErr(1, "You don't have the chip yet");
|
||||
return;
|
||||
}
|
||||
|
||||
if (in_array($page,array_filter(explode("|",$chipDb['inlay_state'])))){
|
||||
if ($chipDb['inlay_state'] == 1){
|
||||
$this->_rspErr(1, "The used chip");
|
||||
return;
|
||||
}
|
||||
@ -155,15 +79,15 @@ class ChipPageController extends BaseAuthedController
|
||||
}
|
||||
if ( $data[$slotId-1]['chip_id'] ){
|
||||
|
||||
Chip::updateInlayState($data[$slotId-1]['chip_id'],$page);
|
||||
Chip::updateInlayState($data[$slotId-1]['chip_id'],0);
|
||||
}
|
||||
$data[$slotId-1]['chip_id'] = $uniqueId;
|
||||
$data[$slotId-1]['chip_id'] = $chip_unnid;
|
||||
|
||||
Chip::updateInlayState($uniqueId,$page);
|
||||
ChipPage::update($page,array(
|
||||
Chip::updateInlayState($chip_unnid,1);
|
||||
ChipPage::update($hero_unnid,array(
|
||||
'data' => json_encode($data)
|
||||
));
|
||||
$newChipPageDb = ChipPage::find($page);
|
||||
$newChipPageDb = ChipPage::find($hero_unnid);
|
||||
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
||||
$this->_rspData(array(
|
||||
'data' => $chipPageDto,
|
||||
@ -171,13 +95,13 @@ class ChipPageController extends BaseAuthedController
|
||||
}
|
||||
|
||||
public function removeChipOne(){
|
||||
$page = getReqVal('page',0);
|
||||
$hero_unnid = getReqVal('hero_unnid',0);
|
||||
$slotId = getReqVal('slot_id',0);
|
||||
if (!$page || !$slotId){
|
||||
if (!$hero_unnid || !$slotId){
|
||||
$this->_rspErr(1, 'Missing parameter');
|
||||
return ;
|
||||
}
|
||||
$chipPageDb = ChipPage::find($page);
|
||||
$chipPageDb = ChipPage::find($hero_unnid);
|
||||
if (!$chipPageDb){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
return ;
|
||||
@ -185,14 +109,14 @@ class ChipPageController extends BaseAuthedController
|
||||
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
||||
foreach ($data as &$value){
|
||||
if ($value['slot_id'] == $slotId){
|
||||
Chip::updateInlayState($value['chip_id'],$page);
|
||||
Chip::updateInlayState($value['chip_id'],0);
|
||||
$value['chip_id'] = 0;
|
||||
}
|
||||
}
|
||||
ChipPage::update($page,array(
|
||||
ChipPage::update($hero_unnid,array(
|
||||
'data' => json_encode($data)
|
||||
));
|
||||
$newChipPageDb = ChipPage::find($page);
|
||||
$newChipPageDb = ChipPage::find($hero_unnid);
|
||||
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
||||
$this->_rspData(array(
|
||||
'data' => $chipPageDto,
|
||||
@ -200,8 +124,8 @@ class ChipPageController extends BaseAuthedController
|
||||
}
|
||||
|
||||
public function removeChipAll(){
|
||||
$page = getReqVal('page',0);
|
||||
$chipPageDb = ChipPage::find($page);
|
||||
$hero_unnid = getReqVal('hero_unnid',0);
|
||||
$chipPageDb = ChipPage::find($hero_unnid);
|
||||
if (!$chipPageDb){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
return ;
|
||||
@ -209,14 +133,14 @@ class ChipPageController extends BaseAuthedController
|
||||
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
||||
foreach ($data as &$value){
|
||||
if ($value['chip_id']){
|
||||
Chip::updateInlayState($value['chip_id'],$page);
|
||||
Chip::updateInlayState($value['chip_id'],0);
|
||||
$value['chip_id'] = 0;
|
||||
}
|
||||
}
|
||||
ChipPage::update($page,array(
|
||||
ChipPage::update($hero_unnid,array(
|
||||
'data' => json_encode($data)
|
||||
));
|
||||
$newChipPageDb = ChipPage::find($page);
|
||||
$newChipPageDb = ChipPage::find($hero_unnid);
|
||||
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
||||
$this->_rspData(array(
|
||||
'data' => $chipPageDto,
|
||||
|
@ -231,11 +231,6 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(1, "You don't have the hero yet");
|
||||
return;
|
||||
}
|
||||
$chipPageDb = ChipPage::find($chipPageId);
|
||||
if (! $chipPageDb){
|
||||
$this->_rspErr(1, "You don't have the chip page");
|
||||
return;
|
||||
}
|
||||
if ($weaponUid1){
|
||||
$gunDb1 = Gun::find($weaponUid1);
|
||||
if (!$gunDb1){
|
||||
|
@ -305,17 +305,11 @@ class Chip extends BaseModel
|
||||
);
|
||||
}
|
||||
|
||||
public static function updateInlayState($idx,$page){
|
||||
$row = self::find($idx);
|
||||
public static function updateInlayState($chip_unnid,$status){
|
||||
$row = self::find($chip_unnid);
|
||||
if ($row){
|
||||
$inlayState = array_filter (explode("|",$row['inlay_state']) );
|
||||
if (in_array($page,$inlayState)){
|
||||
unset($inlayState[array_search($page,$inlayState)]);
|
||||
}else{
|
||||
array_push($inlayState,$page);
|
||||
}
|
||||
self::update2($idx,array(
|
||||
'inlay_state' => implode('|',$inlayState)
|
||||
self::update2($chip_unnid,array(
|
||||
'inlay_state' => $status
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -13,43 +13,22 @@ use services\ChipPageService;
|
||||
class ChipPage extends BaseModel
|
||||
{
|
||||
|
||||
public static function find($page){
|
||||
public static function find($hero_unnid){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_chip_page',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId(),
|
||||
'page_id' => $page
|
||||
'hero_uniid' => $hero_unnid
|
||||
)
|
||||
);
|
||||
if (!$row){
|
||||
return null;
|
||||
if ($row){
|
||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||
$row = null;
|
||||
}
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function getList($cb){
|
||||
SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_chip_page',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId(),
|
||||
),
|
||||
function ($row) use($cb) {
|
||||
$cb($row);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static function toDto($row){
|
||||
return array(
|
||||
'idx' => $row['idx'],
|
||||
'account_id' => $row['account_id'],
|
||||
'page_name' => $row['page_name'],
|
||||
'page_id' => $row['page_id'],
|
||||
'createtime' => $row['createtime'],
|
||||
);
|
||||
}
|
||||
|
||||
public static function toDtoInfo($row){
|
||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||
@ -59,10 +38,10 @@ class ChipPage extends BaseModel
|
||||
$value['chip_id'] = 0;
|
||||
}
|
||||
}
|
||||
self::update($row['page_id'],array(
|
||||
self::update($row['hero_uniid'],array(
|
||||
'data' => json_encode($data)
|
||||
));
|
||||
$newRow = self::find($row['page_id']);
|
||||
$newRow = self::find($row['hero_uniid']);
|
||||
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
||||
$attrs = array();
|
||||
foreach ($newData as $key=>$value){
|
||||
@ -91,8 +70,7 @@ class ChipPage extends BaseModel
|
||||
}
|
||||
$info = array(
|
||||
'idx' => $newRow['idx'],
|
||||
'page_id' => $newRow['page_id'],
|
||||
'page_name' => $newRow['page_name'],
|
||||
'hero_uniid' => $newRow['hero_uniid'],
|
||||
'data' => $newData,
|
||||
'attr' => $item
|
||||
);
|
||||
@ -107,10 +85,10 @@ class ChipPage extends BaseModel
|
||||
$value['chip_id'] = 0;
|
||||
}
|
||||
}
|
||||
self::update($row['page_id'],array(
|
||||
self::update($row['hero_uniid'],array(
|
||||
'data' => json_encode($data)
|
||||
));
|
||||
$newRow = self::find($row['page_id']);
|
||||
$newRow = self::find($row['hero_uniid']);
|
||||
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
||||
$attrs = array();
|
||||
foreach ($newData as $key=>$value){
|
||||
@ -140,40 +118,18 @@ class ChipPage extends BaseModel
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function updatePage($page,$slot_id,$chip_id){
|
||||
$row = self::find($page);
|
||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||
foreach ($data as &$value){
|
||||
if ($value['slot_id'] == $slot_id){
|
||||
$value['chip_id'] = $chip_id;
|
||||
}
|
||||
}
|
||||
public static function update($hero_uniid,$fieldsKv){
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_chip_page',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId(),
|
||||
'page_id' => $page
|
||||
),
|
||||
array(
|
||||
'data'=> json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function update($page,$fieldsKv){
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_chip_page',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId(),
|
||||
'page_id' => $page
|
||||
'hero_uniid'=> $hero_uniid,
|
||||
),
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
public static function addChipPage(){
|
||||
public static function addChipPage($hero_uniid){
|
||||
$data = array();
|
||||
for ($i=1;$i <= ChipPageService::MAX_CHIP_SLOT_NUM;$i++){
|
||||
array_push(
|
||||
@ -185,21 +141,10 @@ class ChipPage extends BaseModel
|
||||
)
|
||||
);
|
||||
}
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_chip_page',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId()
|
||||
)
|
||||
);
|
||||
$page_id = 1;
|
||||
if ($rows){
|
||||
$page_id = count($rows)+1;
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'page_name' => 'page'.$page_id,
|
||||
'page_id' => $page_id,
|
||||
'hero_uniid' => $hero_uniid,
|
||||
'data' => json_encode($data),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
@ -213,26 +158,11 @@ class ChipPage extends BaseModel
|
||||
(myself()->_getSelfMysql(),
|
||||
't_chip_page',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'page_id' => $page_id,
|
||||
'hero_uniid' => $hero_uniid,
|
||||
),
|
||||
array(),
|
||||
$info
|
||||
);
|
||||
}
|
||||
|
||||
public static function getCount(){
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_chip_page',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId()
|
||||
)
|
||||
);
|
||||
$count = 0;
|
||||
if ($rows){
|
||||
$count = count($rows);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
}
|
@ -13,29 +13,6 @@ class ChipPageService extends BaseService
|
||||
const MAX_CHIP_SLOT_NUM = 30;
|
||||
const INIT_CHIP_PAGE_NUM = 3;
|
||||
|
||||
public function init(){
|
||||
$count = ChipPage::getCount();
|
||||
if (!$count){
|
||||
for ($i=0;$i<self::INIT_CHIP_PAGE_NUM;$i++){
|
||||
ChipPage::addChipPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
public function initChipPage(){
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_chip_page',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId()
|
||||
)
|
||||
);
|
||||
if ($rows){
|
||||
foreach ($rows as $row){
|
||||
$this->refreshSlotState($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function refreshSlotState($row){
|
||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||
$userInfo = myself()->_getOrmUserInfo();
|
||||
|
Loading…
x
Reference in New Issue
Block a user