기본 내정턴을 클래스 기반으로 가능하도록 수정
This commit is contained in:
@@ -564,15 +564,15 @@ function processCommand($no) {
|
||||
$log[] = "<C>●</>{$month}월:아무것도 실행하지 않았습니다. <1>$date</>";
|
||||
pushGenLog($general, $log);
|
||||
break;
|
||||
case 1: process_1($general, 1); break; //농업
|
||||
case 2: process_1($general, 2); break; //상업
|
||||
case 3: process_3($general); break; //기술
|
||||
case 4: process_4($general); break; //선정
|
||||
case 5: process_5($general, 1); break; //수비
|
||||
case 6: process_5($general, 2); break; //성벽
|
||||
case 7: process_7($general); break; //정착 장려
|
||||
case 8: process_8($general); break; //치안
|
||||
case 9: process_9($general); break; //조달
|
||||
case 1: //농업
|
||||
case 2: //상업
|
||||
case 3: //기술
|
||||
case 4: //선정
|
||||
case 5: //수비
|
||||
case 6: //성벽
|
||||
case 7: //정착 장려
|
||||
case 8: //치안
|
||||
case 9: process_domestic($command[0], $general); break;//조달
|
||||
|
||||
case 11: process_11($general, 1); break; //징병
|
||||
case 12: process_11($general, 2); break; //모병
|
||||
|
||||
+23
-9
@@ -119,7 +119,7 @@ function getGeneralIntel($general, $withInjury, $withItem, $withStatAdjust, $use
|
||||
* 내정 커맨드 사용시 성공 확률 계산
|
||||
*
|
||||
* @param array $general 장수 정보
|
||||
* @param int $type 내정 커맨드 타입, 0 = 통솔 기반, 1 = 무력 기반, 2 = 지력 기반
|
||||
* @param int|string $type 내정 커맨드 타입, 0|'leader' = 통솔 기반, 1|'power' = 무력 기반, 2|'intel' = 지력 기반
|
||||
*
|
||||
* @return array 계산된 실패, 성공 확률 ('succ' => 성공 확률, 'fail' => 실패 확률)
|
||||
*/
|
||||
@@ -142,9 +142,14 @@ function CriticalRatioDomestic(&$general, $type) {
|
||||
505050(50%,50%), 107070(50%,50%)
|
||||
*/
|
||||
switch($type) {
|
||||
case 'leader':
|
||||
case 0: $ratio = $avg / $leader; break;
|
||||
case 'power':
|
||||
case 1: $ratio = $avg / $power; break;
|
||||
case 'intel':
|
||||
case 2: $ratio = $avg / $intel; break;
|
||||
default:
|
||||
throw new MustNotBeReachedException();
|
||||
}
|
||||
$ratio = min($ratio, 1.2);
|
||||
|
||||
@@ -193,21 +198,30 @@ function CriticalScore($score, $type) {
|
||||
return Util::round($score * $ratio);
|
||||
}
|
||||
|
||||
function process_1(array $rawGeneral, int $type){
|
||||
function process_domestic(array $rawGeneral, int $type){
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$date = substr($general['turntime'],11,5);
|
||||
|
||||
$env = $gameStor->getValues(['startyear', 'year', 'month', 'develcost']);
|
||||
$general = new General($rawGeneral, null, $env['year'], $env['month']);
|
||||
|
||||
if($type == 1){
|
||||
$cmdObj = new Command\che_농지개간($general, $env);
|
||||
}
|
||||
else{
|
||||
$cmdObj = new Command\che_상업투자($general, $env);
|
||||
//TODO: 최종적으로는 클래스 명 그대로 가야함
|
||||
$commandMap = [
|
||||
1=>'Command\che_농지개간',
|
||||
2=>'Command\che_상업투자',
|
||||
3=>'Command\che_기술연구',
|
||||
4=>'Command\che_주민선정',
|
||||
5=>'Command\che_수비강화',
|
||||
6=>'Command\che_성벽보수',
|
||||
7=>'Command\che_정착장려',
|
||||
8=>'Command\che_치안강화',
|
||||
9=>'Command\che_물자조달',
|
||||
];
|
||||
$cmdClass = $commandMap[$type]??null;
|
||||
if(!$cmdClass){
|
||||
throw new \InvalidArgumentException('잘못된 내정 코드');
|
||||
}
|
||||
$cmdObj = new $cmdClass($general, $env);
|
||||
|
||||
if(!$cmdObj->isAvailable()){
|
||||
return;
|
||||
|
||||
@@ -46,6 +46,8 @@ class che_상업투자 extends BaseCommand{
|
||||
}
|
||||
|
||||
protected function calcBaseScore():float{
|
||||
$general = $this->generalObj;
|
||||
|
||||
if(static::$statKey == 'intel'){
|
||||
$score = getGeneralIntel($general->getRaw(), true, true, true, false);
|
||||
}
|
||||
@@ -80,9 +82,9 @@ class che_상업투자 extends BaseCommand{
|
||||
|
||||
$score = $this->calcBaseScore();
|
||||
|
||||
['succ'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), 2);
|
||||
$successRatio = $naionTypeObj->onCalcDomestic(static::$cityKey, 'succ', $successRatio);
|
||||
$failRatio = $naionTypeObj->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
||||
['succ'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey);
|
||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'succ', $successRatio);
|
||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
||||
|
||||
$failRatio = Util::valueFit($failRatio, 0, 1);
|
||||
$successRatio = Util::valueFit($successRatio, 0, 1 - $failRatio);
|
||||
@@ -108,6 +110,7 @@ class che_상업투자 extends BaseCommand{
|
||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$score</> 상승했습니다. <1>$date</>");
|
||||
}
|
||||
else{
|
||||
$score = Util::round($score);
|
||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$score</> 상승했습니다. <1>$date</>");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user