feat,refac: 남은 난수 생성값 추가 수정

- rand, mt_rand, Query rand() 쓰는 영역
- 거래장, 토너먼트는 남김
This commit is contained in:
2022-05-17 23:01:00 +09:00
parent c5ceff6fb5
commit 296a27a409
9 changed files with 63 additions and 36 deletions
+20 -2
View File
@@ -2085,13 +2085,31 @@ function nextRuler(General $general)
//npc or npc유저인 경우 후계 찾기
if (!$fiction && $general->getNPCType() > 0) {
$candidate = $db->queryFirstRow(
'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',
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
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'),
$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) {
$candidate = $db->queryFirstRow(