diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 44baca7a..1a2f20f4 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -455,7 +455,8 @@ class BaseAuthedController extends BaseController { $this->_updateUserInfo($fieldsKv); $this->_incDailyV(TN_DAILY_USED_GOLD_NUM, 0, $itemNum); - $this->_incPeriodV(TN_HASH_RATE_GOLD_CONSUME, 0, $itemNum); +// $this->_incPeriodV(TN_HASH_RATE_GOLD_CONSUME, 0, $itemNum); + myself()->_fireEvent('HashRate','onSpendGold',$itemNum); } break; case V_ITEM_DIAMOND: diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 525cf9d7..710a930a 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -183,6 +183,7 @@ class BattleController extends BaseAuthedController { $teamBattleDataService->addBattleSettlementTeam(); foreach ($teamData['members'] as $member){ $member['pvp_team_rank'] = getXVal($teamData,'pvp_team_rank', 0); + $member['victory'] = getXVal($teamData,'victory', 0); if ($member['account_id'] && !myself()->_isAndroidAccountId($member['account_id'])){ $this->switchAccount($member['account_id']); $teamBattleDataService->battleInfo = $member; diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index d21a8657..8b8e88f6 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -173,7 +173,8 @@ class ChipController extends BaseAuthedController 'modifytime' => myself()->_getNowTime(), )); } - $this->_incPeriodV(TN_HASH_RATE_UP_CHIP_TIMES, 0, 1); +// $this->_incPeriodV(TN_HASH_RATE_UP_CHIP_TIMES, 0, 1); + myself()->_fireEvent('HashRate','onUpLvChip'); $propertyChgService->addChip(); $hashChance = \mt\Manufacture::hashChance($manufactureMeta['chance']); $weight = $hashChance[0]; @@ -251,7 +252,8 @@ class ChipController extends BaseAuthedController $this->_addItems($items,$awardService,$propertyChgService); } $propertyChgService->addChip(); - $this->_incPeriodV(TN_HASH_RATE_SYN_CHIP_TIMES, 0, $number); +// $this->_incPeriodV(TN_HASH_RATE_SYN_CHIP_TIMES, 0, $number); + myself()->_fireEvent('HashRate','onSynChip',$number); $event = array( 'ID' => 'chip', 'SUB_ID' => 'synthesis', diff --git a/webapp/controller/HashRateController.class.php b/webapp/controller/HashRateController.class.php index 4b069497..c7443c1d 100644 --- a/webapp/controller/HashRateController.class.php +++ b/webapp/controller/HashRateController.class.php @@ -32,10 +32,11 @@ class HashRateController extends BaseAuthedController $goldRate = 0; $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); if ($currentPeriod){ - $mateList = \mt\AchievementsPower::getCustomTypeMetaList($type,$this->hashRateService); - foreach ($mateList as $mate) { - $taskDb = HashRate::find($mate['id'],$currentPeriod['id']); - $taskDto = $this->hashRateService->hashRateTaskDto($mate,$taskDb,$currentPeriod['id']); +// $mateList = \mt\AchievementsPower::getCustomTypeMetaList($type,$this->hashRateService); + $taskList = $this->hashRateService->getHashRateTasks($type); + foreach ($taskList as $task) { + $taskDb = HashRate::find($task['task_id'],$currentPeriod['id']); + $taskDto = $this->hashRateService->hashRateTaskDto($task,$taskDb,$currentPeriod['id']); array_push($taskDtoList1, $taskDto); } $mateList2 = \mt\AchievementsPower::getListByType(\mt\AchievementsPower::TYPE5); @@ -90,8 +91,14 @@ class HashRateController extends BaseAuthedController $this->_rspErr(1, 'task_id error'); return; } - $taskDb = HashRate::find($taskMeta['id'],$currentPeriod['id']); - $taskDto = $this->hashRateService->hashRateTaskDto($taskMeta,$taskDb,$currentPeriod['id']); + $taskList = $this->hashRateService->getHashRateTasks($taskMeta['task_type']); + $taskDto = null; + foreach ($taskList as $task){ + if ($task['task_id'] == $taskId){ + $taskDb = HashRate::find($taskMeta['id'],$currentPeriod['id']); + $taskDto = $this->hashRateService->hashRateTaskDto($task,$taskDb,$currentPeriod['id']); + } + } if (!$taskDto) { $this->_rspErr(10, 'server internal error'); diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 7dc327a1..f553d34d 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -110,7 +110,8 @@ class HeroController extends BaseAuthedController { Hero::addSyntheticHero($heroMeta,2); } $propertyChgService->addHeroChg(); - $this->_incPeriodV(TN_HASH_RATE_SYN_HERO_TIMES, 0, $number); +// $this->_incPeriodV(TN_HASH_RATE_SYN_HERO_TIMES, 0, $number); + myself()->_fireEvent('HashRate','onSynHero',$number); $event = array( 'ID' => 'hero', 'SUB_ID' => 'synthesis', @@ -187,7 +188,8 @@ class HeroController extends BaseAuthedController { } //消耗材料 $this->_decItems($costItems); - $this->_incPeriodV(TN_HASH_RATE_UP_HERO_TIMES, 0, 1); +// $this->_incPeriodV(TN_HASH_RATE_UP_HERO_TIMES, 0, 1); + myself()->_fireEvent('HashRate','onUpLvHero'); $propertyChgService = new services\PropertyChgService(); $propertyChgService->addBagChg(); $propertyChgService->addUserChg(); @@ -214,6 +216,9 @@ class HeroController extends BaseAuthedController { $basicMeta = mt\BattleBasicAttribute::get($heroDb['hero_id']); $randMeta = mt\BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$heroDb['quality'] + 1); $attr = mt\BattleRandAttribute::getRandAttr($randMeta); + foreach ($attr as $key=>$value){ + $attr[$key]['new_attr'] = 1; + } $newAttr = array_merge($randAttr,$attr); $fieldsKv['rand_attr'] = json_encode($newAttr); } diff --git a/webapp/controller/HeroSkinController.class.php b/webapp/controller/HeroSkinController.class.php index 8e8725bf..133278fb 100644 --- a/webapp/controller/HeroSkinController.class.php +++ b/webapp/controller/HeroSkinController.class.php @@ -226,7 +226,8 @@ class HeroSkinController extends BaseAuthedController { HeroSkin::addSkin($skinMeta); } $propertyChgService->addHeroSkinChg(); - $this->_incPeriodV(TN_HASH_RATE_SYN_SKIN_TIMES, 0, $number); +// $this->_incPeriodV(TN_HASH_RATE_SYN_SKIN_TIMES, 0, $number); + myself()->_fireEvent('HashRate','onSynSkin',$number); $event = array( 'ID' => 'heroSkin', 'SUB_ID' => 'synthesis', diff --git a/webapp/controller/InGameMallController.class.php b/webapp/controller/InGameMallController.class.php index 9caf5050..42703c6d 100644 --- a/webapp/controller/InGameMallController.class.php +++ b/webapp/controller/InGameMallController.class.php @@ -204,7 +204,7 @@ class InGameMallController extends BaseAuthedController { switch ($itemMeta['type']){ case \mt\Item::HERO_SKIN_TYPE : { $skinDb = HeroSkin::find($goodsUniid); - if (!$skinDb){ + if (!$skinDb || $skinDb['used'] == HeroSkin::USED){ $this->_rspErr(1, 'param goods_unnid error'); return; } diff --git a/webapp/events/Battle.php b/webapp/events/Battle.php index 1a9e952e..5a3cc00e 100644 --- a/webapp/events/Battle.php +++ b/webapp/events/Battle.php @@ -8,6 +8,7 @@ class Battle public static function onSettlement($battleData) { //触发(调用)对应对该事件感兴趣的模块 + myself()->_callServiceStatic('HashRateService', 'onBattleSettele', $battleData); //myself()->_callServiceStatic('A', 'f1', $battleData); //myself()->_callServiceStatic('B', 'f1', $battleData); echo json_encode($battleData); diff --git a/webapp/events/HashRate.php b/webapp/events/HashRate.php new file mode 100644 index 00000000..c52d91ff --- /dev/null +++ b/webapp/events/HashRate.php @@ -0,0 +1,57 @@ +hisBattleData = HashRateBattleData::getMyBattleData(); + /* $this->hisBattleData = HashRateBattleData::getMyBattleData(); $this->hashRateData = getXVal($this->hisBattleData, 'hash_rate_data', array()); if (!$this->hashRateData){ $this->hashRateData = array( @@ -59,7 +63,7 @@ class HashRateService extends BaseService ); } $this->pvpBattleData = $this->hashRateData['pvpData']; - $this->mobaBattleData = $this->hashRateData['mobaData']; + $this->mobaBattleData = $this->hashRateData['mobaData']; */ $this->hashRateTask = BigData::getData(BigData::OFFER_INTEGRAL_HASHRATE_TYPE); if (!$this->hashRateTask) { $this->hashRateTask = array( @@ -71,6 +75,7 @@ class HashRateService extends BaseService 'initTime' => 0 ); } + $currentPeriod= \mt\AchievementsCycle::getCurrentPeriod(); if ($currentPeriod && $currentPeriod['id'] != $this->hashRateTask['currentPeriod']){ $this->initHashRateTask($currentPeriod['id']); } @@ -97,10 +102,14 @@ class HashRateService extends BaseService - public function hashRateTaskDto($taskMate, $taskDb,$period){ + public function hashRateTaskDto($task, $taskDb,$period){ + $taskMate = AchievementsPower::find($task['task_id']); + if (!$taskMate){ + return ; + } $taskDto = array( 'task_id' => $taskMate['id'], - 'current' => 0, + 'current' => $task['current'], 'target' => getXVal($taskMate, 'Completed_quantity', 1), 'state' => self::NOT_FINISHED_STATE, ); @@ -120,59 +129,59 @@ class HashRateService extends BaseService } switch ($taskMate['Completion_type']){ - //吃鸡或4v4获得胜利 - case \mt\AchievementsPower::TOTAL_WINS_TIMES : { - $taskDto['current'] = $this->getBattleData($taskMate, - 'total_win_times'); - } - break; - //击杀人数 - case \mt\AchievementsPower::TOTAL_KILL_TIMES : { - $taskDto['current'] = $this->getBattleData($taskMate, - 'total_kills_times'); - } - break; - //使用X道具 - case \mt\AchievementsPower::USE_ITEM_TIMES : { - $taskDto['current'] = $this->getWeaponsSlotData($taskMate); - } - break; - //X分钟内结束比赛 - case \mt\AchievementsPower::NOMINAL_TIME_BATTLE_END : { - $taskDto['current'] = $this->getBattleData($taskMate, - 'total_fiveMin_times'); - } - break; - //在局内升级最快次数 - case \mt\AchievementsPower::IN_BATTLE_UP_LV : { - $taskDto['current'] = $this->getBattleData($taskMate, - 'total_first_Lv_up'); - } - break; - //游戏场次 - case \mt\AchievementsPower::TOTAL_BATTLE_TIMES : { - $taskDto['current'] = $this->getBattleData($taskMate, - 'total_battle_times'); - } - break; - //最后一名次数 - case \mt\AchievementsPower::TOTAL_LAST_RUNNER : { - $taskDto['current'] = $this->getBattleData($taskMate, - 'total_last_runner_times'); - } - break; - //救援队友数 - case \mt\AchievementsPower::RESCUE_TEAMMATE_TIMES : { - $taskDto['current'] = $this->getBattleData($taskMate, - 'total_rescue_times'); - } - break; - //累计行走距离(米) - case \mt\AchievementsPower::WALKING_DISTANCE : { - $taskDto['current'] = $this->getBattleData($taskMate, - 'total_walking_distance'); - } - break; +// //吃鸡或4v4获得胜利 +// case \mt\AchievementsPower::TOTAL_WINS_TIMES : { +// $taskDto['current'] = $this->getBattleData($taskMate, +// 'total_win_times'); +// } +// break; +// //击杀人数 +// case \mt\AchievementsPower::TOTAL_KILL_TIMES : { +// $taskDto['current'] = $this->getBattleData($taskMate, +// 'total_kills_times'); +// } +// break; +// //使用X道具 +// case \mt\AchievementsPower::USE_ITEM_TIMES : { +// $taskDto['current'] = $this->getWeaponsSlotData($taskMate); +// } +// break; +// //X分钟内结束比赛 +// case \mt\AchievementsPower::NOMINAL_TIME_BATTLE_END : { +// $taskDto['current'] = $this->getBattleData($taskMate, +// 'total_fiveMin_times'); +// } +// break; +// //在局内升级最快次数 +// case \mt\AchievementsPower::IN_BATTLE_UP_LV : { +// $taskDto['current'] = $this->getBattleData($taskMate, +// 'total_first_Lv_up'); +// } +// break; +// //游戏场次 +// case \mt\AchievementsPower::TOTAL_BATTLE_TIMES : { +// $taskDto['current'] = $this->getBattleData($taskMate, +// 'total_battle_times'); +// } +// break; +// //最后一名次数 +// case \mt\AchievementsPower::TOTAL_LAST_RUNNER : { +// $taskDto['current'] = $this->getBattleData($taskMate, +// 'total_last_runner_times'); +// } +// break; +// //救援队友数 +// case \mt\AchievementsPower::RESCUE_TEAMMATE_TIMES : { +// $taskDto['current'] = $this->getBattleData($taskMate, +// 'total_rescue_times'); +// } +// break; +// //累计行走距离(米) +// case \mt\AchievementsPower::WALKING_DISTANCE : { +// $taskDto['current'] = $this->getBattleData($taskMate, +// 'total_walking_distance'); +// } +// break; //指定英雄升阶数 case \mt\AchievementsPower::HERO_UP_QUALITY : { $state = false; @@ -199,7 +208,13 @@ class HashRateService extends BaseService break; //拥有芯片nft数 case \mt\AchievementsPower::OWN_CHIP_NFT_NUM : { - //....../ + $chipNftCount = 0; + Chip::getChipList(function ($row) use (&$chipNftCount){ + if ($row['token_id']){ + $chipNftCount += 1; + } + }); + $taskDto['current'] = $chipNftCount; } break; //拥有金币数 @@ -215,72 +230,59 @@ class HashRateService extends BaseService break; //花费钻石数 case \mt\AchievementsPower::SPEND_DIAMOND : { - $meta = AchievementsCycle::find($period); - if ($meta) { - $obtain_start_time = strtotime($meta['obtain_start_time']); - $income_end_time = strtotime($meta['income_end_time']); - $row = myself()->_getSelfMysql()->execQueryOne( - 'SELECT SUM(amount) FROM t_diamond_consume_product WHERE (account_id=:account_id OR passport_address=:address) AND type=:type AND createtime BETWEEN :star_time AND :end_time', - array( - ':account' => myself()->_getAccountId(), - ':address' => 1, - ':type' => 0, - ':star_time' => $obtain_start_time, - ':end_time' => $income_end_time, - ) - ); - $taskDto['current'] = $row[0]; - } - } - break; - //消耗金币 - case \mt\AchievementsPower::SPEND_GOLD : { - $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_GOLD_CONSUME, 0); - } - break; - //合成英雄 - case \mt\AchievementsPower::SYN_HERO : { - $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_SYN_HERO_TIMES, 0); - } - break; - //合成芯片 - case \mt\AchievementsPower::SYN_CHIP : { - $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_SYN_CHIP_TIMES, 0); - } - break; - //合成皮肤 - case \mt\AchievementsPower::SYN_SKIN : { - $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_SYN_SKIN_TIMES, 0); - } - break; - //升阶英雄 - case \mt\AchievementsPower::UP_HERO : { - $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_UP_HERO_TIMES, 0); - } - break; - //升阶芯片 - case \mt\AchievementsPower::UP_CHIP : { - $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_UP_CHIP_TIMES, 0); + $row = myself()->_getSelfMysql()->execQueryOne( + 'SELECT SUM(amount) FROM t_diamond_consume_product WHERE (account_id=:account_id OR passport_address=:address) AND type=:type AND createtime > :star_time', + array( + ':account' => myself()->_getAccountId(), + ':address' => 1, + ':type' => 0, + ':star_time' => $task['createtime'], + ) + ); + $taskDto['current'] = $row[0]; } +// break; +// //消耗金币 +// case \mt\AchievementsPower::SPEND_GOLD : { +// $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_GOLD_CONSUME, 0); +// } +// break; +// //合成英雄 +// case \mt\AchievementsPower::SYN_HERO : { +// $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_SYN_HERO_TIMES, 0); +// } +// break; +// //合成芯片 +// case \mt\AchievementsPower::SYN_CHIP : { +// $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_SYN_CHIP_TIMES, 0); +// } +// break; +// //合成皮肤 +// case \mt\AchievementsPower::SYN_SKIN : { +// $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_SYN_SKIN_TIMES, 0); +// } +// break; +// //升阶英雄 +// case \mt\AchievementsPower::UP_HERO : { +// $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_UP_HERO_TIMES, 0); +// } +// break; +// //升阶芯片 +// case \mt\AchievementsPower::UP_CHIP : { +// $taskDto['current'] = myself()->_getPeriodV(TN_HASH_RATE_UP_CHIP_TIMES, 0); +// } break; //合成金币卡 case \mt\AchievementsPower::SYN_GOLD_CARD : { - $meta = AchievementsCycle::find($period); - if ($meta){ - $obtain_start_time = strtotime($meta['obtain_start_time']); - $income_end_time = strtotime($meta['income_end_time']); - $row = myself()->_getSelfMysql()->execQueryOne( - 'SELECT COUNT(*) FROM t_gold_bullion WHERE src_account_id=:account AND activated=:activated AND activate_time BETWEEN :star_time AND :end_time', - array( - ':account' => myself()->_getAccountId(), - ':activated' => 1, - ':star_time' => $obtain_start_time, - ':end_time' => $income_end_time, - ) - ); - $taskDto['current'] = $row[0]; - } - + $row = myself()->_getSelfMysql()->execQueryOne( + 'SELECT COUNT(*) FROM t_gold_bullion WHERE src_account_id=:account AND activated=:activated AND activate_time > :star_time ', + array( + ':account' => myself()->_getAccountId(), + ':activated' => 1, + ':star_time' => $task['createtime'], + ) + ); + $taskDto['current'] = $row[0]; } break; //累计完成任务数 @@ -351,6 +353,7 @@ class HashRateService extends BaseService array_push($this->hashRateTask['task'.$type], array( 'task_id' => $meta['id'], + 'current' => 0, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), )); @@ -507,4 +510,93 @@ class HashRateService extends BaseService } + public static function onBattleSettele($battleData) + { + //遍历已刷出的任务列表,更新战斗像相关进度 + $tasks = BigData::getData(BigData::OFFER_INTEGRAL_HASHRATE_TYPE); + if (!$tasks){ + return; + } + self::_computeTaskProgress($tasks['task1'],$battleData); + self::_computeTaskProgress($tasks['task2'],$battleData); + BigData::setData(BigData::OFFER_INTEGRAL_HASHRATE_TYPE, + json_encode($tasks)); + } + + private static function _computeTaskProgress(&$tasks,$battleData){ + foreach ($tasks as &$task){ + $taskMeta = AchievementsPower::find($task['task_id']); + switch ($taskMeta['Completion_type']){ + case AchievementsPower::TOTAL_WINS_TIMES : { + if (getXVal($battleData,'victory', 0)){ + $task['current'] += 1; + } + } + break; + case AchievementsPower::TOTAL_KILL_TIMES : { + $task['current'] += getXVal($battleData,'kills', 0); + } + break; + case AchievementsPower::USE_ITEM_TIMES : { + $task['current'] += self::_procWeaponsSlot($battleData,$taskMeta['condition']); + } + break; + case AchievementsPower::NOMINAL_TIME_BATTLE_END : { + $duration = getXVal($battleData,'game_duration', 0); + if ($duration && floor($duration / 60) < $taskMeta['condition']){ + $task['current'] += 1; + } + } + break; + case AchievementsPower::IN_BATTLE_UP_LV : { + $fullLv = getXVal($battleData,'full_level_idx', 0); + if ($fullLv == 1){ + $task['current'] += 1; + } + } + break; + case AchievementsPower::TOTAL_BATTLE_TIMES : { + if (! getXVal($battleData,'is_run_away', 0)){ + $task['current'] += 1; + } + } + break; + case AchievementsPower::TOTAL_LAST_RUNNER : { + $ranked = getXVal($battleData,'pvp_personal_rank', 0); + if ($ranked == 20){ + $task['current'] += 1; + } + } + break; + case AchievementsPower::RESCUE_TEAMMATE_TIMES : { + $task['current'] += getXVal($battleData,'rescue_teammate_times', 0); + } + break; + case AchievementsPower::WALKING_DISTANCE : { + $task['current'] += getXVal($battleData,'move_distance', 0); + } + break; + } + } + } + + private static function _procWeaponsSlot($battleData,$condition) + { + $useCount = 0; + $tmpStrs1 = explode('|', getXVal($battleData,'weapons_slot', '')); + foreach ($tmpStrs1 as $str) { + $tmpStrs2 = explode(':', $str); + if (count($tmpStrs2) >= 2) { + list($weaponId, $use_times) = $tmpStrs2; + $weaponMeta = Equip::get($weaponId); + if ($weaponMeta && $weaponMeta['inventory_slot'] > 0) { + if ( $weaponId == $condition ){ + $useCount = $use_times; + } + } + } + } + return $useCount; + } + } \ No newline at end of file diff --git a/webapp/services/TameBattleDataService.php b/webapp/services/TameBattleDataService.php index 7a1d9a88..9f994a23 100644 --- a/webapp/services/TameBattleDataService.php +++ b/webapp/services/TameBattleDataService.php @@ -100,7 +100,7 @@ class TameBattleDataService extends BaseService { if (!$heroMeta) { return false; } - + myself()->_fireEvent('Battle','onSettlement',$this->battleInfo); //记录战斗有效行为 $this->_updateBattleData(); //记录战斗数据的排行榜