diff --git a/doc/Chip.py b/doc/Chip.py index abdae5bf..da22277a 100644 --- a/doc/Chip.py +++ b/doc/Chip.py @@ -55,6 +55,7 @@ class Chip(object): 'params': [ _common.ReqHead(), ['item_id', '', '材料item_id'], + ['item_num', '', '材料item_num'], ], 'response': [ _common.RspHead(), diff --git a/doc/Hero.py b/doc/Hero.py index ecddb002..7b910a90 100644 --- a/doc/Hero.py +++ b/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(), '属性变更'], + ] }, ] diff --git a/doc/_common.py b/doc/_common.py index 2db7ac3f..06a7f906 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -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', '', '品阶'], diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 0f5e8f8b..0430e0f5 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -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); diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index ded512f7..20099cb1 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -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',''); - $items = \services\LootService::dropOutItem($synLoot); - $this->_addItems($items,$awardService,$propertyChgService); + $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( diff --git a/webapp/controller/FragmentController.class.php b/webapp/controller/FragmentController.class.php index 49d573b6..1bd4fff0 100644 --- a/webapp/controller/FragmentController.class.php +++ b/webapp/controller/FragmentController.class.php @@ -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); diff --git a/webapp/controller/GMController.class.php b/webapp/controller/GMController.class.php index c8bff8c1..29f3d62a 100644 --- a/webapp/controller/GMController.class.php +++ b/webapp/controller/GMController.class.php @@ -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', diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 57b67391..f1596248 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -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(), diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 9a281228..f578c35b 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -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( diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 4be582ff..7f5b1c70 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -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, diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index b0c70180..5ac2b03b 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -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){ diff --git a/webapp/mt/Manufacture.php b/webapp/mt/Manufacture.php index ede72118..a4b0213b 100644 --- a/webapp/mt/Manufacture.php +++ b/webapp/mt/Manufacture.php @@ -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; } diff --git a/webapp/mt/QualityUpMapRule.php b/webapp/mt/QualityUpMapRule.php deleted file mode 100644 index 929551ff..00000000 --- a/webapp/mt/QualityUpMapRule.php +++ /dev/null @@ -1,32 +0,0 @@ -