feat,refac: 남은 난수 생성값 추가 수정
- rand, mt_rand, Query rand() 쓰는 영역 - 거래장, 토너먼트는 남김
This commit is contained in:
+20
-2
@@ -2085,13 +2085,31 @@ function nextRuler(General $general)
|
|||||||
|
|
||||||
//npc or npc유저인 경우 후계 찾기
|
//npc or npc유저인 경우 후계 찾기
|
||||||
if (!$fiction && $general->getNPCType() > 0) {
|
if (!$fiction && $general->getNPCType() > 0) {
|
||||||
$candidate = $db->queryFirstRow(
|
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||||
'SELECT no,name,officer_level,IF(ABS(affinity-%i)>75,150-ABS(affinity-%i),ABS(affinity-%i)) as npcmatch2 from general where nation=%i and officer_level!=12 and 1 <= npc and npc<=3 order by npcmatch2,rand() LIMIT 1',
|
UniqueConst::$hiddenSeed,
|
||||||
|
'NextNPCRuler',
|
||||||
|
$year,
|
||||||
|
$month,
|
||||||
|
$general->getID(),
|
||||||
|
)));
|
||||||
|
$rawCandidates = $db->query(
|
||||||
|
'SELECT no,name,officer_level,IF(ABS(affinity-%i)>75,150-ABS(affinity-%i),ABS(affinity-%i)) as npcmatch2 from general where nation=%i and officer_level!=12 and 1 <= npc and npc<=3 order by npcmatch2 asc',
|
||||||
$general->getVar('affinity'),
|
$general->getVar('affinity'),
|
||||||
$general->getVar('affinity'),
|
$general->getVar('affinity'),
|
||||||
$general->getVar('affinity'),
|
$general->getVar('affinity'),
|
||||||
$nationID
|
$nationID
|
||||||
);
|
);
|
||||||
|
if ($rawCandidates) {
|
||||||
|
$candidates = [];
|
||||||
|
$minNPCMatch = $rawCandidates[0]['npcmatch2'];
|
||||||
|
foreach ($rawCandidates as $candidate) {
|
||||||
|
if (!$candidate['npcmatch2'] == $minNPCMatch) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$candidates[] = $candidate;
|
||||||
|
}
|
||||||
|
$candidate = $rng->choice($candidates);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!$candidate) {
|
if (!$candidate) {
|
||||||
$candidate = $db->queryFirstRow(
|
$candidate = $db->queryFirstRow(
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ function postUpdateMonthly(RandUtil $rng)
|
|||||||
|
|
||||||
//약간의 랜덤치 부여 (95% ~ 105%)
|
//약간의 랜덤치 부여 (95% ~ 105%)
|
||||||
|
|
||||||
$nation['power'] = Util::round($nation['power'] * (rand() % 101 + 950) / 1000);
|
$nation['power'] = Util::round($nation['power'] * $rng->nextRange(0.95, 1.05));
|
||||||
$powerValues['maxPower'] = max($powerValues['maxPower'] ?? 0, $nation['power']);
|
$powerValues['maxPower'] = max($powerValues['maxPower'] ?? 0, $nation['power']);
|
||||||
$powerValues['maxCrew'] = max($powerValues['maxCrew'] ?? 0, Util::toInt($nation['totalCrew']));
|
$powerValues['maxCrew'] = max($powerValues['maxCrew'] ?? 0, Util::toInt($nation['totalCrew']));
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ while(count($pickResult) < $pickLimit){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$newNonce = mt_rand(0, 0xfffffff);
|
$newNonce = random_int(0, 0xfffffff);
|
||||||
|
|
||||||
$validSecond = max(VALID_SECOND, $turnterm*40);
|
$validSecond = max(VALID_SECOND, $turnterm*40);
|
||||||
$pickMoreSecond = max(PICK_MORE_SECOND, Util::round(pow($turnterm, 0.672)*8));
|
$pickMoreSecond = max(PICK_MORE_SECOND, Util::round(pow($turnterm, 0.672)*8));
|
||||||
|
|||||||
+35
-26
@@ -241,34 +241,43 @@ function do추방(General $general, int $myOfficerLevel):?string{
|
|||||||
}
|
}
|
||||||
$general->setVar('troop', 0);
|
$general->setVar('troop', 0);
|
||||||
|
|
||||||
if($general->getNPCType() >= 2 && Util::randBool(GameConst::$npcBanMessageProb)) {
|
if($general->getNPCType() >= 2){
|
||||||
|
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||||
|
UniqueConst::$hiddenSeed,
|
||||||
|
'BanNPC',
|
||||||
|
$env['year'],
|
||||||
|
$env['month'],
|
||||||
|
$general->getID(),
|
||||||
|
)));
|
||||||
|
if ($rng->nextBool(GameConst::$npcBanMessageProb)) {
|
||||||
|
|
||||||
$str = Util::choiceRandom([
|
$str = $rng->choice([
|
||||||
'날 버리다니... 곧 전장에서 복수해주겠다...',
|
'날 버리다니... 곧 전장에서 복수해주겠다...',
|
||||||
'추방이라... 내가 무얼 잘못했단 말인가...',
|
'추방이라... 내가 무얼 잘못했단 말인가...',
|
||||||
'어디 추방해가면서 잘되나 보자... 꼭 복수하겠다...',
|
'어디 추방해가면서 잘되나 보자... 꼭 복수하겠다...',
|
||||||
'인덕이 제일이거늘... 추방이 웬말인가... 저주한다!',
|
'인덕이 제일이거늘... 추방이 웬말인가... 저주한다!',
|
||||||
'날 추방했으니 그 복수로 적국에 정보를 팔아 넘겨야겠군요. 그럼 이만.'
|
'날 추방했으니 그 복수로 적국에 정보를 팔아 넘겨야겠군요. 그럼 이만.'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$src = new MessageTarget(
|
$src = new MessageTarget(
|
||||||
$generalID,
|
$generalID,
|
||||||
$generalName,
|
$generalName,
|
||||||
$nationID,
|
$nationID,
|
||||||
$nation['name'],
|
$nation['name'],
|
||||||
$nation['color'],
|
$nation['color'],
|
||||||
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
||||||
);
|
);
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PUBLIC,
|
Message::MSGTYPE_PUBLIC,
|
||||||
$src,
|
$src,
|
||||||
$src,
|
$src,
|
||||||
$str,
|
$str,
|
||||||
new \DateTime(),
|
new \DateTime(),
|
||||||
new \DateTime('9999-12-31'),
|
new \DateTime('9999-12-31'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
$msg->send();
|
$msg->send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($env['year'] < $env['startyear']+3) {
|
if($env['year'] < $env['startyear']+3) {
|
||||||
|
|||||||
+2
-2
@@ -590,8 +590,8 @@ function ConquerCity(array $admin, General $general, array $city)
|
|||||||
$loseGeneralGold = 0;
|
$loseGeneralGold = 0;
|
||||||
$loseGeneralRice = 0;
|
$loseGeneralRice = 0;
|
||||||
foreach ($oldNationGenerals as $oldGeneral) {
|
foreach ($oldNationGenerals as $oldGeneral) {
|
||||||
$loseGold = intdiv($oldGeneral->getVar('gold') * (rand() % 30 + 20), 100);
|
$loseGold = Util::toInt($oldGeneral->getVar('gold') * $rng->nextRange(0.2, 0.5));
|
||||||
$loseRice = intdiv($oldGeneral->getVar('rice') * (rand() % 30 + 20), 100);
|
$loseRice = Util::toInt($oldGeneral->getVar('rice') * $rng->nextRange(0.2, 0.5));
|
||||||
$oldGeneral->getLogger()->pushGeneralActionLog(
|
$oldGeneral->getLogger()->pushGeneralActionLog(
|
||||||
"도주하며 금<C>$loseGold</> 쌀<C>$loseRice</>을 분실했습니다.",
|
"도주하며 금<C>$loseGold</> 쌀<C>$loseRice</>을 분실했습니다.",
|
||||||
ActionLogger::PLAIN
|
ActionLogger::PLAIN
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ class Join extends \sammo\BaseAPI
|
|||||||
$character = $rng->choice(GameConst::$availablePersonality);
|
$character = $rng->choice(GameConst::$availablePersonality);
|
||||||
}
|
}
|
||||||
//상성 랜덤
|
//상성 랜덤
|
||||||
$affinity = rand() % 150 + 1;
|
$affinity = $rng->nextRangeInt(1, 150);
|
||||||
|
|
||||||
########## 회원정보 테이블에 입력값을 등록한다. ##########
|
########## 회원정보 테이블에 입력값을 등록한다. ##########
|
||||||
$db->insert('general', [
|
$db->insert('general', [
|
||||||
|
|||||||
@@ -652,7 +652,7 @@ class GeneralBuilder{
|
|||||||
$killturn = $this->killturn;
|
$killturn = $this->killturn;
|
||||||
}
|
}
|
||||||
else if($this->birth !== null){
|
else if($this->birth !== null){
|
||||||
$killturn = ($this->death - $year) * 12 + mt_rand(0, 11) + $month - 1;
|
$killturn = ($this->death - $year) * 12 + $this->rng->nextRangeInt(0, 11) + $month - 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ class WarUnit
|
|||||||
//최소 전투력 50 보장
|
//최소 전투력 50 보장
|
||||||
$warPower = max(0, $warPower);
|
$warPower = max(0, $warPower);
|
||||||
$warPower = ($warPower + 100) / 2;
|
$warPower = ($warPower + 100) / 2;
|
||||||
$warPower = rand($warPower, 100);
|
$warPower = $this->rng->nextRangeInt($warPower, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
$warPower *= $this->getComputedAtmos();
|
$warPower *= $this->getComputedAtmos();
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ if(!is_uploaded_file($image['tmp_name'])) {
|
|||||||
//이미지 저장
|
//이미지 저장
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
$newPicName = dechex(rand(0x000000f,0xfffffff)).$newExt;
|
$newPicName = bin2hex(random_bytes(4)).$newExt;
|
||||||
$dest = AppConf::getUserIconPathFS().'/'.$newPicName;
|
$dest = AppConf::getUserIconPathFS().'/'.$newPicName;
|
||||||
if(file_exists($dest)){
|
if(file_exists($dest)){
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user