diff --git a/hwe/battle_simulator.php b/hwe/battle_simulator.php index 01fd19c0..1660625c 100644 --- a/hwe/battle_simulator.php +++ b/hwe/battle_simulator.php @@ -29,7 +29,7 @@ $startYear = $gameStor->getValue('startyear'); diff --git a/hwe/func.old.php b/hwe/func.old.php index 7bffa121..bdf3952c 100644 --- a/hwe/func.old.php +++ b/hwe/func.old.php @@ -847,7 +847,7 @@ function generalInfo($no) { else { $general['age'] = "{$general['age']} 세"; } $general['connect'] = Util::round($general['connect'] / 10) * 10; - $special = $general['special'] == GameConst::$defaultSpecial ? "{$general['specage']}세" : "".displaySpecialDomesticInfo($general['special']).""; + $special = $general['special'] == GameConst::$defaultSpecialDomestic ? "{$general['specage']}세" : "".displaySpecialDomesticInfo($general['special']).""; $special2 = $general['special2'] == 0 ? "{$general['specage2']}세" : "".displaySpecialWarInfo($general['special2']).""; switch($general['personal']) { @@ -1743,7 +1743,7 @@ function addAge() { $admin = $gameStor->getValues(['startyear', 'year', 'month']); if($admin['year'] >= $admin['startyear']+3) { - foreach($db->query('SELECT no,name,nation,leader,power,intel from general where specage<=age and special=%s', GameConst::$defaultSpecial) as $general){ + foreach($db->query('SELECT no,name,nation,leader,power,intel from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general){ $special = getSpecial($general['leader'], $general['power'], $general['intel']); $specialClass = getGeneralSpecialDomesticClass($special); $specialText = $specialClass::$name; @@ -1756,20 +1756,18 @@ function addAge() { pushGenLog($general, "●특기 【{$specialText}】{$josaUl} 익혔습니다!"); } - $query = "select no,name,nation,leader,power,intel,npc,dex0,dex10,dex20,dex30,dex40 from general where specage2<=age and special2='0'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $gencount = MYDB_num_rows($result); - - for($i=0; $i < $gencount; $i++) { - $general = MYDB_fetch_array($result); + foreach($db->query('SELECT no,name,nation,leader,power,intel,npc,dex0,dex10,dex20,dex30,dex40 from general where spec2age<=age and special2=%s', GameConst::$defaultSpecialWar) as $general){ $special2 = getSpecial2($general['leader'], $general['power'], $general['intel'], 0, $general['dex0'], $general['dex10'], $general['dex20'], $general['dex30'], $general['dex40']); + $specialClass = getGeneralSpecialWarClass($special2); + $specialText = $specialClass::$name; - $query = "update general set special2='$special2' where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('general', [ + 'special2'=>$special2 + ], 'no=%i',$general['no']); - $josaUl = JosaUtil::pick($special2, '을'); - pushGeneralHistory($general, "●{$admin['year']}년 {$admin['month']}월:특기 【".getGenSpecial($special2)."】{$josaUl} 습득"); - pushGenLog($general, "●특기 【".getGenSpecial($special2)."】{$josaUl} 익혔습니다!"); + $josaUl = JosaUtil::pick($specialText, '을'); + pushGeneralHistory($general, "●{$admin['year']}년 {$admin['month']}월:특기 【{$specialText}】{$josaUl} 습득"); + pushGenLog($general, "●특기 【{$specialText}】{$josaUl} 익혔습니다!"); } } } diff --git a/hwe/func.php b/hwe/func.php index 18e1cc24..2aa21176 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -847,7 +847,7 @@ function generalInfo($no) { else { $general['age'] = "{$general['age']} 세"; } $general['connect'] = Util::round($general['connect'] / 10) * 10; - $special = $general['special'] == GameConst::$defaultSpecial ? "{$general['specage']}세" : "".displaySpecialDomesticInfo($general['special']).""; + $special = $general['special'] == GameConst::$defaultSpecialDomestic ? "{$general['specage']}세" : "".displaySpecialDomesticInfo($general['special']).""; $special2 = $general['special2'] == 0 ? "{$general['specage2']}세" : "".displaySpecialWarInfo($general['special2']).""; switch($general['personal']) { @@ -1522,7 +1522,7 @@ function addAge() { $admin = $gameStor->getValues(['startyear', 'year', 'month']); if($admin['year'] >= $admin['startyear']+3) { - foreach($db->query('SELECT no,name,nation,leader,power,intel from general where specage<=age and special=%s', GameConst::$defaultSpecial) as $general){ + foreach($db->query('SELECT no,name,nation,leader,power,intel from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general){ $special = getSpecial($general['leader'], $general['power'], $general['intel']); $specialClass = getGeneralSpecialDomesticClass($special); $specialText = $specialClass::$name; @@ -1535,20 +1535,18 @@ function addAge() { pushGenLog($general, "●특기 【{$specialText}】{$josaUl} 익혔습니다!"); } - $query = "select no,name,nation,leader,power,intel,npc,dex0,dex10,dex20,dex30,dex40 from general where specage2<=age and special2='0'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $gencount = MYDB_num_rows($result); - - for($i=0; $i < $gencount; $i++) { - $general = MYDB_fetch_array($result); + foreach($db->query('SELECT no,name,nation,leader,power,intel,npc,dex0,dex10,dex20,dex30,dex40 from general where spec2age<=age and special2=%s', GameConst::$defaultSpecialWar) as $general){ $special2 = getSpecial2($general['leader'], $general['power'], $general['intel'], 0, $general['dex0'], $general['dex10'], $general['dex20'], $general['dex30'], $general['dex40']); + $specialClass = getGeneralSpecialWarClass($special2); + $specialText = $specialClass::$name; - $query = "update general set special2='$special2' where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('general', [ + 'special2'=>$special2 + ], 'no=%i',$general['no']); - $josaUl = JosaUtil::pick($special2, '을'); - pushGeneralHistory($general, "●{$admin['year']}년 {$admin['month']}월:특기 【".getGenSpecial($special2)."】{$josaUl} 습득"); - pushGenLog($general, "●특기 【".getGenSpecial($special2)."】{$josaUl} 익혔습니다!"); + $josaUl = JosaUtil::pick($specialText, '을'); + pushGeneralHistory($general, "●{$admin['year']}년 {$admin['month']}월:특기 【{$specialText}】{$josaUl} 습득"); + pushGenLog($general, "●특기 【{$specialText}】{$josaUl} 익혔습니다!"); } } } diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 6f16639b..a7779372 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -260,7 +260,7 @@ function getPersonalityClass(?string $type){ function getGeneralSpecialDomesticClass(?string $type){ if($type === null){ - $type = GameConst::$defaultSpecial; + $type = GameConst::$defaultSpecialDomestic; } static $basePath = __NAMESPACE__.'\\TriggerSpecialDomestic\\'; @@ -278,6 +278,26 @@ function getGeneralSpecialDomesticClass(?string $type){ new \InvalidArgumentException("{$type}은 올바른 내정 특기가 아님"); } +function getGeneralSpecialWarClass(?string $type){ + if($type === null){ + $type = GameConst::$defaultSpecialWar; + } + + static $basePath = __NAMESPACE__.'\\TriggerSpecialWar\\'; + $classPath = ($basePath.$type); + + if(class_exists($classPath)){ + return $classPath; + } + + $classPath = ($basePath.'che_'.$type); + if(class_exists($classPath)){ + return $classPath; + } + + new \InvalidArgumentException("{$type}은 올바른 전투 특기가 아님"); +} + function getLevel($level, $nlevel=8) { if($level >= 0 && $level <= 4) { $nlevel = 0; } $code = $nlevel * 100 + $level; diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 157c5596..3740d5b1 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -66,6 +66,7 @@ function getCityLevelList():array{ //TODO: 클래스로 이동 function getSpecial($leader, $power, $intel) { + throw new \sammo\NotImplementedException(); //통장 if($leader*0.9 > $power && $leader*0.9 > $intel) { $type = array('che_인덕', 'che_귀모'); @@ -106,6 +107,7 @@ function getSpecial($leader, $power, $intel) { // 70 저격, 필살, 징병, 의술, 격노, 척사 = 6 공통전투 function getSpecial2($leader, $power, $intel, $nodex=1, $dex0=0, $dex10=0, $dex20=0, $dex30=0, $dex40=0) { + throw new \sammo\NotImplementedException(); $special2 = 70; // 숙련 10,000: 25%, 40,000: 50%, 100,000: 79%, 160,000: 100% $dex = sqrt($dex0 + $dex10 + $dex20 + $dex30 + $dex40); diff --git a/hwe/func_template.php b/hwe/func_template.php index 30aa11d8..669298b6 100644 --- a/hwe/func_template.php +++ b/hwe/func_template.php @@ -76,14 +76,15 @@ function displayCharInfo(?int $type):string{ ]); } -function displaySpecialWarInfo(?int $type):string{ - $info = getSpecialInfo($type); - $text = getGenSpecial($type); +function displaySpecialWarInfo(?string $type):string{ + $class = getGeneralSpecialWarClass($type); + $info = $class::$info; + $name = $class::$name; $templates = new \League\Plates\Engine(__dir__.'/templates'); return $templates->render('tooltip', [ - 'text'=>$text, + 'text'=>$name, 'info'=>$info, ]); } diff --git a/hwe/j_get_select_npc_token.php b/hwe/j_get_select_npc_token.php index b5ae3f8d..e97ec514 100644 --- a/hwe/j_get_select_npc_token.php +++ b/hwe/j_get_select_npc_token.php @@ -92,7 +92,7 @@ $candidates = []; $weight = []; foreach($db->query('SELECT `no`, `name`, leader, power, intel, imgsvr, picture, special, special2 FROM general WHERE npc=2') as $general){ $general['special'] = (getGeneralSpecialDomesticClass($general['special']))::$name; - $general['special2'] = \sammo\SpecialityConst::WAR[$general['special2']][0]??'-'; + $general['special2'] = (getGeneralSpecialWarClass($general['special2']))::$name; $candidates[$general['no']] = $general + ['keepCnt'=>KEEP_CNT]; $allStat = $general['leader'] + $general['power'] + $general['intel']; $weight[$general['no']] = pow($allStat, 1.5); diff --git a/hwe/join_post.php b/hwe/join_post.php index 607a33dd..fe5eca10 100644 --- a/hwe/join_post.php +++ b/hwe/join_post.php @@ -166,7 +166,7 @@ if ($genius) { } //내특 $specage = Util::round((80 - $age)/12) + $age; -$special = GameConst::$defaultSpecial; +$special = GameConst::$defaultSpecialDomestic; $admin = $gameStor->getValues(['scenario', 'turnterm', 'show_img_level']); diff --git a/hwe/js/battle_simulator.js b/hwe/js/battle_simulator.js index c6b2f03c..44d5840a 100644 --- a/hwe/js/battle_simulator.js +++ b/hwe/js/battle_simulator.js @@ -364,7 +364,7 @@ jQuery(function($){ nation: (generalData.no)<=1 ? 1 : 2, city: (generalData.no)<=1 ? 1 : 3, turntime:'2018-08-26 12:00', - special:defaultSpecial, + special:defaultSpecialDomestic, leader2:0, power2:0, intel2:0, diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 5c5778ee..b4e479e8 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -101,12 +101,24 @@ class GameConstBase ]; /** @var array 기본 국가 성향 */ public static $neutralNationType = 'che_중립'; + + /** @var array 기본 내정 특기 */ + public static $defaultSpecialDomestic = 'None'; /** @var array 선택 가능한 장수 내정 특기 */ public static $availableSpecialDomestic = [ 'che_경작', 'che_상재', 'che_발명', 'che_축성', 'che_수비', 'che_통찰', 'che_인덕', 'che_귀모', ]; - /** @var array 기본 특기(공용) */ - public static $defaultSpecial = 'None'; + + /** @var array 기본 전투 특기 */ + public static $defaultSpecialWar = 'None'; + /** @var array 선택 가능한 장수 내정 특기 */ + public static $availableSpecialWar = [ + 'che_귀병', 'che_신산', 'che_환술', 'che_집중', 'che_신중', 'che_반계', + 'che_보병', 'che_궁병', 'che_기병', 'che_공성', + 'che_돌격', 'che_무쌍', 'che_견고', 'che_위압', + 'che_저격', 'che_필살', 'che_징병', 'che_의술', 'che_격노', 'che_척사', + ]; + /** @var array 기본 성향(공용) */ public static $neutralPersonality = 'None'; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index df173194..9fbdaee8 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -52,6 +52,8 @@ class General implements iActionTrigger{ $specialDomesticClass = getGeneralSpecialDomesticClass($raw['special']); $this->specialDomesticObj = new $specialDomesticClass; + $specialWarClass = getGeneralSpecialWarClass($raw['special']); + $this->specialWarObj = new $specialWarClass; //TODO: $specialWarClass 설정 $personalityClass = getPersonalityClass($raw['personal']); diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index e8b67778..f316c913 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -62,7 +62,7 @@ class NPC{ 'intel'=>$intel ]; - $this->charDomestic = \sammo\GameConst::$defaultSpecial; + $this->charDomestic = \sammo\GameConst::$defaultSpecialDomestic; if($char === '랜덤전특'){ $this->charWar = \sammo\SpecialityConst::pickSpecialWar($general); @@ -159,7 +159,7 @@ class NPC{ if($isFictionMode){ $charWar = 0; - $charDomestic = GameConst::$defaultSpecial; + $charDomestic = GameConst::$defaultSpecialDomestic; } $name = 'ⓝ'.$this->name; diff --git a/hwe/sammo/TriggerSpecialDomestic/che_귀모.php b/hwe/sammo/TriggerSpecialDomestic/che_귀모.php index 126d198a..7068fed6 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_귀모.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_귀모.php @@ -21,7 +21,7 @@ class che_귀모 implements iActionTrigger{ public function onCalcDomestic(string $turnType, string $varType, float $value):float{ if($turnType == '계략'){ - if($varType == 'success') return $value + 0.1; + if($varType == 'success') return $value + 0.2; } diff --git a/hwe/sammo/TriggerSpecialWar/che_격노.php b/hwe/sammo/TriggerSpecialWar/che_격노.php new file mode 100644 index 00000000..3af21479 --- /dev/null +++ b/hwe/sammo/TriggerSpecialWar/che_격노.php @@ -0,0 +1,21 @@ +[전투] 성벽 공격 시 대미지 +100%'; + + static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeight = 1; + static $type = [ + SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_SIEGE, + SpecialityConst::STAT_POWER | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_SIEGE, + SpecialityConst::STAT_INTEL | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_SIEGE, + ]; +} \ No newline at end of file diff --git a/hwe/sammo/TriggerSpecialWar/che_궁병.php b/hwe/sammo/TriggerSpecialWar/che_궁병.php new file mode 100644 index 00000000..48bd5466 --- /dev/null +++ b/hwe/sammo/TriggerSpecialWar/che_궁병.php @@ -0,0 +1,20 @@ +[전투] 회피 확률 +20%p'; + + static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeight = 1; + static $type = [ + SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_ARCHER, + SpecialityConst::STAT_POWER | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_ARCHER + ]; +} \ No newline at end of file diff --git a/hwe/sammo/TriggerSpecialWar/che_귀병.php b/hwe/sammo/TriggerSpecialWar/che_귀병.php new file mode 100644 index 00000000..29700440 --- /dev/null +++ b/hwe/sammo/TriggerSpecialWar/che_귀병.php @@ -0,0 +1,19 @@ +[전투] 계략 성공 확률 +20%p'; + + static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeight = 1; + static $type = [ + SpecialityConst::STAT_INTEL | SpecialityConst::ARMY_WIZARD | SpecialityConst::REQ_DEXTERITY + ]; +} \ No newline at end of file diff --git a/hwe/sammo/TriggerSpecialWar/che_기병.php b/hwe/sammo/TriggerSpecialWar/che_기병.php new file mode 100644 index 00000000..039839f2 --- /dev/null +++ b/hwe/sammo/TriggerSpecialWar/che_기병.php @@ -0,0 +1,20 @@ +[전투] 수비 시 대미지 +10%, 공격 시 대미지 +20%'; + + static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeight = 1; + static $type = [ + SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_CAVALRY, + SpecialityConst::STAT_POWER | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_CAVALRY + ]; +} \ No newline at end of file diff --git a/hwe/sammo/TriggerSpecialWar/che_돌격.php b/hwe/sammo/TriggerSpecialWar/che_돌격.php new file mode 100644 index 00000000..8632f7e0 --- /dev/null +++ b/hwe/sammo/TriggerSpecialWar/che_돌격.php @@ -0,0 +1,20 @@ +[전투] 공격 시 아군 피해 -10%, 수비 시 아군 피해 -20%'; + + static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeight = 1; + static $type = [ + SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_FOOTMAN, + SpecialityConst::STAT_POWER | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_FOOTMAN + ]; +} \ No newline at end of file diff --git a/hwe/sammo/TriggerSpecialWar/che_신산.php b/hwe/sammo/TriggerSpecialWar/che_신산.php new file mode 100644 index 00000000..c3ac02e1 --- /dev/null +++ b/hwe/sammo/TriggerSpecialWar/che_신산.php @@ -0,0 +1,27 @@ +[전투] 계략 시도 확률 +20%p, 계략 성공 확률 +20%p'; + + static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeight = 1; + static $type = [ + SpecialityConst::STAT_INTEL, + ]; + + public function onCalcDomestic(string $turnType, string $varType, float $value):float{ + if($turnType == '계략'){ + if($varType == 'success') return $value + 0.1; + } + + return $value; + } +} \ No newline at end of file diff --git a/hwe/sammo/TriggerSpecialWar/che_신중.php b/hwe/sammo/TriggerSpecialWar/che_신중.php new file mode 100644 index 00000000..618b3fc5 --- /dev/null +++ b/hwe/sammo/TriggerSpecialWar/che_신중.php @@ -0,0 +1,19 @@ +[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)'; + + static $selectWeightType = SpecialityConst::WEIGHT_PERCENT; + static $selectWeight = 2; + static $type = [ + SpecialityConst::STAT_LEADERSHIP, + SpecialityConst::STAT_POWER, + SpecialityConst::STAT_INTEL + ]; + + public function onPreTurnExecute(General $general):array{ + return []; + } +} \ No newline at end of file diff --git a/hwe/sammo/TriggerSpecialWar/che_저격.php b/hwe/sammo/TriggerSpecialWar/che_저격.php new file mode 100644 index 00000000..4695b928 --- /dev/null +++ b/hwe/sammo/TriggerSpecialWar/che_저격.php @@ -0,0 +1,21 @@ +