hisBattleData = HashRateBattleData::getMyBattleData(); $this->hashRateData = getXVal($this->hisBattleData, 'data', array()); if (!$this->hashRateData){ $this->hashRateData = array( 'pvpData' => array(), 'mobaData' => array(), 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), ); } $currentPeriod= \mt\AchievementsCycle::getPeriod(); if (myself()->_getDaySeconds(getXVal($this->hashRateData, 'modifytime', 0)) < myself()->_getDaySeconds(strtotime($currentPeriod['obtain_start_time']))) { $this->hashRateData = array( 'pvpData' => array(), 'mobaData' => array(), 'modifytime' => myself()->_getNowTime(), ); } $this->pvpBattleData = $this->hashRateData['pvpData']; $this->mobaBattleData = $this->hashRateData['mobaData']; } public function hashRateTaskDto($taskMate ,$currentPeriod){ $taskDto = array( 'task_id' => $taskMate['id'], 'current' => 0, 'target' => getXVal($taskMate, 'Completed_quantity', 1), 'state' => self::NOT_FINISHED_STATE, ); switch ($taskMate['Completion_type']){ //吃鸡或4v4获得胜利 case AchievementsPower::TOTAL_WINS_TIMES : { $taskDto['current'] = $this->getBattleData($taskMate, 'total_win_times'); } break; //击杀人数 case AchievementsPower::TOTAL_KILL_TIMES : { $taskDto['current'] = $this->getBattleData($taskMate, 'total_kills_times'); } break; //使用X道具 case AchievementsPower::USE_ITEM_TIMES : { $taskDto['current'] = $this->getWeaponsSlotData($taskMate); } break; //X分钟内结束比赛 case AchievementsPower::NOMINAL_TIME_BATTLE_END : { $taskDto['current'] = $this->getBattleData($taskMate, 'total_fiveMin_times'); } break; //在局内升级最快次数 case AchievementsPower::IN_BATTLE_UP_LV : { $taskDto['current'] = $this->getBattleData($taskMate, 'total_first_Lv_up'); } break; //游戏场次 case AchievementsPower::TOTAL_BATTLE_TIMES : { $taskDto['current'] = $this->getBattleData($taskMate, 'total_battle_times'); } break; //最后一名次数 case AchievementsPower::TOTAL_LAST_RUNNER : { $taskDto['current'] = $this->getBattleData($taskMate, 'total_last_runner_times'); } break; //救援队友数 case AchievementsPower::RESCUE_TEAMMATE_TIMES : { $taskDto['current'] = $this->getBattleData($taskMate, 'total_rescue_times'); } break; //累计行走距离(米) case AchievementsPower::WALKING_DISTANCE : { $taskDto['current'] = $this->getBattleData($taskMate, 'total_walking_distance'); } break; //指定英雄升阶数 case AchievementsPower::HERO_UP_QUALITY : { $state = false; Hero::getHeroList(function ($row) use ($taskMate,&$state) { if ($row['hero_id'] == $taskMate['condition'] && $row['quality'] >= $taskMate['Completed_quantity']){ $state = true; } }); if ($state){ $taskDto['current'] = $taskMate['Completed_quantity']; } } break; //拥有英雄nft数 case AchievementsPower::OWN_HERO_NFT_NUM : { //...../ } break; //拥有芯片nft数 case AchievementsPower::OWN_CHIP_NFT_NUM : { //....../ } break; //拥有金币数 case AchievementsPower::OWN_GOLD_NUM : { $taskDto['current'] = myself()->_getPeriodV(TN_TOTAL_GATHER_GOLD,0); } break; } if ($taskDto['current'] >= $taskDto['target']) { $taskDto['current'] = $taskDto['target']; $taskDto['state'] = self::FINISHED_STATE; $hashRateDb = HashRate::find($taskMate['id'],$currentPeriod['id']); if (!$hashRateDb){ $fieldKv = array( 'account_id' => myself()->_getAccountId(), 'task_id' => $taskMate['id'], 'period' => $currentPeriod['id'], 'reward' => $taskMate['Reward_quantity'], 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() ); HashRate::add($fieldKv); } } return $taskDto; } private function getBattleData($taskMate, $key) { $val = 0; $battleData = $this->internalGetBattleData($taskMate); $val = getXVal($battleData, $key, 0); return $val; } private function internalGetBattleData($taskMate) { $battleData = null; if ($taskMate['scene'] == AchievementsPower::PVP_SCENE) { $battleData = $this->pvpBattleData; } else if ($taskMate['scene'] == AchievementsPower::MOBA_SCENE){ $battleData = $this->mobaBattleData; } return $battleData ? $battleData : array(); } private function getWeaponsSlotData($taskMate){ $val = 0; $battleData = $this->internalGetBattleData($taskMate); $slotData = isset($battleData['weapons_slot_data']) ? $battleData['weapons_slot_data'] : array(); if (array_key_exists($taskMate['condition'],$slotData)){ $val = $slotData[$taskMate['condition']]; } return $val; } }