diff --git a/doc/Hero.py b/doc/Hero.py index aac105d8..0b4b0d4b 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -121,6 +121,19 @@ class Hero(object): 'response': [ _common.RspHead(), ] + },{ + 'name': 'heroPieceSys', + 'desc': '英雄碎片合成', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=heroPieceSys', + 'params': [ + _common.ReqHead(), + ['item_id', 0, '碎片itemID'], + ], + 'response': [ + _common.RspHead(), + ['hero_id', 0, '英雄itemId'] + ] }, ] diff --git a/server/game2006service/tasks/star.js b/server/game2006service/tasks/star.js index 986579e5..83b30a8d 100644 --- a/server/game2006service/tasks/star.js +++ b/server/game2006service/tasks/star.js @@ -9,8 +9,8 @@ const constant = require('../constant'); class Star { async start() { console.log('Star And Pass Start'); - let url_star = getUrl('resetStar'); - let url_pass = getUrl('resetPassLevel'); + let url_star = getUrl('Star','resetStar'); + let url_pass = getUrl('Pass','resetPassLevel'); while (true) { await http.get(url_star,null) await http.get(url_pass,null) @@ -25,13 +25,13 @@ class Star { } -function getUrl(action){ +function getUrl(controller,action){ // let url = 'http://james.com/webapp/index.php?&c=Star&a=resetStar'; let url = ''; if (utils.isOnlineEnv()) { - url = 'https://game2006api-test.cebggame.com/webapp/index.php?&c=Star&a=' + action; + url = 'https://game2006api-test.cebggame.com/webapp/index.php?&c=' + controller + '&a=' + action; } else { - url = 'https://game2006api-test.kingsome.cn/webapp/index.php?&c=Star&a=' + action; + url = 'https://game2006api-test.kingsome.cn/webapp/index.php?&c=' + controller + '&a=' + action; } return url; } diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 02a33972..229601a6 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -303,5 +303,31 @@ class HeroController extends BaseAuthedController { )); } + public function heroPieceSys(){ + $itemId = getReqVal('item_id',0); + $pieceNum = \mt\Parameter::getVal('hero_piece_synthesis_num',0); + $itemMeta = \mt\Item::get($itemId); + if (!$itemMeta || $itemMeta['type'] != \mt\Item::FRAGMENT_TYPE){ + $this->_rspErr(1, "param item_id error"); + return; + } + $bagDb = Bag::find($itemId); + if (!$bagDb || $bagDb['item_num'] < $pieceNum){ + $this->_rspErr(1, "Insufficient material"); + return; + } + + $heroMeta = \mt\Item::get($itemMeta['relationship']); + Bag::decItem($itemId,$pieceNum); + Hero::addHero($heroMeta); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addBagChg(); + $this->_rspData(array( + 'hero_id' => $heroMeta['id'], + 'property_chg' => $propertyChgService->toDto(), + )); + } + }