fix: 랜덤임관시 u국 임관하는 문제 수정

This commit is contained in:
2021-08-11 16:15:46 +09:00
parent 836278cfdf
commit be423d8a08
+42 -37
View File
@@ -1,21 +1,22 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil, TimeUtil, Json,
General,
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
};
use \sammo\DB;
use \sammo\Util;
use \sammo\JosaUtil;
use \sammo\TimeUtil;
use \sammo\Json;
use \sammo\General;
use \sammo\ActionLogger;
use \sammo\GameConst;
use \sammo\GameUnitConst;
use \sammo\LastTurn;
use \sammo\Command;
use function \sammo\{
tryUniqueItemLottery,
getInvitationList,
getNationStaticInfo
};
use function \sammo\tryUniqueItemLottery;
use function \sammo\getInvitationList;
use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
@@ -24,10 +25,12 @@ use sammo\MustNotBeReachedException;
class che_랜덤임관 extends Command\GeneralCommand{
class che_랜덤임관 extends Command\GeneralCommand
{
static protected $actionName = '랜덤임관';
protected function argTest():bool{
protected function argTest(): bool
{
$this->arg = null;
return true;
@@ -83,27 +86,33 @@ class che_랜덤임관 extends Command\GeneralCommand{
*/
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
return '무작위 국가로 임관';
}
public function getBrief():string{
public function getBrief(): string
{
return '무작위 국가로 임관';
}
public function getCost():array{
public function getCost(): array
{
return [0, 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function run():bool{
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -132,8 +141,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
$relYear < 3 ? GameConst::$initialNationGenLimit : GameConst::$defaultMaxGeneral,
$notIn
);
}
else{
} else {
$nations = $db->query(
'SELECT nation.`name` as `name`,nation.nation as nation,scout,gennum,`affinity` FROM nation join general on general.nation = nation.nation and general.officer_level = 12 WHERE scout=0 and gennum<%i',
$relYear < 3 ? GameConst::$initialNationGenLimit : GameConst::$defaultMaxGeneral
@@ -164,14 +172,12 @@ class che_랜덤임관 extends Command\GeneralCommand{
$destNation = $testNation;
}
}
}
else{
} 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){
} else if ($relYear < 3) {
$genLimit = GameConst::$initialNationGenLimit;
}
@@ -182,8 +188,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
$genLimit,
$notIn
);
}
else{
} else {
$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 != 9 AND nation.gennum < %i AND nation.scout=0 GROUP BY general.nation, general.npc',
$genLimit
@@ -205,11 +210,14 @@ class che_랜덤임관 extends Command\GeneralCommand{
if ($nation['npc'] <= 2) {
$calcCnt = $nation['cnt'];
}
else{
} else {
$calcCnt = $nation['cnt'] / 2;
}
if ($general->getNPCType() < 2 && Util::starts_with($nation['name'], 'ⓤ')) {
$calcCnt *= 0.01;
}
$generalsCnt[$nationID]['cnt'] += $calcCnt;
}
@@ -259,8 +267,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
if ($gennum < GameConst::$initialNationGenLimit) {
$exp = 700;
}
else {
} else {
$exp = 100;
}
@@ -271,8 +278,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
if ($this->destGeneralObj !== null) {
$general->setVar('city', $this->destGeneralObj->getCityID());
}
else{
} else {
$targetCityID = $db->queryFirstField('SELECT city FROM general WHERE nation = %i AND officer_level=12', $destNationID);
$general->setVar('city', $targetCityID);
}
@@ -296,5 +302,4 @@ class che_랜덤임관 extends Command\GeneralCommand{
return true;
}
}