This commit is contained in:
hujiabin 2024-08-07 14:40:30 +08:00
parent 668c2f54c4
commit 95a512d44c
3 changed files with 20 additions and 8 deletions

View File

@ -3,6 +3,9 @@
namespace models; namespace models;
require_once('mt/AchievementsPower.php');
use mt\AchievementsPower;
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
class HashRate extends BaseModel class HashRate extends BaseModel
{ {
@ -32,6 +35,7 @@ class HashRate extends BaseModel
} }
public static function getCount($period){ public static function getCount($period){
$count = 0;
$rows = SqlHelper::ormSelect( $rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(), myself()->_getSelfMysql(),
't_hash_rate', 't_hash_rate',
@ -40,7 +44,13 @@ class HashRate extends BaseModel
'period' => $period, 'period' => $period,
) )
); );
return count($rows); foreach ($rows as $row){
$hashMeta = AchievementsPower::find($row['task_id']);
if ($hashMeta['task_type'] != AchievementsPower::TYPE5){
$count += 1;
}
}
return $count;
} }

View File

@ -39,13 +39,14 @@ class BattleRandAttribute {
$strs = explode('|', $randMeta['attributeRange']); $strs = explode('|', $randMeta['attributeRange']);
foreach ($strs as $str){ foreach ($strs as $str){
$attrStr = explode(':', $str); $attrStr = explode(':', $str);
if (count($attrStr) == 3){
$rnd = rand($attrStr[1]*100000 , $attrStr[2]*100000) / 100000; $rnd = rand($attrStr[1]*100000 , $attrStr[2]*100000) / 100000;
// $val = $attrStr[1] + ($attrStr[2] - $attrStr[1]) * $rnd;
array_push($attrArray,array( array_push($attrArray,array(
"attr_id" => $attrStr[0], "attr_id" => $attrStr[0],
"val" => $rnd, "val" => $rnd,
)); ));
} }
}
return $attrArray; return $attrArray;
} }

View File

@ -344,7 +344,8 @@ class HashRateService extends BaseService
private function randHashRateTaskList($type){ private function randHashRateTaskList($type){
$metas = AchievementsPower::getListByType($type); $metas = AchievementsPower::getListByType($type);
$this->hashRateTask['task'.$type] = array(); $this->hashRateTask['task'.$type] = array();
foreach (array_rand($metas, 4) as $key) { $count = count($metas) >= 4 ? 4 : count($metas) ;
foreach (array_rand($metas, $count) as $key) {
$meta = $metas[$key]; $meta = $metas[$key];
if (count($this->hashRateTask['task'.$type]) >= if (count($this->hashRateTask['task'.$type]) >=
4) { 4) {