protected function _exec() { $itemId = $this->getParam('itemId', 'int'); $characterId = $this->getParam('heroid', 'int'); $itemDef = get_xml_def($itemId); if (empty($itemDef)) { $this->throwException("itemId is not item {$itemId}"); } $itemMgr = new UserGameItemManager($characterId); $itemMgr->subItem($itemId, 1); $hero_mgr = new CharacterAccountManager(); $hero_account = $hero_mgr->getCharacterAccount($characterId); $new_hero_info = StaticFunction::resetCurPower($hero_account); $cur_power = $new_hero_info['power']; if ($itemId == "80000") { $heroChange = array('power' => $cur_power + 50, 'powertime' => $new_hero_info['powertime']); } else { if ($itemId == "80001") { $heroChange = array('power' => StaticFunction::getTotalPower(StaticFunction::expToGrade($new_hero_info['exp']), StaticFunction::expToVip($new_hero_info['vip'])), 'powertime' => $new_hero_info['powertime']); } } $hero_mgr->updateUserStatus($characterId, $heroChange); $itemMgr->commitToDB(); $heroChange['item_id'] = $itemId; return $heroChange; }
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'); $name = $this->getParam('name', 'string'); $itemId = $this->getParam('itemId', 'int'); $characterId = $this->getParam('characterId', 'int'); $characterDef = get_xml_def($itemId); if (empty($characterDef) || intval($itemId / 10000) != 1) { $this->throwException("itemId is not character {$itemId}", GameStatusCode::DATA_ERROR); } $HeroCost = StaticFunction::$heroCost; $user_mgr = new UserAccountManager(); $user_account = $user_mgr->getUserAccount($gameuid); if ($characterId >= count($HeroCost)) { $this->throwException("character id not enough characterId: {$characterId} ", GameStatusCode::DATA_ERROR); } $costcoin = $HeroCost[$characterId]["coin"]; if ($costcoin > $user_account["coin"]) { $this->throwException("user not enough coin: {$costcoin} ", GameStatusCode::DATA_ERROR); } $change = array('coin' => -$costcoin); $costgem = $HeroCost[$characterId]["gem"]; if ($costgem > $user_account["gem"]) { $this->throwException("user not enough gem: {$costgem} ", GameStatusCode::DATA_ERROR); } $change['gem'] = -$costgem; $new_CharacterId = intval($gameuid * 10 + $characterId); $character_mgr = new CharacterAccountManager(); $character_info = $character_mgr->getCharacterAccount($new_CharacterId); if (!empty($character_info)) { $this->throwException("character id is exist characterId: {$new_CharacterId} ", GameStatusCode::DATA_ERROR); } $character_info = $character_mgr->createCharacterAccount($new_CharacterId, $name, $itemId); $itemMgr = new UserGameItemManager($new_CharacterId); $initItems = InitUser::$item_arr[$itemId]; foreach ($initItems as $v) { $itemMgr->addItem($v['item_id'], $v['count']); } $itemMgr->commitToDB(); $user_mgr->updateUserStatus($gameuid, $change); return array("character" => $character_info, "change" => $change); }
protected function _exec() { $gameuid = $this->getParam('gameuid', 'int'); $itemId = $this->getParam('itemId', 'int'); $count = $this->getParam('count', 'int'); $useGem = $this->getParam('useGem', 'bool'); $characterId = $this->getParam('heroid', 'int'); $itemDef = get_xml_def($itemId); if (empty($itemDef)) { $this->throwException("itemId is not item {$itemId}"); } $cost = 0; if ($useGem) { $cost = $itemDef['gem'] * $count; } else { $cost = $itemDef['coin'] * $count; } if ($cost <= 0) { $this->throwException("itemId is no cost useGem {$useGem} : {$cost}"); } $itemMgr = new UserGameItemManager($characterId); $itemMgr->addItem($itemId, $count); $user_mgr = new UserAccountManager(); $user_account = $user_mgr->getUserAccount($gameuid); if ($useGem) { if ($user_account['gem'] < $cost) { $this->throwException("character {$gameuid} not enough gem {$cost}"); } $user_mgr->updateUserMoney($gameuid, -$cost); } else { if ($user_account['coin'] < $cost) { $this->throwException("character {$gameuid} not enough coin {$cost}"); } $user_mgr->updateUserCoin($gameuid, -$cost); } $itemMgr->commitToDB(); return array("state" => TRUE); }
function additems($gameuid, $item_id, $uid, $name) { $item_def = get_xml_def($item_id, XmlDbType::XMLDB_ITEM); if (empty($item_def['matchPoint'])) { return 0; } else { include_once GAMELIB . '/model/activity/UserMedalManager.class.php'; include_once GAMELIB . '/model/UserPickUpBonusManager.class.php'; //每次新大赛都要会实例化第几个表 $user_medal = new UserMedalManager(8); $user_pick = new UserPickUpBonusManager(); $item = explode("|", $item_def['matchPoint']); $rand_arr = array(); foreach ($item as $v) { $add_item = explode(":", $v); $rand_arr[$add_item[0]] = $add_item[1]; } $count = StaticFunction::getOneByRate($rand_arr); if ($count > 0) { $user_medal->addMedal($gameuid, $uid, $name, $count); $user_pick->setPickUpCache($gameuid, 'special', $count); } return $count; } }