英雄功能变动
This commit is contained in:
parent
3428c498c5
commit
aeb9ed99ce
@ -55,6 +55,7 @@ class Chip(object):
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['item_id', '', '材料item_id'],
|
||||
['item_num', '', '材料item_num'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
|
21
doc/Hero.py
21
doc/Hero.py
@ -82,8 +82,10 @@ class Hero(object):
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['hero_uniid', 0, '英雄唯一id'],
|
||||
['item_id', 0, 'item_id'],
|
||||
['item_num', 0, 'item_num'],
|
||||
['item_id', 0, '碎片item_id'],
|
||||
['item_num', 0, '碎片数量'],
|
||||
['extra_item', 0, '附加道具(选填)'],
|
||||
['extra_num', 0, '附加道具数量(选填)'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
@ -104,6 +106,21 @@ class Hero(object):
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},{
|
||||
'name': 'synHero',
|
||||
'desc': '英雄合成',
|
||||
'group': 'Hero',
|
||||
'url': 'webapp/index.php?c=Hero&a=synHero',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['item_id', 0, '碎片item_id'],
|
||||
['item_num', 0, '碎片数量'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['item_id', 0, '英雄item_id'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
|
@ -900,8 +900,7 @@ class Chip(object):
|
||||
['chip_grade', 0, '芯片等级'],
|
||||
['chip_type', 0, '芯片类型:1 攻击;2 防御;3 辅助'],
|
||||
['state', 0, '0:已购买 1:免费(GIFT标签)'],
|
||||
['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'],
|
||||
['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'],
|
||||
['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 '],
|
||||
['!rand_attr', [ChipAttr()], '属性'],
|
||||
['tags', '', '1:Gen状态'],
|
||||
['quality', '', '品阶'],
|
||||
|
@ -496,11 +496,8 @@ class BaseAuthedController extends BaseController {
|
||||
switch ($itemMeta['type']) {
|
||||
case mt\Item::HERO_TYPE:
|
||||
{
|
||||
if (isset($item['is_payed']) && $item['is_payed']) {
|
||||
$res = Hero::addHero($itemMeta);
|
||||
} else {
|
||||
$res = Hero::addFreeHero($itemMeta);
|
||||
}
|
||||
$heroMeta = \mt\Hero::get($itemMeta['id']);
|
||||
$res = Hero::addHero($heroMeta);
|
||||
if ($res){
|
||||
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
|
||||
$awardService->addHero($item['item_id'],$lastIdx);
|
||||
|
@ -103,7 +103,21 @@ class ChipController extends BaseAuthedController
|
||||
}
|
||||
|
||||
//消耗材料
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$costItems = array();
|
||||
if ($manufactureMeta['gold']){
|
||||
array_push($costItems, array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $manufactureMeta['gold'],
|
||||
));
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService->addUserChg();
|
||||
}
|
||||
foreach ($consumeUniIdArr as $uniid){
|
||||
$consumeChipDb = Chip::find($uniid);
|
||||
array_push($costItems, $consumeChipDb);
|
||||
@ -112,7 +126,7 @@ class ChipController extends BaseAuthedController
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
));
|
||||
}
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
|
||||
$propertyChgService->addChip();
|
||||
$hashChance = \mt\Manufacture::hashChance($manufactureMeta['chance']);
|
||||
$weight = $hashChance[0];
|
||||
@ -139,7 +153,7 @@ class ChipController extends BaseAuthedController
|
||||
'ID' => 'chip',
|
||||
'SUB_ID' => 'advanced',
|
||||
'SUB_KEY' => 'chip_advanced',
|
||||
'cost_chip' => $costItems,
|
||||
'cost_items' => $costItems,
|
||||
'chance' => $weight,
|
||||
'result' => $status,
|
||||
'outcome_chip' =>$chipDb,
|
||||
@ -153,16 +167,22 @@ class ChipController extends BaseAuthedController
|
||||
|
||||
public function synChip(){
|
||||
$itemId = getReqVal('item_id',0);
|
||||
$itemNum = getReqVal('item_num',0);
|
||||
$needItem = \mt\Parameter::getVal('chip_craft_need_item',0);
|
||||
$needItemNum = \mt\Parameter::getVal('chip_craft_need_item_number',50);
|
||||
if ($itemId != $needItem){
|
||||
$this->_rspErr(1, "item_id error");
|
||||
return;
|
||||
}
|
||||
if ($itemNum < $needItemNum){
|
||||
$this->_rspErr(1, "item number enough ");
|
||||
return;
|
||||
}
|
||||
$number = floor($itemNum / $needItemNum);
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $needItemNum
|
||||
'item_num' => $needItemNum * $number
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
@ -177,18 +197,19 @@ class ChipController extends BaseAuthedController
|
||||
$propertyChgService->addBagChg();
|
||||
|
||||
$synLoot = \mt\Parameter::getVal('chip_craft_product_loot','');
|
||||
$outcome_chip = array();
|
||||
for ($i=0;$i<$number;$i++){
|
||||
$items = \services\LootService::dropOutItem($synLoot);
|
||||
array_push($outcome_chip,$items[0]);
|
||||
$this->_addItems($items,$awardService,$propertyChgService);
|
||||
}
|
||||
$propertyChgService->addChip();
|
||||
$event = array(
|
||||
'ID' => 'chip',
|
||||
'SUB_ID' => 'synthesis',
|
||||
'SUB_KEY' => 'chip_synthesis',
|
||||
'cost_item' => array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $needItemNum
|
||||
),
|
||||
'outcome_chip' => $items[0],
|
||||
'cost_item' => $costItems,
|
||||
'outcome_chip' => $outcome_chip,
|
||||
);
|
||||
\services\LogService::burialPointEvent($event);
|
||||
$this->_rspData(array(
|
||||
|
@ -21,182 +21,6 @@ use phpcommon\SqlHelper;
|
||||
class FragmentController extends BaseAuthedController
|
||||
{
|
||||
|
||||
|
||||
//新合成
|
||||
public function synHero(){
|
||||
$itemId = getReqVal('item_id',0);
|
||||
$itemNum = getReqVal('item_num',0);
|
||||
$itemMeta = \mt\Item::get($itemId);
|
||||
if (!$itemMeta || $itemMeta['type'] != \mt\Item::FRAGMENT_TYPE){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['sub_type'] != \mt\Item::HERO_FRAGMENT_SUBTYPE){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
if ($itemNum < 1){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
$heroMeta = \mt\Item::get($itemMeta['relationship']);
|
||||
if ( !$heroMeta ){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
$manufactureMeta = \mt\Manufacture::findHeroAction(\mt\Manufacture::SYN_ACTION,$itemMeta['quality']);
|
||||
if (!$manufactureMeta){
|
||||
$this->_rspErr(1, "Error operation");
|
||||
return;
|
||||
}
|
||||
$itemNum = min($itemNum,$manufactureMeta['numTop']);
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $manufactureMeta['gold']
|
||||
),
|
||||
array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
//消耗材料
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addBagChg();
|
||||
$propertyChgService->addUserChg();
|
||||
|
||||
$hashChance = \mt\Manufacture::hashChance($manufactureMeta['chance']);
|
||||
$weight = isset($hashChance[$itemNum]) ? $hashChance[$itemNum] : 0;
|
||||
$rnd = rand(1,100);
|
||||
$status = 0;
|
||||
if ($rnd <= $weight*100){
|
||||
$status = 1;
|
||||
$propertyChgService->addHeroChg();
|
||||
// if ($itemMeta['quality'] > 1){
|
||||
// 上链
|
||||
|
||||
// }else{
|
||||
Hero::addSyntheticHero($heroMeta,$itemMeta['quality']);
|
||||
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
|
||||
$heroInfo = Hero::toDto(Hero::find($lastIdx));
|
||||
// }
|
||||
}
|
||||
$event = array(
|
||||
'ID' => 'hero',
|
||||
'SUB_ID' => 'synthesis',
|
||||
'SUB_KEY' => 'hero_synthesis',
|
||||
'cost_fragment' => array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum,
|
||||
'item_quality' => $itemMeta['quality'],
|
||||
),
|
||||
'cost_gold' => array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $manufactureMeta['gold']
|
||||
),
|
||||
'chance' => $weight,
|
||||
'result' => $status,
|
||||
'outcome_hero' => isset($heroInfo) ? $heroInfo : array(),
|
||||
);
|
||||
LogService::burialPointEvent($event);
|
||||
$this->_rspData(array(
|
||||
'item_id' => $heroMeta['id'],
|
||||
'status' => $status,
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function synChip(){
|
||||
return
|
||||
$itemId = getReqVal('item_id',0);
|
||||
$itemNum = getReqVal('item_num',0);
|
||||
$itemMeta = \mt\Item::get($itemId);
|
||||
if (!$itemMeta || $itemMeta['type'] != \mt\Item::FRAGMENT_TYPE){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['sub_type'] != \mt\Item::CHIP_FRAGMENT_SUBTYPE){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
if ($itemNum < 1){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
$chipMeta = \mt\Item::get($itemMeta['relationship']);
|
||||
if ( !$chipMeta ){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
$manufactureMeta = \mt\Manufacture::findChipAction(\mt\Manufacture::SYN_ACTION,$itemMeta['quality']);
|
||||
if (!$manufactureMeta){
|
||||
$this->_rspErr(1, "Error operation");
|
||||
return;
|
||||
}
|
||||
$itemNum = min($itemNum,$manufactureMeta['numTop']);
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $manufactureMeta['gold']
|
||||
),
|
||||
array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
//消耗材料
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addBagChg();
|
||||
$propertyChgService->addUserChg();
|
||||
$hashChance = \mt\Manufacture::hashChance($manufactureMeta['chance']);
|
||||
$weight = isset($hashChance[$itemNum]) ? $hashChance[$itemNum] : 0;
|
||||
$rnd = rand(1,100);
|
||||
$status = 0;
|
||||
if ($rnd <= $weight*100){
|
||||
$status = 1;
|
||||
Chip::addSyntheticChip($chipMeta,$itemMeta['quality']);
|
||||
$propertyChgService->addChip();
|
||||
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
|
||||
$chipInfo = Chip::toDto(Chip::find($lastIdx));
|
||||
}
|
||||
$event = array(
|
||||
'ID' => 'chip',
|
||||
'SUB_ID' => 'synthesis',
|
||||
'SUB_KEY' => 'chip_synthesis',
|
||||
'cost_fragment' => array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum,
|
||||
'item_quality' => $itemMeta['quality'],
|
||||
),
|
||||
'cost_gold' => array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $manufactureMeta['gold']
|
||||
),
|
||||
'chance' => $weight,
|
||||
'result' => $status,
|
||||
'outcome_chip' => isset($chipInfo) ? $chipInfo : array(),
|
||||
);
|
||||
LogService::burialPointEvent($event);
|
||||
$this->_rspData(array(
|
||||
'item_id' => $chipMeta['id'],
|
||||
'status' => $status,
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
public function showBaseByItemId(){
|
||||
$item_id = getReqVal('item_id','');
|
||||
$itemMeta = mt\Item::get($item_id);
|
||||
|
@ -3,6 +3,7 @@
|
||||
require_once('phpcommon/tglog.php');
|
||||
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/LootConfig.php');
|
||||
require_once('services/AwardService.php');
|
||||
@ -134,7 +135,8 @@ END
|
||||
myself()->_rspErr(1, 'param item_id error');
|
||||
return;
|
||||
}
|
||||
Hero::addSyntheticHero($itemMeta,$quality);
|
||||
$heroMeta = \mt\Hero::get($itemMeta['id']);
|
||||
Hero::addSyntheticHero($heroMeta,$quality);
|
||||
$propertyChgService->addHeroChg();
|
||||
$this->_rspData(array(
|
||||
'text' => 'add item success',
|
||||
|
@ -3,14 +3,11 @@
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Skill.php');
|
||||
require_once('mt/QualityUpMapRule.php');
|
||||
require_once('mt/ChipAttribute.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
require_once('mt/Manufacture.php');
|
||||
require_once('mt/BattleBasicAttribute.php');
|
||||
require_once('mt/BattleRandAttribute.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/HeroPreset.php');
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
@ -18,11 +15,8 @@ require_once('services/LogService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
use models\HeroSkin;
|
||||
use models\Gun;
|
||||
use models\Nft;
|
||||
use models\HeroPreset;
|
||||
|
||||
use services\LogService;
|
||||
|
||||
class HeroController extends BaseAuthedController {
|
||||
@ -79,46 +73,28 @@ class HeroController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
英雄升阶
|
||||
*/
|
||||
public function upgradeQuality(){
|
||||
$heroUniId = getReqVal('hero_uniid', 0);
|
||||
public function synHero(){
|
||||
$itemId = getReqVal('item_id',0);
|
||||
$itemNum = getReqVal('item_num',0);
|
||||
if ($itemNum < 1){
|
||||
$this->_rspErr(1, "item_num not enough");
|
||||
$itemMeta = \mt\Item::get($itemId);
|
||||
if (!$itemMeta || $itemMeta['type'] != \mt\Item::FRAGMENT_TYPE){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
$heroDb = Hero::find($heroUniId);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(100, 'param hero_uniid error ');
|
||||
$heroMeta = \mt\Hero::get($itemMeta['relationship']);
|
||||
if ( !$heroMeta ){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
if ($heroDb['quality'] == \mt\QualityUpMapRule::MAX_QUALITY){
|
||||
$this->_rspErr(5, "It's already the highest level");
|
||||
if ($itemId != $heroMeta['heroPiece'] || $itemNum < $heroMeta['pieceNumber']){
|
||||
$this->_rspErr(1, "item number enough ");
|
||||
return;
|
||||
}
|
||||
$heroQualityMeta = \mt\QualityUpMapRule::getByQuality($heroDb['hero_id'],$heroDb['quality']+1);
|
||||
if (!$heroQualityMeta || $heroQualityMeta['needItem'] != $itemId){
|
||||
$this->_rspErr(100, 'param item_id error ');
|
||||
return;
|
||||
}
|
||||
|
||||
$manufactureMeta = \mt\Manufacture::findHeroAction(\mt\Manufacture::UP_ACTION,$heroDb['quality']+1);
|
||||
if (!$manufactureMeta){
|
||||
$this->_rspErr(1, "Error operation");
|
||||
return;
|
||||
}
|
||||
$itemNum = min($itemNum,$manufactureMeta['numTop']);
|
||||
$number = floor($itemNum / $heroMeta['pieceNumber']);
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $manufactureMeta['gold']
|
||||
),
|
||||
array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum
|
||||
'item_id' => $heroMeta['heroPiece'],
|
||||
'item_num' => $heroMeta['pieceNumber'] * $number
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
@ -130,29 +106,118 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addBagChg();
|
||||
for ($i=0; $i<$number; $i++){
|
||||
Hero::addSyntheticHero($heroMeta,2);
|
||||
}
|
||||
$propertyChgService->addHeroChg();
|
||||
$event = array(
|
||||
'ID' => 'hero',
|
||||
'SUB_ID' => 'synthesis',
|
||||
'SUB_KEY' => 'hero_synthesis',
|
||||
'cost_item' => $costItems,
|
||||
'outcome_hero' => array(
|
||||
'item_id' => $heroMeta['id'],
|
||||
'item_num' => $number
|
||||
),
|
||||
);
|
||||
LogService::burialPointEvent($event);
|
||||
$this->_rspData(array(
|
||||
'item_id' => $heroMeta['id'],
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function upgradeQuality(){
|
||||
$heroUniId = getReqVal('hero_uniid', 0);
|
||||
$itemId = getReqVal('item_id',0);
|
||||
$itemNum = max(0,getReqVal('item_num',0));
|
||||
$extraItemId = getReqVal('extra_item',0);
|
||||
$extraItemNum = max(0,getReqVal('extra_num',0));
|
||||
$heroDb = Hero::find($heroUniId);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(100, 'param hero_uniid error ');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['quality'] ==1 ){
|
||||
$this->_rspErr(5, "This hero cannot level up");
|
||||
return;
|
||||
}
|
||||
if ($heroDb['quality'] == Hero::HERO_QUALITY_MAX){
|
||||
$this->_rspErr(5, "It's already the highest level");
|
||||
return;
|
||||
}
|
||||
$heroMeta = \mt\Hero::get($heroDb['hero_id']);
|
||||
$manufactureMeta = \mt\Manufacture::getByInvoke($heroMeta['manufacture'],$heroDb['quality']+1);
|
||||
if (!$manufactureMeta){
|
||||
$this->_rspErr(1, "Error operation");
|
||||
return;
|
||||
}
|
||||
if ($itemId != $heroMeta['heroPiece'] || $itemNum < $manufactureMeta['needItem']){
|
||||
$this->_rspErr(100, 'Insufficient material');
|
||||
return;
|
||||
}
|
||||
$extraItem = explode("|",$manufactureMeta['extraItem']);
|
||||
$chanceKey = 0;
|
||||
if ($extraItemId == $extraItem[0]){
|
||||
$chanceKey = min($extraItemNum,$extraItem[1]);
|
||||
}
|
||||
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $manufactureMeta['gold']
|
||||
),
|
||||
array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $manufactureMeta['needItem']
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if ($chanceKey > 0){
|
||||
array_push($costItems, array(
|
||||
'item_id' => $extraItemId,
|
||||
'item_num' => $chanceKey
|
||||
));
|
||||
}
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
//消耗材料
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addBagChg();
|
||||
$propertyChgService->addUserChg();
|
||||
$hashChance = \mt\Manufacture::hashChance($manufactureMeta['chance']);
|
||||
$weight = isset($hashChance[$itemNum]) ? $hashChance[$itemNum] : 0;
|
||||
$weight = $hashChance[$chanceKey];
|
||||
$rnd = rand(1,100);
|
||||
$status = 0;
|
||||
if ($rnd <= $weight*100){
|
||||
$status = 1;
|
||||
$heroMeta = \mt\Item::get($heroDb['hero_id']);
|
||||
$heroAtteMeta = \mt\EconomyAttribute::findByGrade($heroMeta['relationship'],$heroDb['quality']);
|
||||
$heroNextQualityAtteMeta = \mt\EconomyAttribute::findByGrade($heroMeta['relationship'],$heroDb['quality'] + 1);
|
||||
$heroAtteMeta = \mt\EconomyAttribute::findByGrade($heroMeta['economyAttribute'],$heroDb['quality']);
|
||||
$heroNextQualityAtteMeta = \mt\EconomyAttribute::findByGrade($heroMeta['economyAttribute'],$heroDb['quality'] + 1);
|
||||
$unsealTime = $heroDb['unseal_time'] ? $heroDb['unseal_time'] : $heroDb['activate_time'];
|
||||
$validTime = $unsealTime + 86400 * $heroAtteMeta['validTime'] ;
|
||||
$valid_lefttime = max(0, $validTime - myself()->_getNowTime()) + ($heroNextQualityAtteMeta['validTime'] - $heroAtteMeta['validTime']) * 86400;
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($heroMeta['relationship'], $heroDb['quality'] + 1);
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($heroMeta['economyAttribute'], $heroDb['quality'] + 1);
|
||||
$unseal_time_new = $valid_lefttime + myself()->_getNowTime() - 86400 * $heroNextQualityAtteMeta['validTime'];
|
||||
Hero::update($heroUniId, array(
|
||||
$fieldsKv = array(
|
||||
'quality' => $heroDb['quality'] + 1,
|
||||
'unseal_time' => $unseal_time_new,
|
||||
'wealth_attr' => json_encode($attribute),
|
||||
));
|
||||
);
|
||||
if ($heroDb['quality'] + 1 > 4){
|
||||
$randAttr = emptyReplace(json_decode($heroDb['rand_attr'], true), array());
|
||||
$basicMeta = mt\BattleBasicAttribute::get($heroDb['hero_id']);
|
||||
$randMeta = mt\BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$heroDb['quality'] + 1);
|
||||
$attr = mt\BattleRandAttribute::getRandAttr($randMeta);
|
||||
$newAttr = array_merge($randAttr,$attr);
|
||||
$fieldsKv['rand_attr'] = json_encode($newAttr);
|
||||
}
|
||||
Hero::update($heroUniId, $fieldsKv);
|
||||
$heroNew = Hero::toDto(Hero::find($heroUniId));
|
||||
$propertyChgService->addHeroChg();
|
||||
|
||||
$event = array(
|
||||
'ID' => 'luck',
|
||||
'SUB_ID' => 'change',
|
||||
@ -162,7 +227,7 @@ class HeroController extends BaseAuthedController {
|
||||
);
|
||||
LogService::burialPointEvent($event);
|
||||
}
|
||||
$itemMeta = \mt\Item::get($itemId);
|
||||
|
||||
$event = array(
|
||||
'ID' => 'hero',
|
||||
'SUB_ID' => 'advanced',
|
||||
@ -170,13 +235,16 @@ class HeroController extends BaseAuthedController {
|
||||
'cost_hero' => $heroDb,
|
||||
'cost_fragment' => array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum,
|
||||
'item_quality' => $itemMeta['quality'],
|
||||
'item_num' => $manufactureMeta['needItem'],
|
||||
),
|
||||
'cost_gold' => array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $manufactureMeta['gold']
|
||||
),
|
||||
'cost_extraItem' => array(
|
||||
'item_id' => $extraItemId,
|
||||
'item_num' => $chanceKey
|
||||
),
|
||||
'chance' => $weight,
|
||||
'result' => $status,
|
||||
'outcome_hero' => isset($heroNew) ? $heroNew : array(),
|
||||
|
@ -420,37 +420,6 @@ class ShopController extends BaseAuthedController {
|
||||
)
|
||||
{
|
||||
switch ($itemMeta['type']) {
|
||||
case mt\Item::HERO_TYPE:
|
||||
{
|
||||
if (empty($grade)) {
|
||||
$grade = 0;
|
||||
}
|
||||
switch ($grade) {
|
||||
case 1:
|
||||
{
|
||||
Hero::addHero1($itemMeta);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
Hero::addHero2($itemMeta);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
Hero::addHero3($itemMeta);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
Hero::addHero($itemMeta);
|
||||
}
|
||||
break;
|
||||
}
|
||||
$propertyChgService->addHeroChg();
|
||||
$propertyChgService->addUserChg();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
myself()->_addItems(
|
||||
|
@ -125,129 +125,6 @@ class UserController extends BaseAuthedController {
|
||||
return $seasonService->checkSeason($userInfo,$awardService,$propertyService);
|
||||
}
|
||||
|
||||
private function createNewUser($userName, $avatarUrl)
|
||||
{
|
||||
$initRankParameterMeta = mt\Parameter::getByName($this->init_rank);
|
||||
$initRankMeta = mt\Rank::getRankById($initRankParameterMeta['param_value']);
|
||||
$currSeasonMeta = mt\Season::getCurrentSeason();
|
||||
$gold = 0;
|
||||
$diamond = 0;
|
||||
$heroList = array();
|
||||
$haveHeadHeroList = array();
|
||||
$headList = array();
|
||||
$headFrameList = array();
|
||||
$addItems = array();
|
||||
{
|
||||
foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) {
|
||||
$heroMeta = mt\Item::get($heroId);
|
||||
if ($heroMeta) {
|
||||
Hero::addHero($heroMeta);
|
||||
array_push($heroList, $heroMeta);
|
||||
if ($heroMeta['hero_head']) {
|
||||
array_push($haveHeadHeroList, $heroMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
foreach (mt\Parameter::getListValue('creator_present_items') as $itemsStr) {
|
||||
list($itemId, $itemNum) = explode(':', $itemsStr);
|
||||
if ($itemNum > 0) {
|
||||
switch ($itemId) {
|
||||
case V_ITEM_GOLD:
|
||||
{
|
||||
$gold += $itemNum;
|
||||
}
|
||||
break;
|
||||
case V_ITEM_DIAMOND:
|
||||
{
|
||||
$diamond += $itemNum;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$itemMeta = mt\Item::get($itemId);
|
||||
switch ($itemMeta['type']) {
|
||||
case mt\Item::HEAD_TYPE:
|
||||
{
|
||||
array_push($headList, $itemId);
|
||||
}
|
||||
break;
|
||||
case mt\Item::HEAD_FRAME_TYPE:
|
||||
{
|
||||
array_push($headFrameList, $itemId);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
array_push($addItems,
|
||||
array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$headId = !empty($headList) ? $headList[rand() % count($headList)] : 0;
|
||||
$headFrame = !empty($headFrameList) ? $headFrameList[rand() % count($headFrameList)] : 0;
|
||||
$heroUniId = 0;
|
||||
$heroId = !empty($heroList) ? $heroList[rand() % count($heroList)]['id'] : 0;
|
||||
if ($headId == 0 || count($headList) <= 1) {
|
||||
$headId = !empty($haveHeadHeroList) ?
|
||||
$haveHeadHeroList[rand() % count($haveHeadHeroList)]['hero_head'] : 0;
|
||||
}
|
||||
//Hero::randHero($heroUniId, $heroId);
|
||||
$fields = array(
|
||||
'account_id' => $this->_getAccountId(),
|
||||
'channel' => $this->_getChannel(),
|
||||
'name' => $userName,
|
||||
'sex' => rand() % 2,
|
||||
#'avatar_url' => $avatar_url,
|
||||
'gold' => $gold,
|
||||
'diamond' => $diamond,
|
||||
'head_frame' => $headFrame,
|
||||
'level' => 1,
|
||||
'exp' => 0,
|
||||
'rank' => $initRankMeta ? $initRankMeta['id'] : 1,
|
||||
'history_best_rank' => $initRankMeta ? $initRankMeta['id'] : 1,
|
||||
'score' => $initRankMeta ? $initRankMeta['rank_score'] : 0,
|
||||
'history_best_score' => $initRankMeta ? $initRankMeta['rank_score'] : 0,
|
||||
'head_id' => $headId,
|
||||
'hero_id' => $heroId,
|
||||
'last_season_id' => $currSeasonMeta ? $currSeasonMeta['id'] : 0,
|
||||
'head_list' => json_encode($headList),
|
||||
'head_frame_list' => json_encode($headFrameList),
|
||||
'score_modifytime' => $this->_getNowTime(),
|
||||
'best_rank_modifytime' => $this->_getNowTime(),
|
||||
'createtime' => $this->_getNowTime(),
|
||||
'modifytime' => $this->_getNowTime(),
|
||||
'last_login_time' => $this->_getNowTime(),
|
||||
);
|
||||
if ($this->_getChannel() == BC_CHANNEL) {
|
||||
$fields['address'] = $this->_getOpenId();
|
||||
}
|
||||
|
||||
SqlHelper::upsert
|
||||
($this->_getSelfMysql(),
|
||||
't_user',
|
||||
array(
|
||||
'account_id' => $this->_getAccountId()
|
||||
),
|
||||
array(
|
||||
),
|
||||
$fields
|
||||
);
|
||||
$awardService = new services\AwardService();
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$this->_addItems($addItems, $awardService, $propertyChgService);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
@ -1051,7 +928,8 @@ class UserController extends BaseAuthedController {
|
||||
if ($heroMeta['hero_head'] && !in_array($heroMeta['hero_head'],$headList)){
|
||||
array_push($headList,$heroMeta['hero_head']);
|
||||
}
|
||||
Hero::addFreeHero($heroMeta);
|
||||
$addHeroMeta = \mt\Hero::get($heroMeta['id']);
|
||||
Hero::addFreeHero($addHeroMeta);
|
||||
$heroUid = SqlHelper::getLastInsertId($this->_getSelfMysql());
|
||||
$fields = array(
|
||||
'hero_id' => $heroUid,
|
||||
|
@ -4,7 +4,6 @@ namespace models;
|
||||
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/HeroLevelAttr.php');
|
||||
require_once('mt/QualityUpMapRule.php');
|
||||
require_once('mt/HeroLevel.php');
|
||||
require_once('mt/AttrHelper.php');
|
||||
require_once('mt/Item.php');
|
||||
@ -44,12 +43,8 @@ class Hero extends BaseModel {
|
||||
const QUALITY_LOCK = 2;
|
||||
const SEND_LOCK = 3;
|
||||
const COST_LOCK = 4;
|
||||
//添加英雄方式
|
||||
const TYPE_FREE = 0; //免费英雄(D)
|
||||
const TYPE_1 = 1; //收费英雄(D~B)
|
||||
const TYPE_2 = 2; //收费英雄(C~A)
|
||||
const TYPE_3 = 3; //收费英雄(B~S)
|
||||
const TYPE_4 = 4; //收费英雄(D~S)
|
||||
|
||||
const HERO_QUALITY_MAX = 6;
|
||||
|
||||
public static function find($heroUniId)
|
||||
{
|
||||
@ -610,8 +605,8 @@ class Hero extends BaseModel {
|
||||
public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId,$quality = 1)
|
||||
{
|
||||
|
||||
$randAttr = self::getRandAttr($heroMeta['id'],$quality) ;
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($heroMeta['relationship'], $quality);
|
||||
$randAttr = self::getRandAttr($heroMeta['battleAttribute'],$quality) ;
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($heroMeta['economyAttribute'], $quality);
|
||||
$seal_type = 0;
|
||||
$unseal_time = 0;
|
||||
if ($quality > 1){
|
||||
|
@ -13,14 +13,6 @@ class Manufacture {
|
||||
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
|
||||
}
|
||||
|
||||
public static function findHeroAction($action,$quality){
|
||||
foreach (self::getHeroList() as $meta){
|
||||
if ($meta['action'] == $action && $meta['rank'] == $quality){
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public static function hashChance($chance){
|
||||
if (!$chance){
|
||||
@ -35,17 +27,6 @@ class Manufacture {
|
||||
return $hashChance;
|
||||
}
|
||||
|
||||
protected static function getHeroList(){
|
||||
if (!self::$heroList) {
|
||||
self::$heroList = array();
|
||||
foreach (self::getMetaList() as $meta){
|
||||
if ($meta['type'] == 1){
|
||||
array_push(self::$heroList , $meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
return self::$heroList;
|
||||
}
|
||||
|
||||
|
||||
public static function getByInvoke($invoke,$quality){
|
||||
@ -67,7 +48,5 @@ class Manufacture {
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
protected static $heroList;
|
||||
protected static $chipList;
|
||||
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class QualityUpMapRule {
|
||||
const MAX_QUALITY = 6;
|
||||
|
||||
public static function getByQuality($heroId,$quality)
|
||||
{
|
||||
foreach (self::getMetaList() as $meta){
|
||||
if ($meta['targetItem'] == $heroId && $quality == $meta['quality']){
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('qualityUpMapRule@qualityUpMapRule.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
protected static $qualityHash;
|
||||
protected static $coefficientHash;
|
||||
|
||||
}
|
@ -10,7 +10,6 @@ require_once('mt/RankReward.php');
|
||||
require_once('mt/KillReward.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/QualityUpMapRule.php');
|
||||
require_once('mt/AttrHelper.php');
|
||||
require_once('mt/PveGemini.php');
|
||||
require_once('mt/PveGeminiMode.php');
|
||||
|
@ -5,7 +5,6 @@ namespace services;
|
||||
require_once('mt/AttrHelper.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/FormulaPvp.php');
|
||||
require_once('mt/QualityUpMapRule.php');
|
||||
require_once('mt/GunQuality.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('models/RealtimeData.php');
|
||||
|
@ -9,7 +9,6 @@ require_once('mt/Rank.php');
|
||||
require_once('mt/RankReward.php');
|
||||
require_once('mt/KillReward.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/QualityUpMapRule.php');
|
||||
require_once('mt/AttrHelper.php');
|
||||
require_once('mt/RankActivity.php');
|
||||
require_once('mt/EventRanking.php');
|
||||
|
Loading…
x
Reference in New Issue
Block a user