1
This commit is contained in:
parent
c0a0d28474
commit
2a0048ab32
@ -7,61 +7,13 @@ class ChipPage(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.apis = [
|
self.apis = [
|
||||||
{
|
{
|
||||||
'name': 'chipPageList',
|
'name': 'showChipPage',
|
||||||
'desc': '铭文页列表',
|
'desc': '铭文信息',
|
||||||
'group': 'ChipPage',
|
|
||||||
'url': 'webapp/index.php?c=ChipPage&a=chipPageList',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
['!data', [_common.ChipPageList()], '页列表']
|
|
||||||
]
|
|
||||||
},{
|
|
||||||
'name': 'showPageInfo',
|
|
||||||
'desc': '铭文页信息',
|
|
||||||
'group': 'ChipPage',
|
'group': 'ChipPage',
|
||||||
'url': 'webapp/index.php?c=ChipPage&a=showPageInfo',
|
'url': 'webapp/index.php?c=ChipPage&a=showPageInfo',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['page', '', '页id'],
|
['hero_unnid', '', '英雄唯一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'],
|
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
@ -74,9 +26,9 @@ class ChipPage(object):
|
|||||||
'url': 'webapp/index.php?c=ChipPage&a=useChip',
|
'url': 'webapp/index.php?c=ChipPage&a=useChip',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['page', '', '页id'],
|
['hero_unnid', '', '英雄唯一id'],
|
||||||
['slot_id', '', '卡槽id'],
|
['slot_id', '', '卡槽id'],
|
||||||
['unique_id', '', '芯片idx'],
|
['chip_unnid', '', '芯片唯一id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
@ -89,7 +41,7 @@ class ChipPage(object):
|
|||||||
'url': 'webapp/index.php?c=ChipPage&a=removeChipOne',
|
'url': 'webapp/index.php?c=ChipPage&a=removeChipOne',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['page', '', '页id'],
|
['hero_unnid', '', '英雄唯一id'],
|
||||||
['slot_id', '', '卡槽id'],
|
['slot_id', '', '卡槽id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
@ -103,7 +55,7 @@ class ChipPage(object):
|
|||||||
'url': 'webapp/index.php?c=ChipPage&a=removeChipAll',
|
'url': 'webapp/index.php?c=ChipPage&a=removeChipAll',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['page', '', '页id'],
|
['hero_unnid', '', '英雄唯一id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
|
@ -1064,24 +1064,12 @@ class Emoji(object):
|
|||||||
['state', 0, '1:使用 0:未使用'],
|
['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):
|
class ChipPage(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fields = [
|
self.fields = [
|
||||||
['idx', 0, 'idx'],
|
['idx', 0, 'idx'],
|
||||||
['page_id', 0, '页id'],
|
['hero_uniid', 0, '英雄唯一id'],
|
||||||
['page_name', '', '页名'],
|
|
||||||
['!data', [ChipPageSlot()], '卡槽信息'],
|
['!data', [ChipPageSlot()], '卡槽信息'],
|
||||||
['!attr', [Attr()], '属性信息'],
|
['!attr', [Attr()], '属性信息'],
|
||||||
]
|
]
|
||||||
@ -1092,7 +1080,8 @@ class ChipPageSlot(object):
|
|||||||
self.fields = [
|
self.fields = [
|
||||||
['slot_id', 0, '卡槽id'],
|
['slot_id', 0, '卡槽id'],
|
||||||
['state', 0, '0:未解锁 1:已解锁'],
|
['state', 0, '0:未解锁 1:已解锁'],
|
||||||
['chip_id', '', '芯片idx'],
|
['chip_id', '', '芯片唯一id'],
|
||||||
|
['item_id', '', '芯片itemId'],
|
||||||
]
|
]
|
||||||
|
|
||||||
class HeroPreset(object):
|
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['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
||||||
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
||||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
$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['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||||
$info['honor_info'] = $userPresetInfo['honor_info'];
|
$info['honor_info'] = $userPresetInfo['honor_info'];
|
||||||
$battleDb = Battle::find($account_id);
|
$battleDb = Battle::find($account_id);
|
||||||
@ -394,7 +394,7 @@ class BattleController extends BaseAuthedController {
|
|||||||
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
||||||
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
||||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
$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['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||||
$info['honor_info'] = $userPresetInfo['honor_info'];
|
$info['honor_info'] = $userPresetInfo['honor_info'];
|
||||||
$battleDb = Battle::find($accountId);
|
$battleDb = Battle::find($accountId);
|
||||||
@ -497,7 +497,7 @@ class BattleController extends BaseAuthedController {
|
|||||||
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
$info['skill_id'] = $userPresetInfo['presetInfo']['skill_id'];
|
||||||
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
$info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1'];
|
||||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
$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['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||||
$info['honor_info'] = $userPresetInfo['honor_info'];
|
$info['honor_info'] = $userPresetInfo['honor_info'];
|
||||||
$battleDb = Battle::find($accountId);
|
$battleDb = Battle::find($accountId);
|
||||||
|
@ -2,108 +2,32 @@
|
|||||||
require_once('mt/StarLevel.php');
|
require_once('mt/StarLevel.php');
|
||||||
require_once('models/Chip.php');
|
require_once('models/Chip.php');
|
||||||
require_once('models/ChipPage.php');
|
require_once('models/ChipPage.php');
|
||||||
require_once('models/HeroPreset.php');
|
require_once('models/Hero.php');
|
||||||
require_once('services/ChipPageService.php');
|
require_once('services/ChipPageService.php');
|
||||||
|
|
||||||
use models\Chip;
|
use models\Chip;
|
||||||
use models\ChipPage;
|
use models\ChipPage;
|
||||||
use models\HeroPreset;
|
use models\Hero;
|
||||||
use services\ChipPageService;
|
use services\ChipPageService;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
class ChipPageController extends BaseAuthedController
|
class ChipPageController extends BaseAuthedController
|
||||||
{
|
{
|
||||||
public function chipPageList(){
|
|
||||||
$obj = new services\ChipPageService();
|
|
||||||
$obj->initChipPage();
|
|
||||||
|
|
||||||
$list =array();
|
public function showChipPage(){
|
||||||
ChipPage::getList(function ($row) use(&$list){
|
$heroUid = getReqVal('hero_unnid',0);
|
||||||
array_push($list, ChipPage::toDto($row));
|
$heroDb = Hero::find($heroUid);
|
||||||
});
|
if (!$heroDb){
|
||||||
$this->_rspData(array(
|
$this->_rspErr(1,'param error');
|
||||||
'data' => $list,
|
return ;
|
||||||
));
|
}
|
||||||
}
|
$chipPageDb = ChipPage::find($heroUid);
|
||||||
|
|
||||||
public function showPageInfo(){
|
|
||||||
$page = getReqVal('page',1);
|
|
||||||
$chipPageDb = ChipPage::find($page);
|
|
||||||
if (!$chipPageDb){
|
if (!$chipPageDb){
|
||||||
$this->_rspErr(1,'page parameter error');
|
ChipPage::addChipPage($heroUid);
|
||||||
return ;
|
$chipPageDb = ChipPage::find($heroUid);
|
||||||
}
|
}
|
||||||
$obj = new services\ChipPageService();
|
$chipPageService = new services\ChipPageService();
|
||||||
$obj->refreshSlotState($chipPageDb);
|
$chipPageService->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
|
|
||||||
));
|
|
||||||
$chipPageDto = ChipPage::toDtoInfo($chipPageDb);
|
$chipPageDto = ChipPage::toDtoInfo($chipPageDb);
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'data' => $chipPageDto,
|
'data' => $chipPageDto,
|
||||||
@ -111,14 +35,14 @@ class ChipPageController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function useChip(){
|
public function useChip(){
|
||||||
$page = getReqVal('page',0);
|
$hero_unnid = getReqVal('hero_unnid',0);
|
||||||
$slotId = getReqVal('slot_id',0);
|
$slotId = getReqVal('slot_id',0);
|
||||||
$uniqueId = getReqVal('unique_id',0);
|
$chip_unnid = getReqVal('chip_unnid',0);
|
||||||
if (!$page || !$slotId || !$uniqueId){
|
if (!$hero_unnid || !$slotId || !$chip_unnid){
|
||||||
$this->_rspErr(1, 'Missing parameter');
|
$this->_rspErr(1, 'Missing parameter');
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
$chipPageDb = ChipPage::find($page);
|
$chipPageDb = ChipPage::find($hero_unnid);
|
||||||
if (!$chipPageDb){
|
if (!$chipPageDb){
|
||||||
$this->_rspErr(1,'page parameter error');
|
$this->_rspErr(1,'page parameter error');
|
||||||
return ;
|
return ;
|
||||||
@ -132,13 +56,13 @@ class ChipPageController extends BaseAuthedController
|
|||||||
$this->_rspErr(1,'Unlocked state');
|
$this->_rspErr(1,'Unlocked state');
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
$chipDb = Chip::find($uniqueId);
|
$chipDb = Chip::find($chip_unnid);
|
||||||
if (! $chipDb){
|
if (! $chipDb){
|
||||||
$this->_rspErr(1, "You don't have the chip yet");
|
$this->_rspErr(1, "You don't have the chip yet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($page,array_filter(explode("|",$chipDb['inlay_state'])))){
|
if ($chipDb['inlay_state'] == 1){
|
||||||
$this->_rspErr(1, "The used chip");
|
$this->_rspErr(1, "The used chip");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -155,15 +79,15 @@ class ChipPageController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
if ( $data[$slotId-1]['chip_id'] ){
|
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);
|
Chip::updateInlayState($chip_unnid,1);
|
||||||
ChipPage::update($page,array(
|
ChipPage::update($hero_unnid,array(
|
||||||
'data' => json_encode($data)
|
'data' => json_encode($data)
|
||||||
));
|
));
|
||||||
$newChipPageDb = ChipPage::find($page);
|
$newChipPageDb = ChipPage::find($hero_unnid);
|
||||||
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'data' => $chipPageDto,
|
'data' => $chipPageDto,
|
||||||
@ -171,13 +95,13 @@ class ChipPageController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function removeChipOne(){
|
public function removeChipOne(){
|
||||||
$page = getReqVal('page',0);
|
$hero_unnid = getReqVal('hero_unnid',0);
|
||||||
$slotId = getReqVal('slot_id',0);
|
$slotId = getReqVal('slot_id',0);
|
||||||
if (!$page || !$slotId){
|
if (!$hero_unnid || !$slotId){
|
||||||
$this->_rspErr(1, 'Missing parameter');
|
$this->_rspErr(1, 'Missing parameter');
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
$chipPageDb = ChipPage::find($page);
|
$chipPageDb = ChipPage::find($hero_unnid);
|
||||||
if (!$chipPageDb){
|
if (!$chipPageDb){
|
||||||
$this->_rspErr(1,'page parameter error');
|
$this->_rspErr(1,'page parameter error');
|
||||||
return ;
|
return ;
|
||||||
@ -185,14 +109,14 @@ class ChipPageController extends BaseAuthedController
|
|||||||
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
||||||
foreach ($data as &$value){
|
foreach ($data as &$value){
|
||||||
if ($value['slot_id'] == $slotId){
|
if ($value['slot_id'] == $slotId){
|
||||||
Chip::updateInlayState($value['chip_id'],$page);
|
Chip::updateInlayState($value['chip_id'],0);
|
||||||
$value['chip_id'] = 0;
|
$value['chip_id'] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChipPage::update($page,array(
|
ChipPage::update($hero_unnid,array(
|
||||||
'data' => json_encode($data)
|
'data' => json_encode($data)
|
||||||
));
|
));
|
||||||
$newChipPageDb = ChipPage::find($page);
|
$newChipPageDb = ChipPage::find($hero_unnid);
|
||||||
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'data' => $chipPageDto,
|
'data' => $chipPageDto,
|
||||||
@ -200,8 +124,8 @@ class ChipPageController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function removeChipAll(){
|
public function removeChipAll(){
|
||||||
$page = getReqVal('page',0);
|
$hero_unnid = getReqVal('hero_unnid',0);
|
||||||
$chipPageDb = ChipPage::find($page);
|
$chipPageDb = ChipPage::find($hero_unnid);
|
||||||
if (!$chipPageDb){
|
if (!$chipPageDb){
|
||||||
$this->_rspErr(1,'page parameter error');
|
$this->_rspErr(1,'page parameter error');
|
||||||
return ;
|
return ;
|
||||||
@ -209,14 +133,14 @@ class ChipPageController extends BaseAuthedController
|
|||||||
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
||||||
foreach ($data as &$value){
|
foreach ($data as &$value){
|
||||||
if ($value['chip_id']){
|
if ($value['chip_id']){
|
||||||
Chip::updateInlayState($value['chip_id'],$page);
|
Chip::updateInlayState($value['chip_id'],0);
|
||||||
$value['chip_id'] = 0;
|
$value['chip_id'] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChipPage::update($page,array(
|
ChipPage::update($hero_unnid,array(
|
||||||
'data' => json_encode($data)
|
'data' => json_encode($data)
|
||||||
));
|
));
|
||||||
$newChipPageDb = ChipPage::find($page);
|
$newChipPageDb = ChipPage::find($hero_unnid);
|
||||||
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'data' => $chipPageDto,
|
'data' => $chipPageDto,
|
||||||
|
@ -231,11 +231,6 @@ class HeroController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, "You don't have the hero yet");
|
$this->_rspErr(1, "You don't have the hero yet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$chipPageDb = ChipPage::find($chipPageId);
|
|
||||||
if (! $chipPageDb){
|
|
||||||
$this->_rspErr(1, "You don't have the chip page");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($weaponUid1){
|
if ($weaponUid1){
|
||||||
$gunDb1 = Gun::find($weaponUid1);
|
$gunDb1 = Gun::find($weaponUid1);
|
||||||
if (!$gunDb1){
|
if (!$gunDb1){
|
||||||
|
@ -305,17 +305,11 @@ class Chip extends BaseModel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updateInlayState($idx,$page){
|
public static function updateInlayState($chip_unnid,$status){
|
||||||
$row = self::find($idx);
|
$row = self::find($chip_unnid);
|
||||||
if ($row){
|
if ($row){
|
||||||
$inlayState = array_filter (explode("|",$row['inlay_state']) );
|
self::update2($chip_unnid,array(
|
||||||
if (in_array($page,$inlayState)){
|
'inlay_state' => $status
|
||||||
unset($inlayState[array_search($page,$inlayState)]);
|
|
||||||
}else{
|
|
||||||
array_push($inlayState,$page);
|
|
||||||
}
|
|
||||||
self::update2($idx,array(
|
|
||||||
'inlay_state' => implode('|',$inlayState)
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,43 +13,22 @@ use services\ChipPageService;
|
|||||||
class ChipPage extends BaseModel
|
class ChipPage extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function find($page){
|
public static function find($hero_unnid){
|
||||||
$row = SqlHelper::ormSelectOne(
|
$row = SqlHelper::ormSelectOne(
|
||||||
myself()->_getSelfMysql(),
|
myself()->_getSelfMysql(),
|
||||||
't_chip_page',
|
't_chip_page',
|
||||||
array(
|
array(
|
||||||
'account_id'=> myself()->_getAccountId(),
|
'hero_uniid' => $hero_unnid
|
||||||
'page_id' => $page
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (!$row){
|
if ($row){
|
||||||
return null;
|
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||||
|
$row = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $row;
|
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){
|
public static function toDtoInfo($row){
|
||||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||||
@ -59,10 +38,10 @@ class ChipPage extends BaseModel
|
|||||||
$value['chip_id'] = 0;
|
$value['chip_id'] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::update($row['page_id'],array(
|
self::update($row['hero_uniid'],array(
|
||||||
'data' => json_encode($data)
|
'data' => json_encode($data)
|
||||||
));
|
));
|
||||||
$newRow = self::find($row['page_id']);
|
$newRow = self::find($row['hero_uniid']);
|
||||||
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
foreach ($newData as $key=>$value){
|
foreach ($newData as $key=>$value){
|
||||||
@ -91,8 +70,7 @@ class ChipPage extends BaseModel
|
|||||||
}
|
}
|
||||||
$info = array(
|
$info = array(
|
||||||
'idx' => $newRow['idx'],
|
'idx' => $newRow['idx'],
|
||||||
'page_id' => $newRow['page_id'],
|
'hero_uniid' => $newRow['hero_uniid'],
|
||||||
'page_name' => $newRow['page_name'],
|
|
||||||
'data' => $newData,
|
'data' => $newData,
|
||||||
'attr' => $item
|
'attr' => $item
|
||||||
);
|
);
|
||||||
@ -107,10 +85,10 @@ class ChipPage extends BaseModel
|
|||||||
$value['chip_id'] = 0;
|
$value['chip_id'] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::update($row['page_id'],array(
|
self::update($row['hero_uniid'],array(
|
||||||
'data' => json_encode($data)
|
'data' => json_encode($data)
|
||||||
));
|
));
|
||||||
$newRow = self::find($row['page_id']);
|
$newRow = self::find($row['hero_uniid']);
|
||||||
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
foreach ($newData as $key=>$value){
|
foreach ($newData as $key=>$value){
|
||||||
@ -140,40 +118,18 @@ class ChipPage extends BaseModel
|
|||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updatePage($page,$slot_id,$chip_id){
|
public static function update($hero_uniid,$fieldsKv){
|
||||||
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SqlHelper::update
|
SqlHelper::update
|
||||||
(myself()->_getSelfMysql(),
|
(myself()->_getSelfMysql(),
|
||||||
't_chip_page',
|
't_chip_page',
|
||||||
array(
|
array(
|
||||||
'account_id'=> myself()->_getAccountId(),
|
'hero_uniid'=> $hero_uniid,
|
||||||
'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
|
|
||||||
),
|
),
|
||||||
$fieldsKv
|
$fieldsKv
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addChipPage(){
|
public static function addChipPage($hero_uniid){
|
||||||
$data = array();
|
$data = array();
|
||||||
for ($i=1;$i <= ChipPageService::MAX_CHIP_SLOT_NUM;$i++){
|
for ($i=1;$i <= ChipPageService::MAX_CHIP_SLOT_NUM;$i++){
|
||||||
array_push(
|
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(
|
$info = array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => myself()->_getAccountId(),
|
||||||
'page_name' => 'page'.$page_id,
|
'hero_uniid' => $hero_uniid,
|
||||||
'page_id' => $page_id,
|
|
||||||
'data' => json_encode($data),
|
'data' => json_encode($data),
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime(),
|
'modifytime' => myself()->_getNowTime(),
|
||||||
@ -213,26 +158,11 @@ class ChipPage extends BaseModel
|
|||||||
(myself()->_getSelfMysql(),
|
(myself()->_getSelfMysql(),
|
||||||
't_chip_page',
|
't_chip_page',
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'hero_uniid' => $hero_uniid,
|
||||||
'page_id' => $page_id,
|
|
||||||
),
|
),
|
||||||
array(),
|
array(),
|
||||||
$info
|
$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 MAX_CHIP_SLOT_NUM = 30;
|
||||||
const INIT_CHIP_PAGE_NUM = 3;
|
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){
|
public function refreshSlotState($row){
|
||||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||||
$userInfo = myself()->_getOrmUserInfo();
|
$userInfo = myself()->_getOrmUserInfo();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user