diff --git a/hwe/b_processing.php b/hwe/b_processing.php
index 797a809a..633421cc 100644
--- a/hwe/b_processing.php
+++ b/hwe/b_processing.php
@@ -1,127 +1,131 @@
-setReadOnly();
-
-$db = DB::db();
-
-if(!$isChiefTurn && !in_array($commandType, Util::array_flatten(GameConst::$availableGeneralCommand))){
- die_redirect();
-}
-
-if($isChiefTurn && !in_array($commandType, Util::array_flatten(GameConst::$availableChiefCommand))){
- die_redirect();
-}
-
-$gameStor = KVStorage::getStorage($db, 'game_env')->turnOnCache();
-$env = $gameStor->getAll();
-$general = General::createGeneralObjFromDB($session->generalID);
-
-if(!$isChiefTurn){
- $commandObj = buildGeneralCommandClass($commandType, $general, $env);
-}
-else{
- if($general->getVar('officer_level') < 5){
- die_redirect();
- }
- $commandObj = buildNationCommandClass($commandType, $general, $env, new LastTurn());
-}
-
-
-if($commandObj->isArgValid()){
- //인자가 필요없는 타입의 경우 processing에서 '전혀' 처리하지 않음!
- die_redirect();
-}
-
-if(!$commandObj->hasPermissionToReserve()){
- die_redirect();
-}
-
-$jsList = $commandObj->getJSFiles();
-$cssList = $commandObj->getCSSFiles();
-?>
-
-
-
-
-=$commandObj->getName()?>
-
-
-
-=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
-=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
-=WebUtil::printJS('../d_shared/common_path.js')?>
-=WebUtil::printJS('js/common.js')?>
-=WebUtil::printJS('d_shared/base_map.js')?>
-=WebUtil::printJS('js/map.js')?>
-=WebUtil::printJS('js/processing.js')?>
-
-
-=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
-=WebUtil::printCSS('../d_shared/common.css')?>
-=WebUtil::printCSS('css/common.css')?>
-=WebUtil::printCSS('css/main.css')?>
-=WebUtil::printCSS('css/map.css')?>
-
-
-
-
-
-
-=$commandObj->getForm()?>
-
-
-
-
-
-
-
+setReadOnly();
+
+$db = DB::db();
+
+if(!$isChiefTurn && !in_array($commandType, Util::array_flatten(GameConst::$availableGeneralCommand))){
+ die_redirect();
+}
+
+if($isChiefTurn && !in_array($commandType, Util::array_flatten(GameConst::$availableChiefCommand))){
+ die_redirect();
+}
+
+$gameStor = KVStorage::getStorage($db, 'game_env')->turnOnCache();
+$env = $gameStor->getAll();
+$general = General::createGeneralObjFromDB($session->generalID);
+
+if(!$isChiefTurn){
+ $commandObj = buildGeneralCommandClass($commandType, $general, $env);
+}
+else{
+ if($general->getVar('officer_level') < 5){
+ die_redirect();
+ }
+ $commandObj = buildNationCommandClass($commandType, $general, $env, new LastTurn());
+}
+
+
+if($commandObj->isArgValid()){
+ //인자가 필요없는 타입의 경우 processing에서 '전혀' 처리하지 않음!
+ die_redirect();
+}
+
+if(!$commandObj->hasPermissionToReserve()){
+ die_redirect();
+}
+
+$jsList = $commandObj->getJSFiles();
+$cssList = $commandObj->getCSSFiles();
+?>
+
+
+
+
+=$commandObj->getName()?>
+
+
+
+=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
+=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
+=WebUtil::printJS('../e_lib/select2/select2.full.min.js')?>
+=WebUtil::printJS('../d_shared/common_path.js')?>
+=WebUtil::printJS('js/common.js')?>
+=WebUtil::printJS('d_shared/base_map.js')?>
+=WebUtil::printJS('js/map.js')?>
+=WebUtil::printJS('js/processing.js')?>
+
+
+=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
+=WebUtil::printCSS('../e_lib/select2/select2.min.css')?>
+=WebUtil::printCSS('../e_lib/select2/select2-bootstrap4.css')?>
+=WebUtil::printCSS('../d_shared/common.css')?>
+=WebUtil::printCSS('css/common.css')?>
+=WebUtil::printCSS('css/main.css')?>
+=WebUtil::printCSS('css/map.css')?>
+=WebUtil::printCSS('css/processing.css')?>
+
+
+
+
+
+
+=$commandObj->getForm()?>
+
+
+
+
+
+
+
diff --git a/hwe/css/processing.css b/hwe/css/processing.css
new file mode 100644
index 00000000..00f5ccb7
--- /dev/null
+++ b/hwe/css/processing.css
@@ -0,0 +1,11 @@
+#amount {
+ width: 100px;
+}
+
+#colorType {
+ width: 150px;
+}
+
+.no-padding .select2-results__option {
+ padding: 0;
+}
\ No newline at end of file
diff --git a/hwe/js/processing.js b/hwe/js/processing.js
index 365866da..26683855 100644
--- a/hwe/js/processing.js
+++ b/hwe/js/processing.js
@@ -1,102 +1,243 @@
-function reserveTurn(turnList, command, arg){
- var target;
- if(isChiefTurn){
- target = 'j_set_chief_command.php';
- }
- else{
- target = 'j_set_general_command.php';
- }
- $.post({
- url:target,
- dataType:'json',
- data:{
- action:command,
- turnList:turnList,
- arg:JSON.stringify(arg)
- }
- }).then(function(data){
- if(!data.result){
- alert(data.reason);
- return;
- }
-
- if(!isChiefTurn){
- window.location.href = './';
- }
- else{
- window.location.href = 'b_chiefcenter.php';
- }
-
- }, errUnknown);
-}
-
-jQuery(function($){
-
-window.submitAction = function(){
-
- //checkCommandArg 참고
- var availableArgumentList = {
- 'string':[
- 'nationName', 'optionText', 'itemType', 'nationType', 'itemCode',
- ],
- 'int':[
- 'crewType', 'destGeneralID', 'destCityID', 'destNationID',
- 'amount', 'colorType',
- 'year', 'month',
- 'srcArmType', 'destArmType', //숙련전환 전용
- ],
- 'boolean':[
- 'isGold', 'buyRice',
- ],
- 'integerArray':[
- 'destNationIDList', 'destGeneralIDList', 'amountList'
- ]
- }
-
- var handlerList = {
- 'string':function($obj){
- return $.trim($obj.eq(0).val());
- },
- 'int':function($obj){
- return parseInt($obj.eq(0).val());
- },
- 'boolean':function($obj){
- 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(){
- return parseInt($(this).val());
- });
- }
- }
-
- var argument = {};
- for (var typeName in availableArgumentList) {
- availableArgumentList[typeName].forEach(function(argName){
- var $obj = $('#'+argName);
- if($obj.length == 0){
- $obj = $('.'+argName);
- if($obj.length == 0){
- return;
- }
- }
-
- argument[argName] = handlerList[typeName]($obj);
- });
- }
-
- console.log(argument);
- reserveTurn(turnList, command, argument);
-};
-
-$('#commonSubmit').click(submitAction);
-
-
+function reserveTurn(turnList, command, arg) {
+ var target;
+ if (isChiefTurn) {
+ target = 'j_set_chief_command.php';
+ } else {
+ target = 'j_set_general_command.php';
+ }
+ $.post({
+ url: target,
+ dataType: 'json',
+ data: {
+ action: command,
+ turnList: turnList,
+ arg: JSON.stringify(arg)
+ }
+ }).then(function(data) {
+ if (!data.result) {
+ alert(data.reason);
+ return;
+ }
+
+ if (!isChiefTurn) {
+ window.location.href = './';
+ } else {
+ window.location.href = 'b_chiefcenter.php';
+ }
+
+ }, errUnknown);
+}
+
+jQuery(function($) {
+
+ window.submitAction = function() {
+
+ //checkCommandArg 참고
+ var availableArgumentList = {
+ 'string': [
+ 'nationName', 'optionText', 'itemType', 'nationType', 'itemCode',
+ ],
+ 'int': [
+ 'crewType', 'destGeneralID', 'destCityID', 'destNationID',
+ 'amount', 'colorType',
+ 'year', 'month',
+ 'srcArmType', 'destArmType', //숙련전환 전용
+ ],
+ 'boolean': [
+ 'isGold', 'buyRice',
+ ],
+ 'integerArray': [
+ 'destNationIDList', 'destGeneralIDList', 'amountList'
+ ]
+ }
+
+ var handlerList = {
+ 'string': function($obj) {
+ return $.trim($obj.eq(0).val());
+ },
+ 'int': function($obj) {
+ return parseInt($obj.eq(0).val());
+ },
+ 'boolean': function($obj) {
+ 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() {
+ return parseInt($(this).val());
+ });
+ }
+ }
+
+ var argument = {};
+ for (var typeName in availableArgumentList) {
+ availableArgumentList[typeName].forEach(function(argName) {
+ var $obj = $('#' + argName);
+ if ($obj.length == 0) {
+ $obj = $('.' + argName);
+ if ($obj.length == 0) {
+ return;
+ }
+ }
+
+ argument[argName] = handlerList[typeName]($obj);
+ });
+ }
+
+ console.log(argument);
+ reserveTurn(turnList, command, argument);
+ };
+
+ $('#commonSubmit').click(submitAction);
+
+ var $colorType = $('#colorType');
+ if ($colorType.length) {
+ $colorType.select2({
+ theme: 'bootstrap4',
+ placeholder: "색상을 선택해 주세요.",
+ language: "ko",
+ containerCss: {
+ display: "inline-block !important",
+ color: 'white !important',
+ },
+ templateSelection: function(item) {
+ if (item.disabled) {
+ return item.text;
+ }
+ var bgcolor = item.element.dataset.color;
+ var fgcolor = item.element.dataset.fontColor;
+ return $(" {2}".format(
+ bgcolor, fgcolor, item.text
+ ));
+ },
+ templateResult: function(item) {
+ if (item.disabled) {
+ return item.text;
+ }
+ var bgcolor = item.element.dataset.color;
+ var fgcolor = item.element.dataset.fontColor;
+ return $("{2}
".format(
+ bgcolor, fgcolor, item.text
+ ));
+ },
+ containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ dropdownCssClass: 'no-padding simple-select2-align-center bg-secondary text-secondary',
+ });
+ }
+
+ var $nationType = $('#nationType');
+ if ($nationType.length) {
+ $nationType.select2({
+ theme: 'bootstrap4',
+ language: "ko",
+ containerCss: {
+ display: "inline-block !important",
+ color: 'white !important',
+ },
+ containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ });
+ }
+
+ var $destCityID = $('#destCityID');
+ if ($destCityID.length) {
+ $destCityID.select2({
+ theme: 'bootstrap4',
+ placeholder: "도시를 선택해 주세요.",
+ language: "ko",
+ containerCss: {
+ display: "inline-block !important",
+ color: 'white !important',
+ },
+ containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ });
+ }
+
+ var $destNationID = $('#destNationID');
+ if ($destNationID.length) {
+ $destNationID.select2({
+ theme: 'bootstrap4',
+ placeholder: "국가를 선택해 주세요.",
+ language: "ko",
+ containerCss: {
+ display: "inline-block !important",
+ color: 'white !important',
+ },
+ containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ });
+ }
+
+ var $destGeneralID = $('#destGeneralID');
+ if ($destGeneralID.length) {
+ $destGeneralID.select2({
+ theme: 'bootstrap4',
+ placeholder: "장수를 선택해 주세요.",
+ language: "ko",
+ containerCss: {
+ display: "inline-block !important",
+ color: 'white !important',
+ },
+ containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ });
+ }
+
+ var $isGold = $('#isGold');
+ if ($isGold.length) {
+ $isGold.select2({
+ theme: 'bootstrap4',
+ placeholder: "분량을 지정해 주세요.",
+ language: "ko",
+ containerCss: {
+ display: "inline-block !important",
+ color: 'white !important',
+ },
+ minimumResultsForSearch: -1,
+ containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ });
+ }
+
+ var $amount = $('#amount:not([type=hidden])');
+ if ($amount.length) {
+ $amount.select2({
+ theme: 'bootstrap4',
+ placeholder: "분량을 지정해 주세요.",
+ allowClear: false,
+ language: "ko",
+ containerCss: {
+ display: "inline-block !important",
+ color: 'white !important',
+ },
+ tags: true,
+ sorter: function(items) {
+ items.sort(function(lhs, rhs) {
+ return parseInt(lhs.id) - parseInt(rhs.id);
+ })
+ return items;
+ },
+ containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
+ dropdownCssClass: 'select2-only-number simple-select2-align-center bg-secondary text-secondary',
+ })
+ }
+
+ $(document).on('keypress', '.select2-only-number .select2-search__field', function() {
+ $(this).val($(this).val().replace(/[^\d].+/, ""));
+ if ((event.which < 48 || event.which > 57)) {
+ event.preventDefault();
+ }
+ });
+
});
\ No newline at end of file
diff --git a/hwe/sammo/Command/General/che_건국.php b/hwe/sammo/Command/General/che_건국.php
index f23444f3..0650fff4 100644
--- a/hwe/sammo/Command/General/che_건국.php
+++ b/hwe/sammo/Command/General/che_건국.php
@@ -1,287 +1,287 @@
-arg === null) {
- return false;
- }
- $nationName = $this->arg['nationName'] ?? null;
- $nationType = $this->arg['nationType'] ?? null;
- $colorType = $this->arg['colorType'] ?? null;
-
- if ($nationName === null || $nationType === null || $colorType === null) {
- return false;
- }
-
- if (!is_string($nationName) || !is_string($nationType) || !is_int($colorType)) {
- return false;
- }
-
- if (mb_strwidth($nationName) > 18 || $nationName == '') {
- return false;
- }
-
- if (!key_exists($colorType, GetNationColors())) {
- return false;
- }
-
- try {
- $nationTypeClass = buildNationTypeClass($nationType);
- } catch (\InvalidArgumentException $e) {
- return false;
- }
-
- $this->arg = [
- 'nationName' => $nationName,
- 'nationType' => $nationType,
- 'colorType' => $colorType
- ];
-
- return true;
- }
-
- protected function init()
- {
- $env = $this->env;
-
- $this->setCity();
- $this->setNation(['gennum', 'aux']);
-
- $relYear = $env['year'] - $env['startyear'];
-
- $this->minConditionConstraints = [
- ConstraintHelper::BeOpeningPart($relYear + 1),
- ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.')
- ];
- }
-
- protected function initWithArg()
- {
- $env = $this->env;
- $relYear = $env['year'] - $env['startyear'];
-
- $nationName = $this->arg['nationName'];
- $nationType = $this->arg['nationType'];
- $colorType = $this->arg['colorType'];
-
- $this->fullConditionConstraints = [
- ConstraintHelper::BeLord(),
- ConstraintHelper::WanderingNation(),
- ConstraintHelper::ReqNationValue('gennum', '수하 장수', '>=', 2),
- ConstraintHelper::BeOpeningPart($relYear + 1),
- ConstraintHelper::CheckNationNameDuplicate($nationName),
- ConstraintHelper::AllowJoinAction(),
- ConstraintHelper::ConstructableCity(),
- ];
- }
-
- public function getBrief(): string
- {
- $nationName = $this->arg['nationName'];
- $josaUl = JosaUtil::pick($nationName, '을');
- return "【{$nationName}】{$josaUl} 건국";
- }
-
- public function getCost(): array
- {
- return [0, 0];
- }
-
- public function getPreReqTurn(): int
- {
- return 0;
- }
-
- public function getPostReqTurn(): int
- {
- return 0;
- }
-
- public function run(): bool
- {
- if (!$this->hasFullConditionMet()) {
- throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
- }
-
- $db = DB::db();
- $env = $this->env;
-
- $general = $this->generalObj;
- $date = $general->getTurnTime($general::TURNTIME_HM);
- $generalName = $general->getName();
- $josaYi = JosaUtil::pick($generalName, '이');
-
- $nationName = $this->arg['nationName'];
- $nationType = $this->arg['nationType'];
- $colorType = GetNationColors()[$this->arg['colorType']];
-
- $cityName = $this->city['name'];
-
- $josaUl = JosaUtil::pick($nationName, '을');
-
- $logger = $general->getLogger();
-
- $nationTypeClass = buildNationTypeClass($nationType);
- $nationTypeName = $nationTypeClass->getName();
-
-
- $logger->pushGeneralActionLog("{$nationName}>{$josaUl} 건국하였습니다. <1>$date>");
- $logger->pushGlobalActionLog("{$generalName}>{$josaYi} {$cityName}>에 국가를 건설하였습니다.");
-
- $josaNationYi = JosaUtil::pick($nationName, '이');
- $logger->pushGlobalHistoryLog("【건국】>{$nationTypeName} {$nationName}>{$josaNationYi} 새로이 등장하였습니다.");
- $logger->pushGeneralHistoryLog("{$nationName}>{$josaUl} 건국");
- $logger->pushNationalHistoryLog("{$generalName}>{$josaYi} {$nationName}>{$josaUl} 건국");
-
- $exp = 1000;
- $ded = 1000;
-
- $general->addExperience($exp);
- $general->addDedication($ded);
-
- $aux = Json::decode($this->nation['aux'])??[];
- $aux['can_국기변경'] = 1;
-
- $db->update('city', [
- 'nation' => $general->getNationID(),
- 'conflict' => '{}'
- ], 'city=%i', $general->getCityID());
-
- $db->update('nation', [
- 'name' => $nationName,
- 'color' => $colorType,
- 'level' => 1,
- 'type' => $nationType,
- 'capital' => $general->getCityID(),
- 'aux' => Json::encode($aux)
- ], 'nation=%i', $general->getNationID());
-
- refreshNationStaticInfo();
-
- $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
- $general->checkStatChange();
- tryUniqueItemLottery($general, '건국');
- $general->applyDB($db);
-
- return true;
- }
-
- public function getJSFiles(): array
- {
- return [
- 'js/colorSelect.js'
- ];
- }
-
- public function getForm(): string
- {
-
- if (count(getAllNationStaticInfo()) >= $this->env['maxnation']) {
- return '더 이상 건국은 불가능합니다.';
- }
-
-
- //NOTE: 새로운 방법이 생기기 전까진 아무색이나 선택 가능하도록 하자.
- /*
- foreach(GetNationColors() as $color){
- $colorUsed[$color] = 0;
- }
-
- foreach(getAllNationStaticInfo() as $nation){
- if($nation['level'] <= 0){
- continue;
- }
- $colorUsed[$nation['color']]++;
- }
-
- $colorUsedCnt = 0;
- foreach($colorUsed as $color=>$used){
- if($used){
- continue;
- }
- $colorUsedCnt += 1;
- }
-
- //색깔이 다 쓰였으면 그냥 모두 허용
- if($colorUsedCnt === count($colorUsed)){
- foreach(array_keys($colorUsed) as $color){
- $colorUsed[$color] = 0;
- }
- }
- */
-
-
- ob_start();
-?>
- 현재 도시에서 나라를 세웁니다. 중, 소도시에서만 가능합니다.
-
- getName(), $nationClass::$pros, $nationClass::$cons];
- ?>
-
- - = $name ?> : = $pros ?> = $cons ?>
-
-
- 국명 :
- 색상 :
- 성향 :
-
-arg === null) {
+ return false;
+ }
+ $nationName = $this->arg['nationName'] ?? null;
+ $nationType = $this->arg['nationType'] ?? null;
+ $colorType = $this->arg['colorType'] ?? null;
+
+ if ($nationName === null || $nationType === null || $colorType === null) {
+ return false;
+ }
+
+ if (!is_string($nationName) || !is_string($nationType) || !is_int($colorType)) {
+ return false;
+ }
+
+ if (mb_strwidth($nationName) > 18 || $nationName == '') {
+ return false;
+ }
+
+ if (!key_exists($colorType, GetNationColors())) {
+ return false;
+ }
+
+ try {
+ $nationTypeClass = buildNationTypeClass($nationType);
+ } catch (\InvalidArgumentException $e) {
+ return false;
+ }
+
+ $this->arg = [
+ 'nationName' => $nationName,
+ 'nationType' => $nationType,
+ 'colorType' => $colorType
+ ];
+
+ return true;
+ }
+
+ protected function init()
+ {
+ $env = $this->env;
+
+ $this->setCity();
+ $this->setNation(['gennum', 'aux']);
+
+ $relYear = $env['year'] - $env['startyear'];
+
+ $this->minConditionConstraints = [
+ ConstraintHelper::BeOpeningPart($relYear + 1),
+ ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.')
+ ];
+ }
+
+ protected function initWithArg()
+ {
+ $env = $this->env;
+ $relYear = $env['year'] - $env['startyear'];
+
+ $nationName = $this->arg['nationName'];
+ $nationType = $this->arg['nationType'];
+ $colorType = $this->arg['colorType'];
+
+ $this->fullConditionConstraints = [
+ ConstraintHelper::BeLord(),
+ ConstraintHelper::WanderingNation(),
+ ConstraintHelper::ReqNationValue('gennum', '수하 장수', '>=', 2),
+ ConstraintHelper::BeOpeningPart($relYear + 1),
+ ConstraintHelper::CheckNationNameDuplicate($nationName),
+ ConstraintHelper::AllowJoinAction(),
+ ConstraintHelper::ConstructableCity(),
+ ];
+ }
+
+ public function getBrief(): string
+ {
+ $nationName = $this->arg['nationName'];
+ $josaUl = JosaUtil::pick($nationName, '을');
+ return "【{$nationName}】{$josaUl} 건국";
+ }
+
+ public function getCost(): array
+ {
+ return [0, 0];
+ }
+
+ public function getPreReqTurn(): int
+ {
+ return 0;
+ }
+
+ public function getPostReqTurn(): int
+ {
+ return 0;
+ }
+
+ public function run(): bool
+ {
+ if (!$this->hasFullConditionMet()) {
+ throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
+ }
+
+ $db = DB::db();
+ $env = $this->env;
+
+ $general = $this->generalObj;
+ $date = $general->getTurnTime($general::TURNTIME_HM);
+ $generalName = $general->getName();
+ $josaYi = JosaUtil::pick($generalName, '이');
+
+ $nationName = $this->arg['nationName'];
+ $nationType = $this->arg['nationType'];
+ $colorType = GetNationColors()[$this->arg['colorType']];
+
+ $cityName = $this->city['name'];
+
+ $josaUl = JosaUtil::pick($nationName, '을');
+
+ $logger = $general->getLogger();
+
+ $nationTypeClass = buildNationTypeClass($nationType);
+ $nationTypeName = $nationTypeClass->getName();
+
+
+ $logger->pushGeneralActionLog("{$nationName}>{$josaUl} 건국하였습니다. <1>$date>");
+ $logger->pushGlobalActionLog("{$generalName}>{$josaYi} {$cityName}>에 국가를 건설하였습니다.");
+
+ $josaNationYi = JosaUtil::pick($nationName, '이');
+ $logger->pushGlobalHistoryLog("【건국】>{$nationTypeName} {$nationName}>{$josaNationYi} 새로이 등장하였습니다.");
+ $logger->pushGeneralHistoryLog("{$nationName}>{$josaUl} 건국");
+ $logger->pushNationalHistoryLog("{$generalName}>{$josaYi} {$nationName}>{$josaUl} 건국");
+
+ $exp = 1000;
+ $ded = 1000;
+
+ $general->addExperience($exp);
+ $general->addDedication($ded);
+
+ $aux = Json::decode($this->nation['aux'])??[];
+ $aux['can_국기변경'] = 1;
+
+ $db->update('city', [
+ 'nation' => $general->getNationID(),
+ 'conflict' => '{}'
+ ], 'city=%i', $general->getCityID());
+
+ $db->update('nation', [
+ 'name' => $nationName,
+ 'color' => $colorType,
+ 'level' => 1,
+ 'type' => $nationType,
+ 'capital' => $general->getCityID(),
+ 'aux' => Json::encode($aux)
+ ], 'nation=%i', $general->getNationID());
+
+ refreshNationStaticInfo();
+
+ $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
+ $general->checkStatChange();
+ tryUniqueItemLottery($general, '건국');
+ $general->applyDB($db);
+
+ return true;
+ }
+
+ public function getJSFiles(): array
+ {
+ return [
+ 'js/colorSelect.js'
+ ];
+ }
+
+ public function getForm(): string
+ {
+
+ if (count(getAllNationStaticInfo()) >= $this->env['maxnation']) {
+ return '더 이상 건국은 불가능합니다.';
+ }
+
+
+ //NOTE: 새로운 방법이 생기기 전까진 아무색이나 선택 가능하도록 하자.
+ /*
+ foreach(GetNationColors() as $color){
+ $colorUsed[$color] = 0;
+ }
+
+ foreach(getAllNationStaticInfo() as $nation){
+ if($nation['level'] <= 0){
+ continue;
+ }
+ $colorUsed[$nation['color']]++;
+ }
+
+ $colorUsedCnt = 0;
+ foreach($colorUsed as $color=>$used){
+ if($used){
+ continue;
+ }
+ $colorUsedCnt += 1;
+ }
+
+ //색깔이 다 쓰였으면 그냥 모두 허용
+ if($colorUsedCnt === count($colorUsed)){
+ foreach(array_keys($colorUsed) as $color){
+ $colorUsed[$color] = 0;
+ }
+ }
+ */
+
+
+ ob_start();
+?>
+ 현재 도시에서 나라를 세웁니다. 중, 소도시에서만 가능합니다.
+
+ getName(), $nationClass::$pros, $nationClass::$cons];
+ ?>
+
+ - = $name ?> : = $pros ?> = $cons ?>
+
+
+ 국명 :
+ 색상 :
+ 성향 :
+
+arg === null) {
- return false;
- }
- //NOTE: 사망 직전에 '증여' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
- if (!key_exists('isGold', $this->arg)) {
- return false;
- }
- if (!key_exists('amount', $this->arg)) {
- return false;
- }
- if (!key_exists('destGeneralID', $this->arg)) {
- return false;
- }
- $isGold = $this->arg['isGold'];
- $amount = $this->arg['amount'];
- $destGeneralID = $this->arg['destGeneralID'];
- if (!is_numeric($amount)) {
- return false;
- }
- $amount = Util::round($amount, -2);
- $amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
- if ($amount <= 0) {
- return false;
- }
- if (!is_bool($isGold)) {
- return false;
- }
- if (!is_int($destGeneralID)) {
- return false;
- }
- if ($destGeneralID <= 0) {
- return false;
- }
- if ($destGeneralID == $this->generalObj->getID()) {
- return false;
- }
- $this->arg = [
- 'isGold' => $isGold,
- 'amount' => $amount,
- 'destGeneralID' => $destGeneralID
- ];
- return true;
- }
-
- protected function init()
- {
-
- $general = $this->generalObj;
-
- $this->setCity();
- $this->setNation();
-
- $this->minConditionConstraints = [
- ConstraintHelper::NotBeNeutral(),
- ConstraintHelper::OccupiedCity(),
- ConstraintHelper::SuppliedCity(),
- ];
- }
-
- protected function initWithArg()
- {
- $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], 1);
- $this->setDestGeneral($destGeneral);
-
- $this->fullConditionConstraints = [
- ConstraintHelper::NotBeNeutral(),
- ConstraintHelper::OccupiedCity(),
- ConstraintHelper::SuppliedCity(),
- ConstraintHelper::ExistsDestGeneral(),
- ConstraintHelper::FriendlyDestGeneral()
- ];
- if ($this->arg['isGold']) {
- $this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
- } else {
- $this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
- }
- }
-
- public function getCommandDetailTitle(): string
- {
- $name = $this->getName();
- return "{$name}(통솔경험)";
- }
-
- public function getCost(): array
- {
- return [0, 0];
- }
-
- public function getPreReqTurn(): int
- {
- return 0;
- }
-
- public function getPostReqTurn(): int
- {
- return 0;
- }
-
- public function getBrief(): string
- {
- $destGeneralName = $this->destGeneralObj->getName();
- $resText = $this->arg['isGold'] ? '금' : '쌀';
- $name = $this->getName();
- return "【{$destGeneralName}】에게 {$resText} {$this->arg['amount']}을 {$name}";
- }
-
- public function run(): bool
- {
- if (!$this->hasFullConditionMet()) {
- throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
- }
-
- $db = DB::db();
-
- $general = $this->generalObj;
- $date = $general->getTurnTime($general::TURNTIME_HM);
-
- $isGold = $this->arg['isGold'];
- $amount = $this->arg['amount'];
- $resKey = $isGold ? 'gold' : 'rice';
- $resName = $isGold ? '금' : '쌀';
- $destGeneral = $this->destGeneralObj;
-
- $amount = Util::valueFit($amount, 0, $general->getVar($resKey) - ($isGold ? GameConst::$generalMinimumGold : GameConst::$generalMinimumRice));
- $amountText = number_format($amount, 0);
-
- $logger = $general->getLogger();
-
- $destGeneral->increaseVarWithLimit($resKey, $amount);
- $general->increaseVarWithLimit($resKey, -$amount, 0);
-
- $destGeneral->getLogger()->pushGeneralActionLog("{$general->getName()}>에게서 {$resName} {$amountText}>을 증여 받았습니다.", ActionLogger::PLAIN);
- $logger->pushGeneralActionLog("{$destGeneral->getName()}>에게 {$resName} $amountText>을 증여했습니다. <1>$date>");
-
- $exp = 70;
- $ded = 100;
-
- $general->addExperience($exp);
- $general->addDedication($ded);
- $general->increaseVar('leadership_exp', 1);
-
- $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
- $general->checkStatChange();
- $general->applyDB($db);
- $destGeneral->applyDB($db);
-
- return true;
- }
-
- public function getForm(): string
- {
- //TODO: 암행부처럼 보여야...
- $db = DB::db();
-
- $destRawGenerals = $db->query('SELECT no,name,officer_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();
-?>
- 자신의 자금이나 군량을 다른 장수에게 증여합니다.
- 장수를 선택하세요.
-
-
-
-arg === null) {
+ return false;
+ }
+ //NOTE: 사망 직전에 '증여' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
+ if (!key_exists('isGold', $this->arg)) {
+ return false;
+ }
+ if (!key_exists('amount', $this->arg)) {
+ return false;
+ }
+ if (!key_exists('destGeneralID', $this->arg)) {
+ return false;
+ }
+ $isGold = $this->arg['isGold'];
+ $amount = $this->arg['amount'];
+ $destGeneralID = $this->arg['destGeneralID'];
+ if (!is_numeric($amount)) {
+ return false;
+ }
+ $amount = Util::round($amount, -2);
+ $amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
+ if ($amount <= 0) {
+ return false;
+ }
+ if (!is_bool($isGold)) {
+ return false;
+ }
+ if (!is_int($destGeneralID)) {
+ return false;
+ }
+ if ($destGeneralID <= 0) {
+ return false;
+ }
+ if ($destGeneralID == $this->generalObj->getID()) {
+ return false;
+ }
+ $this->arg = [
+ 'isGold' => $isGold,
+ 'amount' => $amount,
+ 'destGeneralID' => $destGeneralID
+ ];
+ return true;
+ }
+
+ protected function init()
+ {
+
+ $general = $this->generalObj;
+
+ $this->setCity();
+ $this->setNation();
+
+ $this->minConditionConstraints = [
+ ConstraintHelper::NotBeNeutral(),
+ ConstraintHelper::OccupiedCity(),
+ ConstraintHelper::SuppliedCity(),
+ ];
+ }
+
+ protected function initWithArg()
+ {
+ $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], 1);
+ $this->setDestGeneral($destGeneral);
+
+ $this->fullConditionConstraints = [
+ ConstraintHelper::NotBeNeutral(),
+ ConstraintHelper::OccupiedCity(),
+ ConstraintHelper::SuppliedCity(),
+ ConstraintHelper::ExistsDestGeneral(),
+ ConstraintHelper::FriendlyDestGeneral()
+ ];
+ if ($this->arg['isGold']) {
+ $this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
+ } else {
+ $this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
+ }
+ }
+
+ public function getCommandDetailTitle(): string
+ {
+ $name = $this->getName();
+ return "{$name}(통솔경험)";
+ }
+
+ public function getCost(): array
+ {
+ return [0, 0];
+ }
+
+ public function getPreReqTurn(): int
+ {
+ return 0;
+ }
+
+ public function getPostReqTurn(): int
+ {
+ return 0;
+ }
+
+ public function getBrief(): string
+ {
+ $destGeneralName = $this->destGeneralObj->getName();
+ $resText = $this->arg['isGold'] ? '금' : '쌀';
+ $name = $this->getName();
+ return "【{$destGeneralName}】에게 {$resText} {$this->arg['amount']}을 {$name}";
+ }
+
+ public function run(): bool
+ {
+ if (!$this->hasFullConditionMet()) {
+ throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
+ }
+
+ $db = DB::db();
+
+ $general = $this->generalObj;
+ $date = $general->getTurnTime($general::TURNTIME_HM);
+
+ $isGold = $this->arg['isGold'];
+ $amount = $this->arg['amount'];
+ $resKey = $isGold ? 'gold' : 'rice';
+ $resName = $isGold ? '금' : '쌀';
+ $destGeneral = $this->destGeneralObj;
+
+ $amount = Util::valueFit($amount, 0, $general->getVar($resKey) - ($isGold ? GameConst::$generalMinimumGold : GameConst::$generalMinimumRice));
+ $amountText = number_format($amount, 0);
+
+ $logger = $general->getLogger();
+
+ $destGeneral->increaseVarWithLimit($resKey, $amount);
+ $general->increaseVarWithLimit($resKey, -$amount, 0);
+
+ $destGeneral->getLogger()->pushGeneralActionLog("{$general->getName()}>에게서 {$resName} {$amountText}>을 증여 받았습니다.", ActionLogger::PLAIN);
+ $logger->pushGeneralActionLog("{$destGeneral->getName()}>에게 {$resName} $amountText>을 증여했습니다. <1>$date>");
+
+ $exp = 70;
+ $ded = 100;
+
+ $general->addExperience($exp);
+ $general->addDedication($ded);
+ $general->increaseVar('leadership_exp', 1);
+
+ $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
+ $general->checkStatChange();
+ $general->applyDB($db);
+ $destGeneral->applyDB($db);
+
+ return true;
+ }
+
+ public function getForm(): string
+ {
+ //TODO: 암행부처럼 보여야...
+ $db = DB::db();
+
+ $destRawGenerals = $db->query('SELECT no,name,officer_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();
+?>
+ 자신의 자금이나 군량을 다른 장수에게 증여합니다.
+ 장수를 선택하세요.
+
+
+
+arg === null) {
- return false;
- }
-
- if (!key_exists('colorType', $this->arg)) {
- return false;
- }
- $colorType = $this->arg['colorType'];
- if (!key_exists($colorType, GetNationColors())) {
- return false;
- }
-
- $this->arg = [
- 'colorType' => $colorType,
- ];
- return true;
- }
-
- protected function init()
- {
- $general = $this->generalObj;
-
- $env = $this->env;
-
- $this->setCity();
- $this->setNation(['aux']);
-
- $actionName = $this->getName();
-
- $this->minConditionConstraints = [
- ConstraintHelper::OccupiedCity(),
- ConstraintHelper::BeChief(),
- ConstraintHelper::SuppliedCity(),
- ConstraintHelper::ReqNationAuxValue("can_{$actionName}", 0, '>', 0, '더이상 변경이 불가능합니다.')
- ];
- }
-
- protected function initWithArg()
- {
- $actionName = $this->getName();
-
- $this->fullConditionConstraints = [
- ConstraintHelper::OccupiedCity(),
- ConstraintHelper::BeChief(),
- ConstraintHelper::SuppliedCity(),
- ConstraintHelper::ReqNationAuxValue("can_{$actionName}", 0, '>', 0, '더이상 변경이 불가능합니다.')
- ];
- }
-
- public function getCost(): array
- {
-
- return [0, 0];
- }
-
- public function getPreReqTurn(): int
- {
- return 0;
- }
-
- public function getPostReqTurn(): int
- {
- return 0;
- }
-
- public function getBrief(): string
- {
- $color = GetNationColors()[$this->arg['colorType']];
- return "【국기】를 변경";
- }
-
- public function run(): bool
- {
- if (!$this->hasFullConditionMet()) {
- throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
- }
-
- $db = DB::db();
- $actionName = $this->getName();
-
- $general = $this->generalObj;
- $generalID = $general->getID();
- $generalName = $general->getName();
- $date = $general->getTurnTime($general::TURNTIME_HM);
-
- $colorType = $this->arg['colorType'];
- $color = GetNationColors()[$colorType];
-
-
- $nationID = $general->getNationID();
- $nationName = $this->nation['name'];
-
- $logger = $general->getLogger();
-
-
- $general->addExperience(5 * ($this->getPreReqTurn() + 1));
- $general->addDedication(5 * ($this->getPreReqTurn() + 1));
-
- $josaYi = JosaUtil::pick($generalName, '이');
- $josaYiNation = JosaUtil::pick($nationName, '이');
-
- $aux = Json::decode($this->nation['aux']);
- $aux["can_{$actionName}"] = 0;
-
- $db->update('nation', [
- 'color'=>$color,
- 'aux'=>Json::encode($aux)
- ], 'nation=%i', $nationID);
-
- $logger->pushGeneralActionLog("국기를 변경하였습니다 <1>$date>");
- $logger->pushGeneralHistoryLog("국기를 변경");
- $logger->pushNationalHistoryLog("{$generalName}>{$josaYi} 국기를 변경하였습니다");
- $logger->pushGlobalActionLog("{$generalName}>{$josaYi} 국기를 변경하였습니다");
- $logger->pushGlobalHistoryLog("【국기변경】>{$nationName}>{$josaYiNation} 국기를 변경하였습니다.");
-
- $this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
- $general->applyDB($db);
- return true;
- }
-
- public function getJSFiles(): array
- {
- return [
- 'js/colorSelect.js'
- ];
- }
-
-
- public function getForm(): string
- {
- ob_start();
-?>
- 국기를 변경합니다. 단 1회 가능합니다.
- 색상 :