랜임 코드 수정
This commit is contained in:
+1
-1
@@ -699,7 +699,7 @@ function command_25($turn, $command) {
|
|||||||
$nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg,gennum FROM nation ORDER BY rand()');
|
$nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg,gennum FROM nation ORDER BY rand()');
|
||||||
|
|
||||||
foreach($nationList as $nation){
|
foreach($nationList as $nation){
|
||||||
if ($gameStor->year == $gameStor->init_year && $gameStor->month <= $gameStor->init_month && $nation['gennum'] >= GameConst::$initialNationGenLimitForRandInit) {
|
if ($onlyRandom && TimeUtil::IsRangeMonth($gameStor->init_year, $gameStor->init_month, 1, $gameStor->year, $gameStor->month) && $nation['gennum'] >= GameConst::$initialNationGenLimitForRandInit) {
|
||||||
$nation['availableJoin'] = false;
|
$nation['availableJoin'] = false;
|
||||||
}
|
}
|
||||||
else if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){
|
else if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace sammo\GeneralCommand;
|
namespace sammo\GeneralCommand;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil, TimeUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst, GameUnitConst,
|
GameConst, GameUnitConst,
|
||||||
@@ -131,16 +131,47 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$nations = $db->queryFirstColumn(
|
$onlyRandom = $env['join_mode'] == 'onlyRandom';
|
||||||
'SELECT nation, name, gennum, scout FROM nation WHERE scout=0 AND gennum < %i AND no NOT IN %li',
|
$genLimit = GameConst::$defaultMaxGeneral;
|
||||||
$relYear<3?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral,
|
if($onlyRandom && TimeUtil::IsRangeMonth($env['init_year'], $env['init_month'], 1, $env['year'], $env['month'])){
|
||||||
|
$genLimit = GameConst::$initialNationGenLimitForRandInit;
|
||||||
|
}
|
||||||
|
else if($relYear < 3){
|
||||||
|
$genLimit = GameConst::$initialNationGenLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$generalsCnt = [];
|
||||||
|
$rawGeneralsCnt = $db->query(
|
||||||
|
'SELECT general.nation as nation, nation.gennum, nation.name, npc, count(*) as cnt FROM general JOIN nation ON general.nation = nation.nation WHERE npc < 5 AND nation.gennum < %i AND nation.nation NOT IN %li GROUP BY general.nation, general.npc',
|
||||||
|
$genLimit,
|
||||||
$notIn
|
$notIn
|
||||||
);
|
);
|
||||||
|
|
||||||
|
foreach($rawGeneralsCnt as $nation){
|
||||||
|
$nationID = $nation['nation'];
|
||||||
|
if(!\key_exists($nationID, $generalsCnt)){
|
||||||
|
$generalsCnt[$nationID] = [
|
||||||
|
'nation'=>$nationID,
|
||||||
|
'gennum'=>$nation['gennum'],
|
||||||
|
'name'=>$nation['name'],
|
||||||
|
'cnt'=>0,
|
||||||
|
];
|
||||||
|
$generalsCnt[$nationID]['cnt'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($nation['npc'] <= 2){
|
||||||
|
$calcCnt = $nation['cnt'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$calcCnt = $nation['cnt'] / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
$generalsCnt[$nationID]['cnt'] += $calcCnt;
|
||||||
|
}
|
||||||
|
|
||||||
$randVals = [];
|
$randVals = [];
|
||||||
foreach($nations as $testNation){
|
foreach($generalsCnt as $testNation){
|
||||||
$nationID = $nations['nation'];
|
$randVals[] += [$testNation, 1/$testNation['cnt']];
|
||||||
$randVals[] = [$testNation, 1/$testNation['gennum']];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$destNation = Util::choiceRandomUsingWeightPair($randVals);
|
$destNation = Util::choiceRandomUsingWeightPair($randVals);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use function sammo\refreshNationStaticInfo;
|
|||||||
use function sammo\GetNationColors;
|
use function sammo\GetNationColors;
|
||||||
use function sammo\getAllNationStaticInfo;
|
use function sammo\getAllNationStaticInfo;
|
||||||
use function sammo\DeleteConflict;
|
use function sammo\DeleteConflict;
|
||||||
|
use function sammo\deleteNation;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user