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