diff --git a/hwe/a_genList.php b/hwe/a_genList.php index 7181eb01..7551178c 100644 --- a/hwe/a_genList.php +++ b/hwe/a_genList.php @@ -163,7 +163,7 @@ foreach($generalList as $general){ $name = $name.'
('.$ownerNameList[$general['owner']].')'; } - $general['connect'] = Util::round($general['connect'] / 10) * 10; + $general['connect'] = Util::round($general['connect'], -1); $imageTemp = GetImageURL($general['imgsvr']); echo " diff --git a/hwe/c_auction.php b/hwe/c_auction.php index 3c49ba74..6ca1ed40 100644 --- a/hwe/c_auction.php +++ b/hwe/c_auction.php @@ -46,10 +46,10 @@ $btCount = $tradeCount + $bidCount; $unit = $turnterm * 60; -$amount = Util::round($amount / 10) * 10; -$cost = Util::round($cost / 10) * 10; -$topv = Util::round($topv / 10) * 10; -$value = Util::round($value / 10) * 10; +$amount = Util::round($amount, -1); +$cost = Util::round($cost, -1); +$topv = Util::round($topv, -1); +$value = Util::round($value, -1); if ($term > 24) { $term = 24; } diff --git a/hwe/func_auction.php b/hwe/func_auction.php index 06719dfb..7812acae 100644 --- a/hwe/func_auction.php +++ b/hwe/func_auction.php @@ -32,9 +32,9 @@ function registerAuction() { if($cost <= $amount*0.8) { $cost = $amount*0.8; } if($cost >= $amount*1.2) { $cost = $amount*1.2; } - $amount = Util::round($amount / 10) * 10; - $cost = Util::round($cost / 10) * 10; - $topv = Util::round($topv / 10) * 10; + $amount = Util::round($amount, -1); + $cost = Util::round($cost, -1); + $topv = Util::round($topv, -1); $term = 3 + rand() % 10; $date = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $unit * $term); @@ -54,9 +54,9 @@ function registerAuction() { if($cost <= $amount*0.8) { $cost = $amount*0.8; } if($cost >= $amount*1.2) { $cost = $amount*1.2; } - $amount = Util::round($amount / 10) * 10; - $cost = Util::round($cost / 10) * 10; - $topv = Util::round($topv / 10) * 10; + $amount = Util::round($amount, -1); + $cost = Util::round($cost, -1); + $topv = Util::round($topv, -1); $term = 3 + rand() % 10; $date = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $unit * $term); diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 2b1b0b3a..7d836aaa 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -740,7 +740,7 @@ class GeneralAI{ if($targetGeneral){ if($targetGeneral === $compNpcCivil){ - $amount = round($targetGeneral->$resName - $minRes * 3, -2); + $amount = Util::round($targetGeneral->$resName - $minRes * 3, -2); } else{ $amount = min(10000, intdiv($targetGeneral->$resName, 5000)*1000 + 1000); diff --git a/src/sammo/Util.php b/src/sammo/Util.php index df065ebb..b41cca86 100644 --- a/src/sammo/Util.php +++ b/src/sammo/Util.php @@ -7,17 +7,20 @@ class Util extends \utilphp\util /** * int 값 반환을 강제하는 부동소수점 반올림 * @param int|float $value + * @param int $pos 반올림 자리수, 0 이하의 '음수만' */ - public static function round($value) : int{ - return intval(round($value)); + public static function round($value, $pos=0) : int{ + assert($pos <= 0, 'Util::round는 음수만 입력 가능'); + return intval(round($value, $pos)); } /** * int 값으로 강제로 설정하는 부동소수점 반올림 * @param int|float $value + * @param int $pos 반올림 자리수, 0 이하의 '음수만' */ - public static function setRound(&$value) : void{ - $value = static::round($value); + public static function setRound(&$value, $pos=0) : void{ + $value = static::round($value, $pos); } private static function _parseReq($value, string $type)