英雄技能备战
This commit is contained in:
parent
0f3a63a779
commit
833e187541
14
doc/Chip.py
14
doc/Chip.py
@ -44,19 +44,6 @@ class Chip(object):
|
|||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['!data', [_common.ChipPro()], '芯片信息']
|
['!data', [_common.ChipPro()], '芯片信息']
|
||||||
]
|
]
|
||||||
},{
|
|
||||||
'name': 'selectChip',
|
|
||||||
'desc': '选择合成材料',
|
|
||||||
'group': 'Chip',
|
|
||||||
'url': 'webapp/index.php?c=Chip&a=selectChip',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['unique_id', '', '芯片unique_id参数 例:参数1源芯片 参数2材料芯片'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
['cost', '', '材料芯片的累计价值']
|
|
||||||
]
|
|
||||||
},{
|
},{
|
||||||
'name': 'upgradeLevel',
|
'name': 'upgradeLevel',
|
||||||
'desc': '芯片升级',
|
'desc': '芯片升级',
|
||||||
@ -70,7 +57,6 @@ class Chip(object):
|
|||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['!data', [_common.Chip()], '芯片信息'],
|
['!data', [_common.Chip()], '芯片信息'],
|
||||||
['state', 0, '1 成功,0 失败'],
|
|
||||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
48
doc/HeroSkill.py
Normal file
48
doc/HeroSkill.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import _common
|
||||||
|
|
||||||
|
class HeroSkill(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.apis = [
|
||||||
|
{
|
||||||
|
'name': 'getSkillList',
|
||||||
|
'desc': '技能列表',
|
||||||
|
'group': 'HeroSkill',
|
||||||
|
'url': 'webapp/index.php?c=HeroSkill&a=getSkillList',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['data', [], '技能itemId']
|
||||||
|
]
|
||||||
|
},{
|
||||||
|
'name': 'presetHero',
|
||||||
|
'desc': '技能预设',
|
||||||
|
'group': 'HeroSkill',
|
||||||
|
'url': 'webapp/index.php?c=HeroSkill&a=presetHero',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['skill_id', '0', '技能id'],
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['!data', [['item_id',0,'英雄itemId'],['state',0,'1:设置 0:未设置']], '技能itemId']
|
||||||
|
]
|
||||||
|
},{
|
||||||
|
'name': 'applyHero',
|
||||||
|
'desc': '技能应用',
|
||||||
|
'group': 'HeroSkill',
|
||||||
|
'url': 'webapp/index.php?c=HeroSkill&a=applyHero',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['skill_id', '0', '技能itemId'],
|
||||||
|
['hero_ids', '0', '英雄itemId'],
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
@ -823,7 +823,7 @@ class ChipPro(object):
|
|||||||
['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'],
|
['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'],
|
||||||
['!rand_attr', [ChipAttr()], '属性'],
|
['!rand_attr', [ChipAttr()], '属性'],
|
||||||
['!rand_attr_after', [ChipAttr()], '芯片升级后的属性'],
|
['!rand_attr_after', [ChipAttr()], '芯片升级后的属性'],
|
||||||
['upgrade_cost', '', '芯片升级所需价值'],
|
['cost',[],'升级所需gold消耗']
|
||||||
]
|
]
|
||||||
|
|
||||||
class BattleMember(object):
|
class BattleMember(object):
|
||||||
|
@ -977,3 +977,22 @@ CREATE TABLE `t_chip_page` (
|
|||||||
UNIQUE KEY `account_page_id` (`account_id`, `page_id`)
|
UNIQUE KEY `account_page_id` (`account_id`, `page_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `t_hero_skill`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_hero_skill`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_hero_skill` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||||
|
`hero_uid` int(11) NOT NULL DEFAULT '0' COMMENT 'hero uniid',
|
||||||
|
`skill_id` int(11) NOT NULL DEFAULT '0' COMMENT '技能 item_id',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
UNIQUE KEY `account_hero_skill` (`account_id`, `hero_uid`, `skill_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
@ -29,9 +29,9 @@ class ChipController extends BaseAuthedController
|
|||||||
{
|
{
|
||||||
$chipList = array();
|
$chipList = array();
|
||||||
Chip::getChipList(function ($row) use(&$chipList){
|
Chip::getChipList(function ($row) use(&$chipList){
|
||||||
if ($row['inlay_state'] != 1){
|
// if ($row['inlay_state'] != 1){
|
||||||
array_push($chipList, Chip::toDto($row));
|
array_push($chipList, Chip::toDto($row));
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'data' => $chipList,
|
'data' => $chipList,
|
||||||
@ -80,8 +80,26 @@ class ChipController extends BaseAuthedController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
$chip['rand_attr_after'] = $rand_attr;
|
$chip['rand_attr_after'] = $rand_attr;
|
||||||
$chip['upgrade_cost']=\services\FormulaService::getChipUpgradeCost($chip['chip_grade']+1);
|
$paramMeta = mt\Parameter::getByName('chip_upgrade_cost');
|
||||||
$this->_rspData(['data'=>$chip]);
|
$gold = 0;
|
||||||
|
if ($paramMeta){
|
||||||
|
$paramValue = explode('|',$paramMeta['param_value']);
|
||||||
|
switch ($chipDb['chip_grade']){
|
||||||
|
case 1: {
|
||||||
|
$gold = $paramValue[0];
|
||||||
|
};break;
|
||||||
|
case 2: {
|
||||||
|
$gold = $paramValue[1];
|
||||||
|
};break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$chip['cost'] = array(
|
||||||
|
'item_id' => V_ITEM_GOLD,
|
||||||
|
'item_num' => $gold
|
||||||
|
);
|
||||||
|
$this->_rspData(array(
|
||||||
|
'data' => $chip
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function selectChip(){
|
public function selectChip(){
|
||||||
@ -115,8 +133,8 @@ class ChipController extends BaseAuthedController
|
|||||||
|
|
||||||
public function upgradeLevel(){
|
public function upgradeLevel(){
|
||||||
$idxMain = trim(getReqVal('unique_id_main', 0));
|
$idxMain = trim(getReqVal('unique_id_main', 0));
|
||||||
$idxParam = array_filter(explode(' ',getReqVal('unique_id_param', 0)));
|
$idxParam = trim(getReqVal('unique_id_param', 0));
|
||||||
if (! $idxMain || count($idxParam)<=0 ) {
|
if (!$idxMain || !$idxParam) {
|
||||||
$this->_rspErr(1, 'Please enter parameter');
|
$this->_rspErr(1, 'Please enter parameter');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -129,52 +147,56 @@ class ChipController extends BaseAuthedController
|
|||||||
$this->_rspErr(1,' Level upper limit');
|
$this->_rspErr(1,' Level upper limit');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$upgrade_cost = \services\FormulaService::getChipUpgradeCost($chipDbMain['chip_grade']+1);
|
$chipDbParam = Chip::find($idxParam);
|
||||||
if ( $upgrade_cost == 0 ){
|
if (!$chipDbParam){
|
||||||
$this->_rspErr(1, 'Error in calculation formula');
|
$this->_rspErr(1,"unique_id_param parameter error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($chipDbParam['token_id']) {
|
||||||
|
$this->_rspErr(1, "Unable to use nft chip");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($chipDbParam['state'] == Chip::FREE_STATE) {
|
||||||
|
$this->_rspErr(1, "Unable to use free chip");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($chipDbParam['chip_grade'] != $chipDbMain['chip_grade']){
|
||||||
|
$this->_rspErr(1, "Material chip grade does not meet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$paramMeta = mt\Parameter::getByName('chip_upgrade_cost');
|
||||||
|
$gold = 0;
|
||||||
|
if ($paramMeta){
|
||||||
|
$paramValue = explode('|',$paramMeta['param_value']);
|
||||||
|
switch ($chipDbMain['chip_grade']){
|
||||||
|
case 1: {
|
||||||
|
$gold = $paramValue[0];
|
||||||
|
};break;
|
||||||
|
case 2: {
|
||||||
|
$gold = $paramValue[1];
|
||||||
|
};break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$costItems = array(
|
||||||
|
array(
|
||||||
|
'item_id' => V_ITEM_GOLD,
|
||||||
|
'item_num' => $gold
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$lackItem = null;
|
||||||
|
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||||
|
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$cumulative_cost = 0;
|
|
||||||
|
|
||||||
foreach ($idxParam as $val){
|
$this->_decItems($costItems);
|
||||||
$chipDbParam = Chip::find($val);
|
Chip::update2($idxParam,
|
||||||
if (!$chipDbParam){
|
array(
|
||||||
$this->_rspErr(1,"unique_id_param:{$val} parameter error");
|
'account_id' => myself()->_getAccountId() . '!!!',
|
||||||
return;
|
)
|
||||||
}
|
);
|
||||||
if ($chipDbParam['token_id']) {
|
|
||||||
$this->_rspErr(1, "Unable to use nft chip");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($chipDbParam['state'] == Chip::FREE_STATE) {
|
|
||||||
$this->_rspErr(1, "Unable to use free chip");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($chipDbParam['chip_grade']>$chipDbMain['chip_grade']){
|
|
||||||
$this->_rspErr(1, "The selected material is too high grade");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$cumulative_cost += \services\FormulaService::getChipCumulativeCost($chipDbParam['chip_grade']);
|
|
||||||
}
|
|
||||||
//清除材料芯片
|
|
||||||
foreach ($idxParam as $idx){
|
|
||||||
Chip::update2($idx,
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId() . '!!!',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$propertyChgService = new services\PropertyChgService();
|
$propertyChgService = new services\PropertyChgService();
|
||||||
$propertyChgService->addChip();
|
$propertyChgService->addChip();
|
||||||
if (round(1,100) > ($cumulative_cost/$upgrade_cost)*100){
|
|
||||||
//合成失败
|
|
||||||
$this->_rspData([
|
|
||||||
'state' => 0,
|
|
||||||
'property_chg' => $propertyChgService->toDto(),
|
|
||||||
]);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rand_attr = emptyReplace(json_decode($chipDbMain['rand_attr'], true), array());
|
$rand_attr = emptyReplace(json_decode($chipDbMain['rand_attr'], true), array());
|
||||||
$attrProMeta = \mt\ChipAttr::getAttrPool($chipDbMain);
|
$attrProMeta = \mt\ChipAttr::getAttrPool($chipDbMain);
|
||||||
array_push($rand_attr,array(
|
array_push($rand_attr,array(
|
||||||
@ -191,7 +213,6 @@ class ChipController extends BaseAuthedController
|
|||||||
$chipDbNew = Chip::toDto(Chip::find($idxMain));
|
$chipDbNew = Chip::toDto(Chip::find($idxMain));
|
||||||
$this->_rspData([
|
$this->_rspData([
|
||||||
'data'=>$chipDbNew,
|
'data'=>$chipDbNew,
|
||||||
'state' => 1,
|
|
||||||
'property_chg' => $propertyChgService->toDto(),
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
111
webapp/controller/HeroSkillController.class.php
Normal file
111
webapp/controller/HeroSkillController.class.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
require_once('mt/Skill.php');
|
||||||
|
require_once('mt/Hero.php');
|
||||||
|
|
||||||
|
require_once('models/Hero.php');
|
||||||
|
|
||||||
|
|
||||||
|
use models\Hero;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
class HeroSkillController extends BaseAuthedController
|
||||||
|
{
|
||||||
|
public function getSkillList(){
|
||||||
|
$skillList = \mt\Skill::getPresetSkill();
|
||||||
|
$list = array_column($skillList,'skill_id');
|
||||||
|
$this->_rspData(array(
|
||||||
|
'data' => $list,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function presetHero(){
|
||||||
|
$skillId = getReqVal('skill_id',0);
|
||||||
|
$skillMeta = \mt\Skill::get($skillId);
|
||||||
|
if (! $skillMeta){
|
||||||
|
$this->_rspErr(1,'skill_id parameter error');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
$heroList = array();
|
||||||
|
Hero::getHeroList(function ($row) use(&$heroList) {
|
||||||
|
array_push($heroList, $row);
|
||||||
|
});
|
||||||
|
$list = array_unique(array_column($heroList,'hero_id'));
|
||||||
|
$data = array();
|
||||||
|
if (count($list) > 0){
|
||||||
|
foreach ($list as $value){
|
||||||
|
$data[$value] = array(
|
||||||
|
'item_id' => $value,
|
||||||
|
'state' => 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = SqlHelper::ormSelect(
|
||||||
|
$this->_getSelfMysql(),
|
||||||
|
't_hero_skill',
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId(),
|
||||||
|
'skill_id' => $skillId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($rows){
|
||||||
|
foreach ($rows as $row){
|
||||||
|
$heroDb = Hero::find($row['hero_uid']);
|
||||||
|
$data[$heroDb['hero_id']]['state'] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_rspData(array(
|
||||||
|
'data' => $data,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyHero(){
|
||||||
|
$skillId = getReqVal('skill_id',0);
|
||||||
|
$heroIds = getReqVal('hero_ids','');
|
||||||
|
$heroIdArr = explode('|',$heroIds);
|
||||||
|
if (!$skillId || count($heroIdArr)<0){
|
||||||
|
$this->_rspErr(1,' parameter error');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
$skillMeta = \mt\Skill::get($skillId);
|
||||||
|
if (! $skillMeta){
|
||||||
|
$this->_rspErr(1,'skill_id parameter error');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
foreach ($heroIdArr as $heroId){
|
||||||
|
$heroMeta = \mt\Hero::get($heroId);
|
||||||
|
if (! $heroMeta){
|
||||||
|
$this->_rspErr(1,'hero_id parameter error');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($heroIdArr as $heroId){
|
||||||
|
$heroList = Hero::getHeroByItemId($heroId);
|
||||||
|
if ($heroList){
|
||||||
|
foreach ($heroList as $hero){
|
||||||
|
SqlHelper::upsert
|
||||||
|
($this->_getSelfMysql(),
|
||||||
|
't_hero_skill',
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId(),
|
||||||
|
'hero_uid' => $hero['idx'],
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'skill_id' => $skillId,
|
||||||
|
'modifytime' => $this->_getNowTime(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId(),
|
||||||
|
'hero_uid' => $hero['idx'],
|
||||||
|
'skill_id' => $skillId,
|
||||||
|
'createtime' => $this->_getNowTime(),
|
||||||
|
'modifytime' => $this->_getNowTime(),
|
||||||
|
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
}
|
@ -65,9 +65,11 @@ class ChipPage extends BaseModel
|
|||||||
$newRow = self::find($row['page_id']);
|
$newRow = self::find($row['page_id']);
|
||||||
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
foreach ($newData as $value){
|
foreach ($newData as $key=>$value){
|
||||||
|
$newData[$key]['item_id'] = 0;
|
||||||
if ($value['chip_id']){
|
if ($value['chip_id']){
|
||||||
$chipDb = Chip::find($value['chip_id']);
|
$chipDb = Chip::find($value['chip_id']);
|
||||||
|
$newData[$key]['item_id'] = $chipDb['item_id'];
|
||||||
$chipAttrMeta = ChipAttr::getAttrByItemId($chipDb['item_id']);
|
$chipAttrMeta = ChipAttr::getAttrByItemId($chipDb['item_id']);
|
||||||
$rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array());
|
$rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array());
|
||||||
array_push($attrs,array(
|
array_push($attrs,array(
|
||||||
|
@ -812,4 +812,14 @@ class Hero extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getHeroByItemId($itemId){
|
||||||
|
$hero = array();
|
||||||
|
self::getHeroList(function ($row) use (&$hero,$itemId) {
|
||||||
|
if ($row['hero_id'] == $itemId) {
|
||||||
|
array_push($hero,$row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return $hero;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,17 @@ class Skill {
|
|||||||
return getXVal(self::getMetaList(), $id);
|
return getXVal(self::getMetaList(), $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getPresetSkill()
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
foreach (self::getMetaList() as $value){
|
||||||
|
if ($value['skill_id'] < 20000){
|
||||||
|
array_push($list,$value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
protected static function getMetaList()
|
protected static function getMetaList()
|
||||||
{
|
{
|
||||||
if (!self::$metaList) {
|
if (!self::$metaList) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user