From 934c1b0cfe65d52d03cb4c5f1068950daec8e3d6 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 6 Oct 2019 14:49:41 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/_admin5.php | 28 ++++----- hwe/c_myBossInfo.php | 2 +- hwe/func.php | 5 +- hwe/func_command.php | 4 +- hwe/func_gamerule.php | 14 +---- hwe/func_process.php | 2 - hwe/func_tournament.php | 4 +- hwe/process_war.php | 30 +++++----- hwe/sammo/Command/BaseCommand.php | 4 +- hwe/sammo/Command/General/che_귀환.php | 2 +- hwe/sammo/Command/General/che_인재탐색.php | 2 +- hwe/sammo/Command/General/che_임관.php | 1 + hwe/sammo/Command/General/che_출병.php | 2 +- hwe/sammo/Command/General/che_하야.php | 1 + hwe/sammo/Command/Nation/che_몰수.php | 11 ++-- hwe/sammo/Constraint/Constraint.php | 11 +++- hwe/sammo/Constraint/ReqEnvValue.php | 4 +- hwe/sammo/DummyGeneral.php | 3 +- hwe/sammo/GeneralAI.php | 60 ++++++++++++------- hwe/sammo/TextDecoration/DyingMessage.php | 2 +- hwe/sammo/TurnExecutionHelper.php | 9 +-- hwe/sammo/WarUnitGeneral.php | 2 +- hwe/sammo/WarUnitTrigger/che_위압시도.php | 2 +- hwe/sammo/WarUnitTrigger/che_저격시도.php | 3 +- hwe/sammo/WarUnitTrigger/che_전투치료시도.php | 2 +- hwe/sammo/WarUnitTrigger/che_회피시도.php | 2 +- src/sammo/JosaUtil.php | 3 + src/sammo/Util.php | 2 +- 28 files changed, 115 insertions(+), 102 deletions(-) diff --git a/hwe/_admin5.php b/hwe/_admin5.php index c39ff436..6bf358fe 100644 --- a/hwe/_admin5.php +++ b/hwe/_admin5.php @@ -230,24 +230,24 @@ for($i=0; $i < $nationCount; $i++) {  {$nation['power']}   {$gen['cnt']}   {$city['cnt']}  -  {$nation['tech']}  +  ".sprintf('%.1f',$nation['tech'])."   {$nation['strategic_cmd_limit']}   {$nation['gold']}   {$nation['rice']}  -  {$gen['avgg']}  -  {$gen['avgr']}  -  {$gen['avgl']}  -  {$gen['avgs']}  -  {$gen['avgi']}  -  {$gen['avge']}  -  {$nation['dex0']}  -  {$nation['dex10']}  -  {$nation['dex20']}  -  {$nation['dex30']}  -  {$nation['dex40']}  -  {$gen['crew']}/{$gen['leadership']}00  +  {$gen['avgg']}  +  {$gen['avgr']}  +  {$gen['avgl']}  +  {$gen['avgs']}  +  {$gen['avgi']}  +  {$gen['avge']}  +  {$nation['dex0']}  +  {$nation['dex10']}  +  {$nation['dex20']}  +  {$nation['dex30']}  +  {$nation['dex40']}  +  {$gen['crew']}/{$gen['leadership']}00   {$city['pop']}/{$city['pop2']}  -  ".round($city['pop']/$city['pop2']*100,1)."%  +  ".sprintf('%.1f',$city['pop']/$city['pop2']*100)."%   {$city['agri']}%   {$city['comm']}%   {$city['secu']}%  diff --git a/hwe/c_myBossInfo.php b/hwe/c_myBossInfo.php index 99dcab35..cecc32b0 100644 --- a/hwe/c_myBossInfo.php +++ b/hwe/c_myBossInfo.php @@ -217,7 +217,7 @@ if($btn == "추방") { if($admin['year'] < $admin['startyear']+3) { //초반엔 군주 부상 증가(엔장 임관지양) $db->update('general', [ - 'injury'=>$db->sqleval('injury + 1'), + 'injury'=>$db->sqleval('least(injury + 1, %i)', 80), ], 'no=%i', $ruler['no']); $db->update('nation', [ diff --git a/hwe/func.php b/hwe/func.php index bf6d8cd6..05849642 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -43,12 +43,13 @@ function getNationStaticInfo($nationID, $forceRefresh=false) 'color'=>'#000000', 'type'=>GameConst::$neutralNationType, 'level'=>0, - 'capital'=>0 + 'capital'=>0, + 'gennum'=>1 ]; } if($nationList === null){ - $nationAll = DB::db()->query("select nation, name, color, type, level, capital from nation"); + $nationAll = DB::db()->query("select nation, name, color, type, level, capital, gennum from nation"); $nationList = Util::convertArrayToDict($nationAll, "nation"); $nationList[-1] = $nationAll; } diff --git a/hwe/func_command.php b/hwe/func_command.php index 824139cc..b43ec0eb 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -159,9 +159,9 @@ function checkCommandArg(?array $arg):?string{ return null; } $defaultCheck = [ - 'string'=>[ + /*'string'=>[ 'nationName', 'optionText', 'itemType', 'nationType' - ], + ],*/ 'integer'=>[ 'crewType', 'destGeneralID', 'destCityID', 'destNationID', 'amount', 'colorType', 'itemCode' diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 8bf7aca7..fa7e4ca0 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -348,19 +348,7 @@ function preUpdateMonthly() { //첩보-1 foreach($db->queryAllLists("SELECT nation, spy FROM nation WHERE spy!='' AND spy!='{}'") as [$nationNo, $rawSpy]){ - 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 = Json::decode($rawSpy); foreach($spyInfo as $cityNo => $remainMonth){ if($remainMonth <= 1){ diff --git a/hwe/func_process.php b/hwe/func_process.php index 24a34e78..3ac7452d 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -1,8 +1,6 @@ isBuyable() && ($tnmt_type == 0 || $tnmt_type == 1)) { diff --git a/hwe/process_war.php b/hwe/process_war.php index 2e5f3ad5..b62f417b 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -34,7 +34,7 @@ function processWar(General $attackerGeneral, array $rawAttackerNation, array $r $city = new WarUnitCity($rawDefenderCity, $rawDefenderNation, $year, $month, $cityRate); $defenderList = []; - foreach ($db->query('SELECT no,name,nation,turntime,personal,special2,crew,crewtype,atmos,train,intel,intel2,book,strength,strength2,weapon,injury,leadership,leadership2,horse,item,explevel,experience,dedication,level,gold,rice,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar,defence_train FROM general WHERE nation=%i AND city=%i AND nation!=0 and crew > 0 and rice>(crew/100) and train>=defence_train and atmos>=defence_train', $city->getVar('nation'), $city->getVar('city')) as $rawGeneral){ + foreach ($db->query('SELECT no,name,nation,turntime,personal,special,special2,crew,crewtype,atmos,train,intel,intel2,book,strength,strength2,weapon,injury,leadership,leadership2,horse,item,explevel,experience,dedication,level,gold,rice,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar,defence_train FROM general WHERE nation=%i AND city=%i AND nation!=0 and crew > 0 and rice>(crew/100) and train>=defence_train and atmos>=defence_train', $city->getVar('nation'), $city->getVar('city')) as $rawGeneral){ $defenderList[] = new General($rawGeneral, $rawDefenderCity, $year, $month); } @@ -142,8 +142,14 @@ function processWar(General $attackerGeneral, array $rawAttackerNation, array $r $defenderIncTech /= 4; } - $updateAttackerNation['tech'] += $attackerIncTech / max(GameConst::$initialNationGenLimit, $rawAttackerNation['gennum']); - $updateDefenderNation['tech'] += $defenderIncTech / max(GameConst::$initialNationGenLimit, $rawDefenderNation['gennum']); + $updateAttackerNation['tech'] = $db->sqleval( + 'tech + %d', + $attackerIncTech / max(GameConst::$initialNationGenLimit, $rawAttackerNation['gennum']) + ); + $updateDefenderNation['tech'] = $db->sqleval( + 'tech + %d', + $defenderIncTech / max(GameConst::$initialNationGenLimit, $rawDefenderNation['gennum']) + ); $db->update('nation', $updateAttackerNation, 'nation=%i', $attackerNationID); $db->update('nation', $updateDefenderNation, 'nation=%i', $defenderNationID); @@ -702,17 +708,13 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) { $db->update('city', $query, 'city=%i', (int)$city['city']); //전방설정 - if($renewFront){ - foreach(getAllNationStaticInfo() as $nation){ - if($nation['level'] <= 0){ - continue; - } - SetNationFront($nation['nation']); - } - } - else{ - SetNationFront($destnation['nation']); - SetNationFront($conquerNation); + + $nearNationsID = $db->queryFirstColumn( + 'SELECT distinct(nation) FROM city WHERE nation != 0 AND city IN %li', + array_merge(array_keys(CityConst::byID($city['city'])->path), [$city['city']]) + ); + foreach($nearNationsID as $nationNationID){ + SetNationFront($nationNationID); } pushGenLog($general, $log); diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index 89a50868..ed656f60 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -252,7 +252,7 @@ abstract class BaseCommand{ 'destNation'=>$this->destNation, ]; - $this->reasonNotReservable = Constraint::testAll($this->reservableConstraints??[], $constraintInput); + $this->reasonNotReservable = Constraint::testAll($this->reservableConstraints??[], $constraintInput, $this->env); $this->reservable = $this->reasonNotReservable === null; return $this->reasonNotReservable; } @@ -288,7 +288,7 @@ abstract class BaseCommand{ 'destNation'=>$this->destNation, ]; - $this->reasonNotRunnable = Constraint::testAll($this->runnableConstraints??[], $constraintInput); + $this->reasonNotRunnable = Constraint::testAll($this->runnableConstraints??[], $constraintInput, $this->env); $this->runnable = $this->reasonNotRunnable === null; return $this->reasonNotRunnable; diff --git a/hwe/sammo/Command/General/che_귀환.php b/hwe/sammo/Command/General/che_귀환.php index dd2d3b12..432be379 100644 --- a/hwe/sammo/Command/General/che_귀환.php +++ b/hwe/sammo/Command/General/che_귀환.php @@ -71,7 +71,7 @@ class che_귀환 extends Command\GeneralCommand{ $generalLevel = $general->getVar('level'); $target = null; - if(2 <= $generalLevel && 4 <= $generalLevel){ + if(2 <= $generalLevel && $generalLevel <= 4){ $target = $db->queryFirstList( 'SELECT city, name FROM city WHERE %b=%i AND nation = %i', 'officer'.$general->getVar('level'), $generalID, $general->getNationID() diff --git a/hwe/sammo/Command/General/che_인재탐색.php b/hwe/sammo/Command/General/che_인재탐색.php index a2a4c7f4..a12596d4 100644 --- a/hwe/sammo/Command/General/che_인재탐색.php +++ b/hwe/sammo/Command/General/che_인재탐색.php @@ -34,7 +34,7 @@ class che_인재탐색 extends Command\GeneralCommand{ $general = $this->generalObj; - $this->setNation(['gennum']); + $this->setNation(['gennum', 'scout']); $env = $this->env; [$reqGold, $reqRice] = $this->getCost(); diff --git a/hwe/sammo/Command/General/che_임관.php b/hwe/sammo/Command/General/che_임관.php index dd9cd8a2..2929a556 100644 --- a/hwe/sammo/Command/General/che_임관.php +++ b/hwe/sammo/Command/General/che_임관.php @@ -160,6 +160,7 @@ class che_임관 extends Command\GeneralCommand{ $db->update('nation', [ 'gennum'=>$db->sqleval('gennum + 1') ], 'nation=%i', $destNationID); + \sammo\refreshNationStaticInfo(); $relYear = $env['year'] - $env['startyear']; if($general->getVar('npc') == 1 || $relYear >= 3){ diff --git a/hwe/sammo/Command/General/che_출병.php b/hwe/sammo/Command/General/che_출병.php index deb59c45..401090e5 100644 --- a/hwe/sammo/Command/General/che_출병.php +++ b/hwe/sammo/Command/General/che_출병.php @@ -128,7 +128,7 @@ class che_출병 extends Command\GeneralCommand{ $general->applyDB($db); //TODO: 장기적으로 통합해야함 - $attackerNation = $db->queryFirstRow('SELECT nation, name, color, type, level, capital, tech from nation WHERE nation = %i', $attackerNationID); + $attackerNation = $db->queryFirstRow('SELECT nation, name, color, type, level, capital, tech, gennum from nation WHERE nation = %i', $attackerNationID); processWar($general, $attackerNation, $this->destCity); tryUniqueItemLottery($general); diff --git a/hwe/sammo/Command/General/che_하야.php b/hwe/sammo/Command/General/che_하야.php index 46beb856..acfc3195 100644 --- a/hwe/sammo/Command/General/che_하야.php +++ b/hwe/sammo/Command/General/che_하야.php @@ -112,6 +112,7 @@ class che_하야 extends Command\GeneralCommand{ 'rice'=>$db->sqleval('rice + %i', $lostRice), 'gennum'=>$db->sqleval('gennum - 1') ], 'nation=%i', $nationID); + \sammo\refreshNationStaticInfo(); $general->setVar('nation', 0); $general->setVar('level', 0); diff --git a/hwe/sammo/Command/Nation/che_몰수.php b/hwe/sammo/Command/Nation/che_몰수.php index 7350b9b6..ba8692db 100644 --- a/hwe/sammo/Command/Nation/che_몰수.php +++ b/hwe/sammo/Command/Nation/che_몰수.php @@ -8,13 +8,16 @@ use \sammo\{ GameConst, LastTurn, GameUnitConst, - Command + Command, + MessageTarget, + Message }; use function \sammo\{ getDomesticExpLevelBonus, CriticalRatioDomestic, - CriticalScoreEx + CriticalScoreEx, + GetImageURL }; use \sammo\Constraint\Constraint; @@ -70,7 +73,7 @@ class che_몰수 extends Command\NationCommand{ $this->setCity(); $this->setNation(['gold', 'rice']); - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation'], 1); $this->setDestGeneral($destGeneral); $relYear = $env['year'] - $env['startyear']; @@ -118,7 +121,7 @@ class che_몰수 extends Command\NationCommand{ $resName = $isGold?'금':'쌀'; $destGeneral = $this->destGeneralObj; - $amount = Util::valueFit($amount, 0, ($general->getVar[$resKey]- $isGold?GameConst::$generalMinimumGold:GameConst::$generalMinimumRice)); + $amount = Util::valueFit($amount, 0, ($general->getVar($resKey)- $isGold?GameConst::$generalMinimumGold:GameConst::$generalMinimumRice)); $amountText = number_format($amount, 0); if($destGeneral->getVar('npc') >= 2 && Util::randBool(0.01)){ diff --git a/hwe/sammo/Constraint/Constraint.php b/hwe/sammo/Constraint/Constraint.php index 44e8280e..8ef1c656 100644 --- a/hwe/sammo/Constraint/Constraint.php +++ b/hwe/sammo/Constraint/Constraint.php @@ -26,6 +26,8 @@ abstract class Constraint{ protected $nation = null; protected $arg = null; + protected $env = null; + protected $cmd_arg = null; protected $destGeneral = null; @@ -62,6 +64,11 @@ abstract class Constraint{ $this->tested = false; $this->reason = null; } + public function setEnv($env){ + $this->env = $env; + $this->tested = false; + $this->reason = null; + } public function setCmdArg($cmd_arg){ $this->cmd_arg = $cmd_arg; $this->tested = false; @@ -182,7 +189,7 @@ abstract class Constraint{ return $this->reason; } - public static function testAll(array $constraintPacks, array $input):?string{ + public static function testAll(array $constraintPacks, array $input, array $env):?string{ foreach($constraintPacks as $constraintArgs){ if (!$constraintArgs){ continue; @@ -194,7 +201,7 @@ abstract class Constraint{ $constraint = call_user_func($method,$input); assert($constraint instanceof Constraint); - + $constraint->setEnv($env); if(count($constraintArgs) == 2){ $arg = $constraintArgs[1]; $constraint->setArg($arg); diff --git a/hwe/sammo/Constraint/ReqEnvValue.php b/hwe/sammo/Constraint/ReqEnvValue.php index e655daa1..54ba60b1 100644 --- a/hwe/sammo/Constraint/ReqEnvValue.php +++ b/hwe/sammo/Constraint/ReqEnvValue.php @@ -23,11 +23,11 @@ class ReqEnvValue extends Constraint{ } if(count($this->arg) == 4){ - [$this->key, $this->reqVal, $comp, $this->msg] = $this->arg; + [$this->key, $comp, $this->reqVal, $this->msg] = $this->arg; if(!in_array($comp, ['>', '>=', '==', '<=', '<', '!=', '===', '!=='])){ if(!$throwExeception){return false; } - throw new \InvalidArgumentException("invalid comparator"); + throw new \InvalidArgumentException("invalid comparator($comp)"); } } else{ diff --git a/hwe/sammo/DummyGeneral.php b/hwe/sammo/DummyGeneral.php index c51b61b7..e0b4833a 100644 --- a/hwe/sammo/DummyGeneral.php +++ b/hwe/sammo/DummyGeneral.php @@ -9,7 +9,8 @@ class DummyGeneral extends General{ 'city'=>0, 'nation'=>0, 'level'=>0, - 'crewtype'=>-1 + 'crewtype'=>-1, + 'turntime'=>'2012-03-04 05:06:07.000000' ]; $this->raw = $raw; diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 2099ff96..c588d8ae 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -127,13 +127,20 @@ class GeneralAI{ $this->attackable = ($frontStatus !== null)?$frontStatus:false; $warTarget = $db->queryAllLists( - 'SELECT you, state FROM diplomacy WHERE me = %i AND (state = 1 OR (state = 0 AND term < 5))', + 'SELECT you, state FROM diplomacy WHERE me = %i AND (state = 0 OR (state = 1 AND term < 5))', $nationID ); + $onWar = false; $warTargetNation = []; foreach($warTarget as [$warNationID, $warState]){ - $warTargetNation[$warNationID] = $warState==0?2:1; + if($warState == 0){ + $onWar = true; + $warTargetNation[$warNationID] = 2; + } + else{ + $warTargetNation[$warNationID] = 1; + } } $warTargetNation[0] = 0; $this->warTargetNation = $warTargetNation; @@ -153,20 +160,14 @@ class GeneralAI{ $this->dipState = self::d직전; } - if( - in_array($this->dipState, [self::d평화, self::d선포]) || - $env['year'] >= $env['startyear'] + 3 || - ($env['year'] && $env['startyear'] + 2 && $env['month'] > 5) - ){ - $this->dipState = self::d징병; - } - if($this->attackable){ //전쟁으로 인한 attackable인가? - $onWar = $db->queryFirstField('SELECT you FROM diplomacy WHERE me = %i AND state=0 LIMIT 1', $nationID) !== null; if($onWar){ $this->dipState = self::d전쟁; } + else{ + $this->dipState = self::d징병; + } } } @@ -194,8 +195,8 @@ class GeneralAI{ ]; // 우선 선정 - if($develRate['trust'] < 0.95 && Util::randBool($leadership / 40)){ - return ['che_선정', null]; + if($develRate['trust'] < 1 && Util::randBool($leadership / 60)){ + return ['che_주민선정', null]; } $commandList = []; @@ -248,7 +249,14 @@ class GeneralAI{ if(!TechLimit($env['startyear'], $env['year'], $nation['tech'])){ $commandObj = buildGeneralCommandClass('che_기술연구', $general, $env); if($commandObj->isRunnable()){ - $commandList['che_기술연구'] = $intel / 4; + if(!TechLimit($env['startyear'], $env['year'], $nation['tech']+1000)){ + //한등급 이상 뒤쳐져 있다면, 조금 더 열심히 하자. + $commandList['che_기술연구'] = $intel; + } + else{ + $commandList['che_기술연구'] = $intel / 4; + } + } } } @@ -256,7 +264,7 @@ class GeneralAI{ if($develRate['trust'] < 1){ $commandObj = buildGeneralCommandClass('che_주민선정', $general, $env); if($commandObj->isRunnable()){ - $commandList['che_주민선정'] = $leadership / 2; + $commandList['che_주민선정'] = power($leadership * 2, 1 / ($develRate['trust'] + 0.001)); } } if($develRate['pop'] < 0.99){ @@ -283,7 +291,7 @@ class GeneralAI{ $commandList['che_물자조달'] = ( (GameConst::$minNationalGold + GameConst::$minNationalRice + 24*5*$env['develcost']) / Util::valueFit($nation['gold'] + $nation['rice'], (GameConst::$defaultGold + GameConst::$defaultRice)/2) - ) * 10; + ); return [Util::choiceRandomUsingWeight($commandList), null]; } @@ -507,6 +515,8 @@ class GeneralAI{ } if($generalObj->getVar('level') == 12 && $this->dipState == self::d평화 && !$this->attackable){ + + $targetNationID = $this->findWarTarget(); if($targetNationID !== null){ return ['che_선전포고', ['destNationID'=>$targetNationID]]; @@ -1357,7 +1367,7 @@ class GeneralAI{ $db = DB::db(); $general = $this->getGeneralObj(); - if(!$this->attackable && in_array($this->dipState, [self::d평화, self::d선포])){ + if(!$this->attackable && $this->dipState == self::d평화){ if($this->dipState == self::d평화 && $general->getVar('crew')>=1000 && Util::randBool(0.25)){ return ['che_소집해제', null]; } @@ -1516,7 +1526,7 @@ class GeneralAI{ $db = DB::db(); if($city['front'] <= 1){ - throw new \RuntimeException('출병 불가'); + throw new \RuntimeException('출병 불가'.$cityID); } $attackableNations = []; @@ -1534,6 +1544,10 @@ class GeneralAI{ $nearCities ); + if(count($attackableCities) == 0){ + throw new \RuntimeException('출병 불가'.$cityID.var_export($attackableNations, true).var_export($nearCities, true)); + } + return ['che_출병', ['destCityID'=>Util::choiceRandom($attackableCities)]]; } @@ -1656,7 +1670,7 @@ class GeneralAI{ $nationID = $this->nation['nation']; $this->devRate = $db->queryFirstRow( - 'SELECT sum(pop)/sum(pop2)*100 as pop_p,(sum(agri)+sum(comm)+sum(secu)+sum(def)+sum(wall))/(sum(agri2)+sum(comm2)+sum(secu2)+sum(def2)+sum(wall2))*100 as all_p from city where nation=%i', + 'SELECT sum(pop)/sum(pop2) as pop_p,(sum(agri)+sum(comm)+sum(secu)+sum(def)+sum(wall))/(sum(agri2)+sum(comm2)+sum(secu2)+sum(def2)+sum(wall2)) as all_p from city where nation=%i', $nationID ); return $this->devRate; @@ -1676,7 +1690,7 @@ class GeneralAI{ } $devRate = $this->getNationDevelopedRate(); - if(($devRate['pop_p'] + $devRate['all_p']) / 2 < 80){ + if(($devRate['pop_p'] + $devRate['all_p']) / 2 < 0.8){ return null; } @@ -1829,9 +1843,9 @@ class GeneralAI{ $avg = ($devRate['pop_p'] + $devRate['all_p']) / 2; - if($avg > 95) $rate = 25; - elseif($avg > 70) $rate = 20; - elseif($avg > 50) $rate = 15; + if($avg > 0.95) $rate = 25; + elseif($avg > 0.70) $rate = 20; + elseif($avg > 0.50) $rate = 15; else $rate = 10; $db->update('nation', [ diff --git a/hwe/sammo/TextDecoration/DyingMessage.php b/hwe/sammo/TextDecoration/DyingMessage.php index 84f778bc..4d2e10e6 100644 --- a/hwe/sammo/TextDecoration/DyingMessage.php +++ b/hwe/sammo/TextDecoration/DyingMessage.php @@ -97,7 +97,7 @@ class DyingMessage{ $this->general = $general; $this->name = $general->getName(); $this->npc = $general->getVar('npc'); - if($general['owner'] > 0 && $general->getVar('startage') - $general->getVar('age') > 1){ + if($general->getVar('owner') > 0 && $general->getVar('startage') - $general->getVar('age') > 1){ $this->realName = $general->getVar('name2'); } } diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index 3356315d..21aaea88 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -238,7 +238,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC', $general->getVar('level') )??[]; $hasNationTurn = true; - $nationCommand = $rawNationTurn['action']; + $nationCommand = $rawNationTurn['action']??null; $nationArg = Json::decode($rawNationTurn['arg']??null); } @@ -410,13 +410,6 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC', $gameStor->turntime = $currentTurn; } - - // 부상 과도 제한 - //TODO: 없애고, 부상 자체가 80 이상 넘지 않도록 처리 - $db->update('general', [ - 'injury'=>80 - ], 'injury>%i', 80); - //토너먼트 처리 processTournament(); //거래 처리 diff --git a/hwe/sammo/WarUnitGeneral.php b/hwe/sammo/WarUnitGeneral.php index 812994cc..ce51ed70 100644 --- a/hwe/sammo/WarUnitGeneral.php +++ b/hwe/sammo/WarUnitGeneral.php @@ -52,7 +52,7 @@ class WarUnitGeneral extends WarUnit{ $general->updateVar('recwar', $general->getTurnTime()); } else if($oppose !== null){ - $general->updateVar('recwar', $oppose->getTurnTime()); + $general->updateVar('recwar', $oppose->getGeneral()->getTurnTime()); } } diff --git a/hwe/sammo/WarUnitTrigger/che_위압시도.php b/hwe/sammo/WarUnitTrigger/che_위압시도.php index 2d4c5c05..5327e3b0 100644 --- a/hwe/sammo/WarUnitTrigger/che_위압시도.php +++ b/hwe/sammo/WarUnitTrigger/che_위압시도.php @@ -32,7 +32,7 @@ class che_위압시도 extends BaseWarUnitTrigger{ return true; } - $this->activateSkill('위압'); + $self->activateSkill('위압'); return true; } } \ No newline at end of file diff --git a/hwe/sammo/WarUnitTrigger/che_저격시도.php b/hwe/sammo/WarUnitTrigger/che_저격시도.php index f60ce4a9..2d16ab80 100644 --- a/hwe/sammo/WarUnitTrigger/che_저격시도.php +++ b/hwe/sammo/WarUnitTrigger/che_저격시도.php @@ -6,6 +6,7 @@ use sammo\WarUnitCity; use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\ObjectTrigger; +use sammo\Util; class che_저격시도 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_PRE + 100; @@ -37,7 +38,7 @@ class che_저격시도 extends BaseWarUnitTrigger{ return true; } - $this->activateSkill('저격'); + $self->activateSkill('저격'); $selfEnv['woundMin'] = $this->woundMin; $selfEnv['woundMax'] = $this->woundMax; diff --git a/hwe/sammo/WarUnitTrigger/che_전투치료시도.php b/hwe/sammo/WarUnitTrigger/che_전투치료시도.php index a423d316..6730fec0 100644 --- a/hwe/sammo/WarUnitTrigger/che_전투치료시도.php +++ b/hwe/sammo/WarUnitTrigger/che_전투치료시도.php @@ -22,7 +22,7 @@ class che_전투치료시도 extends BaseWarUnitTrigger{ return true; } - $this->activateSkill('치료'); + $self->activateSkill('치료'); return true; diff --git a/hwe/sammo/WarUnitTrigger/che_회피시도.php b/hwe/sammo/WarUnitTrigger/che_회피시도.php index 2856579c..512e68a9 100644 --- a/hwe/sammo/WarUnitTrigger/che_회피시도.php +++ b/hwe/sammo/WarUnitTrigger/che_회피시도.php @@ -25,7 +25,7 @@ class che_회피시도 extends BaseWarUnitTrigger{ return true; } - $this->activateSkill('특수', '회피시도', '회피'); + $self->activateSkill('특수', '회피시도', '회피'); return true; diff --git a/src/sammo/JosaUtil.php b/src/sammo/JosaUtil.php index 3a2e9270..d078e44c 100644 --- a/src/sammo/JosaUtil.php +++ b/src/sammo/JosaUtil.php @@ -610,6 +610,9 @@ class JosaUtil{ $search = []; $replace = []; + $prefix = ':'; + $postfix = ':'; + foreach(static::DEFAULT_POSTPOSITION as $wJong => $woJong){ $value = JosaUtil::pick($key, $wJong); $search[] = "{$prefix}{$wJong}{$postfix}"; diff --git a/src/sammo/Util.php b/src/sammo/Util.php index 31741736..df065ebb 100644 --- a/src/sammo/Util.php +++ b/src/sammo/Util.php @@ -571,7 +571,7 @@ class Util extends \utilphp\util * * @param array $items 선택하고자 하는 배열 * - * @return object 선택된 value값. + * @return int|float|string|object 선택된 value값. */ public static function choiceRandom(array $items) {