diff --git a/hwe/func.php b/hwe/func.php index 24d3a532..40f59d3f 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1286,12 +1286,11 @@ function addAge() $generalAux = Json::decode($general['aux']); $updateVars = []; - if(key_exists('inheritSpecificSpecialWar', $generalAux)){ + if (key_exists('inheritSpecificSpecialWar', $generalAux)) { $special2 = $generalAux['inheritSpecificSpecialWar']; unset($generalAux['inheritSpecificSpecialWar']); $updateVars['aux'] = Json::encode($generalAux); - } - else{ + } else { $special2 = SpecialityHelper::pickSpecialWar( $general, ($generalAux['prev_types_special2']) ?? [] @@ -1666,7 +1665,12 @@ function rollbackInheritUniqueTrial(General $general, string $itemKey, string $r $general->applyDB($db); } -function tryInheritUniqueItem(General $general, string $acquireType = '아이템'): bool +function tryRollbackInheritUniqueItem(General $general): void +{ + tryInheritUniqueItem($general, 'Rollback', true); +} + +function tryInheritUniqueItem(General $general, string $acquireType = '아이템', bool $justRollback = false): bool { $ownerID = $general->getVar('owner'); if (!$ownerID) { @@ -1769,6 +1773,9 @@ function tryInheritUniqueItem(General $general, string $acquireType = '아이템 if ($ownTarget === null) { return false; } + if ($justRollback) { + return false; + } LogText("선택유니크획득{$ownerID}", $ownTarget); @@ -1859,9 +1866,9 @@ function tryUniqueItemLottery(General $general, string $acquireType = '아이템 $result = false; $prob /= sqrt(2); - $moreProb = pow(2, 1/4); + $moreProb = pow(2, 1 / 4); - if($general->getAuxVar('inheritRandomUnique')){ + if ($general->getAuxVar('inheritRandomUnique')) { //포인트로 랜덤 유니크 획득 $prob = 1; LogText("{$general->getName()}, {$general->getID()} 유산 포인트 유니크", $prob); diff --git a/hwe/sammo/Command/General/che_NPC능동.php b/hwe/sammo/Command/General/che_NPC능동.php index 33145ef8..1b3d8de9 100644 --- a/hwe/sammo/Command/General/che_NPC능동.php +++ b/hwe/sammo/Command/General/che_NPC능동.php @@ -4,7 +4,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, General, - CityConst, + CityConst, ActionLogger, LastTurn, Command @@ -13,6 +13,7 @@ use \sammo\{ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use function sammo\tryRollbackInheritUniqueItem; class che_NPC능동 extends Command\GeneralCommand{ static protected $actionName = 'NPC능동'; @@ -46,7 +47,7 @@ class che_NPC능동 extends Command\GeneralCommand{ $general = $this->generalObj; $this->setNation(); - + $this->permissionConstraints=[ ConstraintHelper::MustBeNPC() @@ -65,7 +66,7 @@ class che_NPC능동 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -97,11 +98,11 @@ class che_NPC능동 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); } - + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_모반시도.php b/hwe/sammo/Command/General/che_모반시도.php index daf8d0d6..b39e7d5c 100644 --- a/hwe/sammo/Command/General/che_모반시도.php +++ b/hwe/sammo/Command/General/che_모반시도.php @@ -14,6 +14,8 @@ use \sammo\{ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use function sammo\tryRollbackInheritUniqueItem; + class che_모반시도 extends Command\GeneralCommand{ static protected $actionName = '모반시도'; @@ -29,7 +31,7 @@ class che_모반시도 extends Command\GeneralCommand{ $this->setCity(); $this->setNation(); - + $this->fullConditionConstraints=[ ConstraintHelper::NotBeNeutral(), ConstraintHelper::BeChief(), @@ -43,7 +45,7 @@ class che_모반시도 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -72,7 +74,7 @@ class che_모반시도 extends Command\GeneralCommand{ $lordName = $lordGeneral->getName(); $nationName = $this->nation['name']; - + $logger = $general->getLogger(); $lordLogger = $lordGeneral->getLogger(); @@ -82,7 +84,7 @@ class che_모반시도 extends Command\GeneralCommand{ $lordGeneral->setVar('officer_city', 0); $lordGeneral->multiplyVar('experience', 0.7); - + $josaYi = JosaUtil::pick($generalName, '이'); $logger->pushGlobalHistoryLog("【모반】{$generalName}{$josaYi} {$nationName}의 군주 자리를 찬탈했습니다."); $logger->pushNationalHistoryLog("{$generalName}{$josaYi} {$lordName}에게서 군주자리를 찬탈"); @@ -95,11 +97,12 @@ class che_모반시도 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); $lordGeneral->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_방랑.php b/hwe/sammo/Command/General/che_방랑.php index 3132c294..4a54f850 100644 --- a/hwe/sammo/Command/General/che_방랑.php +++ b/hwe/sammo/Command/General/che_방랑.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -15,7 +15,7 @@ use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; use function sammo\DeleteConflict; use function sammo\refreshNationStaticInfo; - +use function sammo\tryRollbackInheritUniqueItem; class che_방랑 extends Command\GeneralCommand{ static protected $actionName = '방랑'; @@ -34,7 +34,7 @@ class che_방랑 extends Command\GeneralCommand{ $this->setNation(); $relYear = $env['year'] - $env['startyear']; - + $this->fullConditionConstraints=[ ConstraintHelper::BeLord(), ConstraintHelper::NotWanderingNation(), @@ -48,7 +48,7 @@ class che_방랑 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -85,7 +85,7 @@ class che_방랑 extends Command\GeneralCommand{ $logger->pushGlobalHistoryLog("【방랑】{$generalName}{$josaUn} 방랑의 길을 떠납니다."); $logger->pushGeneralHistoryLog("{$nationName}{$josaUl} 버리고 방랑"); - + //분쟁기록 모두 지움 DeleteConflict($nationID); // 국명, 색깔 바꿈 국가 레벨 0, 성향리셋, 기술0 @@ -123,6 +123,7 @@ class che_방랑 extends Command\GeneralCommand{ refreshNationStaticInfo(); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_선양.php b/hwe/sammo/Command/General/che_선양.php index 4cc911b2..38377add 100644 --- a/hwe/sammo/Command/General/che_선양.php +++ b/hwe/sammo/Command/General/che_선양.php @@ -20,6 +20,7 @@ use function\sammo\tryUniqueItemLottery; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use function sammo\tryRollbackInheritUniqueItem; class che_선양 extends Command\GeneralCommand { @@ -136,6 +137,7 @@ class che_선양 extends Command\GeneralCommand $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); $destGeneral->applyDB($db); diff --git a/hwe/sammo/Command/General/che_소집해제.php b/hwe/sammo/Command/General/che_소집해제.php index 2ed7a92e..3a8d57e3 100644 --- a/hwe/sammo/Command/General/che_소집해제.php +++ b/hwe/sammo/Command/General/che_소집해제.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -13,6 +13,8 @@ use \sammo\{ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; +use function sammo\tryRollbackInheritUniqueItem; + class che_소집해제 extends Command\GeneralCommand{ static protected $actionName = '소집해제'; @@ -27,7 +29,7 @@ class che_소집해제 extends Command\GeneralCommand{ $this->setCity(); $this->setNation(); - + $this->fullConditionConstraints=[ ConstraintHelper::ReqGeneralCrew(), ]; @@ -43,7 +45,7 @@ class che_소집해제 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -70,7 +72,7 @@ class che_소집해제 extends Command\GeneralCommand{ $exp = 70; $ded = 100; - + $db->update('city', [ 'pop'=>$db->sqleval('pop + %i', $crew) ], 'city=%i', $general->getCityID()); @@ -80,10 +82,11 @@ class che_소집해제 extends Command\GeneralCommand{ $general->addDedication($ded); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_요양.php b/hwe/sammo/Command/General/che_요양.php index 98ee0535..48d31bfc 100644 --- a/hwe/sammo/Command/General/che_요양.php +++ b/hwe/sammo/Command/General/che_요양.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -13,7 +13,7 @@ use \sammo\{ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; - +use function sammo\tryRollbackInheritUniqueItem; class che_요양 extends Command\GeneralCommand{ static protected $actionName = '요양'; @@ -28,7 +28,7 @@ class che_요양 extends Command\GeneralCommand{ $general = $this->generalObj; $this->setNation(); - + $this->fullConditionConstraints=[ ]; @@ -37,7 +37,7 @@ class che_요양 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -56,7 +56,7 @@ class che_요양 extends Command\GeneralCommand{ $general = $this->generalObj; $date = $general->getTurnTime($general::TURNTIME_HM); - + $crew = $general->getVar('crew'); $logger = $general->getLogger(); @@ -71,10 +71,11 @@ class che_요양 extends Command\GeneralCommand{ $general->addDedication($ded); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_첩보.php b/hwe/sammo/Command/General/che_첩보.php index 868c322d..c9ce9ab7 100644 --- a/hwe/sammo/Command/General/che_첩보.php +++ b/hwe/sammo/Command/General/che_첩보.php @@ -15,6 +15,7 @@ use \sammo\Json; use function \sammo\searchDistance; use function \sammo\printCitiesBasedOnDistance; +use function sammo\tryRollbackInheritUniqueItem; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; @@ -217,6 +218,7 @@ class che_첩보 extends Command\GeneralCommand $general->increaseVar('leadership_exp', 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_하야.php b/hwe/sammo/Command/General/che_하야.php index 5a0f5082..c54427f9 100644 --- a/hwe/sammo/Command/General/che_하야.php +++ b/hwe/sammo/Command/General/che_하야.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -14,7 +14,7 @@ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; - +use function sammo\tryRollbackInheritUniqueItem; class che_하야 extends Command\GeneralCommand{ static protected $actionName = '하야'; @@ -32,7 +32,7 @@ class che_하야 extends Command\GeneralCommand{ $this->setNation(); $relYear = $env['year'] - $env['startyear']; - + $this->fullConditionConstraints=[ ConstraintHelper::NotBeNeutral(), ConstraintHelper::NotOpeningPart($relYear), @@ -43,7 +43,7 @@ class che_하야 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -67,7 +67,7 @@ class che_하야 extends Command\GeneralCommand{ $nationID = $this->nation['nation']; $nationName = $this->nation['name']; - + $logger = $general->getLogger(); $logger->pushGeneralActionLog("{$nationName}에서 하야했습니다. <1>$date"); @@ -101,13 +101,14 @@ class che_하야 extends Command\GeneralCommand{ $general->setVar('officer_city', 0); $general->setVar('belong', 0); $general->setVar('makelimit', 12); - + $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_해산.php b/hwe/sammo/Command/General/che_해산.php index 87a7fb80..a4849548 100644 --- a/hwe/sammo/Command/General/che_해산.php +++ b/hwe/sammo/Command/General/che_해산.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -16,13 +16,12 @@ use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; use function sammo\refreshNationStaticInfo; use function sammo\deleteNation; - - +use function sammo\tryRollbackInheritUniqueItem; class che_해산 extends Command\GeneralCommand{ static protected $actionName = '해산'; - protected function argTest():bool{ + protected function argTest():bool{ $this->arg = []; return true; @@ -45,7 +44,7 @@ class che_해산 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -96,11 +95,11 @@ class che_해산 extends Command\GeneralCommand{ $oldGeneral->setVar('makelimit', 12); $oldGeneral->applyDB($db); } - + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_화계.php b/hwe/sammo/Command/General/che_화계.php index 5fd0527b..201e1135 100644 --- a/hwe/sammo/Command/General/che_화계.php +++ b/hwe/sammo/Command/General/che_화계.php @@ -14,6 +14,7 @@ use \sammo\Command; use function \sammo\searchDistance; use function \sammo\printCitiesBasedOnDistance; +use function sammo\tryRollbackInheritUniqueItem; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; @@ -294,6 +295,7 @@ class che_화계 extends Command\GeneralCommand $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return false; } @@ -327,6 +329,7 @@ class che_화계 extends Command\GeneralCommand $general->increaseRankVar('firenum', 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryRollbackInheritUniqueItem($general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/휴식.php b/hwe/sammo/Command/General/휴식.php index fb793d11..5b02f96c 100644 --- a/hwe/sammo/Command/General/휴식.php +++ b/hwe/sammo/Command/General/휴식.php @@ -7,9 +7,11 @@ use \sammo\JosaUtil; use \sammo\LastTurn; use \sammo\DB; +use function sammo\tryRollbackInheritUniqueItem; + class 휴식 extends Command\GeneralCommand{ static protected $actionName = '휴식'; - + protected function argTest():bool{ return true; } @@ -39,7 +41,7 @@ class 휴식 extends Command\GeneralCommand{ $logger->pushGeneralActionLog("아무것도 실행하지 않았습니다. <1>$date"); $this->setResultTurn(new LastTurn()); - + tryRollbackInheritUniqueItem($general); $general->applyDB(DB::db()); return true; }