diff --git a/hwe/_admin2_submit.php b/hwe/_admin2_submit.php index f9e9fdad..cb6198c1 100644 --- a/hwe/_admin2_submit.php +++ b/hwe/_admin2_submit.php @@ -115,12 +115,12 @@ switch($btn) { $msg = new Message(Message::MSGTYPE_PRIVATE, $src, MessageTarget::buildQuick($general['no']), $text, new \DateTime(), new \DateTime('9999-12-31'), []); $msg->send(true); - $specialWar = SpecialityConst::pickSpecialWar($general); + $specialWar = SpecialityHelper::pickSpecialWar($general); $db->update('general', [ 'specage2'=>$db->sqleval('age'), 'special2'=>$specialWar ], 'no=%i', $general['no']); - $specialWarName = SpecialityConst::WAR[$specialWar][0]; + $specialWarName = buildGeneralSpecialWarClass($specialWar)->getName(); $josaUl = JosaUtil::pick($specialWarName, '을'); pushGeneralHistory($general['no'], ["●{$year}년 {$month}월:특기 【{$specialWarName}】{$josaUl} 습득"]); pushGenLog($general['no'], ["●특기 【{$specialWarName}】{$josaUl} 익혔습니다!"]); diff --git a/hwe/b_currentCity.php b/hwe/b_currentCity.php index e632135c..5b9057b0 100644 --- a/hwe/b_currentCity.php +++ b/hwe/b_currentCity.php @@ -280,7 +280,7 @@ foreach($generals as $general){ if($ourGeneral && !$isNPC){ $turnText = []; - $generalObj = new General($general, null, null, null, false); + $generalObj = new General($general, null, null, null, null, false); foreach($generalTurnList[$generalObj->getID()] as $turnRawIdx=>$turn){ $turnIdx = $turnRawIdx+1; $turnText[] = "{$turnIdx} : $turn"; diff --git a/hwe/battle_simulator.php b/hwe/battle_simulator.php index ffbbaa1e..01562b90 100644 --- a/hwe/battle_simulator.php +++ b/hwe/battle_simulator.php @@ -29,7 +29,7 @@ $startYear = $gameStor->getValue('startyear'); @@ -167,7 +167,7 @@ var defaultSpecialDomestic = ;
@@ -339,7 +339,7 @@ var defaultSpecialDomestic = ;
@@ -351,7 +351,7 @@ var defaultSpecialDomestic = ; 성격 @@ -369,9 +369,8 @@ var defaultSpecialDomestic = ; 전특 diff --git a/hwe/func.php b/hwe/func.php index 67b179e7..89fbff13 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1203,7 +1203,7 @@ function addAge() { if($year >= $startYear+3) { foreach($db->query('SELECT no,name,nation,leadership,strength,intel from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general){ $generalID = $general['no']; - $special = SpecialityConst::pickSpecialDomestic($general); + $special = SpecialityHelper::pickSpecialDomestic($general); $specialClass = buildGeneralSpecialDomesticClass($special); $specialText = $specialClass->getName(); $db->update('general', [ @@ -1219,7 +1219,7 @@ function addAge() { foreach($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5 from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general){ $generalID = $general['no']; - $special2 = SpecialityConst::pickSpecialWar($general); + $special2 = SpecialityHelper::pickSpecialWar($general); $specialClass = buildGeneralSpecialWarClass($special2); $specialText = $specialClass->getName(); diff --git a/hwe/func_converter.php b/hwe/func_converter.php index bd61845b..21ab9f17 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -9,12 +9,22 @@ namespace sammo; * (단, autoload, 정적 변수 초기화는 허용) */ -function getCharacterList(){ +function getCharacterList(bool $onlyAvailable=true){ $infoText = []; - foreach(GameConst::$allPersonality as $personalityID){ + if(!$onlyAvailable){ + $class = buildPersonalityClass(GameConst::$neutralPersonality); + $infoText[GameConst::$neutralPersonality] = [$class->getName(), $class->getInfo()]; + } + foreach(GameConst::$availablePersonality as $personalityID){ $class = buildPersonalityClass($personalityID); $infoText[$personalityID] = [$class->getName(), $class->getInfo()]; } + if(!$onlyAvailable){ + foreach(GameConst::$optionalPersonality as $personalityID){ + $class = buildPersonalityClass($personalityID); + $infoText[$personalityID] = [$class->getName(), $class->getInfo()]; + } + } return $infoText; } @@ -247,7 +257,7 @@ function getGeneralSpecialDomesticClass(?string $type){ throw new \InvalidArgumentException("{$type}은 올바른 내정 특기가 아님"); } -function buildGeneralSpecialDomesticClass(?string $type):iAction{ +function buildGeneralSpecialDomesticClass(?string $type):BaseSpecial{ static $cache = []; if($type === null){ $type = 'None'; @@ -282,7 +292,7 @@ function getGeneralSpecialWarClass(?string $type){ throw new \InvalidArgumentException("{$type}은 올바른 전투 특기가 아님"); } -function buildGeneralSpecialWarClass(?string $type):iAction{ +function buildGeneralSpecialWarClass(?string $type):BaseSpecial{ static $cache = []; if($type === null){ $type = 'None'; diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 427da20c..388ba355 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -21,27 +21,6 @@ function getNationLevelList():array{ return $table; } -function getNationTypeList():array{ - return GameConst::$availableNationType; - - $table = [ - 13=>['명가', '기술↑ 인구↑', '쌀수입↓ 수성↓'], - 12=>['음양가', '내정↑ 인구↑', '기술↓ 전략↓'], - 11=>['종횡가', '전략↑ 수성↑', '금수입↓ 내정↓'], - 10=>['불가', '민심↑ 수성↑', '금수입↓'], - 9=>['도적', '계략↑', '금수입↓ 치안↓ 민심↓'], - 8=>['오두미도', '쌀수입↑ 인구↑', '기술↓ 수성↓ 내정↓'], - 7=>['태평도', '인구↑ 민심↑', '기술↓ 수성↓'], - 6=>['도가', '인구↑', '기술↓ 치안↓'], - 5=>['묵가', '수성↑', '기술↓'], - 4=>['덕가', '치안↑인구↑ 민심↑', '쌀수입↓ 수성↓'], - 3=>['병가', '기술↑ 수성↑', '인구↓ 민심↓'], - 2=>['유가', '내정↑ 민심↑', '쌀수입↓'], - 1=>['법가', '금수입↑ 치안↑', '인구↓ 민심↓'], - ]; - return $table; -} - function getCityLevelList():array{ return [ 1 => '수', diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index 1b925f5a..6c145539 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -94,7 +94,7 @@ function processGoldIncome() { // 각 장수들에게 지급 foreach ($generalRawList as $rawGeneral) { - $generalObj = new General($rawGeneral, null, null, $year, $month, false); + $generalObj = new General($rawGeneral, null, null, null, $year, $month, false); $gold = Util::round(getBill($generalObj->getVar('dedication'))*$ratio); $generalObj->increaseVar('gold', $gold); @@ -369,7 +369,7 @@ function processRiceIncome() { // 각 장수들에게 지급 foreach ($generalRawList as $rawGeneral) { - $generalObj = new General($rawGeneral, null, null, $year, $month, false); + $generalObj = new General($rawGeneral, null, null, null, $year, $month, false); $rice = Util::round(getBill($generalObj->getVar('dedication'))*$ratio); $generalObj->increaseVar('rice', $rice); @@ -589,7 +589,7 @@ function disaster() { $generalList = array_map( function($rawGeneral) use ($city, $year, $month){ - return new General($rawGeneral, null, $city, $year, $month, false); + return new General($rawGeneral, null, $city, null, $year, $month, false); }, $generalListByCity[$city['city']]??[] ); diff --git a/hwe/j_getChiefTurn.php b/hwe/j_getChiefTurn.php index dc7fcbc0..b86dbe88 100644 --- a/hwe/j_getChiefTurn.php +++ b/hwe/j_getChiefTurn.php @@ -50,7 +50,7 @@ $turn = []; $generals = []; foreach($db->query('SELECT no,name,turntime,npc,city,nation,officer_level FROM general WHERE nation = %i AND officer_level >= 5',$nationID) as $rawGeneral){ - $generals[$rawGeneral['officer_level']] = new General($rawGeneral, null, null, $year, $month, false); + $generals[$rawGeneral['officer_level']] = new General($rawGeneral, null, null, null, $year, $month, false); } $nationTurnList = []; diff --git a/hwe/j_simulate_battle.php b/hwe/j_simulate_battle.php index 4b0a0bec..224daa6d 100644 --- a/hwe/j_simulate_battle.php +++ b/hwe/j_simulate_battle.php @@ -31,6 +31,7 @@ if($query === null){ ]); } +LogText('simulate', $query); $defaultCheck = [ 'required'=>[ @@ -74,7 +75,7 @@ $rawAttacker['turntime'] = TimeUtil::now(); $rawAttackerCity = $query['attackerCity']; $rawAttackerNation = $query['attackerNation']; -$rawdefenderList = $query['defenderGenerals']; +$rawDefenderList = $query['defenderGenerals']; $rawDefenderCity = $query['defenderCity']; $rawDefenderNation = $query['defenderNation']; @@ -83,13 +84,13 @@ $generalCheck = [ 'required'=>[ 'no', 'name', 'nation', 'turntime', 'personal', 'special2', 'crew', 'crewtype', 'atmos', 'train', 'intel', 'intel_exp', 'book', 'strength', 'strength_exp', 'weapon', 'injury', 'leadership', 'leadership_exp', 'horse', 'item', - 'explevel', 'experience', 'dedication', 'officer_level', 'gold', 'rice', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5', + 'explevel', 'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'recent_war' ], 'integer'=>[ - 'no', 'nation', 'personal', 'special2', 'crew', 'crewtype', 'atmos', 'train', - 'intel', 'intel_exp', 'book', 'strength', 'strength_exp', 'weapon', 'injury', 'leadership', 'leadership_exp', 'horse', 'item', - 'explevel', 'experience', 'dedication', 'officer_level', 'gold', 'rice', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5', + 'no', 'nation', 'crew', 'crewtype', 'atmos', 'train', + 'intel', 'intel_exp', 'strength', 'strength_exp', 'injury', 'leadership', 'leadership_exp', + 'explevel', 'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5', ], 'min'=>[ ['no', 1], @@ -115,8 +116,8 @@ $generalCheck = [ ['officer_level', [1, 12]] ], 'in'=>[ - ['personal', array_keys(getCharacterList())], - ['special2', array_merge(array_keys(SpecialityConst::WAR), ['None'])], + ['personal', array_merge(GameConst::$availablePersonality, GameConst::$optionalPersonality)], + ['special2', array_merge(GameConst::$availableSpecialWar, GameConst::$optionalSpecialWar)], ['crewtype', array_keys(GameUnitConst::all())], ['horse', array_keys(GameConst::$allItems['horse'])], ['weapon', array_keys(GameConst::$allItems['weapon'])], @@ -135,7 +136,6 @@ if(!$v->validate()){ } $defenderList = []; - foreach($rawDefenderList as $idx=>$rawDefenderGeneral){ $v = new Validator($rawDefenderGeneral); $v->rules($generalCheck); @@ -146,7 +146,7 @@ foreach($rawDefenderList as $idx=>$rawDefenderGeneral){ 'reason'=>"[수비자{$idx}]".$v->errorStr() ]); } - $defenderList[] = new General($rawDefenderGeneral, null, $rawDefenderCity, $year, $month, true); + $defenderList[] = new General($rawDefenderGeneral, null, $rawDefenderCity, $rawAttackerNation, $year, $month, true); } @@ -205,7 +205,7 @@ $nationCheck = [ 'nation', 'name', 'gold', 'rice', 'gennum' ], 'integer'=>[ - 'type', 'level', 'capital', 'nation', 'gennum', + 'level', 'capital', 'nation', 'gennum', ], 'numeric'=>[ 'tech', 'gold', 'rice' @@ -217,7 +217,7 @@ $nationCheck = [ ['gennum', 1], ], 'in'=>[ - ['type', array_keys(getNationTypeList())], + ['type', GameConst::$availableNationType], ['level', array_keys(getNationLevelList())] ] ]; @@ -246,8 +246,8 @@ if($action == 'reorder'){ }); $order = []; - foreach($defenderList as $rawDefenderGeneral){ - $order[] = $rawDefenderGeneral['no']; + foreach($defenderList as $defenderGeneral){ + $order[] = $defenderGeneral->getID(); } Json::die([ @@ -261,6 +261,11 @@ usort($defenderList, function(General $lhs, General $rhs){ return -(extractBattleOrder($lhs) <=> extractBattleOrder($rhs)); }); +$rawDefenderList = array_map(function(General $general){ + return $general->getRaw(); +}, $defenderList); +unset($defenderList); + $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); $startYear = $gameStor->startyear; @@ -269,18 +274,17 @@ $cityRate = Util::round(($year - $startYear) / 1.5) + 60; function simulateBattle( $rawAttacker, $rawAttackerCity, $rawAttackerNation, - $defenderList, $rawDefenderCity, $rawDefenderNation, + $rawDefenderList, $rawDefenderCity, $rawDefenderNation, $startYear, $year, $month, $cityRate ){ - $attacker = new WarUnitGeneral( - new General($rawAttacker, null, $rawAttackerCity, $year, $month), + new General($rawAttacker, null, $rawAttackerCity, $rawAttackerNation, $year, $month), $rawAttackerNation, true ); $city = new WarUnitCity($rawDefenderCity, $rawDefenderNation, $year, $month, $cityRate); - $iterDefender = new \ArrayIterator($defenderList); + $iterDefender = new \ArrayIterator($rawDefenderList); $iterDefender->rewind(); $battleResult = []; @@ -306,15 +310,15 @@ function simulateBattle( return null; } - $rawGeneral = $iterDefender->current(); - if(extractBattleOrder($rawGeneral) <= 0){ + $defenderObj = new General($iterDefender->current(), null, $rawDefenderCity, $rawDefenderNation, $year, $month); + if(extractBattleOrder($defenderObj) <= 0){ return null; } - $defenderRice += $rawGeneral['rice']; + $defenderRice += $defenderObj->getVar('rice'); $retVal = new WarUnitGeneral( - new General($rawGeneral, null, $rawDefenderCity, $year, $month), + $defenderObj, $rawDefenderNation, false ); @@ -371,7 +375,7 @@ $defendersActivatedSkills = []; foreach(Util::range($repeatCnt) as $repeatIdx){ [$attacker, $city, $battleResult, $conquerCity, $attackerRice, $defenderRice] = simulateBattle( $rawAttacker, $rawAttackerCity, $rawAttackerNation, - $defenderList, $rawDefenderCity, $rawDefenderNation, + $rawDefenderList, $rawDefenderCity, $rawDefenderNation, $startYear, $year, $month, $cityRate ); $lastWarLog = Util::mapWithKey(function($key, $values){ diff --git a/hwe/join_post.php b/hwe/join_post.php index 4198c429..60d1420b 100644 --- a/hwe/join_post.php +++ b/hwe/join_post.php @@ -158,7 +158,7 @@ $age = 20 + ($pleadership + $pstrength + $pintel) * 2 - (mt_rand(0, 1)); // 아직 남았고 천재등록상태이면 특기 부여 if ($genius) { $specage2 = $age; - $special2 = SpecialityConst::pickSpecialWar([ + $special2 = SpecialityHelper::pickSpecialWar([ 'leadership'=>$leadership, 'strength'=>$strength, 'intel'=>$intel, diff --git a/hwe/js/battle_simulator.js b/hwe/js/battle_simulator.js index 097bcb53..1af0dd99 100644 --- a/hwe/js/battle_simulator.js +++ b/hwe/js/battle_simulator.js @@ -204,19 +204,19 @@ jQuery(function($){ explevel:getInt('.form_exp_level'), leadership:getInt('.form_leadership'), - horse:getInt('.form_general_horse'), + horse:getVal('.form_general_horse'), strength:getInt('.form_strength'), - weapon:getInt('.form_general_weap'), + weapon:getVal('.form_general_weap'), intel:getInt('.form_intel'), - book:getInt('.form_general_book'), - item:getInt('.form_general_item'), + book:getVal('.form_general_book'), + item:getVal('.form_general_item'), injury:getInt('.form_injury'), rice:getInt('.form_rice'), - personal:getInt('.form_general_character'), - special2:getInt('.form_general_special_war'), + personal:getVal('.form_general_character'), + special2:getVal('.form_general_special_war'), crew:getInt('.form_crew'), crewtype:getInt('.form_crewtype'), @@ -523,7 +523,7 @@ jQuery(function($){ }; var attackerNation = { - type:parseInt($attackerNation.find('.form_nation_type').val()), + type:$attackerNation.find('.form_nation_type').val(), tech:parseInt($attackerNation.find('.form_tech').val()) * 1000, level:parseInt($attackerNation.find('.form_nation_level').val()), capital:$attackerNation.find('.form_is_capital:checked').val()=='1'?1:2, @@ -540,7 +540,7 @@ jQuery(function($){ }; var defenderNation = { - type:parseInt($defenderNation.find('.form_nation_type').val()), + type:$defenderNation.find('.form_nation_type').val(), tech:parseInt($defenderNation.find('.form_tech').val()) * 1000, level:parseInt($defenderNation.find('.form_nation_level').val()), capital:$defenderNation.find('.form_is_capital:checked').val()=='1'?3:4, @@ -573,7 +573,7 @@ jQuery(function($){ level:0, gold:0, rice:2000, - type:0, + type:'None', tech:0, gennum:200, }; @@ -616,7 +616,10 @@ jQuery(function($){ var attackerGeneral = extendGeneralInfoForDB(allData.attackerGeneral); if(2 <= attackerGeneral.officer_level && attackerGeneral.officer_level <= 4){ - attackerCity.officer_city = 1; + attackerGeneral.officer_city = 1; + } + else{ + attackerGeneral.officer_city = 0; } var defenderNation = $.extend({}, defaultNation, allData.defenderNation); @@ -635,6 +638,9 @@ jQuery(function($){ if(2 <= defenderGeneral.officer_level && defenderGeneral.officer_level <= 4){ defenderGeneral.officer_city = 3; } + else{ + defenderGeneral.officer_city = 0; + } defenderGenerals.push(defenderGeneral); }); @@ -763,6 +769,7 @@ jQuery(function($){ type:'post', url:'j_simulate_battle.php', dataType:'json', + contentType: "application/json", data:{ action:'reorder', query:JSON.stringify(data), diff --git a/hwe/sammo/ActionSpecialDomestic/None.php b/hwe/sammo/ActionSpecialDomestic/None.php index 85e16f80..bf26bbda 100644 --- a/hwe/sammo/ActionSpecialDomestic/None.php +++ b/hwe/sammo/ActionSpecialDomestic/None.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class None implements iAction{ - use \sammo\DefaultAction; +class None extends \sammo\BaseSpecial{ protected $id = 0; protected $name = '-'; protected $info = ''; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 0; static $type = [ - SpecialityConst::DISABLED + SpecialityHelper::DISABLED ]; } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialDomestic/che_거상.php b/hwe/sammo/ActionSpecialDomestic/che_거상.php index 7331f050..a0b4b519 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_거상.php +++ b/hwe/sammo/ActionSpecialDomestic/che_거상.php @@ -2,16 +2,15 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_거상 implements iAction{ - use \sammo\DefaultAction; +class che_거상 extends \sammo\BaseSpecial{ protected $id = 999; protected $name = '거상'; protected $info = '<비활성화>'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 0; static $type = []; diff --git a/hwe/sammo/ActionSpecialDomestic/che_경작.php b/hwe/sammo/ActionSpecialDomestic/che_경작.php index 59d382ef..0c36d29b 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_경작.php +++ b/hwe/sammo/ActionSpecialDomestic/che_경작.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_경작 implements iAction{ - use \sammo\DefaultAction; +class che_경작 extends \sammo\BaseSpecial{ protected $id = 1; protected $name = '경작'; protected $info = '[내정] 농지 개간 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_INTEL ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialDomestic/che_귀모.php b/hwe/sammo/ActionSpecialDomestic/che_귀모.php index 7b72e722..5b63cac0 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_귀모.php +++ b/hwe/sammo/ActionSpecialDomestic/che_귀모.php @@ -2,21 +2,20 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_귀모 implements iAction{ - use \sammo\DefaultAction; +class che_귀모 extends \sammo\BaseSpecial{ protected $id = 31; protected $name = '귀모'; protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; - static $selectWeightType = SpecialityConst::WEIGHT_PERCENT; + static $selectWeightType = SpecialityHelper::WEIGHT_PERCENT; static $selectWeight = 2.5; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH, - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH, + SpecialityHelper::STAT_INTEL ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialDomestic/che_발명.php b/hwe/sammo/ActionSpecialDomestic/che_발명.php index 4294d31c..efb3775d 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_발명.php +++ b/hwe/sammo/ActionSpecialDomestic/che_발명.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_발명 implements iAction{ - use \sammo\DefaultAction; +class che_발명 extends \sammo\BaseSpecial{ protected $id = 3; protected $name = '발명'; protected $info = '[내정] 기술 연구 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_INTEL ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialDomestic/che_상재.php b/hwe/sammo/ActionSpecialDomestic/che_상재.php index c1e29554..60e9e7bc 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_상재.php +++ b/hwe/sammo/ActionSpecialDomestic/che_상재.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_상재 implements iAction{ - use \sammo\DefaultAction; +class che_상재 extends \sammo\BaseSpecial{ protected $id = 2; protected $name = '상재'; protected $info = '[내정] 상업 투자 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_INTEL ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialDomestic/che_수비.php b/hwe/sammo/ActionSpecialDomestic/che_수비.php index 751dd8c0..72e287e6 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_수비.php +++ b/hwe/sammo/ActionSpecialDomestic/che_수비.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_수비 implements iAction{ - use \sammo\DefaultAction; +class che_수비 extends \sammo\BaseSpecial{ protected $id = 11; protected $name = '수비'; protected $info = '[내정] 수비 강화 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_STRENGTH + SpecialityHelper::STAT_STRENGTH ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialDomestic/che_인덕.php b/hwe/sammo/ActionSpecialDomestic/che_인덕.php index fe6fafe5..c6adacb7 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_인덕.php +++ b/hwe/sammo/ActionSpecialDomestic/che_인덕.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_인덕 implements iAction{ - use \sammo\DefaultAction; +class che_인덕 extends \sammo\BaseSpecial{ protected $id = 20; protected $name = '인덕'; protected $info = '[내정] 주민 선정·정착 장려 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP + SpecialityHelper::STAT_LEADERSHIP ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialDomestic/che_축성.php b/hwe/sammo/ActionSpecialDomestic/che_축성.php index f9999304..d137f241 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_축성.php +++ b/hwe/sammo/ActionSpecialDomestic/che_축성.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_축성 implements iAction{ - use \sammo\DefaultAction; +class che_축성 extends \sammo\BaseSpecial{ protected $id = 10; protected $name = '축성'; protected $info = '[내정] 기술 연구 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_STRENGTH + SpecialityHelper::STAT_STRENGTH ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialDomestic/che_통찰.php b/hwe/sammo/ActionSpecialDomestic/che_통찰.php index 23d24cff..aedeb24a 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_통찰.php +++ b/hwe/sammo/ActionSpecialDomestic/che_통찰.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialDomestic; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class che_통찰 implements iAction{ - use \sammo\DefaultAction; +class che_통찰 extends \sammo\BaseSpecial{ protected $id = 12; protected $name = '통찰'; protected $info = '[내정] 치안 강화 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_STRENGTH + SpecialityHelper::STAT_STRENGTH ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialWar/None.php b/hwe/sammo/ActionSpecialWar/None.php index 303cabd6..9552b563 100644 --- a/hwe/sammo/ActionSpecialWar/None.php +++ b/hwe/sammo/ActionSpecialWar/None.php @@ -2,19 +2,18 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; -class None implements iAction{ - use \sammo\DefaultAction; +class None extends \sammo\BaseSpecial{ protected $id = 0; protected $name = '-'; protected $info = ''; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 0; static $type = [ - SpecialityConst::DISABLED + SpecialityHelper::DISABLED ]; } \ No newline at end of file diff --git a/hwe/sammo/ActionSpecialWar/che_격노.php b/hwe/sammo/ActionSpecialWar/che_격노.php index e087395e..e7720f69 100644 --- a/hwe/sammo/ActionSpecialWar/che_격노.php +++ b/hwe/sammo/ActionSpecialWar/che_격노.php @@ -2,25 +2,24 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; use sammo\WarUnitTriggerCaller; use sammo\WarUnitTrigger\che_격노시도; use sammo\WarUnitTrigger\che_격노발동; -class che_격노 implements iAction{ - use \sammo\DefaultAction; +class che_격노 extends \sammo\BaseSpecial{ protected $id = 74; protected $name = '격노'; protected $info = '[전투] 상대방 필살 및 회피 시도시 일정 확률로 격노(필살) 발동, 공격 시 일정 확률로 진노(1페이즈 추가)'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH, - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH, + SpecialityHelper::STAT_INTEL ]; public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ diff --git a/hwe/sammo/ActionSpecialWar/che_견고.php b/hwe/sammo/ActionSpecialWar/che_견고.php index c6c49bcc..fe994290 100644 --- a/hwe/sammo/ActionSpecialWar/che_견고.php +++ b/hwe/sammo/ActionSpecialWar/che_견고.php @@ -2,24 +2,23 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; use sammo\WarUnitTriggerCaller; use sammo\BaseWarUnitTrigger; use sammo\WarUnitTrigger\WarActivateSkills; -class che_견고 implements iAction{ - use \sammo\DefaultAction; +class che_견고 extends \sammo\BaseSpecial{ protected $id = 62; protected $name = '견고'; protected $info = '[전투] 상대 필살 불가, 상대 계략 시도시 성공 확률 -10%p'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH ]; public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ diff --git a/hwe/sammo/ActionSpecialWar/che_공성.php b/hwe/sammo/ActionSpecialWar/che_공성.php index dd7065ce..9b60bfd7 100644 --- a/hwe/sammo/ActionSpecialWar/che_공성.php +++ b/hwe/sammo/ActionSpecialWar/che_공성.php @@ -2,24 +2,23 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\GameUnitConst; use \sammo\WarUnit; use \sammo\WarUnitCity; -class che_공성 implements iAction{ - use \sammo\DefaultAction; +class che_공성 extends \sammo\BaseSpecial{ protected $id = 53; protected $name = '공성'; protected $info = '[군사] 차병 계통 징·모병비 -10%
[전투] 성벽 공격 시 대미지 +100%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_SIEGE, - SpecialityConst::STAT_STRENGTH | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_SIEGE, - SpecialityConst::STAT_INTEL | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_SIEGE, + SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_SIEGE, + SpecialityHelper::STAT_STRENGTH | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_SIEGE, + SpecialityHelper::STAT_INTEL | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_SIEGE, ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialWar/che_궁병.php b/hwe/sammo/ActionSpecialWar/che_궁병.php index 26682520..e772d275 100644 --- a/hwe/sammo/ActionSpecialWar/che_궁병.php +++ b/hwe/sammo/ActionSpecialWar/che_궁병.php @@ -2,22 +2,21 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\GameUnitConst; -class che_궁병 implements iAction{ - use \sammo\DefaultAction; +class che_궁병 extends \sammo\BaseSpecial{ protected $id = 51; protected $name = '궁병'; protected $info = '[군사] 궁병 계통 징·모병비 -10%
[전투] 회피 확률 +20%p'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_ARCHER, - SpecialityConst::STAT_STRENGTH | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_ARCHER + SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_ARCHER, + SpecialityHelper::STAT_STRENGTH | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_ARCHER ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialWar/che_귀병.php b/hwe/sammo/ActionSpecialWar/che_귀병.php index 28252c3f..1bcdb73c 100644 --- a/hwe/sammo/ActionSpecialWar/che_귀병.php +++ b/hwe/sammo/ActionSpecialWar/che_귀병.php @@ -2,21 +2,20 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\GameUnitConst; use \sammo\WarUnit; -class che_귀병 implements iAction{ - use \sammo\DefaultAction; +class che_귀병 extends \sammo\BaseSpecial{ protected $id = 40; protected $name = '귀병'; protected $info = '[군사] 귀병 계통 징·모병비 -10%
[전투] 계략 성공 확률 +20%p'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_INTEL | SpecialityConst::ARMY_WIZARD | SpecialityConst::REQ_DEXTERITY + SpecialityHelper::STAT_INTEL | SpecialityHelper::ARMY_WIZARD | SpecialityHelper::REQ_DEXTERITY ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialWar/che_기병.php b/hwe/sammo/ActionSpecialWar/che_기병.php index f3fa12d6..aadbad5a 100644 --- a/hwe/sammo/ActionSpecialWar/che_기병.php +++ b/hwe/sammo/ActionSpecialWar/che_기병.php @@ -2,22 +2,21 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\GameUnitConst; use \sammo\WarUnit; -class che_기병 implements iAction{ - use \sammo\DefaultAction; +class che_기병 extends \sammo\BaseSpecial{ protected $id = 52; protected $name = '기병'; protected $info = '[군사] 기병 계통 징·모병비 -10%
[전투] 수비 시 대미지 +10%, 공격 시 대미지 +20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_CAVALRY, - SpecialityConst::STAT_STRENGTH | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_CAVALRY + SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_CAVALRY, + SpecialityHelper::STAT_STRENGTH | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_CAVALRY ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialWar/che_돌격.php b/hwe/sammo/ActionSpecialWar/che_돌격.php index 9995956c..bf0662f2 100644 --- a/hwe/sammo/ActionSpecialWar/che_돌격.php +++ b/hwe/sammo/ActionSpecialWar/che_돌격.php @@ -2,24 +2,23 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; use \sammo\BaseWarUnitTrigger; use \sammo\WarUnitTriggerCaller; use sammo\WarUnitTrigger\WarActivateSkills; -class che_돌격 implements iAction{ - use \sammo\DefaultAction; +class che_돌격 extends \sammo\BaseSpecial{ protected $id = 60; protected $name = '돌격'; protected $info = '[전투] 상대 회피 불가, 공격 시 전투 페이즈 +1, 공격 시 대미지 +10%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH ]; public function onCalcStat(General $general, string $statName, $value, $aux=null){ diff --git a/hwe/sammo/ActionSpecialWar/che_무쌍.php b/hwe/sammo/ActionSpecialWar/che_무쌍.php index c2c34e67..76f803ad 100644 --- a/hwe/sammo/ActionSpecialWar/che_무쌍.php +++ b/hwe/sammo/ActionSpecialWar/che_무쌍.php @@ -2,21 +2,20 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; -class che_무쌍 implements iAction{ - use \sammo\DefaultAction; +class che_무쌍 extends \sammo\BaseSpecial{ protected $id = 61; protected $name = '무쌍'; protected $info = '[전투] 대미지 +10%, 공격 시 필살 확률 +10%p'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH ]; public function onCalcStat(General $general, string $statName, $value, $aux=null){ diff --git a/hwe/sammo/ActionSpecialWar/che_반계.php b/hwe/sammo/ActionSpecialWar/che_반계.php index 229d7f05..09d94928 100644 --- a/hwe/sammo/ActionSpecialWar/che_반계.php +++ b/hwe/sammo/ActionSpecialWar/che_반계.php @@ -2,7 +2,7 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; use sammo\WarUnitTriggerCaller; use \sammo\BaseWarUnitTrigger; @@ -10,17 +10,16 @@ use \sammo\WarUnitTrigger\WarActivateSkills; use \sammo\WarUnitTrigger\che_반계시도; use \sammo\WarUnitTrigger\che_반계발동; -class che_반계 implements iAction{ - use \sammo\DefaultAction; +class che_반계 extends \sammo\BaseSpecial{ protected $id = 45; protected $name = '반계'; protected $info = '[전투] 상대의 계략 성공 확률 -10%p, 상대의 계략을 40% 확률로 되돌림, 반목 성공시 대미지 추가(+60% → +100%)'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_INTEL, + SpecialityHelper::STAT_INTEL, ]; public function onCalcStat(General $general, string $statName, $value, $aux=null){ diff --git a/hwe/sammo/ActionSpecialWar/che_보병.php b/hwe/sammo/ActionSpecialWar/che_보병.php index 8a06f047..b5802e18 100644 --- a/hwe/sammo/ActionSpecialWar/che_보병.php +++ b/hwe/sammo/ActionSpecialWar/che_보병.php @@ -2,22 +2,21 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\GameUnitConst; use \sammo\WarUnit; -class che_보병 implements iAction{ - use \sammo\DefaultAction; +class che_보병 extends \sammo\BaseSpecial{ protected $id = 50; protected $name = '보병'; protected $info = '[군사] 보병 계통 징·모병비 -10%
[전투] 공격 시 아군 피해 -10%, 수비 시 아군 피해 -20%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_FOOTMAN, - SpecialityConst::STAT_STRENGTH | SpecialityConst::REQ_DEXTERITY | SpecialityConst::ARMY_FOOTMAN + SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_FOOTMAN, + SpecialityHelper::STAT_STRENGTH | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_FOOTMAN ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialWar/che_신산.php b/hwe/sammo/ActionSpecialWar/che_신산.php index 1f3a6e1e..4e8e0e49 100644 --- a/hwe/sammo/ActionSpecialWar/che_신산.php +++ b/hwe/sammo/ActionSpecialWar/che_신산.php @@ -2,20 +2,19 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; -class che_신산 implements iAction{ - use \sammo\DefaultAction; +class che_신산 extends \sammo\BaseSpecial{ protected $id = 41; protected $name = '신산'; protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +10%p
[전투] 계략 시도 확률 +20%p, 계략 성공 확률 +20%p'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_INTEL, + SpecialityHelper::STAT_INTEL, ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialWar/che_신중.php b/hwe/sammo/ActionSpecialWar/che_신중.php index 2b796120..638fc6f3 100644 --- a/hwe/sammo/ActionSpecialWar/che_신중.php +++ b/hwe/sammo/ActionSpecialWar/che_신중.php @@ -2,20 +2,19 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; -class che_신중 implements iAction{ - use \sammo\DefaultAction; +class che_신중 extends \sammo\BaseSpecial{ protected $id = 44; protected $name = '신중'; protected $info = '[전투] 계략 성공 확률 100%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_INTEL, + SpecialityHelper::STAT_INTEL, ]; public function onCalcStat(General $general, string $statName, $value, $aux=null){ diff --git a/hwe/sammo/ActionSpecialWar/che_위압.php b/hwe/sammo/ActionSpecialWar/che_위압.php index 2eb1e301..d1b15dbb 100644 --- a/hwe/sammo/ActionSpecialWar/che_위압.php +++ b/hwe/sammo/ActionSpecialWar/che_위압.php @@ -2,24 +2,23 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; use sammo\WarUnitTriggerCaller; use \sammo\WarUnitTrigger\che_위압시도; use \sammo\WarUnitTrigger\che_위압발동; -class che_위압 implements iAction{ - use \sammo\DefaultAction; +class che_위압 extends \sammo\BaseSpecial{ protected $id = 63; protected $name = '위압'; protected $info = '[전투] 훈련/사기≥90, 병력≥1,000 일 때 첫 페이즈 위압 발동(적 공격 불가)'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH ]; public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ diff --git a/hwe/sammo/ActionSpecialWar/che_의술.php b/hwe/sammo/ActionSpecialWar/che_의술.php index 9f2fa1a5..78e69ec4 100644 --- a/hwe/sammo/ActionSpecialWar/che_의술.php +++ b/hwe/sammo/ActionSpecialWar/che_의술.php @@ -2,7 +2,7 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use sammo\BaseGeneralTrigger; -use sammo\SpecialityConst; +use sammo\SpecialityHelper; use \sammo\General; use \sammo\GeneralTrigger; use \sammo\GeneralTriggerCaller; @@ -11,19 +11,18 @@ use sammo\WarUnitTrigger\che_전투치료발동; use sammo\WarUnitTrigger\che_전투치료시도; use sammo\WarUnitTriggerCaller; -class che_의술 implements iAction{ - use \sammo\DefaultAction; +class che_의술 extends \sammo\BaseSpecial{ protected $id = 73; protected $name = '의술'; protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복
[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)'; - static $selectWeightType = SpecialityConst::WEIGHT_PERCENT; + static $selectWeightType = SpecialityHelper::WEIGHT_PERCENT; static $selectWeight = 2; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH, - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH, + SpecialityHelper::STAT_INTEL ]; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ diff --git a/hwe/sammo/ActionSpecialWar/che_저격.php b/hwe/sammo/ActionSpecialWar/che_저격.php index 1bcbe63d..96d523c8 100644 --- a/hwe/sammo/ActionSpecialWar/che_저격.php +++ b/hwe/sammo/ActionSpecialWar/che_저격.php @@ -2,25 +2,24 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; use sammo\WarUnitTriggerCaller; use \sammo\WarUnitTrigger\che_저격시도; use \sammo\WarUnitTrigger\che_저격발동; -class che_저격 implements iAction{ - use \sammo\DefaultAction; +class che_저격 extends \sammo\BaseSpecial{ protected $id = 70; protected $name = '저격'; protected $info = '[전투] 전투 개시 시 1/3 확률로 저격 발동'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH, - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH, + SpecialityHelper::STAT_INTEL ]; public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ diff --git a/hwe/sammo/ActionSpecialWar/che_집중.php b/hwe/sammo/ActionSpecialWar/che_집중.php index a544495c..cc9d0a87 100644 --- a/hwe/sammo/ActionSpecialWar/che_집중.php +++ b/hwe/sammo/ActionSpecialWar/che_집중.php @@ -2,20 +2,19 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; -class che_집중 implements iAction{ - use \sammo\DefaultAction; +class che_집중 extends \sammo\BaseSpecial{ protected $id = 43; protected $name = '집중'; protected $info = '[전투] 계략 성공 시 대미지 +50%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_INTEL, + SpecialityHelper::STAT_INTEL, ]; public function onCalcStat(General $general, string $statName, $value, $aux=null){ diff --git a/hwe/sammo/ActionSpecialWar/che_징병.php b/hwe/sammo/ActionSpecialWar/che_징병.php index 58a92c75..bb3a883e 100644 --- a/hwe/sammo/ActionSpecialWar/che_징병.php +++ b/hwe/sammo/ActionSpecialWar/che_징병.php @@ -2,22 +2,21 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; -class che_징병 implements iAction{ - use \sammo\DefaultAction; +class che_징병 extends \sammo\BaseSpecial{ protected $id = 72; protected $name = '징병'; protected $info = '[군사] 징·모병비 -50%, 통솔 순수 능력치 보정 +15%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH, - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH, + SpecialityHelper::STAT_INTEL ]; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ diff --git a/hwe/sammo/ActionSpecialWar/che_척사.php b/hwe/sammo/ActionSpecialWar/che_척사.php index a810ca8d..ee7efc40 100644 --- a/hwe/sammo/ActionSpecialWar/che_척사.php +++ b/hwe/sammo/ActionSpecialWar/che_척사.php @@ -2,22 +2,21 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; -class che_척사 implements iAction{ - use \sammo\DefaultAction; +class che_척사 extends \sammo\BaseSpecial{ protected $id = 75; protected $name = '척사'; protected $info = '[전투] 지역·도시 병종 상대로 대미지 +10%, 아군 피해 -10%'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH, - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH, + SpecialityHelper::STAT_INTEL ]; public function getWarPowerMultiplier(WarUnit $unit):array{ diff --git a/hwe/sammo/ActionSpecialWar/che_필살.php b/hwe/sammo/ActionSpecialWar/che_필살.php index e682f2a8..d036fe58 100644 --- a/hwe/sammo/ActionSpecialWar/che_필살.php +++ b/hwe/sammo/ActionSpecialWar/che_필살.php @@ -2,22 +2,21 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; -class che_필살 implements iAction{ - use \sammo\DefaultAction; +class che_필살 extends \sammo\BaseSpecial{ protected $id = 71; protected $name = '필살'; protected $info = '[전투] 필살 확률 +20%p'; - static $selectWeightType = SpecialityConst::WEIGHT_NORM; + static $selectWeightType = SpecialityHelper::WEIGHT_NORM; static $selectWeight = 1; static $type = [ - SpecialityConst::STAT_LEADERSHIP, - SpecialityConst::STAT_STRENGTH, - SpecialityConst::STAT_INTEL + SpecialityHelper::STAT_LEADERSHIP, + SpecialityHelper::STAT_STRENGTH, + SpecialityHelper::STAT_INTEL ]; public function onCalcStat(General $general, string $statName, $value, $aux=null){ diff --git a/hwe/sammo/ActionSpecialWar/che_환술.php b/hwe/sammo/ActionSpecialWar/che_환술.php index 98c2a9e1..75ff09bc 100644 --- a/hwe/sammo/ActionSpecialWar/che_환술.php +++ b/hwe/sammo/ActionSpecialWar/che_환술.php @@ -2,20 +2,19 @@ namespace sammo\ActionSpecialWar; use \sammo\iAction; use \sammo\General; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; use \sammo\WarUnit; -class che_환술 implements iAction{ - use \sammo\DefaultAction; +class che_환술 extends \sammo\BaseSpecial{ protected $id = 42; protected $name = '환술'; protected $info = '[전투] 계략 성공 확률 +10%p, 계략 성공 시 대미지 +30%'; - static $selectWeightType = SpecialityConst::WEIGHT_PERCENT; + static $selectWeightType = SpecialityHelper::WEIGHT_PERCENT; static $selectWeight = 5; static $type = [ - SpecialityConst::STAT_INTEL, + SpecialityHelper::STAT_INTEL, ]; public function onCalcStat(General $general, string $statName, $value, $aux=null){ diff --git a/hwe/sammo/BaseSpecial.php b/hwe/sammo/BaseSpecial.php new file mode 100644 index 00000000..1d7af22d --- /dev/null +++ b/hwe/sammo/BaseSpecial.php @@ -0,0 +1,19 @@ +arg); //XXX: 왜 General -> obj -> General 변환을 하고 있나? - $generalObj = new General($this->general, null, null, null, false); + $generalObj = new General($this->general, null, null, null, null, false); if($reqCrewType->id != $generalObj->getCrewTypeObj()->id){ return true; diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 48ddea33..76604819 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -148,25 +148,33 @@ class GameConstBase /** @var array 기본 국가 성향 */ public static $neutralNationType = 'che_중립'; - /** @var array 기본 내정 특기 */ + /** @var string 기본 내정 특기 */ public static $defaultSpecialDomestic = 'None'; /** @var array 선택 가능한 장수 내정 특기 */ public static $availableSpecialDomestic = [ 'che_경작', 'che_상재', 'che_발명', 'che_축성', 'che_수비', 'che_통찰', 'che_인덕', 'che_귀모', ]; + /** @var array 선택할 수 없으나 게임 내에 유효한 장수 내정 특기 */ + public static $optionalSpecialDomestic = [ + 'None', + ]; - /** @var array 기본 전투 특기 */ + /** @var string 기본 전투 특기 */ public static $defaultSpecialWar = 'None'; - /** @var array 선택 가능한 장수 내정 특기 */ + /** @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 $optionalSpecialWar = [ + 'None', + ]; - /** @var array 기본 성향(공용) */ + /** @var string 기본 성향(공용) */ public static $neutralPersonality = 'None'; /** @var array 선택 가능한 성향 */ public static $availablePersonality = [ @@ -174,9 +182,8 @@ class GameConstBase 'che_패권', 'che_의협', 'che_대의', 'che_왕좌' ]; /** @var array 존재하는 모든 성향 */ - public static $allPersonality = [ - 'che_안전', 'che_유지', 'che_재간', 'che_출세', 'che_할거', 'che_정복', - 'che_패권', 'che_의협', 'che_대의', 'che_왕좌', 'che_은둔', 'None' + public static $optionalPersonality = [ + 'che_은둔', 'None' ]; public static $allItems = [ diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index af1e0c25..af6c6c3f 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -83,10 +83,13 @@ class General implements iAction{ * @param int $month 게임 월 * @param bool $fullConstruct iAction, 및 ActionLogger 초기화 여부, false인 경우 no, name, city, nation, officer_level 정도로 초기화 가능 */ - public function __construct(array $raw, ?array $rawRank, ?array $city, ?int $year, ?int $month, bool $fullConstruct=true){ + public function __construct(array $raw, ?array $rawRank, ?array $city, ?array $nation, ?int $year, ?int $month, bool $fullConstruct=true){ //TODO: 밖에서 가져오도록 하면 버그 확률이 높아짐. 필요한 raw 값을 직접 구해야함. - $staticNation = getNationStaticInfo($raw['nation']); + if($nation === null){ + $nation = getNationStaticInfo($raw['nation']); + } + $this->raw = $raw; $this->rawCity = $city; @@ -107,8 +110,8 @@ class General implements iAction{ return; } - $this->nationType = buildNationTypeClass($staticNation['type']); - $this->officerLevelObj = new TriggerOfficerLevel($this->raw, $staticNation['level']); + $this->nationType = buildNationTypeClass($nation['type']); + $this->officerLevelObj = new TriggerOfficerLevel($this->raw, $nation['level']); $this->specialDomesticObj = buildGeneralSpecialDomesticClass($raw['special']); $this->specialWarObj = buildGeneralSpecialWarClass($raw['special2']); diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index 8d2e89ab..e06447f3 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -7,7 +7,7 @@ use \sammo\CityHelper; use \sammo\GameUnitConst; use \sammo\CityConst; use \sammo\GameConst; -use \sammo\SpecialityConst; +use \sammo\SpecialityHelper; class NPC{ @@ -101,17 +101,17 @@ class NPC{ $this->charWar = GameConst::$defaultSpecialWar; if($char === '랜덤전특'){ - $this->charWar = SpecialityConst::pickSpecialWar($general); + $this->charWar = SpecialityHelper::pickSpecialWar($general); } else if($char === '랜덤내특'){ - $this->charDomestic = SpecialityConst::pickSpecialDomestic($general); + $this->charDomestic = SpecialityHelper::pickSpecialDomestic($general); } else if($char === '랜덤'){ if(Util::randBool(2/3)){ - $this->charWar = SpecialityConst::pickSpecialWar($general); + $this->charWar = SpecialityHelper::pickSpecialWar($general); } else{ - $this->charDomestic = SpecialityConst::pickSpecialDomestic($general); + $this->charDomestic = SpecialityHelper::pickSpecialDomestic($general); } } else if($char === null){ @@ -120,12 +120,10 @@ class NPC{ //TODO: 내특, 전특 구분 필요 try{ - $domesticClass = \sammo\getGeneralSpecialDomesticClass($char); - $this->charDomestic = Util::getClassName($domesticClass); + $this->charDomestic = SpecialityHelper::getDomesticClassByName($char); } catch (\Exception $e) { - $warClass = \sammo\getGeneralSpecialWarClass($char); - $this->charWar = Util::getClassName($warClass); + $this->charWar = SpecialityHelper::getWarClassByName($char); } } } diff --git a/hwe/sammo/SpecialityConst.php b/hwe/sammo/SpecialityConst.php deleted file mode 100644 index 0e458633..00000000 --- a/hwe/sammo/SpecialityConst.php +++ /dev/null @@ -1,262 +0,0 @@ - ['경작', 1, [self::STAT_INTEL]], - 'che_상재' => ['상재', 1, [self::STAT_INTEL]], - 'che_발명' => ['발명', 1, [self::STAT_INTEL]], - - 'che_축성' => ['축성', 1, [self::STAT_STRENGTH]], - 'che_수비' => ['수비', 1, [self::STAT_STRENGTH]], - 'che_통찰' => ['통찰', 1, [self::STAT_STRENGTH]], - - 'che_인덕' => ['인덕', 1, [self::STAT_LEADERSHIP]], - - 'che_귀모' => ['귀모', -2.5, [self::STAT_LEADERSHIP, self::STAT_STRENGTH, self::STAT_INTEL]], - ]; - - const WAR = [ - 'che_귀병' => ['귀병', 1, [self::STAT_INTEL | self::ARMY_WIZARD | self::REQ_DEXTERITY]], - - 'che_신산' => ['신산', 1, [self::STAT_INTEL]], - 'che_환술' => ['환술', -5, [self::STAT_INTEL]], - 'che_집중' => ['집중', 1, [self::STAT_INTEL]], - 'che_신중' => ['신중', 1, [self::STAT_INTEL]], - 'che_반계' => ['반계', 1, [self::STAT_INTEL]], - - 'che_보병' => ['보병', 1, [ - self::STAT_LEADERSHIP | self::REQ_DEXTERITY | self::ARMY_FOOTMAN, - self::STAT_STRENGTH | self::REQ_DEXTERITY | self::ARMY_FOOTMAN - ]], - 'che_궁병' => ['궁병', 1, [ - self::STAT_LEADERSHIP | self::REQ_DEXTERITY | self::ARMY_ARCHER, - self::STAT_STRENGTH | self::REQ_DEXTERITY | self::ARMY_ARCHER - ]], - 'che_기병' => ['기병', 1, [ - self::STAT_LEADERSHIP | self::REQ_DEXTERITY | self::ARMY_CAVALRY, - self::STAT_STRENGTH | self::REQ_DEXTERITY | self::ARMY_CAVALRY - ]], - 'che_공성' => ['공성', 1, [ - self::STAT_LEADERSHIP | self::REQ_DEXTERITY | self::ARMY_SIEGE, - self::STAT_STRENGTH | self::REQ_DEXTERITY | self::ARMY_SIEGE, - self::STAT_INTEL | self::REQ_DEXTERITY | self::ARMY_SIEGE - ]], - - 'che_돌격' => ['돌격', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH]], - 'che_무쌍' => ['무쌍', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH]], - 'che_견고' => ['견고', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH]], - 'che_위압' => ['위압', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH]], - - 'che_저격' => ['저격', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH, self::STAT_INTEL]], - 'che_필살' => ['필살', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH, self::STAT_INTEL]], - 'che_징병' => ['징병', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH, self::STAT_INTEL]], - 'che_의술' => ['의술', -2, [self::STAT_LEADERSHIP, self::STAT_STRENGTH, self::STAT_INTEL]], - 'che_격노' => ['격노', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH, self::STAT_INTEL]], - 'che_척사' => ['척사', 1, [self::STAT_LEADERSHIP, self::STAT_STRENGTH, self::STAT_INTEL]], - ]; - - public static function getInvDomestic(string $name){ - if(static::$invDomestic !== null){ - return static::$invDomestic[$name]??null; - } - - $invDomestic = []; - foreach(static::DOMESTIC as $key=>$val){ - $nameKey = $val[0]; - $val[0] = $key; - $invDomestic[$nameKey] = $val; - } - static::$invDomestic = $invDomestic; - - return static::$invDomestic[$name]??null; - } - - public static function getInvWar(string $name){ - if(static::$invWar !== null){ - return static::$invWar[$name]??null; - } - - $invWar = []; - foreach(static::WAR as $key=>$val){ - $nameKey = $val[0]; - $val[0] = $key; - $invWar[$nameKey] = $val; - } - static::$invWar = $invWar; - - return static::$invWar[$name]??null; - } - - private static function calcCondGeneric(array $general) : int { - $myCond = 0; - - $leadership = $general['leadership']??50; - $strength = $general['strength']??50; - $intel = $general['intel']??50; - - if ($leadership * 0.95 > $strength && $leadership * 0.95 > $intel) { - $myCond |= self::STAT_LEADERSHIP; - } - else if($strength >= $intel){ - $myCond |= self::STAT_STRENGTH; - } - else { - $myCond |= self::STAT_INTEL; - } - - return $myCond; - } - - private static function calcCondDexterity(array $general) : int { - $dex = [ - static::ARMY_FOOTMAN => $general['dex1']??0, - static::ARMY_ARCHER => $general['dex2']??0, - static::ARMY_CAVALRY => $general['dex3']??0, - static::ARMY_WIZARD => $general['dex4']??0, - static::ARMY_SIEGE => $general['dex5']??0, - ]; - - $dexSum = array_sum($dex); - $dexBase = Util::round(sqrt($dexSum) / 4); - - if(Util::randBool(0.8)){ - return 0; - } - - if(mt_rand(0, 99) < $dexBase){ - return 0; - } - - if(!$dexSum){ - return array_rand($dex); - } - - return array_keys($dex, max($dex))[0]; - } - - public static function pickSpecialDomestic(array $general) : string{ - $pAbs = []; - $pRel = []; - - $myCond = static::calcCondGeneric($general); - - foreach(self::DOMESTIC as $id=>list($name, $weight, $conds)){ - $valid = false; - foreach($conds as $cond){ - if($cond === ($cond & $myCond)){ - $valid = true; - break; - } - } - if(!$valid){ - continue; - } - - - if($weight < 0){ - $pAbs[$id] = -$weight; - } - else{ - $pRel[$id] = $weight; - } - } - - if($pAbs){ - if($pRel){ - $pAbs[0] = max(0, 100 - array_sum($pAbs)); - } - $id = Util::choiceRandomUsingWeight($pAbs); - if($id){ - return $id; - } - } - - $id = Util::choiceRandomUsingWeight($pRel); - if($id){ - return $id; - } - - throw new MustNotBeReachedException(); - } - - public static function pickSpecialWar(array $general) : string{ - $reqDex = []; - $pAbs = []; - $pRel = []; - - $myCond = static::calcCondGeneric($general); - $myCond |= static::calcCondDexterity($general); - - foreach(self::WAR as $id=>list($name, $weight, $conds)){ - $valid = false; - foreach($conds as $cond){ - if($cond === ($cond & $myCond)){ - $valid = true; - break; - } - } - if(!$valid){ - continue; - } - - if($cond & self::REQ_DEXTERITY){ - $reqDex[$id] = $weight; - } - else if($weight < 0){ - $pAbs[$id] = -$weight; - } - else{ - $pRel[$id] = $weight; - } - } - - if($reqDex){ - return Util::choiceRandomUsingWeight($reqDex); - } - - if($pAbs){ - if($pRel){ - $pAbs[0] = max(0, 100 - array_sum($pAbs)); - } - - $id = Util::choiceRandomUsingWeight($pAbs); - if($id){ - return $id; - } - } - - $id = Util::choiceRandomUsingWeight($pRel); - if($id){ - return $id; - } - - throw new MustNotBeReachedException(); - } -} \ No newline at end of file diff --git a/hwe/sammo/SpecialityHelper.php b/hwe/sammo/SpecialityHelper.php new file mode 100644 index 00000000..20f43671 --- /dev/null +++ b/hwe/sammo/SpecialityHelper.php @@ -0,0 +1,270 @@ +$classObj){ + $cache[$classObj->getName()] = $className; + } + static::$domesticInv = $cache; + return $cache[$type]; + } + + public static function getWarClassByName(?string $type):string{ + if($type === null || $type === ''){ + $type = GameConst::$defaultSpecialWar; + } + + if(static::$warInv){ + if(!key_exists($type, static::$warInv)){ + throw new \InvalidArgumentException('올바르지 않은 특기명:',$type); + } + return static::$warInv[$type]; + } + + $cache = []; + foreach(static::getSpecialWarList(false) as $className=>$classObj){ + $cache[$classObj->getName()] = $className; + } + static::$warInv = $cache; + return $cache[$type]; + } + + private static function calcCondGeneric(array $general) : int { + $myCond = 0; + + $leadership = $general['leadership']??50; + $strength = $general['strength']??50; + $intel = $general['intel']??50; + + if ($leadership * 0.95 > $strength && $leadership * 0.95 > $intel) { + $myCond |= self::STAT_LEADERSHIP; + } + else if($strength >= $intel){ + $myCond |= self::STAT_STRENGTH; + } + else { + $myCond |= self::STAT_INTEL; + } + + return $myCond; + } + + private static function calcCondDexterity(array $general) : int { + $dex = [ + static::ARMY_FOOTMAN => $general['dex1']??0, + static::ARMY_ARCHER => $general['dex2']??0, + static::ARMY_CAVALRY => $general['dex3']??0, + static::ARMY_WIZARD => $general['dex4']??0, + static::ARMY_SIEGE => $general['dex5']??0, + ]; + + $dexSum = array_sum($dex); + $dexBase = Util::round(sqrt($dexSum) / 4); + + if(Util::randBool(0.8)){ + return 0; + } + + if(mt_rand(0, 99) < $dexBase){ + return 0; + } + + if(!$dexSum){ + return array_rand($dex); + } + + return array_keys($dex, max($dex))[0]; + } + + /** @return BaseSpecial[] */ + public static function getSpecialDomesticList(bool $onlyAvailable=true):array{ + $result = []; + if(!$onlyAvailable){ + $specialObj = buildGeneralSpecialDomesticClass(GameConst::$defaultSpecialDomestic); + $result[GameConst::$defaultSpecialDomestic] = $specialObj; + } + + foreach(GameConst::$availableSpecialDomestic as $specialID){ + $specialObj = buildGeneralSpecialDomesticClass($specialID); + $result[$specialID] = $specialObj; + } + + if(!$onlyAvailable){ + foreach(GameConst::$availableSpecialDomestic as $specialID){ + $specialObj = buildGeneralSpecialDomesticClass($specialID); + $result[$specialID] = $specialObj; + } + } + + return $result; + } + + /** @return BaseSpecial[] */ + public static function getSpecialWarList(bool $onlyAvailable=true):array{ + $result = []; + if(!$onlyAvailable){ + $specialObj = buildGeneralSpecialDomesticClass(GameConst::$defaultSpecialDomestic); + $result[GameConst::$defaultSpecialDomestic] = $specialObj; + } + + foreach(GameConst::$availableSpecialDomestic as $specialID){ + $specialObj = buildGeneralSpecialDomesticClass($specialID); + $result[$specialID] = $specialObj; + } + + if(!$onlyAvailable){ + foreach(GameConst::$availableSpecialDomestic as $specialID){ + $specialObj = buildGeneralSpecialDomesticClass($specialID); + $result[$specialID] = $specialObj; + } + } + + return $result; + } + + public static function pickSpecialDomestic(array $general) : string{ + $pAbs = []; + $pRel = []; + + $myCond = static::calcCondGeneric($general); + + foreach(static::getSpecialDomesticList() as $specialID=>$specialObj){ + $conds = $specialObj::$type; + $name = $specialObj->getName(); + $weightType = $specialObj::$selectWeightType; + $weight = $specialObj::$selectWeight; + + $valid = false; + foreach($conds as $cond){ + if($cond === ($cond & $myCond)){ + $valid = true; + break; + } + } + if(!$valid){ + continue; + } + + + if($weightType === static::WEIGHT_PERCENT){ + $pAbs[$specialID] = $weight; + } + else{ + $pRel[$specialID] = $weight; + } + } + + if($pAbs){ + if($pRel){ + $pAbs[0] = max(0, 100 - array_sum($pAbs)); + } + $id = Util::choiceRandomUsingWeight($pAbs); + if($id){ + return $id; + } + } + + $id = Util::choiceRandomUsingWeight($pRel); + if($id){ + return $id; + } + + throw new MustNotBeReachedException(); + } + + public static function pickSpecialWar(array $general) : string{ + $reqDex = []; + $pAbs = []; + $pRel = []; + + $myCond = static::calcCondGeneric($general); + $myCond |= static::calcCondDexterity($general); + + foreach(static::getSpecialWarList() as $specialID=>$specialObj){ + $conds = $specialObj::$type; + $name = $specialObj->getName(); + $weightType = $specialObj::$selectWeightType; + $weight = $specialObj::$selectWeight; + + $valid = false; + foreach($conds as $cond){ + if($cond === ($cond & $myCond)){ + $valid = true; + break; + } + } + if(!$valid){ + continue; + } + + + if($cond & self::REQ_DEXTERITY){ + $reqDex[$specialID] = $weight; + } + else if($weightType === static::WEIGHT_PERCENT){ + $pAbs[$specialID] = $weight; + } + else{ + $pRel[$specialID] = $weight; + } + } + + if($reqDex){ + return Util::choiceRandomUsingWeight($reqDex); + } + + if($pAbs){ + if($pRel){ + $pAbs[0] = max(0, 100 - array_sum($pAbs)); + } + $id = Util::choiceRandomUsingWeight($pAbs); + if($id){ + return $id; + } + } + + $id = Util::choiceRandomUsingWeight($pRel); + if($id){ + return $id; + } + + throw new MustNotBeReachedException(); + } +} \ No newline at end of file diff --git a/hwe/select_npc.php b/hwe/select_npc.php index a4f22c8e..3f6c3968 100644 --- a/hwe/select_npc.php +++ b/hwe/select_npc.php @@ -37,16 +37,15 @@ $nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg FROM nation var specialInfo = getName(); - $info = $domesticClass->getInfo(); +foreach(SpecialityHelper::getSpecialDomesticList() as $specialID=>$specialObj){ + $name = $specialObj->getName(); + $info = $specialObj->getInfo(); $specialAll[$name] = $info; } -foreach (SpecialityConst::WAR as $id=>$values) { - $name = $values[0]; - $text = getSpecialInfo($id); - $specialAll[$name] = $text; +foreach(SpecialityHelper::getSpecialWarList() as $specialID=>$specialObj){ + $name = $specialObj->getName(); + $info = $specialObj->getInfo(); + $specialAll[$name] = $info; } $specialAll['-'] = '없음'; echo Json::encode($specialAll); @@ -55,7 +54,7 @@ echo Json::encode($specialAll); var characterInfo = [$name, $info]){ +foreach(getCharacterList(false) as $id=>[$name, $info]){ $characterAll[$name] = $info; } echo Json::encode($characterAll);