forked from devsam/core
명령 입력턴에 select2 적용
This commit is contained in:
+131
-127
@@ -1,127 +1,131 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
|
||||
$commandType = Util::getReq('command', 'string');
|
||||
$turnList = array_map('intval', explode('_', Util::getReq('turnList', 'string', '0')));
|
||||
$isChiefTurn = Util::getReq('is_chief', 'bool', false);
|
||||
|
||||
function die_redirect()
|
||||
{
|
||||
global $isChiefTurn;
|
||||
if(!$isChiefTurn){
|
||||
header('location:index.php', true, 303);
|
||||
}
|
||||
else{
|
||||
header('location:b_chiefcenter.php', true, 303);
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
if(!$turnList || !$commandType){
|
||||
die_redirect();
|
||||
}
|
||||
if(!is_array($turnList)){
|
||||
die_redirect();
|
||||
}
|
||||
|
||||
$session = Session::requireGameLogin()->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();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?=$commandObj->getName()?></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=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')?>
|
||||
<script>
|
||||
window.serverNick = '<?=DB::prefix()?>';
|
||||
window.serverID = '<?=UniqueConst::$serverID?>';
|
||||
window.command = '<?=$commandType?>';
|
||||
window.turnList = [<?=join(', ',$turnList)?>];
|
||||
window.isChiefTurn = <?=$isChiefTurn?'true':'false'?>;
|
||||
</script>
|
||||
<?php
|
||||
foreach($jsList as $js){
|
||||
print(WebUtil::printJS($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')?>
|
||||
<?php
|
||||
foreach($cssList as $css){
|
||||
print(WebUtil::printCSS($css));
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body class="img_back">
|
||||
<table class="tb_layout bg0" style="width:1000px;margin:auto;">
|
||||
<tr><td class="bg1" style='text-align:center;'><?=$commandObj->getName()?></td></tr>
|
||||
<tr><td>
|
||||
<input type=button value='돌아가기' onclick="history.back();"><br>
|
||||
</td></tr></table>
|
||||
|
||||
<div class="tb_layout bg0" style="width:1000px;margin:auto;padding-bottom:2em;border:solid 1px gray;">
|
||||
<?=$commandObj->getForm()?>
|
||||
</div>
|
||||
|
||||
<table class="tb_layout bg0" style="width:1000px;margin:auto;">
|
||||
<tr><td>
|
||||
<input type=button value='돌아가기' onclick="history.back();"><br>
|
||||
<?=banner()?>
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
|
||||
$commandType = Util::getReq('command', 'string');
|
||||
$turnList = array_map('intval', explode('_', Util::getReq('turnList', 'string', '0')));
|
||||
$isChiefTurn = Util::getReq('is_chief', 'bool', false);
|
||||
|
||||
function die_redirect()
|
||||
{
|
||||
global $isChiefTurn;
|
||||
if(!$isChiefTurn){
|
||||
header('location:index.php', true, 303);
|
||||
}
|
||||
else{
|
||||
header('location:b_chiefcenter.php', true, 303);
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
if(!$turnList || !$commandType){
|
||||
die_redirect();
|
||||
}
|
||||
if(!is_array($turnList)){
|
||||
die_redirect();
|
||||
}
|
||||
|
||||
$session = Session::requireGameLogin()->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();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?=$commandObj->getName()?></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=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')?>
|
||||
<script>
|
||||
window.serverNick = '<?=DB::prefix()?>';
|
||||
window.serverID = '<?=UniqueConst::$serverID?>';
|
||||
window.command = '<?=$commandType?>';
|
||||
window.turnList = [<?=join(', ',$turnList)?>];
|
||||
window.isChiefTurn = <?=$isChiefTurn?'true':'false'?>;
|
||||
</script>
|
||||
<?php
|
||||
foreach($jsList as $js){
|
||||
print(WebUtil::printJS($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')?>
|
||||
<?php
|
||||
foreach($cssList as $css){
|
||||
print(WebUtil::printCSS($css));
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body class="img_back">
|
||||
<table class="tb_layout bg0" style="width:1000px;margin:auto;">
|
||||
<tr><td class="bg1" style='text-align:center;'><?=$commandObj->getName()?></td></tr>
|
||||
<tr><td>
|
||||
<input type=button value='돌아가기' onclick="history.back();"><br>
|
||||
</td></tr></table>
|
||||
|
||||
<div class="tb_layout bg0" style="width:1000px;margin:auto;padding-bottom:2em;border:solid 1px gray;">
|
||||
<?=$commandObj->getForm()?>
|
||||
</div>
|
||||
|
||||
<table class="tb_layout bg0" style="width:1000px;margin:auto;">
|
||||
<tr><td>
|
||||
<input type=button value='돌아가기' onclick="history.back();"><br>
|
||||
<?=banner()?>
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#amount {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#colorType {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.no-padding .select2-results__option {
|
||||
padding: 0;
|
||||
}
|
||||
+242
-101
@@ -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 $("<span><span style='background-color:{0};color:{1};'> </span> {2}</span>".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 $("<div style='padding: 0.75rem 0.375rem; background-color:{0};color:{1};'>{2}</div>".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();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,287 +1,287 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command,
|
||||
Json
|
||||
};
|
||||
|
||||
|
||||
use function\sammo\{
|
||||
tryUniqueItemLottery,
|
||||
getAllNationStaticInfo
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\CityConst;
|
||||
use function sammo\buildNationTypeClass;
|
||||
use function sammo\refreshNationStaticInfo;
|
||||
use function sammo\GetNationColors;
|
||||
use function sammo\newColor;
|
||||
|
||||
|
||||
class che_건국 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '건국';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->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("<D><b>{$nationName}</b></>{$josaUl} 건국하였습니다. <1>$date</>");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <G><b>{$cityName}</b></>에 국가를 건설하였습니다.");
|
||||
|
||||
$josaNationYi = JosaUtil::pick($nationName, '이');
|
||||
$logger->pushGlobalHistoryLog("<Y><b>【건국】</b></>{$nationTypeName} <D><b>{$nationName}</b></>{$josaNationYi} 새로이 등장하였습니다.");
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 건국");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$nationName}</b></>{$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();
|
||||
?>
|
||||
현재 도시에서 나라를 세웁니다. 중, 소도시에서만 가능합니다.<br>
|
||||
|
||||
<?php foreach (GameConst::$availableNationType as $nationType) :
|
||||
$nationClass = buildNationTypeClass($nationType);
|
||||
|
||||
[$name, $pros, $cons] = [$nationClass->getName(), $nationClass::$pros, $nationClass::$cons];
|
||||
?>
|
||||
|
||||
- <?= $name ?> : <span style='color:cyan;'><?= $pros ?></span> <span style='color:magenta;'><?= $cons ?></span><br>
|
||||
<?php endforeach; ?>
|
||||
<br>
|
||||
국명 : <input type='text' class='formInput' name="nationName" id="nationName" size='18' maxlength='18' style='color:white;background-color:black;'>
|
||||
색상 : <select class='formInput' name='colorType' id='colorType' size='1'>
|
||||
|
||||
<?php foreach (GetNationColors() as $idx => $color) :
|
||||
/*
|
||||
if($colorUsed[$color] > 0){
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
?>
|
||||
<option value="<?= $idx ?>" style='background-color:<?= $color ?>;color:<?= newColor($color) ?>;'>국가명(<?=$color?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
성향 : <select class='formInput' name='nationType' id='nationType' size='1'>
|
||||
|
||||
<?php foreach (GameConst::$availableNationType as $nationType) :
|
||||
$nationTypeName = buildNationTypeClass($nationType)->getName();
|
||||
?>
|
||||
<option value='<?= $nationType ?>' style=background-color:black;color:white;><?= $nationTypeName ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command,
|
||||
Json
|
||||
};
|
||||
|
||||
|
||||
use function\sammo\{
|
||||
tryUniqueItemLottery,
|
||||
getAllNationStaticInfo
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\CityConst;
|
||||
use function sammo\buildNationTypeClass;
|
||||
use function sammo\refreshNationStaticInfo;
|
||||
use function sammo\GetNationColors;
|
||||
use function sammo\newColor;
|
||||
|
||||
|
||||
class che_건국 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '건국';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->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("<D><b>{$nationName}</b></>{$josaUl} 건국하였습니다. <1>$date</>");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <G><b>{$cityName}</b></>에 국가를 건설하였습니다.");
|
||||
|
||||
$josaNationYi = JosaUtil::pick($nationName, '이');
|
||||
$logger->pushGlobalHistoryLog("<Y><b>【건국】</b></>{$nationTypeName} <D><b>{$nationName}</b></>{$josaNationYi} 새로이 등장하였습니다.");
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 건국");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$nationName}</b></>{$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();
|
||||
?>
|
||||
현재 도시에서 나라를 세웁니다. 중, 소도시에서만 가능합니다.<br>
|
||||
|
||||
<?php foreach (GameConst::$availableNationType as $nationType) :
|
||||
$nationClass = buildNationTypeClass($nationType);
|
||||
|
||||
[$name, $pros, $cons] = [$nationClass->getName(), $nationClass::$pros, $nationClass::$cons];
|
||||
?>
|
||||
|
||||
- <?= $name ?> : <span style='color:cyan;'><?= $pros ?></span> <span style='color:magenta;'><?= $cons ?></span><br>
|
||||
<?php endforeach; ?>
|
||||
<br>
|
||||
국명 : <input type='text' class='formInput' name="nationName" id="nationName" size='18' maxlength='18' style='color:white;background-color:black;'>
|
||||
색상 : <select class='formInput' name='colorType' id='colorType' size='1'>
|
||||
|
||||
<?php foreach (GetNationColors() as $idx => $color) :
|
||||
/*
|
||||
if($colorUsed[$color] > 0){
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
?>
|
||||
<option value="<?= $idx ?>" data-color="<?= $color ?>" data-font-color="<?=newColor($color)?>" style='background-color:<?= $color ?>;color:<?= newColor($color) ?>;'>국가명(<?=$color?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
성향 : <select class='formInput' name='nationType' id='nationType' size='1'>
|
||||
|
||||
<?php foreach (GameConst::$availableNationType as $nationType) :
|
||||
$nationTypeName = buildNationTypeClass($nationType)->getName();
|
||||
?>
|
||||
<option value='<?= $nationType ?>' style=background-color:black;color:white;><?= $nationTypeName ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,222 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
class che_증여 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '증여';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->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("<Y>{$general->getName()}</>에게서 {$resName} <C>{$amountText}</>을 증여 받았습니다.", ActionLogger::PLAIN);
|
||||
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게 {$resName} <C>$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();
|
||||
?>
|
||||
자신의 자금이나 군량을 다른 장수에게 증여합니다.<br>
|
||||
장수를 선택하세요.<br>
|
||||
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach ($destRawGenerals as $destGeneral) :
|
||||
$color = \sammo\getNameColor($destGeneral['npc']);
|
||||
if ($color) {
|
||||
$color = " style='color:{$color}'";
|
||||
}
|
||||
$name = $destGeneral['name'];
|
||||
if ($destGeneral['officer_level'] >= 5) {
|
||||
$name = "*{$name}*";
|
||||
}
|
||||
?>
|
||||
<option value='<?= $destGeneral['no'] ?>' <?= $color ?>><?= $name ?>(금:<?= $destGeneral['gold'] ?>, 쌀:<?= $destGeneral['rice'] ?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select class='formInput' name="isGold" id="isGold" size='1' style='color:white;background-color:black;'>
|
||||
<option value="true">금</option>
|
||||
<option value="false">쌀</option>
|
||||
</select>
|
||||
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach (GameConst::$resourceActionAmountGuide as $amount) : ?>
|
||||
<option value='<?= $amount ?>'><?= $amount ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
class che_증여 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '증여';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->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("<Y>{$general->getName()}</>에게서 {$resName} <C>{$amountText}</>을 증여 받았습니다.", ActionLogger::PLAIN);
|
||||
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게 {$resName} <C>$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();
|
||||
?>
|
||||
자신의 자금이나 군량을 다른 장수에게 증여합니다.<br>
|
||||
장수를 선택하세요.<br>
|
||||
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach ($destRawGenerals as $destGeneral) :
|
||||
$color = \sammo\getNameColor($destGeneral['npc']);
|
||||
if ($color) {
|
||||
$color = " style='color:{$color}'";
|
||||
}
|
||||
$name = $destGeneral['name'];
|
||||
if ($destGeneral['officer_level'] >= 5) {
|
||||
$name = "*{$name}*";
|
||||
}
|
||||
?>
|
||||
<option value='<?= $destGeneral['no'] ?>' <?= $color ?>><?= $name ?>(금:<?= $destGeneral['gold'] ?>, 쌀:<?= $destGeneral['rice'] ?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select class='formInput' name="isGold" id="isGold" size='1' style='color:white;background-color:black;'>
|
||||
<option value="true">금</option>
|
||||
<option value="false">쌀</option>
|
||||
</select>
|
||||
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach (GameConst::$resourceActionAmountGuide as $amount) : ?>
|
||||
<option value='<?= $amount ?>'><?= $amount ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,191 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command,
|
||||
MessageTarget,
|
||||
Message,
|
||||
CityConst,
|
||||
Json,
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
GetImageURL,
|
||||
getNationStaticInfo,
|
||||
GetNationColors,
|
||||
newColor,
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Event\Action;
|
||||
|
||||
class che_국기변경 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '국기변경';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->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 "【<span style='color:{$color};'>국기</span>】를 변경";
|
||||
}
|
||||
|
||||
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("<span style='color:{$color};'><b>국기</b></span>를 변경하였습니다 <1>$date</>");
|
||||
$logger->pushGeneralHistoryLog("<span style='color:{$color};'><b>국기</b></span>를 변경");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다");
|
||||
$logger->pushGlobalHistoryLog("<S><b>【국기변경】</b></><D><b>{$nationName}</b></>{$josaYiNation} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다.");
|
||||
|
||||
$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회 가능합니다.<br>
|
||||
색상 : <select class='formInput' name='colorType' id='colorType' size='1'>
|
||||
|
||||
<?php foreach (GetNationColors() as $idx => $color) :
|
||||
/*
|
||||
if($colorUsed[$color] > 0){
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
?>
|
||||
<option value="<?= $idx ?>" style='background-color:<?= $color ?>;color:<?= newColor($color) ?>;'>국가명(<?=$color?>)</option>
|
||||
<?php endforeach; ?> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
|
||||
<br>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command,
|
||||
MessageTarget,
|
||||
Message,
|
||||
CityConst,
|
||||
Json,
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
GetImageURL,
|
||||
getNationStaticInfo,
|
||||
GetNationColors,
|
||||
newColor,
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Event\Action;
|
||||
|
||||
class che_국기변경 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '국기변경';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->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 "【<span style='color:{$color};'>국기</span>】를 변경";
|
||||
}
|
||||
|
||||
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("<span style='color:{$color};'><b>국기</b></span>를 변경하였습니다 <1>$date</>");
|
||||
$logger->pushGeneralHistoryLog("<span style='color:{$color};'><b>국기</b></span>를 변경");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다");
|
||||
$logger->pushGlobalHistoryLog("<S><b>【국기변경】</b></><D><b>{$nationName}</b></>{$josaYiNation} <span style='color:{$color};'><b>국기</b></span>를 변경하였습니다.");
|
||||
|
||||
$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회 가능합니다.<br>
|
||||
색상 : <select class='formInput' name='colorType' id='colorType' size='1'>
|
||||
|
||||
<?php foreach (GetNationColors() as $idx => $color) :
|
||||
/*
|
||||
if($colorUsed[$color] > 0){
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
?>
|
||||
<option value="<?= $idx ?>" data-color=<?=$color?> data-font-color="<?=newColor($color)?>" style='background-color:<?= $color ?>;color:<?= newColor($color) ?>;'>국가명(<?=$color?>)</option>
|
||||
<?php endforeach; ?> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
|
||||
<br>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user