diff --git a/.vscode/settings.json b/.vscode/settings.json index 87d45fb0..54876998 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,5 +24,8 @@ "/nya":true, "/pya":true, "/twe":true, - }, + }, + "cSpell.words": [ + "sammo" + ], } \ No newline at end of file diff --git a/hwe/process_war.php b/hwe/process_war.php index 62b57584..6d2067e4 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -2,16 +2,12 @@ namespace sammo; -function processWar(array $rawAttacker, array $rawDefenderCity){ +function processWar(General $attacker, array $rawNation, array $rawDefenderCity){ $db = DB::db(); - $rawAttackerCity = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $rawAttacker['city']); - $attackerNationID = $rawAttacker['nation']; $defenderNationID = $rawDefenderCity['nation']; - $rawAttackerNation = $db->queryFirstRow('SELECT nation,`level`,`name`,capital,gennum,tech,`type`,gold,rice FROM nation WHERE nation = %i', $attackerNationID); - if($defenderNationID == 0){ $rawDefenderNation = [ 'nation'=>0, @@ -32,7 +28,7 @@ function processWar(array $rawAttacker, array $rawDefenderCity){ $gameStor = KVStorage::getStorage($db, 'game_env'); [$startYear, $year, $month, $cityRate, $joinMode] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'city_rate', 'join_mode']); - $attacker = new WarUnitGeneral($rawAttacker, $rawAttackerCity, $rawAttackerNation, true, $year, $month); + $attacker = new WarUnitGeneral($attacker, $rawNation, true, $year, $month); $city = new WarUnitCity($rawDefenderCity, $rawDefenderNation, $year, $month, $cityRate); diff --git a/hwe/sammo/ActionPersonality/che_대의.php b/hwe/sammo/ActionPersonality/che_대의.php index 7aa3c9ed..0262f837 100644 --- a/hwe/sammo/ActionPersonality/che_대의.php +++ b/hwe/sammo/ActionPersonality/che_대의.php @@ -10,7 +10,7 @@ class che_대의 implements iAction{ static $name = '대의'; static $info = '명성 +10%, 훈련 -5'; - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'experience'){ return $value * 1.1; } diff --git a/hwe/sammo/ActionPersonality/che_안전.php b/hwe/sammo/ActionPersonality/che_안전.php index 66ef705a..f947e2c8 100644 --- a/hwe/sammo/ActionPersonality/che_안전.php +++ b/hwe/sammo/ActionPersonality/che_안전.php @@ -20,7 +20,7 @@ class che_안전 implements iAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'bonusAtmos'){ return $value - 5; } diff --git a/hwe/sammo/ActionPersonality/che_왕좌.php b/hwe/sammo/ActionPersonality/che_왕좌.php index eb8a2289..6b85624b 100644 --- a/hwe/sammo/ActionPersonality/che_왕좌.php +++ b/hwe/sammo/ActionPersonality/che_왕좌.php @@ -10,7 +10,7 @@ class che_왕좌 implements iAction{ static $name = '왕좌'; static $info = '명성 +10%, 사기 -5'; - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'experience'){ return $value * 1.1; } diff --git a/hwe/sammo/ActionPersonality/che_유지.php b/hwe/sammo/ActionPersonality/che_유지.php index fd49313d..1f9d3054 100644 --- a/hwe/sammo/ActionPersonality/che_유지.php +++ b/hwe/sammo/ActionPersonality/che_유지.php @@ -20,7 +20,7 @@ class che_유지 implements iAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'bonusTrain'){ return $value - 5; } diff --git a/hwe/sammo/ActionPersonality/che_은둔.php b/hwe/sammo/ActionPersonality/che_은둔.php index b7e1294e..c0fc9705 100644 --- a/hwe/sammo/ActionPersonality/che_은둔.php +++ b/hwe/sammo/ActionPersonality/che_은둔.php @@ -20,7 +20,7 @@ class che_은둔 implements iAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'bonusAtmos'){ return $value - 5; } diff --git a/hwe/sammo/ActionPersonality/che_의협.php b/hwe/sammo/ActionPersonality/che_의협.php index 13d8e4cf..2edc2911 100644 --- a/hwe/sammo/ActionPersonality/che_의협.php +++ b/hwe/sammo/ActionPersonality/che_의협.php @@ -20,7 +20,7 @@ class che_의협 implements iAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'bonusAtmos'){ return $value + 5; } diff --git a/hwe/sammo/ActionPersonality/che_재간.php b/hwe/sammo/ActionPersonality/che_재간.php index 1e619aad..5ca86718 100644 --- a/hwe/sammo/ActionPersonality/che_재간.php +++ b/hwe/sammo/ActionPersonality/che_재간.php @@ -20,7 +20,7 @@ class che_재간 implements iAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'experience'){ return $value * 0.9; } diff --git a/hwe/sammo/ActionPersonality/che_정복.php b/hwe/sammo/ActionPersonality/che_정복.php index 6c3772a3..327727ba 100644 --- a/hwe/sammo/ActionPersonality/che_정복.php +++ b/hwe/sammo/ActionPersonality/che_정복.php @@ -10,7 +10,7 @@ class che_정복 implements iAction{ static $name = '정복'; static $info = '명성 -10%, 사기 +5'; - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'experience'){ return $value * 0.9; } diff --git a/hwe/sammo/ActionPersonality/che_출세.php b/hwe/sammo/ActionPersonality/che_출세.php index 77f82472..f775f0a2 100644 --- a/hwe/sammo/ActionPersonality/che_출세.php +++ b/hwe/sammo/ActionPersonality/che_출세.php @@ -20,7 +20,7 @@ class che_출세 implements iAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'experience'){ return $value * 1.1; } diff --git a/hwe/sammo/ActionPersonality/che_패권.php b/hwe/sammo/ActionPersonality/che_패권.php index f63a1635..7f14eb28 100644 --- a/hwe/sammo/ActionPersonality/che_패권.php +++ b/hwe/sammo/ActionPersonality/che_패권.php @@ -20,7 +20,7 @@ class che_패권 implements iAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'bonusTrain'){ return $value + 5; } diff --git a/hwe/sammo/ActionPersonality/che_할거.php b/hwe/sammo/ActionPersonality/che_할거.php index 3b556b0b..02a6eca3 100644 --- a/hwe/sammo/ActionPersonality/che_할거.php +++ b/hwe/sammo/ActionPersonality/che_할거.php @@ -10,7 +10,7 @@ class che_할거 implements iAction{ static $name = '할거'; static $info = '명성 -10%, 훈련 +5'; - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ if($statName == 'experience'){ return $value * 0.9; } diff --git a/hwe/sammo/ActionSpecialWar/che_돌격.php b/hwe/sammo/ActionSpecialWar/che_돌격.php index 97937ffd..cb6bf29c 100644 --- a/hwe/sammo/ActionSpecialWar/che_돌격.php +++ b/hwe/sammo/ActionSpecialWar/che_돌격.php @@ -17,4 +17,11 @@ class che_돌격 implements iAction{ SpecialityConst::STAT_LEADERSHIP, SpecialityConst::STAT_POWER ]; + + public function onCalcStat(General $general, string $statName, $value, $aux=null){ + if($statName === 'initWarPhase'){ + return $value += 1; + } + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialWar/che_무쌍.php b/hwe/sammo/ActionSpecialWar/che_무쌍.php index 1cd83946..954b36e4 100644 --- a/hwe/sammo/ActionSpecialWar/che_무쌍.php +++ b/hwe/sammo/ActionSpecialWar/che_무쌍.php @@ -17,4 +17,11 @@ class che_무쌍 implements iAction{ SpecialityConst::STAT_LEADERSHIP, SpecialityConst::STAT_POWER ]; + + public function onCalcStat(General $general, string $statName, $value, $aux=null){ + if($statName === 'warCriticalRatio' && $aux['isAttacker']??false){ + return $value += 0.1; + } + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialWar/che_필살.php b/hwe/sammo/ActionSpecialWar/che_필살.php index 9cd43808..67d223dd 100644 --- a/hwe/sammo/ActionSpecialWar/che_필살.php +++ b/hwe/sammo/ActionSpecialWar/che_필살.php @@ -18,4 +18,11 @@ class che_필살 implements iAction{ SpecialityConst::STAT_POWER, SpecialityConst::STAT_INTEL ]; + + public function onCalcStat(General $general, string $statName, $value, $aux=null){ + if($statName === 'warCriticalRatio'){ + return $value += 0.2; + } + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_강행.php b/hwe/sammo/Command/General/che_강행.php index 3739a416..2b66fc45 100644 --- a/hwe/sammo/Command/General/che_강행.php +++ b/hwe/sammo/Command/General/che_강행.php @@ -104,7 +104,7 @@ class che_강행 extends Command\GeneralCommand{ $exp = 100; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $exp = $general->onCalcStat($general, 'experience', $exp); $general->setVar('city', $destCityID); if($general->getVar('level') == 12 && $this->nation['level'] == 0){ diff --git a/hwe/sammo/Command/General/che_거병.php b/hwe/sammo/Command/General/che_거병.php index 3239915d..ed88071f 100644 --- a/hwe/sammo/Command/General/che_거병.php +++ b/hwe/sammo/Command/General/che_거병.php @@ -157,8 +157,8 @@ class che_거병 extends Command\GeneralCommand{ $exp = 100; $ded = 100; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVar('experience', $exp); $general->increaseVar('dedication', $ded); diff --git a/hwe/sammo/Command/General/che_건국.php b/hwe/sammo/Command/General/che_건국.php index aff1bbea..1d5ada68 100644 --- a/hwe/sammo/Command/General/che_건국.php +++ b/hwe/sammo/Command/General/che_건국.php @@ -143,8 +143,8 @@ class che_건국 extends Command\GeneralCommand{ $exp = 1000; $ded = 1000; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVar('experience', $exp); $general->increaseVar('dedication', $ded); diff --git a/hwe/sammo/Command/General/che_견문.php b/hwe/sammo/Command/General/che_견문.php index a52b38ea..fa07ca7a 100644 --- a/hwe/sammo/Command/General/che_견문.php +++ b/hwe/sammo/Command/General/che_견문.php @@ -107,7 +107,7 @@ class che_견문 extends Command\GeneralCommand{ $logger->pushGeneralActionLog("{$text} <1>$date"); - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $exp = $general->onCalcStat($general, 'experience', $exp); $general->increaseVar('experience', $exp); $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); diff --git a/hwe/sammo/Command/General/che_군량매매.php b/hwe/sammo/Command/General/che_군량매매.php index edc4b000..7de9cd59 100644 --- a/hwe/sammo/Command/General/che_군량매매.php +++ b/hwe/sammo/Command/General/che_군량매매.php @@ -157,8 +157,8 @@ class che_군량매매 extends Command\GeneralCommand{ $exp = 30; $ded = 50; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $incStat = Util::choiceRandomUsingWeight([ 'leader2'=>$general->getLeadership(false, false, false, false), diff --git a/hwe/sammo/Command/General/che_귀환.php b/hwe/sammo/Command/General/che_귀환.php index 7ab96634..956e6bad 100644 --- a/hwe/sammo/Command/General/che_귀환.php +++ b/hwe/sammo/Command/General/che_귀환.php @@ -84,8 +84,8 @@ class che_귀환 extends Command\GeneralCommand{ $exp = 70; $ded = 100; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->setVar('city', $cityID); diff --git a/hwe/sammo/Command/General/che_기술연구.php b/hwe/sammo/Command/General/che_기술연구.php index be602de2..54a77448 100644 --- a/hwe/sammo/Command/General/che_기술연구.php +++ b/hwe/sammo/Command/General/che_기술연구.php @@ -106,8 +106,8 @@ class che_기술연구 extends che_상업투자{ } - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); if(TechLimit($this->env['startyear'], $this->env['year'], $this->nation['tech'])){ $score /= 4; diff --git a/hwe/sammo/Command/General/che_단련.php b/hwe/sammo/Command/General/che_단련.php index 9213d8ed..02b7642f 100644 --- a/hwe/sammo/Command/General/che_단련.php +++ b/hwe/sammo/Command/General/che_단련.php @@ -96,7 +96,7 @@ class che_단련 extends Command\GeneralCommand{ } $exp = $general->getVar('crew') / 400; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $exp = $general->onCalcStat($general, 'experience', $exp); $general->addDex($general->getCrewTypeObj(), $score, false); diff --git a/hwe/sammo/Command/General/che_등용.php b/hwe/sammo/Command/General/che_등용.php index a989e32f..d8c7dda6 100644 --- a/hwe/sammo/Command/General/che_등용.php +++ b/hwe/sammo/Command/General/che_등용.php @@ -130,8 +130,8 @@ class che_등용 extends Command\GeneralCommand{ $exp = 100; $ded = 200; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); [$reqGold, $reqRice] = $this->getCost(); diff --git a/hwe/sammo/Command/General/che_랜덤임관.php b/hwe/sammo/Command/General/che_랜덤임관.php index 7915fba6..805ec5eb 100644 --- a/hwe/sammo/Command/General/che_랜덤임관.php +++ b/hwe/sammo/Command/General/che_랜덤임관.php @@ -236,7 +236,7 @@ class che_랜덤임관 extends Command\GeneralCommand{ $exp = 100; } - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $exp = $general->onCalcStat($general, 'experience', $exp); $general->setVar('nation', $destNationID); $general->setVar('level', 1); $general->setVar('belong', 1); diff --git a/hwe/sammo/Command/General/che_물자조달.php b/hwe/sammo/Command/General/che_물자조달.php index cd1a5f7d..d33ff770 100644 --- a/hwe/sammo/Command/General/che_물자조달.php +++ b/hwe/sammo/Command/General/che_물자조달.php @@ -103,8 +103,8 @@ class che_물자조달 extends Command\GeneralCommand{ $exp = $score * 0.7 / 3; $ded = $score * 1.0 / 3; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $incStat = Util::choiceRandomUsingWeight([ 'leader2'=>$general->getLeadership(false, false, false, false), diff --git a/hwe/sammo/Command/General/che_사기진작.php b/hwe/sammo/Command/General/che_사기진작.php index a7955857..3e2cda25 100644 --- a/hwe/sammo/Command/General/che_사기진작.php +++ b/hwe/sammo/Command/General/che_사기진작.php @@ -83,8 +83,8 @@ class che_사기진작 extends Command\GeneralCommand{ $exp = 100; $ded = 70; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVarWithLimit('atmos', $score, 0, GameConst::$maxAtmosByCommand); $general->setVar('train', $sideEffect); diff --git a/hwe/sammo/Command/General/che_상업투자.php b/hwe/sammo/Command/General/che_상업투자.php index 51993447..755d926f 100644 --- a/hwe/sammo/Command/General/che_상업투자.php +++ b/hwe/sammo/Command/General/che_상업투자.php @@ -171,8 +171,8 @@ class che_상업투자 extends Command\GeneralCommand{ $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 $scoreText 상승했습니다. <1>$date"); } - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); if(in_array($this->city['front'], [1, 3]) && $this->nation['capital'] != $this->city['city']){ $score *= static::$debuffFront; diff --git a/hwe/sammo/Command/General/che_소집해제.php b/hwe/sammo/Command/General/che_소집해제.php index f7abef0a..5ff6d5ed 100644 --- a/hwe/sammo/Command/General/che_소집해제.php +++ b/hwe/sammo/Command/General/che_소집해제.php @@ -70,8 +70,8 @@ class che_소집해제 extends Command\GeneralCommand{ $exp = 70; $ded = 100; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $db->update('city', [ 'pop'=>$db->sqleval('pop + %i', $crew) diff --git a/hwe/sammo/Command/General/che_요양.php b/hwe/sammo/Command/General/che_요양.php index 64eadc25..065df5d3 100644 --- a/hwe/sammo/Command/General/che_요양.php +++ b/hwe/sammo/Command/General/che_요양.php @@ -71,8 +71,8 @@ class che_요양 extends Command\GeneralCommand{ $exp = 10; $ded = 7; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->setVar('injury', 0); $general->increaseVar('experience', $exp); diff --git a/hwe/sammo/Command/General/che_이동.php b/hwe/sammo/Command/General/che_이동.php index a8b61218..672ac05e 100644 --- a/hwe/sammo/Command/General/che_이동.php +++ b/hwe/sammo/Command/General/che_이동.php @@ -104,7 +104,7 @@ class che_이동 extends Command\GeneralCommand{ $exp = 50; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $exp = $general->onCalcStat($general, 'experience', $exp); $general->setVar('city', $destCityID); if($general->getVar('level') == 12 && $this->nation['level'] == 0){ diff --git a/hwe/sammo/Command/General/che_인재탐색.php b/hwe/sammo/Command/General/che_인재탐색.php index 81d3929b..89725827 100644 --- a/hwe/sammo/Command/General/che_인재탐색.php +++ b/hwe/sammo/Command/General/che_인재탐색.php @@ -107,8 +107,8 @@ class che_인재탐색 extends Command\GeneralCommand{ $exp = 100; $ded = 70; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVarWithLimit('gold', -$reqGold, 0); $general->increaseVarWithLimit('rice', -$reqRice, 0); @@ -254,8 +254,8 @@ class che_인재탐색 extends Command\GeneralCommand{ $exp = 200; $ded = 300; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVarWithLimit('gold', -$reqGold, 0); $general->increaseVarWithLimit('rice', -$reqRice, 0); diff --git a/hwe/sammo/Command/General/che_임관.php b/hwe/sammo/Command/General/che_임관.php index c079ad2a..4ce9884b 100644 --- a/hwe/sammo/Command/General/che_임관.php +++ b/hwe/sammo/Command/General/che_임관.php @@ -143,7 +143,7 @@ class che_임관 extends Command\GeneralCommand{ $exp = 100; } - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $exp = $general->onCalcStat($general, 'experience', $exp); $general->setVar('nation', $destNationID); $general->setVar('level', 1); $general->setVar('belong', 1); diff --git a/hwe/sammo/Command/General/che_장비매매.php b/hwe/sammo/Command/General/che_장비매매.php index 40372d47..4095df19 100644 --- a/hwe/sammo/Command/General/che_장비매매.php +++ b/hwe/sammo/Command/General/che_장비매매.php @@ -168,7 +168,7 @@ class che_장비매매 extends Command\GeneralCommand{ } $exp = 10; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $exp = $general->onCalcStat($general, 'experience', $exp); $general->increaseVar('experience', $exp); $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); diff --git a/hwe/sammo/Command/General/che_전투태세.php b/hwe/sammo/Command/General/che_전투태세.php index 8c8d769c..d8be9f05 100644 --- a/hwe/sammo/Command/General/che_전투태세.php +++ b/hwe/sammo/Command/General/che_전투태세.php @@ -113,8 +113,8 @@ class che_전투태세 extends Command\GeneralCommand{ $exp = 100 * 3; $ded = 70 * 3; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVar('experience', $exp); $general->increaseVar('dedication', $ded); diff --git a/hwe/sammo/Command/General/che_정착장려.php b/hwe/sammo/Command/General/che_정착장려.php index a3641d90..c9fe8202 100644 --- a/hwe/sammo/Command/General/che_정착장려.php +++ b/hwe/sammo/Command/General/che_정착장려.php @@ -140,8 +140,8 @@ class che_정착장려 extends Command\GeneralCommand{ - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); //NOTE: 내정량 상승시 초과 가능? $cityUpdated = [ diff --git a/hwe/sammo/Command/General/che_주민선정.php b/hwe/sammo/Command/General/che_주민선정.php index 4f569734..94905869 100644 --- a/hwe/sammo/Command/General/che_주민선정.php +++ b/hwe/sammo/Command/General/che_주민선정.php @@ -138,8 +138,8 @@ class che_주민선정 extends Command\GeneralCommand{ $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 $scoreText 상승했습니다. <1>$date"); } - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); //NOTE: 내정량 상승시 초과 가능? $cityUpdated = [ diff --git a/hwe/sammo/Command/General/che_증여.php b/hwe/sammo/Command/General/che_증여.php index 7c4b7d47..eb41d72e 100644 --- a/hwe/sammo/Command/General/che_증여.php +++ b/hwe/sammo/Command/General/che_증여.php @@ -135,8 +135,8 @@ class che_증여 extends Command\GeneralCommand{ $exp = 70; $ded = 100; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVar('experience', $exp); $general->increaseVar('dedication', $ded); diff --git a/hwe/sammo/Command/General/che_집합.php b/hwe/sammo/Command/General/che_집합.php index bf105877..7a459f50 100644 --- a/hwe/sammo/Command/General/che_집합.php +++ b/hwe/sammo/Command/General/che_집합.php @@ -97,8 +97,8 @@ class che_집합 extends Command\GeneralCommand{ $exp = 70; $ded = 100; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVar('experience', $exp); $general->increaseVar('dedication', $ded); diff --git a/hwe/sammo/Command/General/che_징병.php b/hwe/sammo/Command/General/che_징병.php index f6e2be11..a9f2b8db 100644 --- a/hwe/sammo/Command/General/che_징병.php +++ b/hwe/sammo/Command/General/che_징병.php @@ -179,8 +179,8 @@ class che_징병 extends Command\GeneralCommand{ $exp = Util::round($reqCrew / 100); $ded = Util::round($reqCrew / 100); - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->addDex($general->getCrewTypeObj(), $reqCrew / 100, false); diff --git a/hwe/sammo/Command/General/che_첩보.php b/hwe/sammo/Command/General/che_첩보.php index 02f9a296..e5658d5a 100644 --- a/hwe/sammo/Command/General/che_첩보.php +++ b/hwe/sammo/Command/General/che_첩보.php @@ -166,8 +166,8 @@ class che_첩보 extends Command\GeneralCommand{ $exp = Util::randRangeInt(1, 100); $ded = Util::randRangeInt(1, 70); - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); [$reqGold, $reqRice] = $this->getCost(); $general->increaseVarWithLimit('gold', -$reqGold, 0); diff --git a/hwe/sammo/Command/General/che_출병.php b/hwe/sammo/Command/General/che_출병.php index 610f47ba..fd939e86 100644 --- a/hwe/sammo/Command/General/che_출병.php +++ b/hwe/sammo/Command/General/che_출병.php @@ -48,7 +48,7 @@ class che_출병 extends Command\GeneralCommand{ $this->setCity(); $this->setNation(['war', 'gennum', 'tech', 'gold', 'rice']); - $this->setDestCity($this->arg['destCityID'], ['city', 'name', 'nation']); + $this->setDestCity($this->arg['destCityID'], null); [$reqGold, $reqRice] = $this->getCost(); $relYear = $this->env['year'] - $this->env['startyear']; diff --git a/hwe/sammo/Command/General/che_헌납.php b/hwe/sammo/Command/General/che_헌납.php index fd324e9f..0d4802e6 100644 --- a/hwe/sammo/Command/General/che_헌납.php +++ b/hwe/sammo/Command/General/che_헌납.php @@ -116,8 +116,8 @@ class che_헌납 extends Command\GeneralCommand{ $exp = 70; $ded = 100; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVar('experience', $exp); $general->increaseVar('dedication', $ded); diff --git a/hwe/sammo/Command/General/che_화계.php b/hwe/sammo/Command/General/che_화계.php index f0aed35e..cb2a969e 100644 --- a/hwe/sammo/Command/General/che_화계.php +++ b/hwe/sammo/Command/General/che_화계.php @@ -237,8 +237,8 @@ class che_화계 extends Command\GeneralCommand{ $exp = Util::randRangeInt(1, 100); $ded = Util::randRangeInt(1, 70); - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); [$reqGold, $reqRice] = $this->getCost(); $general->increaseVarWithLimit('gold', -$reqGold, 0); @@ -273,8 +273,8 @@ class che_화계 extends Command\GeneralCommand{ $exp = Util::randRangeInt(201, 300); $ded = Util::randRangeInt(141, 210); - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); [$reqGold, $reqRice] = $this->getCost(); $general->increaseVarWithLimit('gold', -$reqGold, 0); diff --git a/hwe/sammo/Command/General/che_훈련.php b/hwe/sammo/Command/General/che_훈련.php index e5c9605a..292ce362 100644 --- a/hwe/sammo/Command/General/che_훈련.php +++ b/hwe/sammo/Command/General/che_훈련.php @@ -79,8 +79,8 @@ class che_훈련 extends Command\GeneralCommand{ $exp = 100; $ded = 70; - $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); - $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); $general->increaseVarWithLimit('train', $score, 0, GameConst::$maxTrainByCommand); $general->setVar('atmos', $sideEffect); diff --git a/hwe/sammo/DefaultAction.php b/hwe/sammo/DefaultAction.php index 3d81786e..4bb5d66b 100644 --- a/hwe/sammo/DefaultAction.php +++ b/hwe/sammo/DefaultAction.php @@ -9,11 +9,7 @@ trait DefaultAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ - return $value; - } - - public function onCalcStat(General $general, string $stat, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ return $value; } diff --git a/hwe/sammo/GameUnitDetail.php b/hwe/sammo/GameUnitDetail.php index 6a813082..9c4be87d 100644 --- a/hwe/sammo/GameUnitDetail.php +++ b/hwe/sammo/GameUnitDetail.php @@ -124,7 +124,7 @@ class GameUnitDetail{ return $def * $crew / 100; } - public function getCriticalRatio(array $general){ + public function getCriticalRatio(General $general){ if($this->armType == GameUnitConst::T_CASTLE){ //성벽은 필살을 사용하지 않는다. return 0; @@ -134,26 +134,26 @@ class GameUnitDetail{ // 지장 지력 : 65 5%, 70 8%, 75 10%, 80 13% //충차장 통솔: 65 5%, 70 8%, 75 10%, 80 13% if($this->armType == GameUnitConst::T_WIZARD){ - $mainstat = getGeneralIntel($general, false, true, true, false); + $mainstat = $general->getIntel(false, true, true, false); $coef = 0.4; } else if($this->armType == GameUnitConst::T_SIEGE){ - $mainstat = getGeneralLeadership($general, false, true, true, false); + $mainstat = $general->getLeadership(false, true, true, false); $coef = 0.4; } else if($this->armType == GameUnitConst::T_MISC){ - $mainstat = getGeneralIntel($general, false, true, true, false) + - getGeneralLeadership($general, false, true, true, false) + - getGeneralPower($general, false, true, true, false); + $mainstat = $general->getIntel(false, true, true, false) + + $general->getLeadership(false, true, true, false) + + $general->getPower(false, true, true, false); $mainstat /= 3; $coef = 0.4; } else{ - $mainstat = getGeneralPower($general, false, true, true, false); + $mainstat = $general->getPower(false, true, true, false); $coef = 0.5; } - $ratio = max($mainstat - 65, 0); + $ratio = Util::valueFit($mainstat - 65, 0); $ratio *= $coef; return min(50, $ratio) / 100; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 7417b551..b314d489 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -406,7 +406,7 @@ class General implements iAction{ return $value; } - public function onPreGeneralStatUpdate(General $general, string $statName, $value){ + public function onCalcStat(General $general, string $statName, $value, $aux=null){ //xxx: $general? foreach(array_merge([ $this->nationType, @@ -419,16 +419,11 @@ class General implements iAction{ continue; } /** @var iAction $iObj */ - $value = $iObj->onPreGeneralStatUpdate($this, $statName, $value); + $value = $iObj->onCalcStat($this, $statName, $value, $aux); } return $value; } - public function onCalcStat(General $general, string $stat, $value){ - //xxx: $general? - return $value; - } - public function onCalcStrategic(string $turnType, string $varType, $value){ foreach(array_merge([ $this->nationType, diff --git a/hwe/sammo/WarUnit.php b/hwe/sammo/WarUnit.php index 89309e10..6811d611 100644 --- a/hwe/sammo/WarUnit.php +++ b/hwe/sammo/WarUnit.php @@ -2,9 +2,8 @@ namespace sammo; class WarUnit{ - use LazyVarUpdater; - protected $raw = []; + protected $general; protected $rawNation; protected $logger; @@ -31,7 +30,8 @@ class WarUnit{ protected $logActivatedSkill = []; protected $isFinished = false; - private function __construct(){ + private function __construct(General $general){ + $this->general = $general; } protected function clearActivatedSkill(){ @@ -110,16 +110,12 @@ class WarUnit{ return $this->deadCurr; } - function getSpecialDomestic():string{ - return GameConst::$defaultSpecialDomestic; + function getGeneral():General{ + return $this->general; } - function getSpecialWar():string{ - return 0; - } - - function getItem():int{ - return 0; + function getVar(string $key){ + return $this->general->getVar($key); } function getMaxPhase():int{ @@ -241,7 +237,7 @@ class WarUnit{ } function getComputedCriticalRatio():float{ - return $this->getCrewType()->getCriticalRatio($this->getRaw()); + return $this->getCrewType()->getCriticalRatio($this->general); } function getComputedAvoidRatio():float{ @@ -324,16 +320,19 @@ class WarUnit{ function getHP():int{ throw new NotInheritedMethodException(); + return 0; } function decreaseHP(int $damage):int{ $this->dead += $damage; throw new NotInheritedMethodException(); + return 0; } function increaseKilled(int $damage):int{ $this->killed += $damage; throw new NotInheritedMethodException(); + return 0; } function calcDamage():int{ diff --git a/hwe/sammo/WarUnitGeneral.php b/hwe/sammo/WarUnitGeneral.php index 80f7b4a6..78d7cabe 100644 --- a/hwe/sammo/WarUnitGeneral.php +++ b/hwe/sammo/WarUnitGeneral.php @@ -2,26 +2,16 @@ namespace sammo; class WarUnitGeneral extends WarUnit{ - protected $rawCity; - protected $bonusPhase = 0; - function __construct($raw, $rawCity, $rawNation, $isAttacker, $year, $month){ - setLeadershipBonus($raw, $rawNation['level']); - - $this->raw = $raw; - $this->rawCity = $rawCity; //read-only + function __construct(General $general, array $rawNation, bool $isAttacker, int $year, int $month){ + $this->general = $general; + $this->raw = $general->getRaw(); $this->rawNation = $rawNation; //read-only $this->isAttacker = $isAttacker; - $this->logger = new ActionLogger( - $this->getVar('no'), - $this->getVar('nation'), - $year, - $month, - false - ); - $this->crewType = GameUnitConst::byID($this->getVar('crewtype')); + $this->logger = $this->general->getLogger(); + $this->crewType = $this->general->getCrewTypeObj(); $cityLevel = $this->getCityVar('level'); @@ -46,86 +36,62 @@ class WarUnitGeneral extends WarUnit{ } function getName():string{ - return $this->getVar('name'); + return $this->general->getName(); } function getCityVar(string $key){ - return $this->rawCity[$key]; + return $this->general->getRawCity()[$key]; } - function getSpecialDomestic():string{ - return $this->getVar('special'); - } - function setOppose(?WarUnit $oppose){ parent::setOppose($oppose); - $this->increaseVar('warnum', 1); + $general = $this->general; + $this->general->increaseVar('warnum', 1); if($this->isAttacker){ - $this->updateVar('recwar', $this->getVar('turntime')); + $general->updateVar('recwar', $general->getVar('turntime')); } else if($oppose !== null){ - $this->updateVar('recwar', $oppose->getVar('turntime')); + $general->updateVar('recwar', $oppose->getVar('turntime')); } } - function getSpecialWar():int{ - return $this->getVar('special2'); - } - - function getCharacter():int{ - return $this->getVar('personal'); - } - - function getItem():int{ - return $this->getVar('item'); - } - function getMaxPhase():int{ $phase = $this->getCrewType()->speed; - if($this->getSpecialWar() == 60){ - $phase += 1; - } + $phase = $this->general->onCalcStat($this->general, 'initWarPhase', $phase); return $phase + $this->bonusPhase; } function addTrain(int $train){ - $this->increaseVarWithLimit('train', $train, 0, GameConst::$maxTrainByWar); + $this->general->increaseVarWithLimit('train', $train, 0, GameConst::$maxTrainByWar); } function addAtmos(int $atmos){ - $this->increaseVarWithLimit('atmos', $atmos, 0, GameConst::$maxAtmosByWar); + $this->general->increaseVarWithLimit('atmos', $atmos, 0, GameConst::$maxAtmosByWar); } function getComputedTrain(){ - $train = $this->getVar('train'); + $train = $this->general->getVar('train'); + $train = $this->general->onCalcStat($this->general, 'bonusTrain', $train); $train += $this->trainBonus; return $train; } function getComputedAtmos(){ - $atmos = $this->getVar('atmos'); + $atmos = $this->general->getVar('atmos'); + $atmos = $this->general->onCalcStat($this->general, 'bonusAtmos', $atmos); $atmos += $this->atmosBonus; return $atmos; } function getComputedCriticalRatio():float{ - $critialRatio = $this->getCrewType()->getCriticalRatio($this->getRaw()); + $general = $this->general; + $criticalRatio = $this->getCrewType()->getCriticalRatio($general); - $specialWar = $this->getSpecialWar(); - $item = $this->getItem(); - - if($specialWar == 61){ - if($this->isAttacker){ - $critialRatio += 0.1; - } - } - else if($specialWar == 71){ - $critialRatio += 0.2; - } - return $critialRatio; + $criticalRatio = $general->onCalcStat($general, 'warCriticalRatio', $criticalRatio, ['isAttacker'=>$this->isAttacker]); + return $criticalRatio; } function getComputedAvoidRatio():float{ diff --git a/hwe/sammo/iAction.php b/hwe/sammo/iAction.php index 9bfdfb4d..ae4a2a2c 100644 --- a/hwe/sammo/iAction.php +++ b/hwe/sammo/iAction.php @@ -5,13 +5,12 @@ interface iAction{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float; - public function onPreGeneralStatUpdate(General $general, string $statName, $value); - - public function onCalcStat(General $general, string $stat, $value); + public function onCalcStat(General $general, string $statName, $value, $aux=null); public function onCalcStrategic(string $turnType, string $varType, $value); public function onCalcNationalIncome(string $type, int $amount):int; public function getWarPowerMultiplier(WarUnit $unit):array; public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller; public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller; + //NOTE: getBattleEndSkillTriggerList도 필요한가? } \ No newline at end of file