fix: phan 지시에 따라 일부 버그 수정

- null && key_exists 버그
- or assign이 integer 대상이므로 직접 연산
- false 대신 0 입력한 곳 수정
- 자체 Deprecate 처리한 함수 회피
- 초기화되지 않은 [] 확인하여 처리
- sleep은 정수만 받으므로 usleep으로 변경
- 선언하지 않고 그냥 사용하던 member 변수 선언
- boolean operation 순서 틀린 부분 수정
This commit is contained in:
2021-08-12 23:58:20 +09:00
parent 0975e925a9
commit ee8854451c
67 changed files with 51 additions and 137 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ class che_병가 extends \sammo\BaseNation{
public function onCalcNationalIncome(string $type, $amount):int{
if($type == 'pop' && $amount > 0){
return $amount * 0.8;
return Util::toInt($amount * 0.8);
}
return $amount;
+3 -1
View File
@@ -39,7 +39,7 @@ class AutorunGeneralPolicy{
static public $default_priority = [
static public array $default_priority = [
'NPC사망대비',
'귀환',
'금쌀구매',
@@ -89,6 +89,8 @@ class AutorunGeneralPolicy{
public $can건국 = true;
public $can선양 = false;
public array $priority;
function doNPCState(General $general){
$npc = $general->getNPCType();
$nationID = $general->getNationID();
+2
View File
@@ -18,6 +18,7 @@ abstract class BaseCommand{
static protected $actionName = 'CommandName';
static public $reqArg = false;
static protected $isLazyCalcReqTurn = false;
public ?string $reason;
public function getCommandDetailTitle():string{
return $this->getName();
@@ -48,6 +49,7 @@ abstract class BaseCommand{
protected $fullConditionConstraints = null;
protected $minConditionConstraints = null;
protected $permissionConstraints = null;
protected $reasonConstraint = null;
protected $logger;
-2
View File
@@ -12,8 +12,6 @@ use \sammo\GameUnitConst;
use \sammo\LastTurn;
use \sammo\Command;
use function \sammo\tryUniqueItemLottery;
use function \sammo\printCitiesBasedOnDistance;
use \sammo\Constraint\Constraint;
-2
View File
@@ -14,9 +14,7 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use function sammo\buildNationTypeClass;
use function sammo\refreshNationStaticInfo;
use function sammo\GetNationColors;
use function sammo\getAllNationStaticInfo;
-3
View File
@@ -10,9 +10,6 @@ use \sammo\{
Command
};
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use \sammo\TextDecoration\SightseeingMessage;
@@ -12,8 +12,6 @@ use \sammo\{
Command
};
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\MustNotBeReachedException;
-3
View File
@@ -10,9 +10,6 @@ use \sammo\{
Command
};
use function \sammo\getNationStaticInfo;
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
@@ -11,7 +11,6 @@ use \sammo\{
use function sammo\{
TechLimit,
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
tryUniqueItemLottery,
@@ -10,9 +10,6 @@ use \sammo\{
Command
};
use function \sammo\getNationStaticInfo;
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
-1
View File
@@ -11,7 +11,6 @@ use \sammo\{
};
use function \sammo\getNationStaticInfo;
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
@@ -15,8 +15,6 @@ use \sammo\LastTurn;
use \sammo\Command;
use function \sammo\tryUniqueItemLottery;
use function \sammo\getInvitationList;
use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
@@ -16,9 +16,7 @@ use \sammo\Command;
use \sammo\ServConfig;
use function \sammo\getDexCall;
use function \sammo\getTechCall;
use function \sammo\tryUniqueItemLottery;
use function \sammo\getTechAbil;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
-1
View File
@@ -12,7 +12,6 @@ use \sammo\GameUnitConst;
use \sammo\LastTurn;
use \sammo\Command;
use function \sammo\tryUniqueItemLottery;
use function \sammo\printCitiesBasedOnDistance;
use \sammo\Constraint\Constraint;
@@ -12,11 +12,7 @@ use \sammo\LastTurn;
use \sammo\GameUnitConst;
use \sammo\Command;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\tryUniqueItemLottery;
use function \sammo\getAllNationStaticInfo;
use function \sammo\pickGeneralFromPool;
use \sammo\Constraint\Constraint;
-5
View File
@@ -13,11 +13,6 @@ use \sammo\LastTurn;
use \sammo\GameUnitConst;
use \sammo\Command;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
-1
View File
@@ -13,7 +13,6 @@ use \sammo\LastTurn;
use \sammo\Command;
use \sammo\Json;
use function \sammo\tryUniqueItemLottery;
use function \sammo\searchDistance;
use function \sammo\printCitiesBasedOnDistance;
-3
View File
@@ -14,10 +14,7 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use function sammo\buildNationTypeClass;
use function sammo\refreshNationStaticInfo;
use function sammo\GetNationColors;
use function sammo\getAllNationStaticInfo;
use function sammo\deleteNation;
-5
View File
@@ -12,11 +12,6 @@ use \sammo\LastTurn;
use \sammo\GameUnitConst;
use \sammo\Command;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
@@ -17,11 +17,6 @@ use \sammo\Message;
use \sammo\CityConst;
use \sammo\Json;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\GetImageURL;
use function \sammo\getNationStaticInfo;
use function \sammo\GetNationColors;
use function \sammo\newColor;
@@ -17,12 +17,6 @@ use \sammo\MessageTarget;
use \sammo\Message;
use \sammo\CityConst;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\GetImageURL;
use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Event\Action;
-4
View File
@@ -15,12 +15,8 @@ use \sammo\Command;
use \sammo\Message;
use \sammo\MessageTarget;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\getAllNationStaticInfo;
use function \sammo\getNationStaticInfo;
use function \sammo\GetImageURL;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
-3
View File
@@ -15,9 +15,6 @@ use \sammo\Command;
use \sammo\MessageTarget;
use \sammo\Message;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\GetImageURL;
use \sammo\Constraint\Constraint;
@@ -14,9 +14,6 @@ use \sammo\{
StringUtil
};
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\getAllNationStaticInfo;
use function \sammo\getNationStaticInfo;
@@ -16,12 +16,7 @@ use \sammo\MessageTarget;
use \sammo\DiplomaticMessage;
use \sammo\Message;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\getAllNationStaticInfo;
use function \sammo\getNationStaticInfo;
use function \sammo\GetImageUR;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
@@ -16,9 +16,6 @@ use \sammo\MessageTarget;
use \sammo\DiplomaticMessage;
use \sammo\Message;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\getAllNationStaticInfo;
use function \sammo\GetImageURL;
use function \sammo\getNationStaticInfo;
@@ -16,12 +16,7 @@ use \sammo\MessageTarget;
use \sammo\DiplomaticMessage;
use \sammo\Message;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\getAllNationStaticInfo;
use function \sammo\getNationStaticInfo;
use function \sammo\GetImageURL;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
@@ -15,9 +15,6 @@ use \sammo\Command;
use \sammo\Message;
use \sammo\MessageTarget;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\getAllNationStaticInfo;
use function \sammo\getNationStaticInfo;
use function \sammo\GetImageURL;
@@ -13,11 +13,6 @@ use \sammo\GameUnitConst;
use \sammo\Command;
use \sammo\KVStorage;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
@@ -15,12 +15,8 @@ use \sammo\Command;
use \sammo\Message;
use \sammo\MessageTarget;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\getAllNationStaticInfo;
use function \sammo\getNationStaticInfo;
use function \sammo\GetImageURL;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
@@ -18,12 +18,7 @@ use \sammo\{
Message,
};
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\getAllNationStaticInfo;
use function \sammo\getNationStaticInfo;
use function \sammo\GetImageURL;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
-7
View File
@@ -15,13 +15,6 @@ use \sammo\Command;
use \sammo\MessageTarget;
use \sammo\Message;
use \sammo\CityConst;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\GetImageURL;
use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Event\Action;
-4
View File
@@ -13,10 +13,6 @@ use \sammo\LastTurn;
use \sammo\GameUnitConst;
use \sammo\Command;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
-4
View File
@@ -16,10 +16,6 @@ use \sammo\MessageTarget;
use \sammo\Message;
use \sammo\CityConst;
use function \sammo\getDomesticExpLevelBonus;
use function \sammo\CriticalRatioDomestic;
use function \sammo\CriticalScoreEx;
use function \sammo\GetImageURL;
use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
@@ -9,6 +9,7 @@ class AllowDiplomacyStatus extends Constraint{
protected $nationID;
protected $allowStatus = [];
protected $errMsg = null;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
+5 -5
View File
@@ -154,27 +154,27 @@ abstract class Constraint{
throw new \InvalidArgumentException('require arg');
}
if(($valueType&static::REQ_STRING_ARG===static::REQ_STRING_ARG) && !is_string($this->arg)){
if((($valueType&static::REQ_STRING_ARG)===static::REQ_STRING_ARG) && !is_string($this->arg)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException('require string arg');
}
if(($valueType&static::REQ_BOOLEAN_ARG===static::REQ_BOOLEAN_ARG) && !is_bool($this->arg)){
if((($valueType&static::REQ_BOOLEAN_ARG)===static::REQ_BOOLEAN_ARG) && !is_bool($this->arg)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException('require bool arg');
}
if(($valueType&static::REQ_INT_ARG===static::REQ_INT_ARG) && !is_int($this->arg)){
if((($valueType&static::REQ_INT_ARG)===static::REQ_INT_ARG) && !is_int($this->arg)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException('require int arg');
}
if(($valueType&static::REQ_NUMERIC_ARG===static::REQ_NUMERIC_ARG) && !is_numeric($this->arg)){
if((($valueType&static::REQ_NUMERIC_ARG)===static::REQ_NUMERIC_ARG) && !is_numeric($this->arg)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException('require numeric arg');
}
if(($valueType&static::REQ_ARRAY_ARG===static::REQ_ARRAY_ARG) && !is_array($this->arg)){
if((($valueType&static::REQ_ARRAY_ARG)===static::REQ_ARRAY_ARG) && !is_array($this->arg)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException('require array arg');
}
+1
View File
@@ -9,6 +9,7 @@ class RemainCityTrust extends Constraint{
protected $key;
protected $maxKey;
protected $maxVal;
protected $keyNick;
public function checkInputValues(bool $throwExeception=true):bool{
+1
View File
@@ -12,6 +12,7 @@ class ReqCityCapacity extends Constraint{
protected $maxKey;
protected $keyNick;
protected $reqVal;
protected $isPercent;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
+1
View File
@@ -10,6 +10,7 @@ class ReqCityTrust extends Constraint{
protected $key;
protected $maxKey;
protected $keyNick;
protected $reqVal;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
+1
View File
@@ -17,6 +17,7 @@ class ReqCityValue extends Constraint{
protected $reqVal;
protected $comp;
protected $errMsg;
protected $isPercent;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
@@ -17,6 +17,7 @@ class ReqDestCityValue extends Constraint{
protected $reqVal;
protected $comp;
protected $errMsg;
protected $isPercent;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
@@ -17,6 +17,7 @@ class ReqDestNationValue extends Constraint{
protected $reqVal;
protected $comp;
protected $errMsg;
protected $isPercent;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
@@ -38,7 +38,7 @@ class ReqGeneralCrewMargin extends Constraint{
$reqCrewType = GameUnitConst::byID($this->arg);
//XXX: 왜 General -> obj -> General 변환을 하고 있나?
$generalObj = new General($this->general, null, null, null, null, false);
$generalObj = new General($this->general, null, null, null, null, null, false);
if($reqCrewType->id != $generalObj->getCrewTypeObj()->id){
return true;
@@ -14,6 +14,7 @@ class ReqNationAuxValue extends Constraint
const REQ_VALUES = Constraint::REQ_NATION | Constraint::REQ_ARRAY_ARG;
protected $key;
protected $maxKey;
protected $defaultValue;
protected $reqVal;
protected $comp;
+1
View File
@@ -17,6 +17,7 @@ class ReqNationValue extends Constraint{
protected $reqVal;
protected $comp;
protected $errMsg;
protected $isPercent;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
-2
View File
@@ -1,8 +1,6 @@
<?php
namespace sammo\Event\Action;
use function sammo\getNationStaticInfo;
use sammo\ActionLogger;
use sammo\CityConst;
use sammo\DB;
-1
View File
@@ -12,7 +12,6 @@ use sammo\Scenario\Nation;
use sammo\UniqueConst;
use sammo\Util;
use function sammo\getNationStaticInfo;
use function sammo\refreshNationStaticInfo;
/**
@@ -15,7 +15,6 @@ use sammo\UniqueConst;
use sammo\Util;
use function sammo\GetNationColors;
use function sammo\getNationStaticInfo;
use function sammo\pickGeneralFromPool;
use function sammo\refreshNationStaticInfo;
+1 -1
View File
@@ -25,7 +25,7 @@ class RegNPC extends \sammo\Event\Action{
$this->npc=(new \sammo\Scenario\GeneralBuilder(
$name,
0,
false,
$picturePath,
$nationID
))
+1 -1
View File
@@ -23,7 +23,7 @@ class RegNeutralNPC extends \sammo\Event\Action{
){
$this->npc=(new \sammo\Scenario\GeneralBuilder(
$name,
0,
false,
$picturePath,
$nationID
))
+1 -1
View File
@@ -98,7 +98,7 @@ class Logic extends \sammo\Event\Condition{
foreach($this->conditions as $cond){
$sub = self::_eval($cond, $env);
$chain[] = $sub['chain'];
$value ^= $sub['value'];
$value = ($value != $sub['value']);
}
return [
+1 -1
View File
@@ -148,7 +148,7 @@ class GameConstBase
'che_도적', 'che_명가', 'che_음양가', 'che_종횡가', 'che_불가', 'che_오두미도', 'che_태평도', 'che_도가',
'che_묵가', 'che_덕가', 'che_병가', 'che_유가', 'che_법가'
];
/** @var array 기본 국가 성향 */
/** @var string 기본 국가 성향 */
public static $neutralNationType = 'che_중립';
/** @var string 기본 내정 특기 */
+1 -1
View File
@@ -708,7 +708,7 @@ class General implements iAction{
if($updateVals){
$db->update('general', $updateVals, 'no=%i', $generalID);
$result |= $db->affectedRows() > 0;
$result = $result || $db->affectedRows() > 0;
if(key_exists('nation', $updateVals)){
$db->update('rank_data', [
'nation_id'=>$updateVals['nation']
+1 -1
View File
@@ -74,7 +74,7 @@ class RandomNameGeneral extends AbsGeneralPool{
$builder = $this->getGeneralBuilder();
$builder->setStat($leadership, $strength, $intel);
$builder->setDex($dexVal[0], $dexVal[1], $dexVal[2], $dexVal[3], $avgGen['dex5']);
$builder->Util::choiceRandom(array_keys(\sammo\CityConst::all()));
$builder->setCityID(Util::choiceRandom(array_keys(\sammo\CityConst::all())));
$builder->setExpDed($avgGen['exp'], $avgGen['ded']);
}
+2
View File
@@ -44,6 +44,8 @@ class Scenario{
private $gameConf = null;
private $tmpEnv;
public function generateGeneral($rawGeneral, $initFull, $npcType=2): GeneralBuilder{
while(count($rawGeneral) < 14){
$rawGeneral[] = null;
-3
View File
@@ -9,9 +9,6 @@ use \sammo\CityConst;
use \sammo\GameConst;
use \sammo\SpecialityHelper;
use sammo\TimeUtil;
use function sammo\buildGeneralSpecialClass;
class GeneralBuilder{
protected $generalID = null;