refac: 유산 포인트 파트를 별도의 Manager로 분리, enum 적용

This commit is contained in:
2022-05-08 04:40:36 +09:00
parent f7776d5067
commit eff79c4778
35 changed files with 463 additions and 345 deletions
+3 -1
View File
@@ -14,6 +14,8 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
use function sammo\refreshNationStaticInfo;
use function sammo\getAllNationStaticInfo;
use function sammo\tryUniqueItemLottery;
@@ -162,7 +164,7 @@ class che_거병 extends Command\GeneralCommand{
$exp = 100;
$ded = 100;
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$general->addExperience($exp);
$general->addDedication($ded);
$general->setVar('belong', 1);
+3 -1
View File
@@ -19,6 +19,8 @@ use function \sammo\getAllNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
use function sammo\buildNationTypeClass;
use function sammo\refreshNationStaticInfo;
use function sammo\GetNationColors;
@@ -188,7 +190,7 @@ class che_건국 extends Command\GeneralCommand
refreshNationStaticInfo();
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general, '건국');
@@ -18,7 +18,7 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
class che_등용수락 extends Command\GeneralCommand{
static protected $actionName = '등용 수락';
@@ -194,7 +194,7 @@ class che_등용수락 extends Command\GeneralCommand{
}
$db->update('nation', $setScoutNationValues, 'nation=%i', $destNationID);
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$general->setVar('permission', 'normal');
$general->setVar('belong', 1);
$general->setVar('officer_level', 1);
@@ -19,6 +19,7 @@ use function \sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
use sammo\MustNotBeReachedException;
@@ -285,7 +286,7 @@ class che_랜덤임관 extends Command\GeneralCommand
$general->setAuxVar('joinedNations', $joinedNations);
}
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$general->addExperience($exp);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
@@ -13,6 +13,7 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use function sammo\tryRollbackInheritUniqueItem;
@@ -96,7 +97,7 @@ class che_모반시도 extends Command\GeneralCommand{
$lordLogger->pushGeneralHistoryLog("<D><b>{$generalName}</b></>의 모반으로 인해 <D><b>{$nationName}</b></>의 군주자리를 박탈당함");
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db);
+3 -1
View File
@@ -13,6 +13,8 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
use function sammo\DeleteConflict;
use function sammo\refreshNationStaticInfo;
use function sammo\tryRollbackInheritUniqueItem;
@@ -121,7 +123,7 @@ class che_방랑 extends Command\GeneralCommand{
], 'me=%i OR you=%i', $nationID, $nationID);
refreshNationStaticInfo();
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
tryRollbackInheritUniqueItem($general);
$general->applyDB($db);
+2 -1
View File
@@ -19,6 +19,7 @@ use function\sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use function sammo\tryRollbackInheritUniqueItem;
@@ -135,7 +136,7 @@ class che_선양 extends Command\GeneralCommand
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>의 군주자리를 <Y>{$destGeneralName}</>에게 선양");
$destLogger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>의 군주자리를 물려 받음");
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryRollbackInheritUniqueItem($general);
@@ -17,7 +17,7 @@ use function \sammo\pickGeneralFromPool;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
class che_인재탐색 extends Command\GeneralCommand
{
@@ -210,7 +210,7 @@ class che_인재탐색 extends Command\GeneralCommand
$exp = 200;
$ded = 300;
$general->increaseInheritancePoint('active_action', Util::valueFit(sqrt(1 / $foundProp), 1));
$general->increaseInheritancePoint(InheritanceKey::active_action, Util::valueFit(sqrt(1 / $foundProp), 1));
$general->increaseVarWithLimit('gold', -$reqGold, 0);
$general->increaseVarWithLimit('rice', -$reqRice, 0);
$general->addExperience($exp);
+2 -3
View File
@@ -23,8 +23,7 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
class che_임관 extends Command\GeneralCommand
{
@@ -183,7 +182,7 @@ class che_임관 extends Command\GeneralCommand
$general->setAuxVar('joinedNations', $joinedNations);
}
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$general->addExperience($exp);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
@@ -21,6 +21,7 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
class che_장수대상임관 extends Command\GeneralCommand{
static protected $actionName = '장수를 따라 임관';
@@ -175,7 +176,7 @@ class che_장수대상임관 extends Command\GeneralCommand{
$general->setAuxVar('joinedNations', $joinedNations);
}
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$general->addExperience($exp);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
+2 -3
View File
@@ -20,8 +20,7 @@ use function sammo\tryRollbackInheritUniqueItem;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
class che_첩보 extends Command\GeneralCommand
{
@@ -211,7 +210,7 @@ class che_첩보 extends Command\GeneralCommand
$ded = Util::randRangeInt(1, 70);
[$reqGold, $reqRice] = $this->getCost();
$general->increaseInheritancePoint('active_action', 0.5);//NOTE: 첩보만 예외!
$general->increaseInheritancePoint(InheritanceKey::active_action, 0.5);//NOTE: 첩보만 예외!
$general->increaseVarWithLimit('gold', -$reqGold, 0);
$general->increaseVarWithLimit('rice', -$reqRice, 0);
$general->addExperience($exp);
+2 -1
View File
@@ -19,6 +19,7 @@ use function \sammo\processWar;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
class che_출병 extends Command\GeneralCommand
{
@@ -226,7 +227,7 @@ class che_출병 extends Command\GeneralCommand
$general->addDex($general->getCrewTypeObj(), $general->getVar('crew') / 100);
if($general->getVar('crew') > 500 && $general->getVar('train') * $general->getVar('atmos') > 70 * 70){
//500명 이상, 모훈출, 모사출
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
}
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
+2 -1
View File
@@ -13,6 +13,7 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst;
use sammo\Enums\InheritanceKey;
use function sammo\tryRollbackInheritUniqueItem;
@@ -113,7 +114,7 @@ class che_하야 extends Command\GeneralCommand{
}
$general->setVar('troop', 0);
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
+2 -1
View File
@@ -17,6 +17,7 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
class che_감축 extends Command\NationCommand{
@@ -199,7 +200,7 @@ class che_감축 extends Command\NationCommand{
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>{$josaUl} <M>감축</>하였습니다.");
$logger->pushGlobalHistoryLog("<M><b>【감축】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>{$josaUl} <M>감축</>하였습니다.");
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
$general->applyDB($db);
@@ -22,6 +22,7 @@ use function \sammo\newColor;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
class che_국기변경 extends Command\NationCommand
@@ -146,7 +147,7 @@ class che_국기변경 extends Command\NationCommand
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다");
$logger->pushGlobalHistoryLog("<S><b>【국기변경】</b></><D><b>{$nationName}</b></>{$josaYiNation} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다.");
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
$general->applyDB($db);
return true;
@@ -19,6 +19,7 @@ use \sammo\CityConst;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
class che_국호변경 extends Command\NationCommand
@@ -152,7 +153,7 @@ class che_국호변경 extends Command\NationCommand
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} 국호를 <D><b>{$newNationName}</b></>{$josaRo} 변경합니다.");
$logger->pushGlobalHistoryLog("<S><b>【국호변경】</b></><D><b>{$nationName}</b></>{$josaYiNation} 국호를 <D><b>{$newNationName}</b></>{$josaRo} 변경합니다.");
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
$general->applyDB($db);
return true;
+2 -1
View File
@@ -16,6 +16,7 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
class che_증축 extends Command\NationCommand{
@@ -162,7 +163,7 @@ class che_증축 extends Command\NationCommand{
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$josaUl = JosaUtil::pick($destCityName, '을');
$josaYi = JosaUtil::pick($generalName, '이');
+2 -1
View File
@@ -17,6 +17,7 @@ use \sammo\Message;
use \sammo\CityConst;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
class che_천도 extends Command\NationCommand
@@ -219,7 +220,7 @@ class che_천도 extends Command\NationCommand
], 'nation=%i', $nationID);
\sammo\refreshNationStaticInfo();
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaRo} 천도했습니다. <1>$date</>");
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>{$josaRo} <M>천도</>명령");
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>{$josaRo} <M>천도</> 명령");
+2 -1
View File
@@ -17,6 +17,7 @@ use \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Event\Action;
class che_초토화 extends Command\NationCommand{
@@ -184,7 +185,7 @@ class che_초토화 extends Command\NationCommand{
\sammo\refreshNationStaticInfo();
\sammo\SetNationFront($nationID);
$general->increaseInheritancePoint('active_action', 1);
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaUl} 초토화했습니다. <1>$date</>");
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>{$josaUl} <M>초토화</> 명령");
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>{$josaUl} <M>초토화</> 명령");