From 2ee06eab2de61e140cb6a298764b87f915c2514a Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 15 Oct 2018 02:05:39 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9B=88=EB=A0=A8=20=ED=84=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Command/General/che_기술연구.php | 3 +- hwe/sammo/Command/General/che_훈련.php | 102 ++++++++++++++++++ .../Constraint/ReqGeneralAtmosMargin.php | 33 ++++++ hwe/sammo/Constraint/ReqGeneralCrew.php | 32 ++++++ .../Constraint/ReqGeneralTrainMargin.php | 33 ++++++ hwe/sammo/GameConstBase.php | 2 + hwe/sammo/General.php | 32 ++++++ 7 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 hwe/sammo/Command/General/che_훈련.php create mode 100644 hwe/sammo/Constraint/ReqGeneralAtmosMargin.php create mode 100644 hwe/sammo/Constraint/ReqGeneralCrew.php create mode 100644 hwe/sammo/Constraint/ReqGeneralTrainMargin.php diff --git a/hwe/sammo/Command/General/che_기술연구.php b/hwe/sammo/Command/General/che_기술연구.php index 1431e74a..bd8960b5 100644 --- a/hwe/sammo/Command/General/che_기술연구.php +++ b/hwe/sammo/Command/General/che_기술연구.php @@ -39,8 +39,7 @@ class che_기술연구 extends che_상업투자{ ['OccupiedCity'], ['SuppliedCity'], ['ReqGeneralGold', $reqGold], - ['ReqGeneralRice', $reqRice], - ['ReqGeneralGold', $reqGold] + ['ReqGeneralRice', $reqRice] ]; $this->reqGold = $reqGold; diff --git a/hwe/sammo/Command/General/che_훈련.php b/hwe/sammo/Command/General/che_훈련.php new file mode 100644 index 00000000..efc95aa3 --- /dev/null +++ b/hwe/sammo/Command/General/che_훈련.php @@ -0,0 +1,102 @@ +generalObj; + + $this->setCity(); + $this->setNation(); + + $this->runnableConstraints=[ + ['NoNeutral'], + ['NoWanderingNation'], + ['OccupiedCity'], + ['ReqGeneralCrew'], + ['ReqGeneralTrainMargin'], + ]; + + } + + protected function argTest():bool{ + $this->arg = null; + return true; + } + + public function getCost():array{ + return [0, 0]; + } + + public function getPreReqTurn():int{ + return 0; + } + + public function getPostReqTurn():int{ + return 0; + } + + public function run():bool{ + if(!$this->isRunnable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $date = substr($general->getVar('turntime'),11,5); + + $score = Util::round($general->getLeadership() * 100 / $general->getVar('crew') * GameConst::$trainDelta); + $scoreText = number_format($score, 0); + + $sideEffect = Util::valueFit(intval($general->getVar('atmos') * GameConst::$atmosSideEffectByTraining), 0); + + $logger = $general->getLogger(); + + $logger->pushGeneralActionLog("훈련치가 $scoreText 상승했습니다. <1>$date"); + + $exp = 100; + $ded = 70; + + $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + + $general->increaseVarWithLimit('train', $score, 0, GameConst::$maxTrainByCommand); + $general->setVar('atmos', $sideEffect); + + $general->addDex($general->getVar('crew')/100, $score, false); + + $general->increaseVar('experience', $exp); + $general->increaseVar('dedication', $ded); + $general->increaseVar('leader2', 1); + $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->applyDB($db); + + $this->checkStatChange(); + uniqueItemEx($general->getVar('no'), $logger); + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/ReqGeneralAtmosMargin.php b/hwe/sammo/Constraint/ReqGeneralAtmosMargin.php new file mode 100644 index 00000000..e0bec533 --- /dev/null +++ b/hwe/sammo/Constraint/ReqGeneralAtmosMargin.php @@ -0,0 +1,33 @@ +general)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require atmos in general"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($this->general['atmos'] < GameConst::$maxAtmosByCommand){ + return true; + } + + $this->reason = "병사들은 이미 정예병사들입니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/ReqGeneralCrew.php b/hwe/sammo/Constraint/ReqGeneralCrew.php new file mode 100644 index 00000000..0ad27e19 --- /dev/null +++ b/hwe/sammo/Constraint/ReqGeneralCrew.php @@ -0,0 +1,32 @@ +general)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require crew in general"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($this->general['crew'] > 0){ + return true; + } + + $this->reason = "병사들이 없습니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/ReqGeneralTrainMargin.php b/hwe/sammo/Constraint/ReqGeneralTrainMargin.php new file mode 100644 index 00000000..e02106f4 --- /dev/null +++ b/hwe/sammo/Constraint/ReqGeneralTrainMargin.php @@ -0,0 +1,33 @@ +general)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require train in general"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($this->general['train'] < GameConst::$maxTrainByCommand){ + return true; + } + + $this->reason = "병사들은 이미 정예병사들입니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index ae7ec9f8..30073f3a 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -39,6 +39,8 @@ class GameConstBase public static $atmosDelta = 30; /** @var float 훈련시 사기 감소율*/ public static $atmosSideEffectByTraining = 1; + /** @var float 사기시 훈련 감소율*/ + public static $trainSideEffectByAtmosTurn = 1; /** @var float 계략 기본 성공률*/ public static $sabotageDefaultProb = 0.35; /** @var int 계략시 확률 가중치(수치가 클수록 변화가 적음 : (지력차/$firing + $basefiring)*/ diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 855500ea..038acbb6 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -166,6 +166,10 @@ class General implements iAction{ return $this->levelObj; } + function getCrewTypeObj():GameUnitDetail{ + return GameUnitConst::byID($this->getVar('crewtype')); + } + //TODO: 장기적으로 General 클래스로 모두 옮겨와야함. function getLeadership($withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{ return getGeneralLeadership($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor); @@ -179,6 +183,34 @@ class General implements iAction{ return getGeneralIntel($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor); } + function addDex(GameUnitDetail $crewType, float $exp, bool $affectTrainAtmos=false){ + $armType = $crewType->armType; + + if($armType == GameUnitConst::T_CASTLE){ + $armType = GameUnitConst::T_SIEGE; + } + + if($armType < 0){ + return; + } + + if($armType == GameUnitConst::T_WIZARD) { + $exp *= 0.9; + } + else if($armType == GameUnitConst::T_SIEGE) { + $exp *= 0.9; + } + + if($affectTrainAtmos){ + $exp *= ($this->getVar('train') + $this->getVar('atmos')) / 200; + } + + $ntype = $armType*10; + $dexType = "dex{$ntype}"; + + $this->increaseVar($dexType, $exp); + } + /** * @param \MeekroDB $db */