diff --git a/hwe/func.php b/hwe/func.php index b9f916b1..6b7d3e32 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1510,7 +1510,7 @@ function tryUniqueItemLottery(General $general, string $acquireType='아이템') [$itemType, $itemCode] = Util::choiceRandomUsingWeightPair($availableUnique); $nationName = $general->getStaticNation()['name']; - $generalName = $general->getNation(); + $generalName = $general->getName(); $josaYi = JosaUtil::pick($generalName, '이'); $itemName = getItemName($itemCode); $josaUl = JosaUtil::pick($itemName, '을'); diff --git a/hwe/js/processing.js b/hwe/js/processing.js index 4a9d59b8..258bd4e6 100644 --- a/hwe/js/processing.js +++ b/hwe/js/processing.js @@ -54,7 +54,14 @@ $('#commonSubmit').click(function(){ return parseInt($obj.eq(0).val()); }, 'boolean':function($obj){ - return !!($obj.eq(0).val()); + switch ($obj.eq(0).val().toLowerCase()) { + case "true": case "yes": case "1": + return true; + case "false": case "no": case "0": + return false; + default: + throw new Error ("Boolean.parse: Cannot convert string to boolean."); + } }, 'integerArray':function($obj){ return $obj.map(function(){ diff --git a/hwe/sammo/Command/General/che_강행.php b/hwe/sammo/Command/General/che_강행.php index 557e4316..a57e3afc 100644 --- a/hwe/sammo/Command/General/che_강행.php +++ b/hwe/sammo/Command/General/che_강행.php @@ -168,23 +168,22 @@ class che_강행 extends Command\GeneralCommand{ public function getForm(): string { $currentCityID = $this->generalObj->getCityID(); - - $form = []; - $form[] = \sammo\getMapHtml(); $currentCityName = CityConst::byID($currentCityID)->name; - $form[] = << +
선택된 도시로 강행합니다.
최대 3칸내 도시로만 강행이 가능합니다.
목록을 선택하거나 도시를 클릭하세요.
-{$currentCityName} => '; - $form[] = ''; - $form[] = printCitiesBasedOnDistance($currentCityID, 3); - - return join("
\n",$form); + =>
+
+
+ +arg['nationName']; + $josaUl = JosaUtil::pick($nationName, '을'); + return "【{$nationName}】{$josaUl} 건국"; + } + public function getCost():array{ return [0, 0]; } @@ -211,44 +218,42 @@ class che_건국 extends Command\GeneralCommand{ */ - $form = []; + ob_start(); +?> +현재 도시에서 나라를 세웁니다. 중, 소도시에서만 가능합니다.
- $form[] = '현재 도시에서 나라를 세웁니다. 중, 소도시에서만 가능합니다.

'; +getName(), $nationClass::$pros, $nationClass::$cons]; - $form[] = "- $name : {$pros} {$cons}
"; - - } - $form[] = <<getName(), $nationClass::$pros, $nationClass::$cons]; +?> + + - :
+
국명 : 색깔 : 성향 : '; - $form[] = ''; - - return join("\n",$form); +getName(); +?> + + + + +arg['amount']??null; if(!is_int($amount)){ return false; @@ -53,6 +54,12 @@ class che_군량매매 extends Command\GeneralCommand{ return true; } + public function getBrief(): string + { + $buyRiceText = $this->arg['buyRice']?'구입':'판매'; + return "군량 {$this->arg['amount']}을 {$buyRiceText}"; + } + protected function init(){ $general = $this->generalObj; @@ -174,5 +181,42 @@ class che_군량매매 extends Command\GeneralCommand{ return true; } + public function getForm(): string + { + ob_start(); +?> +자신의 군량을 사거나 팝니다.
+ +
+generalObj; $this->setCity(); - $this->setNation(); + $this->setNation(['gennum', 'scout']); $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], 0); $this->setDestGeneral($destGeneral); @@ -153,14 +153,7 @@ class che_등용 extends Command\GeneralCommand{ public function getForm(): string { $db = DB::db(); - $form = []; - $form[] = << -서신은 개인 메세지로 전달됩니다.
-등용할 장수를 목록에서 선택하세요.
- + + '>【】 + + + + + - $form[] = ''; - $form[] = ''; - - return join("\n",$form); +
+ generalObj->getCityID(); - - $form = []; - $form[] = \sammo\getMapHtml(); $currentCityName = CityConst::byID($currentCityID)->name; - $form[] = << +
선택된 도시로 이동합니다.
인접 도시로만 이동이 가능합니다.
목록을 선택하거나 도시를 클릭하세요.
-{$currentCityName} => '; - $form[] = ''; - $form[] = printCitiesBasedOnDistance($currentCityID, 1); - - return join("
\n",$form); + =>
+
+
+ +runnableConstraints=[ - ConstraintHelper::ReqEnvValue('join_mode', '==', 'onlyRandom', '랜덤 임관만 가능합니다'), + ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'), ConstraintHelper::BeNeutral(), ConstraintHelper::ExistsDestNation(), ConstraintHelper::AllowJoinDestNation($relYear), @@ -113,6 +115,13 @@ class che_임관 extends Command\GeneralCommand{ return 0; } + public function getBrief():string{ + $commandName = $this->getName(); + $destNationName = getNationStaticInfo($this->arg['destNationID'])['name']; + $josaRo = JosaUtil::pick($destNationName, '로'); + return "【{$destNationName}】{$josaRo} {$commandName}"; + } + public function run():bool{ if(!$this->isRunnable()){ throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); @@ -153,7 +162,7 @@ class che_임관 extends Command\GeneralCommand{ $general->setVar('city', $this->destGeneralObj->getCityID()); } else{ - $targetCityID = $db->queryFirstField('SELECT city FROM nation WHERE nation = %i AND level=12', $destNationID); + $targetCityID = $db->queryFirstField('SELECT city FROM general WHERE nation = %i AND level=12', $destNationID); $general->setVar('city', $targetCityID); } @@ -187,18 +196,13 @@ class che_임관 extends Command\GeneralCommand{ $env = $this->env; - $joinedNations = Json::decode($db->queryFirstField('SELECT nations FROM general WHERE no = %i', $generalObj->getID())); + $joinedNations = \sammo\Json::decode($db->queryFirstField('SELECT nations FROM general WHERE no = %i', $generalObj->getID())); $nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg,gennum FROM nation'); shuffle($nationList); - $onlyRandom = $env['join_mode'] == 'onlyRandom'; - foreach($nationList as &$nation){ - if ($onlyRandom && TimeUtil::IsRangeMonth($env['init_year'], $env['init_month'], 1, $env['year'], $env['month']) && $nation['gennum'] >= GameConst::$initialNationGenLimitForRandInit) { - $nation['availableJoin'] = false; - } - else if($env['year'] < $env['startyear']+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){ + if($env['year'] < $env['startyear']+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){ $nation['availableJoin'] = false; } else if($nation['scout'] == 1) { @@ -213,26 +217,22 @@ class che_임관 extends Command\GeneralCommand{ } } unset($nation); - - $form[] = << 국가에 임관합니다.
이미 임관/등용되었던 국가는 다시 임관할 수 없습니다.
바로 군주의 위치로 이동합니다.
임관할 국가를 목록에서 선택하세요.
-EOT; - $form[] = getInvitationList($nationList); - return join("\n",$form); + + + + + +query('SELECT no,name,level,npc,gold,rice FROM general WHERE nation != 0 AND nation = %i AND no != %i ORDER BY npc,binary(name)',$this->generalObj->getNationID(), $this->generalObj->getID()); + ob_start(); +?> 자신의 자금이나 군량을 다른 장수에게 증여합니다.
장수를 선택하세요.
- - -EOT; - return join("\n",$form); +
+arg['isGold']?'금':'쌀'; + $name = $this->getName(); + return "{$resText} {$this->arg['amount']}을 {$name}"; + } + public function getCommandDetailTitle():string{ $name = $this->getName(); return "{$name}(통솔경험)"; @@ -137,42 +144,38 @@ class che_헌납 extends Command\GeneralCommand{ public function getForm(): string { - //TODO: 암행부처럼 보여야... - $form = []; - - $form[] = << - + + - - - -EOT; - return join("\n",$form); +
+generalObj->getCityID(); + $commandName = $this->getName(); + $josaUl = JosaUtil::pick($commandName, '을'); - $josaUl = JosaUtil::pick($this->getName(), '을'); - - $form[] = <<getName()}{$josaUl} 실행합니다.
+ ob_start(); +?> +
+선택된 도시에 실행합니다.
목록을 선택하거나 도시를 클릭하세요.
-'; - $form[] = "
+
+
+
+
+ +nation)){ + if(!key_exists('scout', $this->destNation)){ if(!$throwExeception){return false; } throw new \InvalidArgumentException("require scout in nation"); } - if(!key_exists('gennum', $this->nation)){ + if(!key_exists('gennum', $this->destNation)){ if(!$throwExeception){return false; } throw new \InvalidArgumentException("require gennum in nation"); } @@ -50,7 +50,7 @@ class AllowJoinDestNation extends Constraint{ return false; } - $joinedNations = Json::decode($this->general['nations']); + $joinedNations = \sammo\Json::decode($this->general['nations']); if(in_array($this->destNation['nation'], $joinedNations)){ $this->reason = "이미 임관했었던 국가입니다."; return false; diff --git a/hwe/sammo/Constraint/ReqNationalGold.php b/hwe/sammo/Constraint/ReqNationGold.php similarity index 100% rename from hwe/sammo/Constraint/ReqNationalGold.php rename to hwe/sammo/Constraint/ReqNationGold.php diff --git a/hwe/sammo/Constraint/ReqNationalRice.php b/hwe/sammo/Constraint/ReqNationRice.php similarity index 100% rename from hwe/sammo/Constraint/ReqNationalRice.php rename to hwe/sammo/Constraint/ReqNationRice.php diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 3770bdc0..d70cf64d 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -226,6 +226,7 @@ class GameConstBase 'che_이동', 'che_강행', 'che_인재탐색', + 'che_등용', 'che_집합', 'che_귀환', 'che_임관', diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index e680c101..2fed19ab 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -430,7 +430,7 @@ class GeneralAI{ if($targetNpcWarGeneral->$resName < $reqMoney){ //국고 1/5과 '충분한 금액'의 기하평균 - $payAmount = sqrt($enoughMoney - $reqMoney, $remainResource[$resName] / 5); + $payAmount = sqrt(($enoughMoney - $reqMoney) * ($remainResource[$resName] / 5)); if ($remainResource[$resName] >= $payAmount / 2) { $candidateCommand[] = [ ['che_포상', [ @@ -454,7 +454,7 @@ class GeneralAI{ if($targetNpcWarGeneral->$resName < $reqMoney){ //국고와 '충분한 금액'의 기하평균 - $payAmount = sqrt($enoughMoney - $reqMoney, $remainResource[$resName]); + $payAmount = sqrt(($enoughMoney - $reqMoney) * $remainResource[$resName]); if($remainResource[$resName] >= $payAmount / 2){ $candidateCommand[] = [ @@ -672,7 +672,7 @@ class GeneralAI{ $isWarUser = null; foreach($userGenerals as $compUser){ - if($compUser['leadership'] >= 50){ + if($compUser->leadership >= 50){ $isWarUser = true; break; } @@ -686,7 +686,7 @@ class GeneralAI{ break; } - $compRes = $compUser[$resName]; + $compRes = $compUser->$resName; $work = false; if(!$isWarUser){ @@ -697,7 +697,7 @@ class GeneralAI{ $work = true; } - if((($isWarUser || $resName == 'gold') && $compUser[$resName] < 21000) || ($compUser[$resName] < 5000)){ + if((($isWarUser || $resName == 'gold') && $compUser->$resName < 21000) || ($compUser->$resName < 5000)){ if($work){ $amount = min(100, intdiv(($nation[$resName]-($resName=='rice'?(GameConst::$baserice):(GameConst::$basegold))), 3000)*10 + 10); $commandList[] = [['che_포상', [ diff --git a/hwe/sammo/LazyVarUpdater.php b/hwe/sammo/LazyVarUpdater.php index 327a1680..a6b887dd 100644 --- a/hwe/sammo/LazyVarUpdater.php +++ b/hwe/sammo/LazyVarUpdater.php @@ -31,12 +31,12 @@ trait LazyVarUpdater{ } function updateVar(string $key, $value){ - if($this->raw[$key] === $value){ - return; - } if(!key_exists($key, $this->updatedVar)){ $this->updatedVar[$key] = $this->raw[$key]; } + if($this->raw[$key] === $value){ + return; + } $this->raw[$key] = $value; }