diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 4d5216fb..1d2f5435 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -4,6 +4,7 @@ require_once('mt/Parameter.php'); require_once('mt/Item.php'); require_once('mt/Drop.php'); require_once('mt/Hero.php'); +require_once('mt/LootConfig.php'); require_once('models/Bag.php'); require_once('models/Hero.php'); @@ -135,6 +136,8 @@ class BagController extends BaseAuthedController { $this->openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); } else if ($itemMeta['type'] == mt\Item::TREASURE_BOX) { $this->openTreasureBox($itemDb, $itemMeta, $itemNum); + }else if ($itemMeta['type'] == mt\Item::GOLD_SYN) { + $this->resolveGolds($itemDb, $itemMeta, $itemNum); } else if ($itemMeta['type'] == mt\Item::BATTLE_REWARD_BOX) { $this->openBattleBox($itemDb, $itemMeta, $itemNum); } else { @@ -380,32 +383,30 @@ class BagController extends BaseAuthedController { 'property_chg' => $this->propertyChgService->toDto(), )); } -// public function test(){ -// $itemMeta = mt\Item::get(400001); -// $itemDb= 0; -// $itemNum= 0; -// $this->openBattleBox($itemDb,$itemMeta,$itemNum); -//// print_r($itemMeta); -// } private function openBattleBox($itemDb,$itemMeta,$itemNum){ - $lucky = Hero::getAccountLucky(myself()->_getAddress()); - $luckyParam = \mt\Parameter::getVal('economy_account_luck_K',0); - $luckyMaxPro = \mt\Parameter::getVal('economy_account_luck_E',0); - $prob = $luckyMaxPro * ($lucky / ($lucky+$luckyParam)); - $times = $this->proEffect($prob,1); - $items = \services\LootService::dropOutItem($itemMeta['loot']); + $lootMeta = mt\LootConfig::find($itemMeta['loot']); + if ($lootMeta['isAffected']){ + $lucky = Hero::getAccountLucky(myself()->_getAddress()); + $luckyParam = \mt\Parameter::getVal('economy_account_luck_K',0); + $luckyMaxPro = \mt\Parameter::getVal('economy_account_luck_E',0); + $prob = $luckyMaxPro * ($lucky / ($lucky+$luckyParam)); + $times = $this->proEffect($prob,1); + $items = \services\LootService::dropOutItem($itemMeta['loot']); + if ($times > 0){ + foreach ($items as &$item){ + $item['item_num'] += $item['item_num']*$times; + } + } + }else{ + $items = \services\LootService::dropOutItem($itemMeta['loot']); + } $this->_decItems(array( array( 'item_id' => $itemMeta['id'], 'item_num' => 1 ) )); - if ($times > 0){ - foreach ($items as &$item){ - $item['item_num'] += $item['item_num']*$times; - } - } $this->_addItems($items,$this->awardService,$this->propertyChgService); $this->propertyChgService->addBagChg(); $this->_rspData(array( @@ -591,4 +592,49 @@ class BagController extends BaseAuthedController { } + private function resolveGolds($itemDb,$itemMeta,$itemNum){ + $paramMeta = mt\Parameter::getVal('gold_synthesis_rank',0); + if (!$paramMeta){ + $this->_rspErr(1,"config error"); + return ; + } + $consume = explode("|",$paramMeta); + switch ($itemMeta['id']){ + case V_ITEM_GOLDS :{ + $items = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $consume[0] + ) + ); + } + break; + case V_ITEM_GOLDBRICK :{ + $items = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $consume[1] + ) + ); + } + break; + default:{ + $this->_rspErr(1,"param error"); + return ; + } + } + $this->_decItems(array( + array( + 'item_id' => $itemMeta['id'], + 'item_num' => 1 + ) + )); + $this->_addItems($items, $this->awardService, $this->propertyChgService); + $this->propertyChgService->addUserChg(); + $this->propertyChgService->addBagChg(); + $this->_rspData(array( + 'property_chg' => $this->propertyChgService->toDto(), + )); + } + } diff --git a/webapp/controller/GMController.class.php b/webapp/controller/GMController.class.php index 0be7e825..86e1cac8 100644 --- a/webapp/controller/GMController.class.php +++ b/webapp/controller/GMController.class.php @@ -4,6 +4,7 @@ require_once('phpcommon/tglog.php'); require_once('mt/Item.php'); require_once('mt/Parameter.php'); +require_once('mt/LootConfig.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); require_once('services/LootService.php'); @@ -227,27 +228,32 @@ END $this->_rspErr(2, 'config error'); return; } - - $luckyParam = \mt\Parameter::getVal('economy_account_luck_K',0); - $luckyMaxPro = \mt\Parameter::getVal('economy_account_luck_E',0); - $prob = $luckyMaxPro * ($lucky / ($lucky+$luckyParam)); - - for ($i=0; $i<$itemNum; $i++){ - $times = $this->proEffect($prob,1); - $temp = array( - "prob" => $prob, - "times" => $times - ); - $items = \services\LootService::dropOutItem($itemMeta['loot']); - if ($times > 0){ - foreach ($items as &$item){ - $item['item_num'] += $item['item_num']*$times; + $lootMeta = mt\LootConfig::find($itemMeta['loot']); + if ($lootMeta['isAffected']){ + $luckyParam = \mt\Parameter::getVal('economy_account_luck_K',0); + $luckyMaxPro = \mt\Parameter::getVal('economy_account_luck_E',0); + $prob = $luckyMaxPro * ($lucky / ($lucky+$luckyParam)); + for ($i=0; $i<$itemNum; $i++){ + $times = $this->proEffect($prob,1); + $temp = array( + "prob" => $prob, + "times" => $times + ); + $items = \services\LootService::dropOutItem($itemMeta['loot']); + if ($times > 0){ + foreach ($items as &$item){ + $item['item_num'] += $item['item_num']*$times; + } } + array_unshift($items,$temp); + TGLog::writeToLog("game_2006_api","loot",$items); + } + }else{ + for ($i=0; $i<$itemNum; $i++){ + $items = \services\LootService::dropOutItem($itemMeta['loot']); + TGLog::writeToLog("game_2006_api","loot",$items); } - array_unshift($items,$temp); - TGLog::writeToLog("game_2006_api","loot",$items); } - } private function proEffect($p,$b){ diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index 4801206d..b697d0d7 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -108,6 +108,7 @@ class Item { const PLANET_TYPE = 28; const AVATAR_TYPE = 29; const TREASURE_BOX = 30; + const GOLD_SYN = 31; const BATTLE_REWARD_BOX = 32; const FUNC_RENAME_CARD_SUBTYPE = 1;