From 55a2250efccb0054b5c2f0d4a39bc8793fb18ed3 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 23 Jul 2018 01:49:43 +0900 Subject: [PATCH] =?UTF-8?q?NPC=EC=9D=98=20=EC=84=A0=ED=8F=AC=20=EB=8C=80?= =?UTF-8?q?=EC=83=81=EC=9D=84=20'=EA=B5=AD=EB=A0=A5'=EC=9D=B4=20=EB=82=AE?= =?UTF-8?q?=EC=9D=80=20=EA=B5=AD=EA=B0=80=EC=97=90=20=EB=8D=94=20=EC=9E=98?= =?UTF-8?q?=20=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_npc.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hwe/func_npc.php b/hwe/func_npc.php index 8058736a..bdccd13f 100644 --- a/hwe/func_npc.php +++ b/hwe/func_npc.php @@ -466,18 +466,18 @@ function processAI($no) { break; } - $nations = $db->queryFirstColumn('SELECT nation FROM nation WHERE level>0'); - shuffle($nations); - foreach($nations as $youNationID){ + $nations = []; + foreach ($db->queryAllLists('SELECT nation, power FROM nation WHERE level>0') as [$youNationID, $youNationPower]) { if(!isNeighbor($general['nation'], $youNationID)){ continue; } - $command = EncodeCommand(0, 0, $youNationID, 62); - $db->update('nation', [ - 'l12turn0'=>$command - ], 'nation=%i', $general['nation']); - break; + $nations[$youNationID] = sqrt(1/$youNationPower); } + $youNationID = Util::choiceRandomUsingWeight($nations); + $command = EncodeCommand(0, 0, $youNationID, 62); + $db->update('nation', [ + 'l12turn0'=>$command + ], 'nation=%i', $general['nation']); }while(false); } }