protected function _exec()
 {
     $gameuid = $this->getParam('gameuid', 'int');
     $characterId = $this->getParam('heroid', 'int');
     $pieceItemId = $this->getParam('pieceItemId', 'int');
     $pieceitemDef = get_xml_def($pieceItemId);
     if (empty($pieceitemDef)) {
         $this->throwException("itemId is not item {$pieceItemId}");
     }
     $composeId = $pieceitemDef['boundItem'];
     $composeDef = get_xml_def($composeId);
     if (empty($composeDef)) {
         $this->throwException("composeitemId is not item {$composeId}");
     }
     $itemMgr = new UserGameItemManager($characterId);
     $composeOwnItem = $itemMgr->getItem($composeId);
     $pieceOwnItem = $itemMgr->getItem($pieceItemId);
     $curLevel = 0;
     if (!empty($composeOwnItem)) {
         $curLevel = $composeOwnItem['count'];
     }
     $pieceArr = explode(",", $composeDef['upCount']);
     $needPiece = $pieceArr[$curLevel];
     if ($pieceitemDef['type'] == "skill") {
         $needCoin = StaticFunction::getUpSkillCoin($curLevel);
     } else {
         if ($pieceitemDef['type'] == "soldier") {
             $needCoin = StaticFunction::getUpSoldierCoin($curLevel);
         }
     }
     if (empty($pieceOwnItem) || $pieceOwnItem['count'] < $needPiece) {
         $this->throwException("composeitemId piece is not enough {$pieceItemId}");
     }
     $user_mgr = new UserAccountManager();
     $user_account = $user_mgr->getUserAccount($gameuid);
     if ($user_account['coin'] < $needCoin) {
         $this->throwException("character {$gameuid} not enough coin {$needCoin} ");
     }
     $itemMgr->addItem($composeId, 1);
     $itemMgr->subItem($pieceItemId, $needPiece);
     $user_mgr->updateUserCoin($gameuid, -$needCoin);
     $itemMgr->commitToDB();
     return array("state" => TRUE);
 }
 protected function _exec()
 {
     $gameuid = $this->getParam('gameuid', 'int');
     $specId = $this->getParam('specId', 'string');
     $battletype = $this->getParam('battletype', 'string');
     $heroId = $this->getParam('heroid', 'int');
     $rewards = $this->getParam('battlerewards', 'array');
     $battleStar = $this->getParam('battleStar', 'int');
     $battleMgr = new BattleManager();
     $cacheInfo = $battleMgr->getBattleCache($heroId);
     if (!empty($cacheInfo)) {
         $cacheInfoArr = explode(":", $cacheInfo);
         if ($cacheInfoArr[2] == 1) {
             $this->throwException("battle has get rewards");
         }
     }
     $battleMgr->setBattleCache($heroId, $specId, $battletype, 1);
     $heroMgr = new CharacterAccountManager();
     $itemMgr = new UserGameItemManager($heroId);
     foreach ($rewards as $oneReward) {
         if ($oneReward['item_id'] == 'coin') {
             $userMgr = new UserAccountManager();
             $userMgr->updateUserCoin($gameuid, $oneReward['count']);
         } else {
             if ($oneReward['item_id'] == 'exp') {
                 $heroMgr->updateUserExperience($heroId, $oneReward['count']);
             } else {
                 $itemMgr->addItem($oneReward['item_id'], $oneReward['count']);
                 $itemMgr->commitToDB();
             }
         }
     }
     //Elite Ordinary
     if ($battleStar > 0 && $battleStar <= 3) {
         if ($battletype == "Ordinary") {
             $newItemId = $specId;
         } else {
             $newItemId = 100000 + intval($specId);
         }
         $itemInfo = $itemMgr->getItem($newItemId);
         if (empty($itemInfo)) {
             $itemMgr->addItem($newItemId, $battleStar);
         } else {
             $oldC = $itemInfo['count'];
             if ($oldC < $battleStar) {
                 $itemMgr->addItem($newItemId, $battleStar - $oldC);
             }
         }
         $itemMgr->commitToDB();
     }
     return TRUE;
 }
 protected function _exec()
 {
     $characterId = $this->getParam('heroid', 'int');
     $skillArr = $this->getParam('skill', 'array');
     $itemMgr = new UserGameItemManager($characterId);
     foreach ($skillArr as $skillId) {
         $skill = $itemMgr->getItem($skillId);
         if (empty($skill) || $skill['count'] <= 0) {
             $this->throwException("hero {$characterId} do not have the skill {$skillId}");
         }
     }
     $new_skill_str = implode(":", $skillArr);
     $characterMgr = new CharacterAccountManager();
     $characterMgr->updateUserStatus($characterId, array("skills" => $new_skill_str));
     return array("stats" => TRUE);
 }
 protected function _exec()
 {
     $gameuid = $this->getParam('gameuid', 'int');
     $specId = $this->getParam('specId', 'string');
     $battletype = $this->getParam('battletype', 'string');
     $heroId = $this->getParam('heroid', 'int');
     $rewards = $this->getParam('battlerewards', 'array');
     $itemMgr = new UserGameItemManager($heroId);
     $hero_mgr = new CharacterAccountManager();
     $hero_info = $hero_mgr->getCharacterAccount($heroId);
     $new_hero_info = StaticFunction::resetCurPower($hero_info);
     $totalPower = StaticFunction::getTotalPower(StaticFunction::expToGrade($hero_info['exp']), StaticFunction::expToVip($hero_info['vip']));
     $cur_power = $new_hero_info['power'];
     if ($cur_power < StaticFunction::$power_battle_cost) {
         $this->throwException("power is not enough ,cur power = {$cur_power} , totalpower = {$totalPower} , oldpower = {$heroId}");
     } else {
         $heroChange = array('power' => $cur_power - StaticFunction::$power_battle_cost, 'powertime' => $new_hero_info['powertime']);
         if ($battletype == "Ordinary") {
             $newItemId = $specId;
         } else {
             $newItemId = 100000 + intval($specId);
         }
         $itemInfo = $itemMgr->getItem($newItemId);
         if ($itemInfo['count'] < 3) {
             $this->throwException("this battle spec id {$newItemId} do not have 3 star");
         }
         $itemMgr->subItem("80003", 1);
         foreach ($rewards as $oneReward) {
             if ($oneReward['item_id'] == 'coin') {
                 $userMgr = new UserAccountManager();
                 $userMgr->updateUserCoin($gameuid, $oneReward['count']);
             } else {
                 if ($oneReward['item_id'] == 'exp') {
                     $heroChange['exp'] = $oneReward['count'];
                 } else {
                     $itemMgr->addItem($oneReward['item_id'], $oneReward['count']);
                 }
             }
         }
         $itemMgr->commitToDB();
         $hero_mgr->updateUserStatus($heroId, $heroChange);
         return TRUE;
     }
     return FALSE;
 }