From a31b5ea29d2e23b93ab5e4994b6add559009766d Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 9 May 2020 13:14:11 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8A=B9=EA=B8=B0=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 14 +- hwe/sammo/ActionSpecialWar/che_필살.php | 2 - .../Command/General/che_내정특기초기화.php | 29 ++++ .../Command/General/che_전투특기초기화.php | 130 ++++++++++++++++++ hwe/sammo/GameConstBase.php | 4 +- hwe/sammo/LazyVarUpdater.php | 2 +- hwe/sammo/SpecialityHelper.php | 18 ++- 7 files changed, 188 insertions(+), 11 deletions(-) create mode 100644 hwe/sammo/Command/General/che_내정특기초기화.php create mode 100644 hwe/sammo/Command/General/che_전투특기초기화.php diff --git a/hwe/func.php b/hwe/func.php index 0bd5a1c8..ee3ffde7 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1254,9 +1254,12 @@ function addAge() [$startYear, $year, $month] = $gameStor->getValuesAsArray(['startyear', 'year', 'month']); if ($year >= $startYear + 3) { - foreach ($db->query('SELECT no,name,nation,leadership,strength,intel from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general) { + foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,aux from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general) { $generalID = $general['no']; - $special = SpecialityHelper::pickSpecialDomestic($general); + $special = SpecialityHelper::pickSpecialDomestic( + $general, + (Json::decode($general['aux'])['prev_types_special2'])??[] + ); $specialClass = buildGeneralSpecialDomesticClass($special); $specialText = $specialClass->getName(); $db->update('general', [ @@ -1270,9 +1273,12 @@ function addAge() $logger->pushGeneralHistoryLog("특기 【{$specialText}】{$josaUl} 습득"); } - foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5 from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general) { + foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5,aux from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general) { $generalID = $general['no']; - $special2 = SpecialityHelper::pickSpecialWar($general); + $special2 = SpecialityHelper::pickSpecialWar( + $general, + (Json::decode($general['aux'])['prev_types_special2'])??[] + ); $specialClass = buildGeneralSpecialWarClass($special2); $specialText = $specialClass->getName(); diff --git a/hwe/sammo/ActionSpecialWar/che_필살.php b/hwe/sammo/ActionSpecialWar/che_필살.php index 885c5801..74c2042a 100644 --- a/hwe/sammo/ActionSpecialWar/che_필살.php +++ b/hwe/sammo/ActionSpecialWar/che_필살.php @@ -7,8 +7,6 @@ use \sammo\WarUnit; use sammo\WarUnitTriggerCaller; use sammo\WarUnitTrigger\che_필살강화_회피불가; -use function sammo\LogText; - class che_필살 extends \sammo\BaseSpecial{ protected $id = 71; diff --git a/hwe/sammo/Command/General/che_내정특기초기화.php b/hwe/sammo/Command/General/che_내정특기초기화.php new file mode 100644 index 00000000..8dc6d00f --- /dev/null +++ b/hwe/sammo/Command/General/che_내정특기초기화.php @@ -0,0 +1,29 @@ +arg = null; + return true; + } + + protected function init(){ + + $general = $this->generalObj; + $env = $this->env; + $yearMonth = Util::joinYearMonth($env['year'], $env['month']); + $auxYearMonth = $general->getAuxVar('used_'.$this->getName())??-999; + + if($yearMonth < $auxYearMonth + 60){ + $this->minConditionConstraints=[ + ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다') + ]; + + $this->fullConditionConstraints=[ + ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다') + ]; + return; + } + + + $this->minConditionConstraints=[ + ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'), + ]; + + $this->fullConditionConstraints=[ + ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.') + ]; + + } + + public function getCommandDetailTitle():string{ + $name = $this->getName(); + if($this->getPreReqTurn()){ + $reqTurn = ($this->getPreReqTurn()+1).'턴, '; + } + else{ + $reqTurn = 0; + } + + $title = "{$name}({$reqTurn}5년마다 1회)"; + return $title; + } + + public function getCost():array{ + return [0, 0]; + } + + public function getPreReqTurn():int{ + return 1; + } + + public function getPostReqTurn():int{ + return 0; + } + + public function getTermString():string{ + $term = $this->getResultTurn()->getTerm(); + $termMax = $this->getPreReqTurn() + 1; + return "새로운 적성을 찾는 중... ({$term}/{$termMax})"; + } + + public function run():bool{ + if(!$this->hasFullConditionMet()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $date = $general->getTurnTime($general::TURNTIME_HM); + + $oldTypeKey = 'prev_types_'.static::$specialType; + $specialName = static::$specialText; + + $env = $this->env; + + $yearMonth = Util::joinYearMonth($env['year'], $env['month']); + $oldSpecialList = $general->getAuxVar($oldTypeKey)??[]; + $oldSpecialList[] = $general->getVar(static::$specialType); + $general->setAuxVar($oldTypeKey, $oldSpecialList); + + $general->setVar(static::$specialType, 'None'); + $general->setVar(static::$speicalAge, $general->getVar('age') + 1); + $general->setAuxVar('used_'.$this->getName(), $yearMonth); + + $logger = $general->getLogger(); + + $logger->pushGeneralActionLog("새로운 {$specialName}를 가질 준비가 되었습니다. <1>$date"); + + $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); + tryUniqueItemLottery($general); + $general->applyDB($db); + + return true; + } + + +} \ No newline at end of file diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index f469fb83..c0f3f098 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -275,8 +275,8 @@ class GameConstBase 'che_선동', ], '개인'=>[ - //'che_내정특기초기화', - //'che_전투특기초기화', + 'che_내정특기초기화', + 'che_전투특기초기화', 'che_단련', 'che_숙련전환', 'che_견문', diff --git a/hwe/sammo/LazyVarUpdater.php b/hwe/sammo/LazyVarUpdater.php index 5260bd83..ec75f0eb 100644 --- a/hwe/sammo/LazyVarUpdater.php +++ b/hwe/sammo/LazyVarUpdater.php @@ -33,7 +33,7 @@ trait LazyVarUpdater{ } function unpackAux(){ - if($this->raw['auxVar']??null === null){ + if(($this->raw['auxVar']??null) === null){ if(!key_exists('aux', $this->raw)){ throw new \RuntimeException('aux is not set'); } diff --git a/hwe/sammo/SpecialityHelper.php b/hwe/sammo/SpecialityHelper.php index 3c677b9e..fdd4c428 100644 --- a/hwe/sammo/SpecialityHelper.php +++ b/hwe/sammo/SpecialityHelper.php @@ -179,7 +179,7 @@ class SpecialityHelper{ return $result; } - public static function pickSpecialDomestic(array $general) : string{ + public static function pickSpecialDomestic(array $general, array $prevSpecials=[]) : string{ $pAbs = []; $pRel = []; @@ -201,6 +201,9 @@ class SpecialityHelper{ if(!$valid){ continue; } + if(in_array($specialID, $prevSpecials)){ + continue; + } if($weightType === static::WEIGHT_PERCENT){ @@ -226,10 +229,14 @@ class SpecialityHelper{ return $id; } + if($prevSpecials){ + return static::pickSpecialDomestic($general, []); + } + throw new MustNotBeReachedException(); } - public static function pickSpecialWar(array $general) : string{ + public static function pickSpecialWar(array $general, array $prevSpecials=[]) : string{ $reqDex = []; $pAbs = []; $pRel = []; @@ -254,6 +261,9 @@ class SpecialityHelper{ if(!$valid){ continue; } + if(in_array($specialID, $prevSpecials)){ + continue; + } if($cond & self::REQ_DEXTERITY){ @@ -286,6 +296,10 @@ class SpecialityHelper{ return $id; } + if($prevSpecials){ + return static::pickSpecialWar($general, []); + } + throw new MustNotBeReachedException(); } } \ No newline at end of file