This commit is contained in:
hujiabin 2024-04-18 15:22:10 +08:00
parent 1686e136ba
commit d9ed2ba11e
3 changed files with 89 additions and 36 deletions

View File

@ -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(),
));
}
}

View File

@ -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){

View File

@ -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;