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;
require_once('mt/AchievementsPower.php');
use mt\AchievementsPower;
use phpcommon\SqlHelper;
class HashRate extends BaseModel
{
@ -32,6 +35,7 @@ class HashRate extends BaseModel
}
public static function getCount($period){
$count = 0;
$rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_hash_rate',
@ -40,7 +44,13 @@ class HashRate extends BaseModel
'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,12 +39,13 @@ class BattleRandAttribute {
$strs = explode('|', $randMeta['attributeRange']);
foreach ($strs as $str){
$attrStr = explode(':', $str);
$rnd = rand($attrStr[1]*100000 , $attrStr[2]*100000) / 100000;
// $val = $attrStr[1] + ($attrStr[2] - $attrStr[1]) * $rnd;
array_push($attrArray,array(
"attr_id" => $attrStr[0],
"val" => $rnd,
));
if (count($attrStr) == 3){
$rnd = rand($attrStr[1]*100000 , $attrStr[2]*100000) / 100000;
array_push($attrArray,array(
"attr_id" => $attrStr[0],
"val" => $rnd,
));
}
}
return $attrArray;
}

View File

@ -344,7 +344,8 @@ class HashRateService extends BaseService
private function randHashRateTaskList($type){
$metas = AchievementsPower::getListByType($type);
$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];
if (count($this->hashRateTask['task'.$type]) >=
4) {