랜임 코드 수정
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()');
|
||||
|
||||
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;
|
||||
}
|
||||
else if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB, Util, JosaUtil, TimeUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
@@ -130,17 +130,48 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$nations = $db->queryFirstColumn(
|
||||
'SELECT nation, name, gennum, scout FROM nation WHERE scout=0 AND gennum < %i AND no NOT IN %li',
|
||||
$relYear<3?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral,
|
||||
else{
|
||||
$onlyRandom = $env['join_mode'] == 'onlyRandom';
|
||||
$genLimit = 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
|
||||
);
|
||||
|
||||
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 = [];
|
||||
foreach($nations as $testNation){
|
||||
$nationID = $nations['nation'];
|
||||
$randVals[] = [$testNation, 1/$testNation['gennum']];
|
||||
foreach($generalsCnt as $testNation){
|
||||
$randVals[] += [$testNation, 1/$testNation['cnt']];
|
||||
}
|
||||
|
||||
$destNation = Util::choiceRandomUsingWeightPair($randVals);
|
||||
|
||||
@@ -18,6 +18,7 @@ use function sammo\refreshNationStaticInfo;
|
||||
use function sammo\GetNationColors;
|
||||
use function sammo\getAllNationStaticInfo;
|
||||
use function sammo\DeleteConflict;
|
||||
use function sammo\deleteNation;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user