diff --git a/doc/_common.py b/doc/_common.py index 015ad1be..2919f4c3 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -286,6 +286,7 @@ class Hero(object): ['wealth', 0, '财富值'], ['seal_type', 0, '0:未封存 1:已封存'], ['unseal_time', 0, '解封时间'], + ['valid_time', 0, '有效时间], ] class LevelingHero(object): diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 37721fb8..75b8c3c3 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -14,6 +14,7 @@ require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); require_once('services/LogService.php'); require_once('services/NameService.php'); +require_once('services/LootService.php'); use phpcommon\SqlHelper; use models\Bag; @@ -133,7 +134,9 @@ class BagController extends BaseAuthedController { } else if ($itemMeta['type'] == mt\Item::GIFT_PACKAGE_TYPE) { $this->openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); } else if ($itemMeta['type'] == mt\Item::TREASURE_BOX) { - $this->openBox($itemDb, $itemMeta, $itemNum); + $this->openTreasureBox($itemDb, $itemMeta, $itemNum); + } else if ($itemMeta['type'] == mt\Item::BATTLE_REWARD_BOX) { + $this->openBattleBox($itemDb, $itemMeta, $itemNum); } else { $this->_rspErr(4, 'The prop function has not been realized yet'); } @@ -329,7 +332,7 @@ class BagController extends BaseAuthedController { )); } - private function openBox($itemDb,$itemMeta,$itemNum){ + private function openTreasureBox($itemDb,$itemMeta,$itemNum){ $dropMeta = mt\Drop::get($itemMeta['drop']); if (!$dropMeta) { @@ -365,6 +368,52 @@ 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']); + $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( + 'award' => $this->awardService->toDto(), + 'property_chg' => $this->propertyChgService->toDto(), + )); + } + + private function proEffect($p,$b){ + if ($p * $b > -1 && $b != 0) { + $x = floor($p) * $b; + $y = max($x+$b,-1); + $q = ($p * $b - $y) / ($x - $y); + $rnd = rand(1,100); + return $rnd < $q*100 ? $x : $y; + }else{ + return 0; + } + } + public function buyItem() { diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index ac614447..38c202fe 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -250,6 +250,12 @@ class Hero extends BaseModel { } $skinDb = HeroSkin::findBx($row['hero_id']); // $attribute = self::celHeroWealthUpLimit($row); + { + $heroMeta = \mt\Item::get($row['hero_id']); + $heroAtteMeta = \mt\EconomyAttribute::findByGrade($heroMeta['relationship'],$row['quality']); + $unsealTime = $row['unseal_time'] ? $row['unseal_time'] : $row['activate_time']; + $validTime = $unsealTime + 86400 * $heroAtteMeta['validTime'] ; + } $dto = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -281,6 +287,8 @@ class Hero extends BaseModel { 'ability' => self::abilityInfo($row, $attr), 'seal_type' => $row['seal_type'], 'unseal_time' => $row['unseal_time'], + 'valid_time' => max(0, + $validTime - myself()->_getNowTime()) ); // $nft_address = ''; diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index f7faf9e2..79f1b404 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 BATTLE_REWARD_BOX = 32; const FUNC_RENAME_CARD_SUBTYPE = 1; const FUNC_GUILD_CARD_SUBTYPE = 3; @@ -272,6 +273,7 @@ class Item { self::CHEST_BOX_TYPE, self::CRYSTAL_TYPE, self::TREASURE_BOX, + self::BATTLE_REWARD_BOX, )); } diff --git a/webapp/services/TameBattleDataService.php b/webapp/services/TameBattleDataService.php index c9dd8d94..a7b8e642 100644 --- a/webapp/services/TameBattleDataService.php +++ b/webapp/services/TameBattleDataService.php @@ -659,10 +659,10 @@ class TameBattleDataService extends BaseService { $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); $lastCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id'] - 1); $currentCompute = HashRate::getTotalByAccount($userDb['account_id'], $currentPeriod['id']); - $s = mt\Parameter::getVal('compute_inherit_rate',0); + $s = mt\Parameter::getVal('economy_account_compute_s',0); $totalCompute = $currentCompute + $s * $lastCompute; - $computeParam = mt\Parameter::getVal('compute_parameter',0); - $computeMaxEffect = mt\Parameter::getVal('compute_maximum_effect',0); + $computeParam = mt\Parameter::getVal('economy_account_compute_K',0); + $computeMaxEffect = mt\Parameter::getVal('economy_account_compute_E',0); $gold = intval( $gold * ($totalCompute / ($totalCompute + $computeParam) * $computeMaxEffect + 1)); if ($gold > 0){ array_push($reward,array(