diff --git a/hwe/func_process.php b/hwe/func_process.php index e616ed6e..0944a729 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -399,149 +399,6 @@ function process_11(&$general, $type) { $actLog->pushGeneralActionLog($log, ActionLogger::RAWTEXT); } -function process_31(&$general) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); - - $log = []; - $alllog = []; - $history = []; - $date = substr($general['turntime'],11,5); - $msg = []; - - $admin = $gameStor->getValues(['year', 'month', 'develcost']); - - $dist = searchDistance($general['city'], 2, false); - $command = DecodeCommand($general['turn0']); - $destination = $command[1]; - - $query = "select * from city where city='$destination'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $city = MYDB_fetch_array($result); - - if(!$city) { - $log[] = "●{$admin['month']}월:없는 도시입니다. 첩보 실패. <1>$date"; - } elseif($general['gold'] < $admin['develcost']*3) { - $log[] = "●{$admin['month']}월:자금이 모자랍니다. {$city['name']}에 첩보 실패. <1>$date"; - } elseif($general['rice'] < $admin['develcost']*3) { - $log[] = "●{$admin['month']}월:군량이 모자랍니다. {$city['name']}에 첩보 실패. <1>$date"; - } elseif($general['nation'] == $city['nation']) { - $log[] = "●{$admin['month']}월:아국입니다. {$city['name']}에 첩보 실패. <1>$date"; -// } elseif(!key_exists($destination, $dist)) { -// $log[] = "●{$admin['month']}월:너무 멉니다. {$city['name']}에 첩보 실패. <1>$date"; - } else { - $query = "select crew,crewtype from general where city='$destination' and nation='{$city['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $gencount = MYDB_num_rows($result); - $crew = 0; - $typecount = []; - for($i=0; $i < $gencount; $i++) { - $gen = MYDB_fetch_array($result); - if($gen['crew'] != 0) { - if(!key_exists($gen['crewtype'], $typecount)){ - $typecount[$gen['crewtype']] = 1; - } - else{ - $typecount[$gen['crewtype']]+=1; - } - - $crew += $gen['crew']; - } - } - if(!key_exists($destination, $dist)) { - $josaUl = JosaUtil::pick($city['name'], '을'); - $alllog[] = "●{$admin['month']}월:누군가가 {$city['name']}{$josaUl} 살피는 것 같습니다."; - $log[] = "●{$admin['month']}월:{$city['name']}의 소문만 들을 수 있었습니다. <1>$date"; - $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:".round($city['trust'], 1).", 장수:$gencount, 병력:$crew"; - } elseif($dist[$destination] == 2) { - $josaUl = JosaUtil::pick($city['name'], '을'); - $alllog[] = "●{$admin['month']}월:누군가가 {$city['name']}{$josaUl} 살피는 것 같습니다."; - $log[] = "●{$admin['month']}월:{$city['name']}의 어느정도 정보를 얻었습니다. <1>$date"; - $log[] = "【첩보】농업:{$city['agri']}, 상업:{$city['comm']}, 치안:{$city['secu']}, 수비:{$city['def']}, 성벽:{$city['wall']}"; - $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:".round($city['trust'], 1).", 장수:$gencount, 병력:$crew"; - } else { - $josaUl = JosaUtil::pick($city['name'], '을'); - $alllog[] = "●{$admin['month']}월:누군가가 {$city['name']}{$josaUl} 살피는 것 같습니다."; - $log[] = "●{$admin['month']}월:{$city['name']}의 많은 정보를 얻었습니다. <1>$date"; - $msg[] = "【병종】"; - - foreach($typecount as $crewtype=>$cnt){ - $crewtypeText = mb_substr(GameUnitConst::byID($crewtype)->name, 0, 2); - $msg[] = "{$crewtypeText}:{$cnt}"; - } - - $log[] = join(' ', $msg); - $msg = []; - - $log[] = "【첩보】농업:{$city['agri']}, 상업:{$city['comm']}, 치안:{$city['secu']}, 수비:{$city['def']}, 성벽:{$city['wall']}"; - $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:".round($city['trust'], 1).", 장수:$gencount, 병력:$crew"; - - if($general['nation'] != 0 && $city['nation'] != 0) { - $query = "select name,tech from nation where nation='{$city['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $yourTech = MYDB_fetch_array($result); - - $query = "select tech from nation where nation='{$general['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $myTech = MYDB_fetch_array($result); - - $diff = floor($yourTech['tech']) - floor($myTech['tech']); // 차이 - if($diff >= 1000) { $log[] = "【{$yourTech['name']}】아국대비기술:↑압도"; } - elseif($diff >= 250) { $log[] = "【{$yourTech['name']}】아국대비기술:▲우위"; } - elseif($diff >= -250) { $log[] = "【{$yourTech['name']}】아국대비기술:↕대등"; } - elseif($diff >= -1000) { $log[] = "【{$yourTech['name']}】아국대비기술:▼열위"; } - else { $log[] = "【{$yourTech['name']}】아국대비기술:↓미미"; } - } - } - - // 자금 하락 // 경험치 상승 // 공헌도, 명성 상승 - $exp = rand() % 100 + 1; - $ded = rand() % 70 + 1; - - // 성격 보정 - $exp = CharExperience($exp, $general['personal']); - $ded = CharDedication($ded, $general['personal']); - - $general['leader2']++; - $general['gold'] -= $admin['develcost']*3; - $general['rice'] -= $admin['develcost']*3; - $query = "update general set resturn='SUCCESS',gold='{$general['gold']}',rice='{$general['rice']}',leader2='{$general['leader2']}',dedication=dedication+'$ded',experience=experience+'$exp' where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - - - - $rawSpy = $db->queryFirstField('SELECT spy FROM nation WHERE nation = %i', $general['nation']); - - if($rawSpy == ''){ - $spyInfo = []; - } - else if(strpos($rawSpy, '|') !== false || is_numeric($rawSpy)){ - //TODO: 0.8 버전 이후에는 삭제할 것. 이후 버전은 json으로 변경됨. - $spyInfo = []; - foreach(explode('|', $rawSpy) as $value){ - $value = intval($value); - $cityNo = intdiv($value, 10); - $remainMonth = $value % 10; - $spyInfo[$cityNo] = $remainMonth; - } - } - else{ - $spyInfo = Json::decode($rawSpy); - } - - $spyInfo[$destination] = 3; - - $db->update('nation', [ - 'spy'=>Json::encode($spyInfo, Json::EMPTY_ARRAY_IS_DICT) - ], 'nation=%i', $general['nation']); - - $log = checkAbility($general, $log); - } - pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']); - pushGenLog($general, $log); -} - function process_48(&$general) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); diff --git a/hwe/j_set_general_command.php b/hwe/j_set_general_command.php index 9107952e..865da70d 100644 --- a/hwe/j_set_general_command.php +++ b/hwe/j_set_general_command.php @@ -20,11 +20,11 @@ if(!$action){ $defaultCheck = [ 'string'=>[ - 'crewType', 'nationName', 'optionText', 'itemType' + 'nationName', 'optionText', 'itemType' ], 'integer'=>[ - 'destGeneralID', 'destCityID', 'destNationID', - 'amountMoney', 'amountCrew', 'colorType', 'nationType' + 'crewType', 'destGeneralID', 'destCityID', 'destNationID', + 'amount', 'colorType', 'nationType' ], 'boolean'=>[ 'isGold', 'buyRice' diff --git a/hwe/sammo/ActionNationType/che_덕가.php b/hwe/sammo/ActionNationType/che_덕가.php index 3d01e661..702442a8 100644 --- a/hwe/sammo/ActionNationType/che_덕가.php +++ b/hwe/sammo/ActionNationType/che_덕가.php @@ -11,7 +11,7 @@ class che_덕가 implements iAction{ static $pros = '치안↑ 인구↑ 민심↑'; static $cons = '쌀수입↓ 수성↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '치안'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_도가.php b/hwe/sammo/ActionNationType/che_도가.php index 580de604..600cd77f 100644 --- a/hwe/sammo/ActionNationType/che_도가.php +++ b/hwe/sammo/ActionNationType/che_도가.php @@ -11,7 +11,7 @@ class che_도가 implements iAction{ static $pros = '인구↑'; static $cons = '기술↓ 치안↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '기술'){ if($varType == 'score') return $value * 0.9; if($varType == 'cost') return $value * 1.2; diff --git a/hwe/sammo/ActionNationType/che_도적.php b/hwe/sammo/ActionNationType/che_도적.php index 976d5dbf..03979be5 100644 --- a/hwe/sammo/ActionNationType/che_도적.php +++ b/hwe/sammo/ActionNationType/che_도적.php @@ -11,7 +11,7 @@ class che_도적 implements iAction{ static $pros = '계략↑'; static $cons = '금수입↓ 치안↓ 민심↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '치안'){ if($varType == 'score') return $value * 0.9; if($varType == 'cost') return $value * 1.2; diff --git a/hwe/sammo/ActionNationType/che_명가.php b/hwe/sammo/ActionNationType/che_명가.php index be5e9ddc..44dc82a4 100644 --- a/hwe/sammo/ActionNationType/che_명가.php +++ b/hwe/sammo/ActionNationType/che_명가.php @@ -11,7 +11,7 @@ class che_명가 implements iAction{ static $pros = '기술↑ 인구↑'; static $cons = '쌀수입↓ 수성↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '기술'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_묵가.php b/hwe/sammo/ActionNationType/che_묵가.php index bba2caa2..1254b994 100644 --- a/hwe/sammo/ActionNationType/che_묵가.php +++ b/hwe/sammo/ActionNationType/che_묵가.php @@ -11,7 +11,7 @@ class che_묵가 implements iAction{ static $pros = '수성↑'; static $cons = '기술↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '수비' || $turnType == '성벽'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_법가.php b/hwe/sammo/ActionNationType/che_법가.php index f431a40a..70fa6735 100644 --- a/hwe/sammo/ActionNationType/che_법가.php +++ b/hwe/sammo/ActionNationType/che_법가.php @@ -11,7 +11,7 @@ class che_법가 implements iAction{ static $pros = '금수입↑ 치안↑'; static $cons = '인구↓ 민심↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '치안'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_병가.php b/hwe/sammo/ActionNationType/che_병가.php index 03e7381e..37026eaf 100644 --- a/hwe/sammo/ActionNationType/che_병가.php +++ b/hwe/sammo/ActionNationType/che_병가.php @@ -11,7 +11,7 @@ class che_병가 implements iAction{ static $pros = '기술↑ 수성↑'; static $cons = '인구↓ 민심↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '기술'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_불가.php b/hwe/sammo/ActionNationType/che_불가.php index 80bed359..c8a40532 100644 --- a/hwe/sammo/ActionNationType/che_불가.php +++ b/hwe/sammo/ActionNationType/che_불가.php @@ -11,7 +11,7 @@ class che_불가 implements iAction{ static $pros = '민심↑ 수성↑'; static $cons = '금수입↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '민심' || $turnType == '인구'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_오두미도.php b/hwe/sammo/ActionNationType/che_오두미도.php index 29a6a3f9..f46f41e0 100644 --- a/hwe/sammo/ActionNationType/che_오두미도.php +++ b/hwe/sammo/ActionNationType/che_오두미도.php @@ -12,7 +12,7 @@ class che_오두미도 implements iAction{ static $cons = '기술↓ 수성↓ 내정↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '기술'){ if($varType == 'score') return $value * 0.9; if($varType == 'cost') return $value * 1.2; diff --git a/hwe/sammo/ActionNationType/che_유가.php b/hwe/sammo/ActionNationType/che_유가.php index 59d4df6b..3a476669 100644 --- a/hwe/sammo/ActionNationType/che_유가.php +++ b/hwe/sammo/ActionNationType/che_유가.php @@ -11,7 +11,7 @@ class che_유가 implements iAction{ static $pros = '내정↑ 민심↑'; static $cons = '쌀수입↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '농업' || $turnType == '상업'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_음양가.php b/hwe/sammo/ActionNationType/che_음양가.php index 8b714c85..d8ebb6f6 100644 --- a/hwe/sammo/ActionNationType/che_음양가.php +++ b/hwe/sammo/ActionNationType/che_음양가.php @@ -11,7 +11,7 @@ class che_음양가 implements iAction{ static $pros = '내정↑ 인구↑'; static $cons = '기술↓ 전략↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '농업' || $turnType == '상업'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_종횡가.php b/hwe/sammo/ActionNationType/che_종횡가.php index a3a810f5..8a48b03b 100644 --- a/hwe/sammo/ActionNationType/che_종횡가.php +++ b/hwe/sammo/ActionNationType/che_종횡가.php @@ -11,7 +11,7 @@ class che_종횡가 implements iAction{ static $pros = '전략↑ 수성↑'; static $cons = '금수입↓ 내정↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '수비' || $turnType == '성벽'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionNationType/che_태평도.php b/hwe/sammo/ActionNationType/che_태평도.php index d80f7b06..0bd2f6e8 100644 --- a/hwe/sammo/ActionNationType/che_태평도.php +++ b/hwe/sammo/ActionNationType/che_태평도.php @@ -11,7 +11,7 @@ class che_태평도 implements iAction{ static $pros = '인구↑ 민심↑'; static $cons = '기술↓ 수성↓'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '민심' || $turnType == '인구'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionPersonality/che_안전.php b/hwe/sammo/ActionPersonality/che_안전.php index 13ac4c9d..66ef705a 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 = '사기 -5, 징·모병 비용 -20%'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if(in_array($turnType, ['징병', '모병'])){ if($varType == 'cost'){ return $value * 0.8; diff --git a/hwe/sammo/ActionPersonality/che_유지.php b/hwe/sammo/ActionPersonality/che_유지.php index 57d76e52..fd49313d 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 = '훈련 -5, 징·모병 비용 -20%'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if(in_array($turnType, ['징병', '모병'])){ if($varType == 'cost'){ return $value * 0.8; diff --git a/hwe/sammo/ActionPersonality/che_은둔.php b/hwe/sammo/ActionPersonality/che_은둔.php index f2db621e..b7e1294e 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%, 계급 -10%, 사기 -5, 훈련 -5, 단련 성공률 +10%'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '단련'){ if($varType == 'success'){ return $value + 0.1; diff --git a/hwe/sammo/ActionPersonality/che_의협.php b/hwe/sammo/ActionPersonality/che_의협.php index 2ac3e37a..13d8e4cf 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 = '사기 +5, 징·모병 비용 +20%'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if(in_array($turnType, ['징병', '모병'])){ if($varType == 'cost'){ return $value * 1.2; diff --git a/hwe/sammo/ActionPersonality/che_재간.php b/hwe/sammo/ActionPersonality/che_재간.php index 81b435e9..1e619aad 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%, 징·모병 비용 -20%'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if(in_array($turnType, ['징병', '모병'])){ if($varType == 'cost'){ return $value * 0.8; diff --git a/hwe/sammo/ActionPersonality/che_출세.php b/hwe/sammo/ActionPersonality/che_출세.php index f4462baa..77f82472 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%, 징·모병 비용 +20%'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if(in_array($turnType, ['징병', '모병'])){ if($varType == 'cost'){ return $value * 1.2; diff --git a/hwe/sammo/ActionPersonality/che_패권.php b/hwe/sammo/ActionPersonality/che_패권.php index 76a713bf..f63a1635 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 = '훈련 +5, 징·모병 비용 +20%'; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if(in_array($turnType, ['징병', '모병'])){ if($varType == 'cost'){ return $value * 1.2; diff --git a/hwe/sammo/ActionSpecialDomestic/che_경작.php b/hwe/sammo/ActionSpecialDomestic/che_경작.php index 6264cfd6..52f5c4c1 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_경작.php +++ b/hwe/sammo/ActionSpecialDomestic/che_경작.php @@ -17,7 +17,7 @@ class che_경작 implements iAction{ SpecialityConst::STAT_INTEL ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '농업'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionSpecialDomestic/che_귀모.php b/hwe/sammo/ActionSpecialDomestic/che_귀모.php index 3407466a..f07b5688 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_귀모.php +++ b/hwe/sammo/ActionSpecialDomestic/che_귀모.php @@ -19,7 +19,7 @@ class che_귀모 implements iAction{ SpecialityConst::STAT_INTEL ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '계략'){ if($varType == 'success') return $value + 0.2; } diff --git a/hwe/sammo/ActionSpecialDomestic/che_발명.php b/hwe/sammo/ActionSpecialDomestic/che_발명.php index 16efcf5a..335bcde2 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_발명.php +++ b/hwe/sammo/ActionSpecialDomestic/che_발명.php @@ -17,7 +17,7 @@ class che_발명 implements iAction{ SpecialityConst::STAT_INTEL ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '기술'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionSpecialDomestic/che_상재.php b/hwe/sammo/ActionSpecialDomestic/che_상재.php index 8d2b2119..cacc4344 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_상재.php +++ b/hwe/sammo/ActionSpecialDomestic/che_상재.php @@ -17,7 +17,7 @@ class che_상재 implements iAction{ SpecialityConst::STAT_INTEL ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '상업'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionSpecialDomestic/che_수비.php b/hwe/sammo/ActionSpecialDomestic/che_수비.php index 711ab5fe..f6d77363 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_수비.php +++ b/hwe/sammo/ActionSpecialDomestic/che_수비.php @@ -17,7 +17,7 @@ class che_수비 implements iAction{ SpecialityConst::STAT_POWER ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '수비'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionSpecialDomestic/che_인덕.php b/hwe/sammo/ActionSpecialDomestic/che_인덕.php index 8dffb2c0..04ad166b 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_인덕.php +++ b/hwe/sammo/ActionSpecialDomestic/che_인덕.php @@ -17,7 +17,7 @@ class che_통찰 implements iAction{ SpecialityConst::STAT_LEADERSHIP ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '민심' || $turnType == '인구'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionSpecialDomestic/che_축성.php b/hwe/sammo/ActionSpecialDomestic/che_축성.php index e49fe905..931c5c72 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_축성.php +++ b/hwe/sammo/ActionSpecialDomestic/che_축성.php @@ -17,7 +17,7 @@ class che_축성 implements iAction{ SpecialityConst::STAT_POWER ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '성벽'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionSpecialDomestic/che_통찰.php b/hwe/sammo/ActionSpecialDomestic/che_통찰.php index 4a4d7d35..ee89a060 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_통찰.php +++ b/hwe/sammo/ActionSpecialDomestic/che_통찰.php @@ -17,7 +17,7 @@ class che_통찰 implements iAction{ SpecialityConst::STAT_POWER ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '치안'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; diff --git a/hwe/sammo/ActionSpecialWar/che_공성.php b/hwe/sammo/ActionSpecialWar/che_공성.php index 36d79c81..305e6968 100644 --- a/hwe/sammo/ActionSpecialWar/che_공성.php +++ b/hwe/sammo/ActionSpecialWar/che_공성.php @@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; use \sammo\SpecialityConst; +use \sammo\GameUnitConst; class che_공성 implements iAction{ use \sammo\DefaultAction; @@ -18,4 +19,12 @@ class che_공성 implements iAction{ SpecialityConst::STAT_POWER | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_SIEGE, SpecialityConst::STAT_INTEL | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_SIEGE, ]; + + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ + if(in_array($turnType, ['징병', '모병'])){ + if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_SIEGE) return $value * 0.9; + } + + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialWar/che_궁병.php b/hwe/sammo/ActionSpecialWar/che_궁병.php index 35ded16f..d9fbb1ca 100644 --- a/hwe/sammo/ActionSpecialWar/che_궁병.php +++ b/hwe/sammo/ActionSpecialWar/che_궁병.php @@ -4,6 +4,8 @@ use \sammo\iAction; use \sammo\General; use \sammo\SpecialityConst; +use \sammo\GameUnitConst; + class che_궁병 implements iAction{ use \sammo\DefaultAction; @@ -17,4 +19,12 @@ class che_궁병 implements iAction{ SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_ARCHER, SpecialityConst::STAT_POWER | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_ARCHER ]; + + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ + if(in_array($turnType, ['징병', '모병'])){ + if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_ARCHER) return $value * 0.9; + } + + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialWar/che_귀병.php b/hwe/sammo/ActionSpecialWar/che_귀병.php index 964392c7..80c1e7b0 100644 --- a/hwe/sammo/ActionSpecialWar/che_귀병.php +++ b/hwe/sammo/ActionSpecialWar/che_귀병.php @@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; use \sammo\SpecialityConst; +use \sammo\GameUnitConst; class che_귀병 implements iAction{ use \sammo\DefaultAction; @@ -16,4 +17,12 @@ class che_귀병 implements iAction{ static $type = [ SpecialityConst::STAT_INTEL | SpecialityConst::ARMY_WIZARD | SpecialityConst::REQ_DEXTERITY ]; + + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ + if(in_array($turnType, ['징병', '모병'])){ + if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_WIZARD) return $value * 0.9; + } + + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialWar/che_기병.php b/hwe/sammo/ActionSpecialWar/che_기병.php index d5792ae9..f4aafa9e 100644 --- a/hwe/sammo/ActionSpecialWar/che_기병.php +++ b/hwe/sammo/ActionSpecialWar/che_기병.php @@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; use \sammo\SpecialityConst; +use \sammo\GameUnitConst; class che_기병 implements iAction{ use \sammo\DefaultAction; @@ -17,4 +18,12 @@ class che_기병 implements iAction{ SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_CAVALRY, SpecialityConst::STAT_POWER | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_CAVALRY ]; + + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ + if(in_array($turnType, ['징병', '모병'])){ + if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_CAVALRY) return $value * 0.9; + } + + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialWar/che_보병.php b/hwe/sammo/ActionSpecialWar/che_보병.php index d6395a2f..95f770d8 100644 --- a/hwe/sammo/ActionSpecialWar/che_보병.php +++ b/hwe/sammo/ActionSpecialWar/che_보병.php @@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; use \sammo\SpecialityConst; +use \sammo\GameUnitConst; class che_보병 implements iAction{ use \sammo\DefaultAction; @@ -17,4 +18,12 @@ class che_보병 implements iAction{ SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_FOOTMAN, SpecialityConst::STAT_POWER | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_FOOTMAN ]; + + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ + if(in_array($turnType, ['징병', '모병'])){ + if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_FOOTMAN) return $value * 0.9; + } + + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialWar/che_신산.php b/hwe/sammo/ActionSpecialWar/che_신산.php index 271f9fab..13f05dab 100644 --- a/hwe/sammo/ActionSpecialWar/che_신산.php +++ b/hwe/sammo/ActionSpecialWar/che_신산.php @@ -17,7 +17,7 @@ class che_신산 implements iAction{ SpecialityConst::STAT_INTEL, ]; - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '계략'){ if($varType == 'success') return $value + 0.1; } diff --git a/hwe/sammo/ActionSpecialWar/che_징병.php b/hwe/sammo/ActionSpecialWar/che_징병.php index bdf1cf6c..44940c37 100644 --- a/hwe/sammo/ActionSpecialWar/che_징병.php +++ b/hwe/sammo/ActionSpecialWar/che_징병.php @@ -18,4 +18,12 @@ class che_징병 implements iAction{ SpecialityConst::STAT_POWER, SpecialityConst::STAT_INTEL ]; + + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ + if(in_array($turnType, ['징병', '모병'])){ + if($varType == 'cost') return $value * 0.5; + } + + return $value; + } } \ No newline at end of file diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index 04875f57..950763af 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -41,7 +41,17 @@ abstract class BaseCommand{ protected $alternative = null; + static private $isInitStatic = false; + protected static function initStatic(){ + + } + public function __construct(General $generalObj, array $env, $arg = null){ + if(!static::$isInitStatic){ + static::initStatic(); + static::$isInitStatic = true; + } + $this->generalObj = $generalObj; $this->logger = $generalObj->getLogger(); $this->env = $env; diff --git a/hwe/sammo/Command/General/che_모병.php b/hwe/sammo/Command/General/che_모병.php new file mode 100644 index 00000000..f90c1c0e --- /dev/null +++ b/hwe/sammo/Command/General/che_모병.php @@ -0,0 +1,24 @@ +getLastTurn(); $turnResult = new LastTurn(static::getName(), $this->arg); + $reqTurn = $this->getPreReqTurn(); + if($lastTurn->getCommand() != static::getName()){ $turnResult->setTerm(1); } - else if($lastTurn->getTerm() == 3){ + else if($lastTurn->getTerm() == $reqTurn){ $turnResult->setTerm(1); } - else if($lastTurn->getTerm() < 3){ + else if($lastTurn->getTerm() < $reqTurn){ $turnResult->setTerm($lastTurn->getTerm()+1); } else{ - throw new MustNotBeReachedException('전투 태세는 1~3까지만 가능함'); + throw new MustNotBeReachedException('전투 태세에 올바른 턴이 아님'); } $term = $turnResult->getTerm(); diff --git a/hwe/sammo/Command/General/che_징병.php b/hwe/sammo/Command/General/che_징병.php new file mode 100644 index 00000000..601627db --- /dev/null +++ b/hwe/sammo/Command/General/che_징병.php @@ -0,0 +1,198 @@ +generalObj; + + $this->setCity(); + $this->setNation(['tech']); + + $leadership = $general->getLeadership(); + $currCrewType = $general->getCrewTypeObj(); + $maxCrew = $leadership * 100; + + $reqCrewType = GameUnitConst::byID($this->arg['crewType']); + if($reqCrewType->id == $currCrewType->id){ + $maxCrew -= $general->getVar('crew'); + } + $reqCrew = Util::valueFit($this->arg['amount'], 100, $maxCrew); + $this->reqCrew = $reqCrew; + $this->reqCrewType = $reqCrewType; + $this->currCrewType = $currCrewType; + + [$reqGold, $reqRice] = $this->getCost(); + + $this->runnableConstraints=[ + ['NoNeutral'], + ['OccupiedCity'], + ['ReqCityCapacity', 'pop', '주민', 30000 + $reqCrew], + ['ReqCityTrust', 20], + ['ReqGeneralGold', $reqGold], + ['ReqGeneralRice', $reqRice], + ['ReqGeneralCrewMargin', $reqCrewType->id], + ['AvailableRecruitCrewType', $reqCrewType->id] + ]; + + } + + protected function argTest():bool{ + if(!key_exists('crewType', $this->arg)){ + return false; + } + if(!key_exists('amount', $this->arg)){ + return false; + } + $crewType = $this->arg['crewType']; + $amount = $this->arg['amountCrew']; + + if(!is_int($crewType)){ + return false; + } + if(!is_int($amount)){ + return false; + } + + if(GameUnitConst::byID($crewType) === null){ + return false; + } + if($amount < 100){ + return false; + } + $this->arg = [ + 'crewType'=>$crewType, + 'amount'=>$amount + ]; + return true; + } + + public function getCost():array{ + if($this->reqCrewType === null || $this->reqCrew){ + return [0, 0]; + //throw new \RuntimeException('요구사항 초기화가 이뤄지지 않았음'); + } + $reqGold = $this->reqCrewType->costWithTech($this->nation['tech'], $this->reqCrew); + $reqGold = $general->onCalcDomestic('징병', 'cost', $reqGold, ['armType'=>$this->reqCrewType->armType]); + $reqGold *= static::$costOffset; + $reqRice = $this->reqCrew / 100; + return [$reqGold, $reqRice]; + } + + 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); + + $reqCrew = $this->reqCrew; + $reqCrewText = number_format($reqCrew); + $reqCrewType = $this->reqCrewType; + + $currCrew = $general->getVar('crew'); + $currCrewType = $this->currCrewType; + + $crewTypeName = $reqCrewType->name; + $josaUl = JosaUtil::pick($crewTypeName, '을'); + + $logger = $general->getLogger(); + + if($reqCrewType->id == $currCrewType->id && $currCrew > 0){ + $logger->pushGeneralActionLog("{$crewTypeName}{$josaUl} {$reqCrewText}명을 추가{$this->getName()}했습니다. <1>$date"); + $train = ($currCrew * $general->getVar('train') + $reqCrew * static::$defaultTrain) / ($currCrew + $reqCrew); + $atmos = ($currCrew * $general->getVar('atmos') + $reqCrew * static::$defaultAtmos) / ($currCrew + $reqCrew); + + $general->increaseVar('crew', $reqCrew); + $general->setVar('train', $train); + $general->setVar('atmos', $atmos); + } + else{ + $logger->pushGeneralActionLog("{$crewTypeName}{$josaUl} {$reqCrewText}명을 {$this->getName()}했습니다. <1>$date"); + $general->setVar('crewtype', $reqCrewType->id); + $general->setVar('crew', $reqCrew); + $general->setVar('train', static::$defaultTrain); + $general->setVar('atmos', static::$defaultAtmos); + } + + $newTrust = Util::valueFit($this->city['trust'] - ($reqCrew / $this->city['pop']) / static::$costOffset * 100, 0); + + $db->update('city', [ + 'trust'=>$newTrust, + 'pop'=>$this->city['pop'] - $reqCrew + ], 'city=%i', $general->getCityID()); + + $exp = Util::round($reqCrew / 100); + $ded = Util::round($reqCrew / 100); + + $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + + $general->addDex($general->getCrewTypeObj(), $reqCrew / 100, false); + + [$reqGold, $reqRice] = $this->getCost(); + + $general->increaseVar('experience', $exp); + $general->increaseVar('dedication', $ded); + $general->increaseVarWithLimit('gold', -$reqGold, 0); + $general->increaseVarWithLimit('rice', -$reqRice, 0); + $general->increaseVar('leader2', 1); + $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->checkStatChange(); + $general->applyDB($db); + + uniqueItemEx($general->getID(), $logger); + + return true; + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/AvailableRecruitCrewType.php b/hwe/sammo/Constraint/AvailableRecruitCrewType.php new file mode 100644 index 00000000..6d6b8433 --- /dev/null +++ b/hwe/sammo/Constraint/AvailableRecruitCrewType.php @@ -0,0 +1,61 @@ +nation)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require nation in nation"); + } + + if(!key_exists('tech', $this->nation)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require tecg in nation"); + } + + if(GameUnitConst::byID($this->arg) === null){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("invalid crewtype"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game_env'); + + [$startyear, $year] = $gameStor->getValuesAsArray(['startyear', 'year']); + + $nationID = $this->nation['nation']; + $tech = $this->nation['tech']; + + $ownCities = []; + $ownRegions = []; + foreach($db->queryFirstColumn('SELECT city FROM city WHERE nation = %i', $nationID) as $ownCity){ + $ownCities[$ownCity] = 1; + $ownRegions[CityConst::byId($ownCity)->region] = 1; + } + + $crewType = GameUnitConst::byID($this->arg); + if($crewType->isValid($ownCities, $ownRegions, $year = $startyear, $tech)){ + return true; + } + + $this->reason = "현재 선택할 수 없는 병종입니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/ReqCityCapacity.php b/hwe/sammo/Constraint/ReqCityCapacity.php new file mode 100644 index 00000000..a5bf5868 --- /dev/null +++ b/hwe/sammo/Constraint/ReqCityCapacity.php @@ -0,0 +1,70 @@ +key, $this->keyNick, $this->reqVal] = $this->arg; + + $this->maxKey = $this->key.'2'; + + if(!key_exists($this->key, $this->city)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require {$this->key} in city"); + } + + if(is_numeric($this->reqVal)){ + $this->isPercent = false; + } + else if(is_str($this->reqVal)){ + $this->reqVal = Util::convPercentStrToFloat($this->reqVal); + if($this->reqVal === null){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require valid reqVal(percentStr|numeric) format"); + } + + if(!key_exists($this->maxKey, $this->city)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require {$this->maxKey} in city"); + } + $this->isPercent = true; + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($this->isPercent){ + if($this->city[$this->key] >= $this->city[$this->maxKey] * $this->reqVal){ + return true; + } + + } + else{ + if($this->city[$this->key] >= $this->reqVal){ + return true; + } + } + + $josaYi = JosaUtil::pick($keyNick, '이'); + $this->reason = "{$keyNick}{$josaUn} 모자랍니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/ReqCityTrust.php b/hwe/sammo/Constraint/ReqCityTrust.php new file mode 100644 index 00000000..9f476713 --- /dev/null +++ b/hwe/sammo/Constraint/ReqCityTrust.php @@ -0,0 +1,42 @@ +keyNick = '민심'; + $this->key = 'trust'; + $this->reqVal = $this->arg; + + if(!key_exists($this->key, $this->city)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require {$this->key} in city"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($this->city[$this->key] >= $this->reqVal){ + return true; + } + + $this->reason = "민심이 낮아 주민들이 도망갑니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/ReqGeneralCrewMargin.php b/hwe/sammo/Constraint/ReqGeneralCrewMargin.php new file mode 100644 index 00000000..03bff532 --- /dev/null +++ b/hwe/sammo/Constraint/ReqGeneralCrewMargin.php @@ -0,0 +1,46 @@ +general)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require {$key} in general"); + } + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($crewType != $this->general['crewtype']){ + return true; + } + + //XXX: 왜 General -> obj -> General 변환을 하고 있나? + $generalObj = new General($this->general, null, null, null, false); + $leadership = $generalObj->getLeadership(); + $crew = $this->general['crew']; + + if($leadership * 100 > $crew){ + return true; + } + + $this->reason = "이미 많은 병력을 보유하고 있습니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/DefaultActionTrigger.php b/hwe/sammo/DefaultActionTrigger.php index a068fb5c..bb7dc22d 100644 --- a/hwe/sammo/DefaultActionTrigger.php +++ b/hwe/sammo/DefaultActionTrigger.php @@ -5,7 +5,7 @@ trait DefaultAction{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return null; } - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ return $value; } diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index db107631..1ee27d57 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -371,7 +371,7 @@ class General implements iAction{ } return $caller; } - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ foreach(array_merge([ $this->nationType, $this->levelObj, diff --git a/hwe/sammo/TriggerGeneralLevel.php b/hwe/sammo/TriggerGeneralLevel.php index 92d0b00b..9a3ab752 100644 --- a/hwe/sammo/TriggerGeneralLevel.php +++ b/hwe/sammo/TriggerGeneralLevel.php @@ -33,7 +33,7 @@ class TriggerGeneralLevel implements iAction{ } } - public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '농업' || $turnType == '상업'){ if(in_array($this->generalLevel, [12, 11, 9, 7, 5, 3])){ return $value * 1.05; diff --git a/hwe/sammo/iAction.php b/hwe/sammo/iAction.php index 148289ff..0fd7d323 100644 --- a/hwe/sammo/iAction.php +++ b/hwe/sammo/iAction.php @@ -4,7 +4,7 @@ namespace sammo; interface iAction{ //TODO: 능력치는? public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller; - public function onCalcDomestic(string $turnType, string $varType, float $value):float; + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float; public function onPreGeneralStatUpdate(General $general, string $statName, $value); diff --git a/src/sammo/Util.php b/src/sammo/Util.php index 007acd8a..e7dfb861 100644 --- a/src/sammo/Util.php +++ b/src/sammo/Util.php @@ -415,6 +415,19 @@ class Util extends \utilphp\util { return self::randF() < $prob; } + + /** + * aaa(.bbb)?% 의 텍스트를 float으로 변환. 100% = 1.0 + * @return float|null + */ + public static function convPercentStrToFloat(string $text):?float{ + preg_match('/^(\d+(\.\d+)?)\%$/', $text, $matches); + if($matches === null){ + return null; + } + + return (float)$matches[1] / 100; + } /**