diff --git a/.phan/config.php b/.phan/config.php index efe75f54..7f07e7f3 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -15,13 +15,14 @@ return [ // Note that the **only** effect of choosing `'5.6'` is to infer // that functions removed in php 7.0 exist. // (See `backward_compatibility_checks` for additional options) - "target_php_version" => '7.4', + "target_php_version" => '8.0', 'backward_compatibility_checks ' => false, 'ignore_undeclared_variables_in_global_scope' => false, - 'minimum_severity'=>\Phan\Issue::SEVERITY_LOW, + 'minimum_severity'=>\Phan\Issue::SEVERITY_CRITICAL, 'file_list' => [ 'f_config/config.php', + 'hwe/MYDB.php', 'hwe/a_bestGeneral.php', 'hwe/a_emperior.php', 'hwe/a_emperior2.php', diff --git a/hwe/_119_b.php b/hwe/_119_b.php index 15f17f86..71e569f0 100644 --- a/hwe/_119_b.php +++ b/hwe/_119_b.php @@ -63,7 +63,7 @@ case "분지연": $locked = true; break; } - sleep(0.5); + usleep(500000); } $gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']); $turntime = (new \DateTimeImmutable($gameStor->turntime))->add(new \DateInterval("PT{$minute}M")); diff --git a/hwe/_admin2_submit.php b/hwe/_admin2_submit.php index cb6198c1..2b34aaff 100644 --- a/hwe/_admin2_submit.php +++ b/hwe/_admin2_submit.php @@ -342,7 +342,7 @@ switch($btn) { $turntime = getRandTurn($turnterm); $cutTurn = cutTurn($turntime, $turnterm); $db->update('general', [ - 'turntime'=>$curTurn + 'turntime'=>$cutTurn ], '`no` IN %li', $genlist); } break; diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 2f82e843..1fdba053 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -2,6 +2,8 @@ namespace sammo; +use sammo\Command\BaseCommand; + /** * Value Converter * @@ -156,7 +158,7 @@ function getNationTypeClass(?string $type){ throw new \InvalidArgumentException("{$type}은 올바른 국가 타입 클래스가 아님"); } -function buildNationTypeClass(?string $type):iAction{ +function buildNationTypeClass(?string $type):BaseNation{ static $cache = []; if($type === null){ $type = 'None'; diff --git a/hwe/sammo/ActionNationType/None.php b/hwe/sammo/ActionNationType/None.php index d381a175..34779fd3 100644 --- a/hwe/sammo/ActionNationType/None.php +++ b/hwe/sammo/ActionNationType/None.php @@ -2,8 +2,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; -class None implements iAction{ - use \sammo\DefaultAction; +class None extends \sammo\BaseNation{ protected $name = '-'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_덕가.php b/hwe/sammo/ActionNationType/che_덕가.php index 077af039..ddd668f4 100644 --- a/hwe/sammo/ActionNationType/che_덕가.php +++ b/hwe/sammo/ActionNationType/che_덕가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_덕가 implements iAction{ - use \sammo\DefaultAction; +class che_덕가 extends \sammo\BaseNation{ protected $name = '덕가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_도가.php b/hwe/sammo/ActionNationType/che_도가.php index 32f4da83..80221f39 100644 --- a/hwe/sammo/ActionNationType/che_도가.php +++ b/hwe/sammo/ActionNationType/che_도가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_도가 implements iAction{ - use \sammo\DefaultAction; +class che_도가 extends \sammo\BaseNation{ protected $name = '도가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_도적.php b/hwe/sammo/ActionNationType/che_도적.php index be889c9d..447da481 100644 --- a/hwe/sammo/ActionNationType/che_도적.php +++ b/hwe/sammo/ActionNationType/che_도적.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_도적 implements iAction{ - use \sammo\DefaultAction; +class che_도적 extends \sammo\BaseNation{ protected $name = '도적'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_명가.php b/hwe/sammo/ActionNationType/che_명가.php index af164fe9..5063beaa 100644 --- a/hwe/sammo/ActionNationType/che_명가.php +++ b/hwe/sammo/ActionNationType/che_명가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_명가 implements iAction{ - use \sammo\DefaultAction; +class che_명가 extends \sammo\BaseNation{ protected $name = '명가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_묵가.php b/hwe/sammo/ActionNationType/che_묵가.php index 28764f2a..d62458cc 100644 --- a/hwe/sammo/ActionNationType/che_묵가.php +++ b/hwe/sammo/ActionNationType/che_묵가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_묵가 implements iAction{ - use \sammo\DefaultAction; +class che_묵가 extends \sammo\BaseNation{ protected $name = '묵가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_법가.php b/hwe/sammo/ActionNationType/che_법가.php index e73d2149..e18cf9fb 100644 --- a/hwe/sammo/ActionNationType/che_법가.php +++ b/hwe/sammo/ActionNationType/che_법가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_법가 implements iAction{ - use \sammo\DefaultAction; +class che_법가 extends \sammo\BaseNation{ protected $name = '법가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_병가.php b/hwe/sammo/ActionNationType/che_병가.php index 0b446af2..7a378809 100644 --- a/hwe/sammo/ActionNationType/che_병가.php +++ b/hwe/sammo/ActionNationType/che_병가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_병가 implements iAction{ - use \sammo\DefaultAction; +class che_병가 extends \sammo\BaseNation{ protected $name = '병가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_불가.php b/hwe/sammo/ActionNationType/che_불가.php index dc3ad31d..425f6496 100644 --- a/hwe/sammo/ActionNationType/che_불가.php +++ b/hwe/sammo/ActionNationType/che_불가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_불가 implements iAction{ - use \sammo\DefaultAction; +class che_불가 extends \sammo\BaseNation{ protected $name = '불가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_오두미도.php b/hwe/sammo/ActionNationType/che_오두미도.php index adafe52b..af564566 100644 --- a/hwe/sammo/ActionNationType/che_오두미도.php +++ b/hwe/sammo/ActionNationType/che_오두미도.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_오두미도 implements iAction{ - use \sammo\DefaultAction; +class che_오두미도 extends \sammo\BaseNation{ protected $name = '오두미도'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_유가.php b/hwe/sammo/ActionNationType/che_유가.php index 747cd4e8..1e024848 100644 --- a/hwe/sammo/ActionNationType/che_유가.php +++ b/hwe/sammo/ActionNationType/che_유가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_유가 implements iAction{ - use \sammo\DefaultAction; +class che_유가 extends \sammo\BaseNation{ protected $name = '유가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_음양가.php b/hwe/sammo/ActionNationType/che_음양가.php index fc5aef73..db874f9d 100644 --- a/hwe/sammo/ActionNationType/che_음양가.php +++ b/hwe/sammo/ActionNationType/che_음양가.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_음양가 implements iAction{ - use \sammo\DefaultAction; +class che_음양가 extends \sammo\BaseNation{ protected $name = '음양가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_종횡가.php b/hwe/sammo/ActionNationType/che_종횡가.php index 7fcdb38d..361f5006 100644 --- a/hwe/sammo/ActionNationType/che_종횡가.php +++ b/hwe/sammo/ActionNationType/che_종횡가.php @@ -4,8 +4,7 @@ use \sammo\iAction; use \sammo\General; use \sammo\Util; -class che_종횡가 implements iAction{ - use \sammo\DefaultAction; +class che_종횡가 extends \sammo\BaseNation{ protected $name = '종횡가'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_중립.php b/hwe/sammo/ActionNationType/che_중립.php index eea5e72a..c42839fb 100644 --- a/hwe/sammo/ActionNationType/che_중립.php +++ b/hwe/sammo/ActionNationType/che_중립.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_중립 implements iAction{ - use \sammo\DefaultAction; +class che_중립 extends \sammo\BaseNation{ protected $name = '-'; protected $info = ''; diff --git a/hwe/sammo/ActionNationType/che_태평도.php b/hwe/sammo/ActionNationType/che_태평도.php index e2b1a153..3f3b68cb 100644 --- a/hwe/sammo/ActionNationType/che_태평도.php +++ b/hwe/sammo/ActionNationType/che_태평도.php @@ -3,8 +3,7 @@ namespace sammo\ActionNationType; use \sammo\iAction; use \sammo\General; -class che_태평도 implements iAction{ - use \sammo\DefaultAction; +class che_태평도 extends \sammo\BaseNation{ protected $name = '태평도'; protected $info = ''; diff --git a/hwe/sammo/BaseNation.php b/hwe/sammo/BaseNation.php new file mode 100644 index 00000000..ee1fa40e --- /dev/null +++ b/hwe/sammo/BaseNation.php @@ -0,0 +1,13 @@ +affectDestCity($injuryCount); $itemObj = $general->getItem(); - if($itemObj->isConsumableNow('GeneralCommand', '계략') && $itemObj::$consumable){ + if($itemObj->isConsumableNow('GeneralCommand', '계략') && $itemObj->isConsumableNow('GeneralCommand', '계략')){ $itemName = $itemObj->getName(); $itemRawName = $itemObj->getRawName(); $josaUl = JosaUtil::pick($itemRawName, '을'); diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index fe853977..da6f84ec 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -3332,8 +3332,24 @@ class GeneralAI $picked = false; foreach(Util::range(5) as $idx){ + /** @var General */ - $randGeneral = Util::choiceRandom($this->npcWarGenerals); + if($this->npcWarGenerals){ + $randGeneral = Util::choiceRandom($this->npcWarGenerals); + } + else if($this->npcCivilGenerals){ + $randGeneral = Util::choiceRandom($this->npcCivilGenerals); + } + else if($this->userWarGenerals){ + $randGeneral = Util::choiceRandom($this->userWarGenerals); + } + else if($this->userCivilGenerals){ + $randGeneral = Util::choiceRandom($this->userCivilGenerals); + } + else{ + break; + } + if($randGeneral->getVar('officer_level') != 1){ continue; } @@ -3357,10 +3373,11 @@ class GeneralAI break; } - if(!$picked){ + if(!$picked || !$randGeneral){ continue; } + /** @var General $randGeneral */ $randGeneral->setVar('officer_level', $chiefLevel); $randGeneral->setVar('officer_city', 0); $randGeneral->applyDB($db); diff --git a/hwe/sammo/Message.php b/hwe/sammo/Message.php index 143db1f5..8c1b4e42 100644 --- a/hwe/sammo/Message.php +++ b/hwe/sammo/Message.php @@ -473,4 +473,12 @@ class Message ], 'id=%i', $this->id); } + + public function agreeMessage(int $receiverID, string &$reason):int{ + throw new NotInheritedMethodException(); + } + + public function declineMessage(int $receiverID, string &$reason):int{ + throw new NotInheritedMethodException(); + } } diff --git a/hwe/sammo/Scenario.php b/hwe/sammo/Scenario.php index b1f40b32..2deab360 100644 --- a/hwe/sammo/Scenario.php +++ b/hwe/sammo/Scenario.php @@ -18,7 +18,9 @@ class Scenario{ private $history; + /** @var \sammo\Scenario\Nation[] */ private $nations; + /** @var \sammo\Scenario\Nation[] */ private $nationsInv; private $diplomacy; @@ -125,7 +127,7 @@ class Scenario{ ) = $rawGeneral; if(key_exists($nationName, $this->nationsInv)){ - $nationID = $this->nationsInv[$nationName]->id;; + $nationID = $this->nationsInv[$nationName]->getID(); } else if(key_exists($nationName, $this->nations)){ $nationID = (int)$nationName; @@ -167,7 +169,7 @@ class Scenario{ ) = $rawGeneral; if(key_exists($nationName, $this->nationsInv)){ - $nationID = $this->nationsInv[$nationName]->id;; + $nationID = $this->nationsInv[$nationName]->getID(); } else if(key_exists($nationName, $this->nations)){ $nationID = (int)$nationName; diff --git a/hwe/sammo/WarUnit.php b/hwe/sammo/WarUnit.php index 28f93ac4..b701a5b9 100644 --- a/hwe/sammo/WarUnit.php +++ b/hwe/sammo/WarUnit.php @@ -18,6 +18,7 @@ class WarUnit{ protected $currPhase = 0; protected $prePhase = 0; + protected $bonusPhase = 0; protected $atmosBonus = 0; protected $trainBonus = 0; @@ -166,7 +167,8 @@ class WarUnit{ } function getMaxPhase():int{ - return $this->getCrewType()->speed; + $phase = $this->getCrewType()->speed; + return $phase + $this->bonusPhase; } function setPrePhase(int $phase){ @@ -177,6 +179,10 @@ class WarUnit{ $this->currPhase += 1; } + function addBonusPhase(int $cnt){ + $this->bonusPhase += $cnt; + } + function setOppose(?WarUnit $oppose){ $this->oppose = $oppose; $this->killedCurr = 0; diff --git a/hwe/sammo/WarUnitGeneral.php b/hwe/sammo/WarUnitGeneral.php index 319321b0..0e394a17 100644 --- a/hwe/sammo/WarUnitGeneral.php +++ b/hwe/sammo/WarUnitGeneral.php @@ -2,8 +2,6 @@ namespace sammo; class WarUnitGeneral extends WarUnit{ - protected $bonusPhase = 0; - function __construct(General $general, array $rawNation, bool $isAttacker){ $this->general = $general; $this->raw = $general->getRaw(); @@ -56,10 +54,6 @@ class WarUnitGeneral extends WarUnit{ } } - function addBonusPhase(int $cnt){ - $this->bonusPhase += $cnt; - } - function getMaxPhase():int{ $phase = $this->getCrewType()->speed; $phase = $this->general->onCalcStat($this->general, 'initWarPhase', $phase); diff --git a/src/sammo/Util.php b/src/sammo/Util.php index a52571f4..004cd918 100644 --- a/src/sammo/Util.php +++ b/src/sammo/Util.php @@ -63,7 +63,7 @@ class Util extends \utilphp\util throw new \InvalidArgumentException('올바르지 않은 type 지정'); } - public static function zip(iterable ...$iterators){ + public static function zip(\Generator ...$iterators){ while(true){ $hasValue = false; $values = [];