forked from devsam/core
커맨드 유효성을 2개에서 3개구성으로 변경
This commit is contained in:
+14
-8
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
define('ROOT', realpath(__DIR__ . '/..'));
|
||||
@@ -13,8 +14,7 @@ ini_set("session.gc_maxlifetime", '604800'); // seconds
|
||||
|
||||
function getFriendlyErrorType($type)
|
||||
{
|
||||
switch($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case E_ERROR: // 1 //
|
||||
return 'E_ERROR';
|
||||
case E_WARNING: // 2 //
|
||||
@@ -49,7 +49,8 @@ function getFriendlyErrorType($type)
|
||||
return "{$type}";
|
||||
}
|
||||
|
||||
function getExceptionTraceAsString($exception) {
|
||||
function getExceptionTraceAsString($exception)
|
||||
{
|
||||
//https://gist.github.com/abtris/1437966
|
||||
$rtn = "";
|
||||
$count = 0;
|
||||
@@ -77,18 +78,21 @@ function getExceptionTraceAsString($exception) {
|
||||
}
|
||||
$args = join(", ", $args);
|
||||
}
|
||||
$rtn[] = sprintf( "#%s %s:%s %s(%s)",
|
||||
$rtn[] = sprintf(
|
||||
"#%s %s:%s %s(%s)",
|
||||
$count,
|
||||
isset($frame['file']) ? $frame['file'] : 'unknown file',
|
||||
isset($frame['line']) ? $frame['line'] : 'unknown line',
|
||||
(isset($frame['class'])) ? $frame['class'] . $frame['type'] . $frame['function'] : $frame['function'],
|
||||
$args );
|
||||
$args
|
||||
);
|
||||
$count++;
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
function logError(string $err, string $errstr, string $errpath, array $trace){
|
||||
function logError(string $err, string $errstr, string $errpath, array $trace)
|
||||
{
|
||||
$fdb = FileDB::db(ROOT . '/d_log/err_log.sqlite3', ROOT . '/f_install/sql/err_log.sql');
|
||||
$date = date("Ymd_His");
|
||||
|
||||
@@ -113,7 +117,8 @@ function logError(string $err, string $errstr, string $errpath, array $trace){
|
||||
]);
|
||||
}
|
||||
|
||||
function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, int $errline, array $errcontext){
|
||||
function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, int $errline, array $errcontext)
|
||||
{
|
||||
if (!(error_reporting() & $errno)) {
|
||||
// This error code is not included in error_reporting, so let it fall
|
||||
// through to the standard PHP error handler
|
||||
@@ -132,7 +137,8 @@ function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, in
|
||||
set_error_handler("\sammo\logErrorByCustomHandler");
|
||||
|
||||
|
||||
function logExceptionByCustomHandler(\Throwable $e){
|
||||
function logExceptionByCustomHandler(\Throwable $e)
|
||||
{
|
||||
|
||||
logError(
|
||||
get_class($e),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
@@ -74,7 +75,8 @@ if (file_exists(ROOT.'/d_setting') && !is_dir(ROOT.'/d_setting')) {
|
||||
]);
|
||||
}
|
||||
|
||||
if (!file_exists(ROOT.'/d_log')
|
||||
if (
|
||||
!file_exists(ROOT . '/d_log')
|
||||
|| !file_exists(ROOT . '/d_shared')
|
||||
|| !file_exists(ROOT . '/d_setting')
|
||||
|| !file_exists(AppConf::getUserIconPathFS())
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
@@ -43,20 +44,17 @@ if($servHost){
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
}
|
||||
else if($sharedIconPath || $gameImagePath){
|
||||
} else if ($sharedIconPath || $gameImagePath) {
|
||||
$servHost = ServConfig::$serverWebPath;
|
||||
if ($sharedIconPath) {
|
||||
$sharedIconPath = WebUtil::resolveRelativePath($sharedIconPath, $servHost);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$sharedIconPath = ServConfig::$sharedIconPath;
|
||||
}
|
||||
|
||||
if ($gameImagePath) {
|
||||
$gameImagePath = WebUtil::resolveRelativePath($gameImagePath, $servHost);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$gameImagePath = ServConfig::$gameImagePath;
|
||||
}
|
||||
|
||||
@@ -77,8 +75,7 @@ else if($sharedIconPath || $gameImagePath){
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$servHost = ServConfig::$serverWebPath;
|
||||
$sharedIconPath = ServConfig::$sharedIconPath;
|
||||
$gameImagePath = ServConfig::$gameImagePath;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
class RootDB
|
||||
@@ -30,7 +31,8 @@ class RootDB
|
||||
self::$uDB = new \MeekroDB(self::$host, self::$user, self::$password, self::$dbName, self::$port, self::$encoding);
|
||||
self::$uDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||
|
||||
self::$uDB->error_handler= function(){};
|
||||
self::$uDB->error_handler = function () {
|
||||
};
|
||||
self::$uDB->throw_exception_on_error = true;
|
||||
self::$uDB->throw_exception_on_nonsql_error = true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
class ServConfig
|
||||
|
||||
+1
-18
@@ -6,24 +6,7 @@ include "func.php";
|
||||
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
if($session->userGrade < 4) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
</head>
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?=banner()?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
die(requireAdminPermissionHTML());
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
|
||||
+1
-18
@@ -7,24 +7,7 @@ include "func.php";
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
|
||||
if($session->userGrade < 5) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
</head>
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?=banner()?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
die(requireAdminPermissionHTML());
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
+27
-26
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -7,24 +8,7 @@ include "func.php";
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
|
||||
if ($session->userGrade < 5) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
</head>
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?=banner()?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
die(requireAdminPermissionHTML());
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
@@ -32,6 +16,7 @@ $db = DB::db();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>회원관리</title>
|
||||
<meta charset="UTF-8">
|
||||
@@ -40,9 +25,12 @@ $db = DB::db();
|
||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||
<?= WebUtil::printCSS('css/common.css') ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td>회 원 관 리<br><?=backButton()?></td></tr>
|
||||
<tr>
|
||||
<td>회 원 관 리<br><?= backButton() ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<form name=form1 method=post action=_admin2_submit.php>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
@@ -53,7 +41,11 @@ $db = DB::db();
|
||||
</table>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td width=80 align=center rowspan=12>회원선택<br><br><font color=cyan>NPC</font><br><font color=skyblue>NPC유저</font><br><font color=red>접속제한</font><br><b style=background-color:red;>블럭회원</b></td>
|
||||
<td width=80 align=center rowspan=12>회원선택<br><br>
|
||||
<font color=cyan>NPC</font><br>
|
||||
<font color=skyblue>NPC유저</font><br>
|
||||
<font color=red>접속제한</font><br><b style=background-color:red;>블럭회원</b>
|
||||
</td>
|
||||
<td width=105 rowspan=12>
|
||||
<?php
|
||||
|
||||
@@ -63,9 +55,14 @@ $generalList = $db->query('SELECT `no`, `name`, npc, `block` FROM general ORDER
|
||||
|
||||
foreach ($generalList as $general) {
|
||||
$style = "style=;";
|
||||
if($general['block'] > 0) { $style .= "background-color:red;"; }
|
||||
if($general['npc'] >= 2) { $style .= "color:cyan;"; }
|
||||
elseif($general['npc'] == 1) { $style .= "color:skyblue;"; }
|
||||
if ($general['block'] > 0) {
|
||||
$style .= "background-color:red;";
|
||||
}
|
||||
if ($general['npc'] >= 2) {
|
||||
$style .= "color:cyan;";
|
||||
} elseif ($general['npc'] == 1) {
|
||||
$style .= "color:skyblue;";
|
||||
}
|
||||
|
||||
echo "
|
||||
<option value={$general['no']} $style>{$general['name']}</option>";
|
||||
@@ -86,7 +83,6 @@ foreach(GameConst::$allItems as $itemCategories){
|
||||
if ($itemObj->isBuyable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for ($i = 0; $i < 27; $i++) {
|
||||
@@ -139,8 +135,13 @@ for($i=0; $i < 27; $i++) {
|
||||
</table>
|
||||
</form>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td><?=backButton()?></td></tr>
|
||||
<tr><td><?=banner()?> </td></tr>
|
||||
<tr>
|
||||
<td><?= backButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= banner() ?> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+9
-16
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -223,8 +224,7 @@ switch($btn) {
|
||||
|
||||
if ($item == 'None') {
|
||||
$text = "무기 회수!";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$text = getItemName($item) . " 지급!";
|
||||
}
|
||||
|
||||
@@ -237,8 +237,7 @@ switch($btn) {
|
||||
$db->update('general', [
|
||||
'weapon' => 'None'
|
||||
], '`no` IN %li', $genlist);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$db->update('general', [
|
||||
'weapon' => $item
|
||||
], '`no` IN %li', $genlist, $item);
|
||||
@@ -247,8 +246,7 @@ switch($btn) {
|
||||
case "책지급":
|
||||
if ($item == 'None') {
|
||||
$text = "책 회수!";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$text = getItemName($item) . " 지급!";
|
||||
}
|
||||
|
||||
@@ -261,8 +259,7 @@ switch($btn) {
|
||||
$db->update('general', [
|
||||
'book' => 'None'
|
||||
], '`no` IN %li', $genlist);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$db->update('general', [
|
||||
'book' => $item
|
||||
], '`no` IN %li', $genlist);
|
||||
@@ -271,8 +268,7 @@ switch($btn) {
|
||||
case "말지급":
|
||||
if ($item == 'None') {
|
||||
$text = "말 회수!";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$text = getItemName($item) . " 지급!";
|
||||
}
|
||||
|
||||
@@ -285,8 +281,7 @@ switch($btn) {
|
||||
$db->update('general', [
|
||||
'horse' => 'None'
|
||||
], '`no` IN %li', $genlist);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$db->update('general', [
|
||||
'horse' => $item
|
||||
], '`no` IN %li', $genlist);
|
||||
@@ -295,8 +290,7 @@ switch($btn) {
|
||||
case "도구지급":
|
||||
if ($item == 'None') {
|
||||
$text = "특수도구 회수!";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$text = getItemName($item) . " 지급!";
|
||||
}
|
||||
|
||||
@@ -309,8 +303,7 @@ switch($btn) {
|
||||
$db->update('general', [
|
||||
'item' => 'None'
|
||||
], '`no` IN %li', $genlist);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$db->update('general', [
|
||||
'item' => $item
|
||||
], '`no` IN %li AND item < %i', $genlist, $item);
|
||||
|
||||
+30
-26
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -7,24 +8,7 @@ include "func.php";
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
|
||||
if ($session->userGrade < 5) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
</head>
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?=banner()?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
die(requireAdminPermissionHTML());
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
@@ -35,6 +19,7 @@ $conlimit = $gameStor->conlimit;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>멀티관리</title>
|
||||
<meta charset="UTF-8">
|
||||
@@ -43,14 +28,21 @@ $conlimit = $gameStor->conlimit;
|
||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||
<?= WebUtil::printCSS('css/common.css') ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td>멀 티 관 리<br><?=backButton()?></td></tr>
|
||||
<tr>
|
||||
<td>멀 티 관 리<br><?= backButton() ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<form name=form1 method=post action=_admin4_submit.php>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td width=80 align=center rowspan=3>회원선택<br><br><font color=cyan>NPC</font><br><font color=skyblue>NPC유저</font><br><font color=red>접속제한</font><br><b style=background-color:red;>블럭회원</b></td>
|
||||
<td width=80 align=center rowspan=3>회원선택<br><br>
|
||||
<font color=cyan>NPC</font><br>
|
||||
<font color=skyblue>NPC유저</font><br>
|
||||
<font color=red>접속제한</font><br><b style=background-color:red;>블럭회원</b>
|
||||
</td>
|
||||
<td width=105 rowspan=3>
|
||||
<?php
|
||||
|
||||
@@ -59,10 +51,17 @@ echo "
|
||||
|
||||
foreach ($db->query('SELECT no,name,npc,block,con from general where ip!=\'\' order by npc,ip') as $general) {
|
||||
$style = "style=;";
|
||||
if($general['block'] > 0) { $style .= "background-color:red;"; }
|
||||
if($general['npc'] >= 2) { $style .= "color:cyan;"; }
|
||||
elseif($general['npc'] == 1) { $style .= "color:skyblue;"; }
|
||||
if($general['con'] > $conlimit) { $style .= "color:red;"; }
|
||||
if ($general['block'] > 0) {
|
||||
$style .= "background-color:red;";
|
||||
}
|
||||
if ($general['npc'] >= 2) {
|
||||
$style .= "color:cyan;";
|
||||
} elseif ($general['npc'] == 1) {
|
||||
$style .= "color:skyblue;";
|
||||
}
|
||||
if ($general['con'] > $conlimit) {
|
||||
$style .= "color:red;";
|
||||
}
|
||||
|
||||
echo "
|
||||
<option value={$general['no']} $style>{$general['name']}</option>";
|
||||
@@ -135,8 +134,13 @@ echo "
|
||||
?>
|
||||
</form>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td><?=backButton()?></td></tr>
|
||||
<tr><td><?=banner()?> </td></tr>
|
||||
<tr>
|
||||
<td><?= backButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= banner() ?> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -81,4 +82,3 @@ switch($btn) {
|
||||
}
|
||||
|
||||
header('location:_admin4.php');
|
||||
|
||||
|
||||
+117
-56
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -18,24 +19,7 @@ if($type2 < 0 || $type2 > 6){
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
|
||||
if ($session->userGrade < 5) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
</head>
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?=banner()?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
die(requireAdminPermissionHTML());
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
@@ -49,6 +33,7 @@ $sel2[$type2] = "selected";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>일제정보</title>
|
||||
<meta charset="UTF-8">
|
||||
@@ -57,10 +42,14 @@ $sel2[$type2] = "selected";
|
||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||
<?= WebUtil::printCSS('css/common.css') ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td>일 제 정 보<br><?=closeButton()?></td></tr>
|
||||
<tr><td>
|
||||
<tr>
|
||||
<td>일 제 정 보<br><?= closeButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<form name=form1 method=post>정렬순서 :
|
||||
<select name=type size=1>
|
||||
<option <?= $sel[0] ?? '' ?> value=0>국력</option>
|
||||
@@ -110,7 +99,8 @@ for($i=1; $i <= $count; $i++) {
|
||||
</select>
|
||||
<input type=submit name=btn value='국가변경'>
|
||||
</form>
|
||||
</td></tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table align=center width=1600 class="tb_layout bg0">
|
||||
@@ -171,24 +161,60 @@ GROUP BY B.nation
|
||||
";
|
||||
|
||||
switch ($type) {
|
||||
case 0: $query .= " order by power desc"; break;
|
||||
case 1: $query .= " order by gennum desc"; break;
|
||||
case 2: $query .= " order by A.tech desc"; break;
|
||||
case 3: $query .= " order by A.gold desc"; break;
|
||||
case 4: $query .= " order by A.rice desc"; break;
|
||||
case 5: $query .= " order by avg(B.gold) desc"; break;
|
||||
case 6: $query .= " order by avg(B.rice) desc"; break;
|
||||
case 7: $query .= " order by avg(B.leadership) desc"; break;
|
||||
case 8: $query .= " order by avg(B.strength) desc"; break;
|
||||
case 9: $query .= " order by avg(B.intel) desc"; break;
|
||||
case 10: $query .= " order by avg(B.explevel) desc"; break;
|
||||
case 11: $query .= " order by avg(B.connect) desc"; break;
|
||||
case 12: $query .= " order by avg(B.con) desc"; break;
|
||||
case 13: $query .= " order by avg(B.dex1) desc"; break;
|
||||
case 14: $query .= " order by avg(B.dex2) desc"; break;
|
||||
case 15: $query .= " order by avg(B.dex3) desc"; break;
|
||||
case 16: $query .= " order by avg(B.dex4) desc"; break;
|
||||
case 17: $query .= " order by avg(B.dex5) desc"; break;
|
||||
case 0:
|
||||
$query .= " order by power desc";
|
||||
break;
|
||||
case 1:
|
||||
$query .= " order by gennum desc";
|
||||
break;
|
||||
case 2:
|
||||
$query .= " order by A.tech desc";
|
||||
break;
|
||||
case 3:
|
||||
$query .= " order by A.gold desc";
|
||||
break;
|
||||
case 4:
|
||||
$query .= " order by A.rice desc";
|
||||
break;
|
||||
case 5:
|
||||
$query .= " order by avg(B.gold) desc";
|
||||
break;
|
||||
case 6:
|
||||
$query .= " order by avg(B.rice) desc";
|
||||
break;
|
||||
case 7:
|
||||
$query .= " order by avg(B.leadership) desc";
|
||||
break;
|
||||
case 8:
|
||||
$query .= " order by avg(B.strength) desc";
|
||||
break;
|
||||
case 9:
|
||||
$query .= " order by avg(B.intel) desc";
|
||||
break;
|
||||
case 10:
|
||||
$query .= " order by avg(B.explevel) desc";
|
||||
break;
|
||||
case 11:
|
||||
$query .= " order by avg(B.connect) desc";
|
||||
break;
|
||||
case 12:
|
||||
$query .= " order by avg(B.con) desc";
|
||||
break;
|
||||
case 13:
|
||||
$query .= " order by avg(B.dex1) desc";
|
||||
break;
|
||||
case 14:
|
||||
$query .= " order by avg(B.dex2) desc";
|
||||
break;
|
||||
case 15:
|
||||
$query .= " order by avg(B.dex3) desc";
|
||||
break;
|
||||
case 16:
|
||||
$query .= " order by avg(B.dex4) desc";
|
||||
break;
|
||||
case 17:
|
||||
$query .= " order by avg(B.dex5) desc";
|
||||
break;
|
||||
}
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$nationCount = MYDB_num_rows($result);
|
||||
@@ -259,7 +285,9 @@ for($i=0; $i < $nationCount; $i++) {
|
||||
?>
|
||||
</table>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td><?=getSabotageLogRecent(20)?></td></tr>
|
||||
<tr>
|
||||
<td><?= getSabotageLogRecent(20) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table align=center width=1760 class="tb_layout bg0">
|
||||
@@ -271,13 +299,27 @@ for($i=0; $i < $nationCount; $i++) {
|
||||
<?php
|
||||
switch ($type2) {
|
||||
default:
|
||||
case 0: echo "<td width=1600>국력(국력,장수수,도시수,인구/100,최대인구/100,국가자원/100,장수자원/100,능력치,숙련/1000,경험공헌/100)</td>"; break;
|
||||
case 1: echo "<td width=1600>국가별성향</td>"; break;
|
||||
case 2: echo "<td width=1600>국가성향</td>"; break;
|
||||
case 3: echo "<td width=1600>장수성격</td>"; break;
|
||||
case 4: echo "<td width=1600>장수특기</td>"; break;
|
||||
case 5: echo "<td width=1600>병종수</td>"; break;
|
||||
case 6: echo "<td width=1600>기타</td>"; break;
|
||||
case 0:
|
||||
echo "<td width=1600>국력(국력,장수수,도시수,인구/100,최대인구/100,국가자원/100,장수자원/100,능력치,숙련/1000,경험공헌/100)</td>";
|
||||
break;
|
||||
case 1:
|
||||
echo "<td width=1600>국가별성향</td>";
|
||||
break;
|
||||
case 2:
|
||||
echo "<td width=1600>국가성향</td>";
|
||||
break;
|
||||
case 3:
|
||||
echo "<td width=1600>장수성격</td>";
|
||||
break;
|
||||
case 4:
|
||||
echo "<td width=1600>장수특기</td>";
|
||||
break;
|
||||
case 5:
|
||||
echo "<td width=1600>병종수</td>";
|
||||
break;
|
||||
case 6:
|
||||
echo "<td width=1600>기타</td>";
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
@@ -297,13 +339,27 @@ for($i=0; $i < $count; $i++) {
|
||||
";
|
||||
switch ($type2) {
|
||||
default:
|
||||
case 0: echo "<td>{$stat['power_hist']}</td>"; break;
|
||||
case 1: echo "<td>{$stat['nation_name']}</td>"; break;
|
||||
case 2: echo "<td>{$stat['nation_hist']}</td>"; break;
|
||||
case 3: echo "<td>{$stat['personal_hist']}</td>"; break;
|
||||
case 4: echo "<td>{$stat['special_hist']}</td>"; break;
|
||||
case 5: echo "<td>{$stat['crewtype']}</td>"; break;
|
||||
case 6: echo "<td>{$stat['etc']}</td>"; break;
|
||||
case 0:
|
||||
echo "<td>{$stat['power_hist']}</td>";
|
||||
break;
|
||||
case 1:
|
||||
echo "<td>{$stat['nation_name']}</td>";
|
||||
break;
|
||||
case 2:
|
||||
echo "<td>{$stat['nation_hist']}</td>";
|
||||
break;
|
||||
case 3:
|
||||
echo "<td>{$stat['personal_hist']}</td>";
|
||||
break;
|
||||
case 4:
|
||||
echo "<td>{$stat['special_hist']}</td>";
|
||||
break;
|
||||
case 5:
|
||||
echo "<td>{$stat['crewtype']}</td>";
|
||||
break;
|
||||
case 6:
|
||||
echo "<td>{$stat['etc']}</td>";
|
||||
break;
|
||||
}
|
||||
|
||||
echo "
|
||||
@@ -314,8 +370,13 @@ for($i=0; $i < $count; $i++) {
|
||||
</table>
|
||||
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td><?=closeButton()?></td></tr>
|
||||
<tr><td><?=banner()?> </td></tr>
|
||||
<tr>
|
||||
<td><?= closeButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= banner() ?> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -46,5 +47,3 @@ switch($btn) {
|
||||
}
|
||||
|
||||
header('location:_admin5.php');
|
||||
|
||||
|
||||
|
||||
+34
-28
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -13,24 +14,7 @@ if($type < 0 || $type > 4){
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
|
||||
if ($session->userGrade < 5) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
</head>
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?=banner()?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
die(requireAdminPermissionHTML());
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
@@ -41,6 +25,7 @@ $sel[$type] = "selected";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>접속정보</title>
|
||||
<meta charset="UTF-8">
|
||||
@@ -49,10 +34,15 @@ $sel[$type] = "selected";
|
||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||
<?= WebUtil::printCSS('css/common.css') ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td>접 속 정 보<br><?=closeButton()?></td></tr>
|
||||
<tr><td><form name=form1 method=post>정렬순서 :
|
||||
<tr>
|
||||
<td>접 속 정 보<br><?= closeButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<form name=form1 method=post>정렬순서 :
|
||||
<select name=type size=1>
|
||||
<option <?= $sel[0] ?? '' ?> value=0>접속률</option>
|
||||
<option <?= $sel[1] ?? '' ?> value=1>총갱신</option>
|
||||
@@ -61,7 +51,8 @@ $sel[$type] = "selected";
|
||||
<option <?= $sel[4] ?? '' ?> value=4>갱신/로그인</option>
|
||||
</select>
|
||||
<input type=submit value='정렬하기'></form>
|
||||
</td></tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table align=center class='tb_layout bg0'>
|
||||
<tr id=bg1>
|
||||
@@ -76,11 +67,21 @@ $sel[$type] = "selected";
|
||||
</tr>
|
||||
<?php
|
||||
switch ($type) {
|
||||
case 0: $query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by connect desc limit 0,30"; break;
|
||||
case 1: $query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by refcnt desc limit 0,30"; break;
|
||||
case 2: $query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by ref desc limit 0,30"; break;
|
||||
case 3: $query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by logcnt desc limit 0,30"; break;
|
||||
case 4: $query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by log desc limit 0,30"; break;
|
||||
case 0:
|
||||
$query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by connect desc limit 0,30";
|
||||
break;
|
||||
case 1:
|
||||
$query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by refcnt desc limit 0,30";
|
||||
break;
|
||||
case 2:
|
||||
$query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by ref desc limit 0,30";
|
||||
break;
|
||||
case 3:
|
||||
$query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by logcnt desc limit 0,30";
|
||||
break;
|
||||
case 4:
|
||||
$query = "select name,connect,startage,age,refcnt,logcnt,refcnt/(age-startage+1)/12 as ref,refcnt/logcnt as log from general order by log desc limit 0,30";
|
||||
break;
|
||||
}
|
||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$gencount = MYDB_num_rows($genresult);
|
||||
@@ -103,8 +104,13 @@ for($i=0; $i < $gencount; $i++) {
|
||||
?>
|
||||
</table>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td><?=closeButton()?></td></tr>
|
||||
<tr><td><?=banner()?> </td></tr>
|
||||
<tr>
|
||||
<td><?= closeButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= banner() ?> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+46
-40
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -35,24 +36,7 @@ if($reqQueryType === null || !key_exists($reqQueryType, $queryMap)){
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
|
||||
if ($session->userGrade < 5) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
</head>
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?=banner()?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
die(requireAdminPermissionHTML());
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
@@ -64,25 +48,23 @@ if($btn == '정렬하기') {
|
||||
[$queryTypeText, $reqArgType, $comp] = $queryMap[$reqQueryType];
|
||||
if ($reqArgType === 0) {
|
||||
$generalBasicList = $db->query('SELECT no, name, nation, npc, turntime FROM general');
|
||||
}
|
||||
else if($reqArgType===1){
|
||||
} else if ($reqArgType === 1) {
|
||||
$generalBasicList = $db->query('SELECT no, name, nation, npc, turntime, %b FROM general', $reqQueryType);
|
||||
}
|
||||
else if($reqArgType===2){
|
||||
$generalBasicList = $db->query('SELECT no, name, nation, npc, turntime, value as %b
|
||||
} else if ($reqArgType === 2) {
|
||||
$generalBasicList = $db->query(
|
||||
'SELECT no, name, nation, npc, turntime, value as %b
|
||||
FROM general LEFT JOIN rank_data
|
||||
ON general.no = rank_data.general_id
|
||||
WHERE rank_data.type = %s',
|
||||
$reqQueryType, $reqQueryType
|
||||
$reqQueryType,
|
||||
$reqQueryType
|
||||
);
|
||||
}
|
||||
else if($reqArgType===3){
|
||||
} else if ($reqArgType === 3) {
|
||||
$generalBasicList = array_map(function ($arr) {
|
||||
$arr['aux'] = Json::decode($arr['aux']);
|
||||
return $arr;
|
||||
}, $db->query('SELECT no, name, nation, npc, turntime, aux FROM general'));
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
throw new \sammo\MustNotBeReachedException();
|
||||
}
|
||||
|
||||
@@ -97,6 +79,7 @@ $generalObj = General::createGeneralObjFromDB($gen);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>로그정보</title>
|
||||
<meta charset="UTF-8">
|
||||
@@ -105,10 +88,14 @@ $generalObj = General::createGeneralObjFromDB($gen);
|
||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||
<?= WebUtil::printCSS('css/common.css') ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td>로 그 정 보<br><?=closeButton()?></td></tr>
|
||||
<tr><td>
|
||||
<tr>
|
||||
<td>로 그 정 보<br><?= closeButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<form name=form1 method=post>
|
||||
정렬순서 :
|
||||
<select name='query_type' size=1>
|
||||
@@ -125,23 +112,33 @@ $generalObj = General::createGeneralObjFromDB($gen);
|
||||
</select>
|
||||
<input type=submit name=btn value='조회하기'>
|
||||
</form>
|
||||
</td></tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width=1000 align=center class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td width=50% align=center id=bg1><font color=skyblue size=3>장 수 정 보</font></td>
|
||||
<td width=50% align=center id=bg1><font color=orange size=3>-</font></td>
|
||||
<td width=50% align=center id=bg1>
|
||||
<font color=skyblue size=3>장 수 정 보</font>
|
||||
</td>
|
||||
<td width=50% align=center id=bg1>
|
||||
<font color=orange size=3>-</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top>
|
||||
<?php generalInfo($generalObj); generalInfo2($generalObj); ?>
|
||||
<?php generalInfo($generalObj);
|
||||
generalInfo2($generalObj); ?>
|
||||
</td>
|
||||
<td valign=top>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center id=bg1><font color=skyblue size=3>개인 기록</font></td>
|
||||
<td align=center id=bg1><font color=orange size=3>전투 기록</font></td>
|
||||
<td align=center id=bg1>
|
||||
<font color=skyblue size=3>개인 기록</font>
|
||||
</td>
|
||||
<td align=center id=bg1>
|
||||
<font color=orange size=3>전투 기록</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top>
|
||||
@@ -152,8 +149,12 @@ $generalObj = General::createGeneralObjFromDB($gen);
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center id=bg1><font color=skyblue size=3>장수 열전</font></td>
|
||||
<td align=center id=bg1><font color=orange size=3>전투 결과</font></td>
|
||||
<td align=center id=bg1>
|
||||
<font color=skyblue size=3>장수 열전</font>
|
||||
</td>
|
||||
<td align=center id=bg1>
|
||||
<font color=orange size=3>전투 결과</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top>
|
||||
@@ -165,8 +166,13 @@ $generalObj = General::createGeneralObjFromDB($gen);
|
||||
</tr>
|
||||
</table>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td><?=closeButton()?></td></tr>
|
||||
<tr><td><?=banner()?> </td></tr>
|
||||
<tr>
|
||||
<td><?= closeButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= banner() ?> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+1
-18
@@ -12,24 +12,7 @@ $type = 0;
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
|
||||
if ($session->userGrade < 5) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
</head>
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?=banner()?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit();
|
||||
die(requireAdminPermissionHTML());
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
|
||||
@@ -9,7 +9,8 @@ $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(){
|
||||
function die_redirect()
|
||||
{
|
||||
global $isChiefTurn;
|
||||
if(!$isChiefTurn){
|
||||
header('location:index.php', true, 303);
|
||||
@@ -59,9 +60,9 @@ if($commandObj->isArgValid()){
|
||||
die_redirect();
|
||||
}
|
||||
|
||||
/*if(!$commandObj->isReservable()){
|
||||
if(!$commandObj->hasPermissionToReserve()){
|
||||
die_redirect();
|
||||
}*/
|
||||
}
|
||||
|
||||
$jsList = $commandObj->getJSFiles();
|
||||
$cssList = $commandObj->getCSSFiles();
|
||||
|
||||
+8
-6
@@ -75,14 +75,16 @@ function getNationStaticInfo($nationID, $forceRefresh=false)
|
||||
/**
|
||||
* getNationStaticInfo() 함수의 국가 캐시를 초기화
|
||||
*/
|
||||
function refreshNationStaticInfo(){
|
||||
function refreshNationStaticInfo()
|
||||
{
|
||||
getNationStaticInfo(null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* getNationStaticInfo(-1) 의 단축형
|
||||
*/
|
||||
function getAllNationStaticInfo(){
|
||||
function getAllNationStaticInfo()
|
||||
{
|
||||
return getNationStaticInfo(-1);
|
||||
}
|
||||
|
||||
@@ -447,10 +449,10 @@ function printCommandTable(General $generalObj) {
|
||||
}
|
||||
?>
|
||||
<option
|
||||
class='commandBasic <?=$getCompensateClassName($commandObj->getCompensationStyle())?> <?=$commandObj->isReservable()?'':'commandImpossible'?>'
|
||||
class='commandBasic <?=$getCompensateClassName($commandObj->getCompensationStyle())?> <?=$commandObj->hasMinConditionMet()?'':'commandImpossible'?>'
|
||||
value='<?=Util::getClassNameFromObj($commandObj)?>'
|
||||
data-reqArg='<?=($commandObj::$reqArg)?'true':'false'?>'
|
||||
><?=$commandObj->getCommandDetailTitle()?><?=$commandObj->isReservable()?'':'(불가)'?></option>
|
||||
><?=$commandObj->getCommandDetailTitle()?><?=$commandObj->hasMinConditionMet()?'':'(불가)'?></option>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -499,10 +501,10 @@ function chiefCommandTable(General $generalObj) {
|
||||
}
|
||||
?>
|
||||
<option
|
||||
class='commandBasic <?=$getCompensateClassName($commandObj->getCompensationStyle())?> <?=$commandObj->isReservable()?'':'commandImpossible'?>'
|
||||
class='commandBasic <?=$getCompensateClassName($commandObj->getCompensationStyle())?> <?=$commandObj->hasMinConditionMet()?'':'commandImpossible'?>'
|
||||
value='<?=Util::getClassNameFromObj($commandObj)?>'
|
||||
data-reqArg='<?=($commandObj::$reqArg)?'true':'false'?>'
|
||||
><?=$commandObj->getCommandDetailTitle()?><?=$commandObj->isReservable()?'':'(불가)'?></option>
|
||||
><?=$commandObj->getCommandDetailTitle()?><?=$commandObj->hasMinConditionMet()?'':'(불가)'?></option>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -328,11 +328,11 @@ function setGeneralCommand(int $generalID, array $rawTurnList, string $command,
|
||||
];
|
||||
}
|
||||
|
||||
if(!$commandObj->isReservable()){
|
||||
if(!$commandObj->hasPermissionToReserve()){
|
||||
return [
|
||||
'result'=>false,
|
||||
'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testReservable(),
|
||||
'test'=>'isReservable',
|
||||
'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testPermissionToReserve(),
|
||||
'test'=>'hasPermissionToReserve',
|
||||
'target'=>'command'
|
||||
];
|
||||
}
|
||||
@@ -408,18 +408,14 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
|
||||
];
|
||||
}
|
||||
|
||||
if(!$commandObj->isReservable()){
|
||||
if(!$commandObj->hasPermissionToReserve()){
|
||||
return [
|
||||
'result'=>false,
|
||||
'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testReservable(),
|
||||
'test'=>'isReservable',
|
||||
'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testPermissionToReserve(),
|
||||
'test'=>'hasPermissionToReserve',
|
||||
'target'=>'command'
|
||||
];
|
||||
}
|
||||
//TODO: Reservable은 '정말로 입력 불가'이고, '입력은 가능하지만 실행은 안될 것 같은' 군을 하나더 추가해야함
|
||||
// Runnable은 Arg를 모두 받아서 처리해야 하는 것이고, Arg를 받지 않아도 안될 것 같지만 입력 자체는 가능할 것 같은 커맨드.
|
||||
|
||||
$brief = $commandObj->getBrief();
|
||||
|
||||
_setNationCommand($commandObj, $turnList);
|
||||
return [
|
||||
|
||||
@@ -497,7 +497,7 @@ function checkWander() {
|
||||
|
||||
foreach(General::createGeneralObjListFromDB($wanderers) as $wanderer){
|
||||
$wanderCmd = buildGeneralCommandClass('che_해산', $wanderer, $admin);
|
||||
if($wanderCmd->isRunnable()){
|
||||
if($wanderCmd->hasFullConditionMet()){
|
||||
$logger = $wanderer->getLogger();
|
||||
$logger->pushGeneralActionLog('초반 제한후 방랑군은 자동 해산됩니다.', ActionLogger::PLAIN);
|
||||
$wanderCmd->run();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
function getMailboxList(){
|
||||
function getMailboxList()
|
||||
{
|
||||
|
||||
$generalNations = [];
|
||||
|
||||
|
||||
+64
-26
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
|
||||
@@ -10,8 +11,38 @@ namespace sammo;
|
||||
* TODO: side effect를 제거
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자 권한이 필요함을 출력.
|
||||
* @return void
|
||||
*/
|
||||
function requireAdminPermissionHTML()
|
||||
{
|
||||
ob_start();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
function turnTable() {
|
||||
<head>
|
||||
<title>관리메뉴</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||
<?= WebUtil::printCSS('css/common.css') ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
관리자가 아닙니다.<br>
|
||||
<?= banner() ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function turnTable()
|
||||
{
|
||||
|
||||
$turnList = [];
|
||||
$turnList[] = "<option selected value='0'>1턴</option>";
|
||||
@@ -32,7 +63,8 @@ function turnTable() {
|
||||
";
|
||||
}
|
||||
|
||||
function chiefTurnTable() {
|
||||
function chiefTurnTable()
|
||||
{
|
||||
$turnList = [];
|
||||
$turnList[] = "<option selected value='0'>1턴</option>";
|
||||
foreach (Util::range(1, GameConst::$maxChiefTurn) as $turnIdx) {
|
||||
@@ -49,12 +81,12 @@ return "
|
||||
";
|
||||
}
|
||||
|
||||
function displayiActionObjInfo(?iAction $action){
|
||||
function displayiActionObjInfo(?iAction $action)
|
||||
{
|
||||
if ($action === null) {
|
||||
$info = '';
|
||||
$text = '-';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$info = $action->getInfo();
|
||||
$text = $action->getName();
|
||||
}
|
||||
@@ -66,7 +98,8 @@ function displayiActionObjInfo(?iAction $action){
|
||||
'info' => $info,
|
||||
]);
|
||||
}
|
||||
function displayCharInfo(string $type):string{
|
||||
function displayCharInfo(string $type): string
|
||||
{
|
||||
$class = buildPersonalityClass($type);
|
||||
$info = $class->getInfo();
|
||||
$text = $class->getName();
|
||||
@@ -79,7 +112,8 @@ function displayCharInfo(string $type):string{
|
||||
]);
|
||||
}
|
||||
|
||||
function displaySpecialWarInfo(?string $type):string{
|
||||
function displaySpecialWarInfo(?string $type): string
|
||||
{
|
||||
$class = buildGeneralSpecialWarClass($type);
|
||||
$info = $class->getInfo();
|
||||
$name = $class->getName();
|
||||
@@ -92,7 +126,8 @@ function displaySpecialWarInfo(?string $type):string{
|
||||
]);
|
||||
}
|
||||
|
||||
function displaySpecialDomesticInfo(?string $type):string{
|
||||
function displaySpecialDomesticInfo(?string $type): string
|
||||
{
|
||||
$class = buildGeneralSpecialDomesticClass($type);
|
||||
$info = $class->getInfo();
|
||||
$name = $class->getName();
|
||||
@@ -105,7 +140,8 @@ function displaySpecialDomesticInfo(?string $type):string{
|
||||
]);
|
||||
}
|
||||
|
||||
function allButton(bool $seizeNPCMode) {
|
||||
function allButton(bool $seizeNPCMode)
|
||||
{
|
||||
if ($seizeNPCMode) {
|
||||
$site = "a_npcList.php";
|
||||
$call = "빙의일람";
|
||||
@@ -116,8 +152,7 @@ function allButton(bool $seizeNPCMode) {
|
||||
|
||||
if (\file_exists(__DIR__ . "/d_setting/templates/allButton.php")) {
|
||||
$templates = new \League\Plates\Engine(__DIR__ . '/d_setting/templates');
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||
}
|
||||
|
||||
@@ -129,7 +164,8 @@ function allButton(bool $seizeNPCMode) {
|
||||
}
|
||||
|
||||
|
||||
function commandButton() {
|
||||
function commandButton()
|
||||
{
|
||||
$session = Session::getInstance();
|
||||
$userID = Session::getUserID();
|
||||
if (!$session->isGameLoggedIn()) {
|
||||
@@ -154,8 +190,7 @@ function commandButton() {
|
||||
$permission = checkSecretPermission($me);
|
||||
if ($permission >= 1) {
|
||||
$showSecret = true;
|
||||
}
|
||||
else if($me['officer_level']== 0){
|
||||
} else if ($me['officer_level'] == 0) {
|
||||
$showSecret = false;
|
||||
}
|
||||
|
||||
@@ -169,7 +204,8 @@ function commandButton() {
|
||||
]);
|
||||
}
|
||||
|
||||
function formatWounded(int $value, int $wound): string{
|
||||
function formatWounded(int $value, int $wound): string
|
||||
{
|
||||
if ($wound == 0) {
|
||||
return "$value";
|
||||
}
|
||||
@@ -177,36 +213,37 @@ function formatWounded(int $value, int $wound): string{
|
||||
return "<font color=red>$woundedValue</font>";
|
||||
}
|
||||
|
||||
function formatDefenceTrain(int $value): string{
|
||||
function formatDefenceTrain(int $value): string
|
||||
{
|
||||
if ($value === 999) {
|
||||
return "×";
|
||||
}
|
||||
else if($value >= 80){
|
||||
} else if ($value >= 80) {
|
||||
return "◎";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return "○";
|
||||
}
|
||||
}
|
||||
|
||||
function formatLeadershipBonus(int $value): string{
|
||||
function formatLeadershipBonus(int $value): string
|
||||
{
|
||||
if ($value == 0) {
|
||||
return '';
|
||||
}
|
||||
return "<font color=cyan>+{$value}</font>";
|
||||
}
|
||||
|
||||
function formatName(string $name, int $npc): string{
|
||||
function formatName(string $name, int $npc): string
|
||||
{
|
||||
if ($npc == 1) {
|
||||
$name = "<font color='skyblue'>$name</font>";
|
||||
}
|
||||
else if($npc>1){
|
||||
} else if ($npc > 1) {
|
||||
$name = "<font color='cyan'>$name</font>";
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
function getMapHtml(?string $mapTheme=null){
|
||||
function getMapHtml(?string $mapTheme = null)
|
||||
{
|
||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||
|
||||
if ($mapTheme === null) {
|
||||
@@ -220,7 +257,8 @@ function getMapHtml(?string $mapTheme=null){
|
||||
]);
|
||||
}
|
||||
|
||||
function getInvitationList(array $nationList){
|
||||
function getInvitationList(array $nationList)
|
||||
{
|
||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||
|
||||
foreach ($nationList as &$nation) {
|
||||
|
||||
+32
-20
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace sammo;
|
||||
|
||||
class ActionLogger{
|
||||
class ActionLogger
|
||||
{
|
||||
//TODO: global을 따로 뗴어내고, 장수 Logger를 상속해서 받는 형식으로.
|
||||
protected $generalID;
|
||||
protected $nationID;
|
||||
@@ -37,7 +38,8 @@ class ActionLogger{
|
||||
/** <R>★</>{$year}년 {$month}월: */
|
||||
const NOTICE_YEAR_MONTH = 8;
|
||||
|
||||
public function __construct(int $generalID, int $nationID, int $year, int $month, bool $autoFlush = true){
|
||||
public function __construct(int $generalID, int $nationID, int $year, int $month, bool $autoFlush = true)
|
||||
{
|
||||
$this->generalID = $generalID;
|
||||
$this->nationID = $nationID;
|
||||
$this->year = $year;
|
||||
@@ -45,13 +47,15 @@ class ActionLogger{
|
||||
$this->autoFlush = $autoFlush;
|
||||
}
|
||||
|
||||
public function __destruct(){
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->autoFlush) {
|
||||
$this->flush();
|
||||
}
|
||||
}
|
||||
|
||||
public function rollback(){
|
||||
public function rollback()
|
||||
{
|
||||
$backup = [
|
||||
'generalHistoryLog' => $this->generalHistoryLog,
|
||||
'generalActionLog' => $this->generalActionLog,
|
||||
@@ -73,7 +77,8 @@ class ActionLogger{
|
||||
return $backup;
|
||||
}
|
||||
|
||||
public function flush(){
|
||||
public function flush()
|
||||
{
|
||||
if ($this->generalHistoryLog && $this->generalID) {
|
||||
pushGeneralHistory($this->generalID, $this->generalHistoryLog, $this->year, $this->month);
|
||||
$this->generalHistoryLog = [];
|
||||
@@ -111,7 +116,8 @@ class ActionLogger{
|
||||
}
|
||||
|
||||
|
||||
public function pushGeneralHistoryLog($text, int $formatType = self::YEAR_MONTH){
|
||||
public function pushGeneralHistoryLog($text, int $formatType = self::YEAR_MONTH)
|
||||
{
|
||||
if (!$text) {
|
||||
return;
|
||||
}
|
||||
@@ -126,7 +132,8 @@ class ActionLogger{
|
||||
$this->generalHistoryLog[] = $text;
|
||||
}
|
||||
|
||||
public function pushGeneralActionLog($text, int $formatType = self::MONTH){
|
||||
public function pushGeneralActionLog($text, int $formatType = self::MONTH)
|
||||
{
|
||||
if (!$text) {
|
||||
return;
|
||||
}
|
||||
@@ -141,7 +148,8 @@ class ActionLogger{
|
||||
$this->generalActionLog[] = $text;
|
||||
}
|
||||
|
||||
public function pushGeneralBattleResultLog($text, int $formatType = self::RAWTEXT){
|
||||
public function pushGeneralBattleResultLog($text, int $formatType = self::RAWTEXT)
|
||||
{
|
||||
if (!$text) {
|
||||
return;
|
||||
}
|
||||
@@ -156,7 +164,8 @@ class ActionLogger{
|
||||
$this->generalBattleResultLog[] = $text;
|
||||
}
|
||||
|
||||
public function pushGeneralBattleDetailLog($text, int $formatType = self::PLAIN){
|
||||
public function pushGeneralBattleDetailLog($text, int $formatType = self::PLAIN)
|
||||
{
|
||||
if (!$text) {
|
||||
return;
|
||||
}
|
||||
@@ -171,7 +180,8 @@ class ActionLogger{
|
||||
$this->generalBattleDetailLog[] = $text;
|
||||
}
|
||||
|
||||
public function pushNationalHistoryLog($text, int $formatType = self::YEAR_MONTH){
|
||||
public function pushNationalHistoryLog($text, int $formatType = self::YEAR_MONTH)
|
||||
{
|
||||
if (!$text) {
|
||||
return;
|
||||
}
|
||||
@@ -186,7 +196,8 @@ class ActionLogger{
|
||||
$this->nationalHistoryLog[] = $text;
|
||||
}
|
||||
|
||||
public function pushGlobalActionLog($text, int $formatType = self::MONTH){
|
||||
public function pushGlobalActionLog($text, int $formatType = self::MONTH)
|
||||
{
|
||||
if (!$text) {
|
||||
return;
|
||||
}
|
||||
@@ -201,7 +212,8 @@ class ActionLogger{
|
||||
$this->globalActionLog[] = $text;
|
||||
}
|
||||
|
||||
public function pushGlobalHistoryLog($text, int $formatType = self::YEAR_MONTH){
|
||||
public function pushGlobalHistoryLog($text, int $formatType = self::YEAR_MONTH)
|
||||
{
|
||||
if (!$text) {
|
||||
return;
|
||||
}
|
||||
@@ -216,7 +228,8 @@ class ActionLogger{
|
||||
$this->globalHistoryLog[] = $text;
|
||||
}
|
||||
|
||||
public function formatText(string $text, int $formatType):string{
|
||||
public function formatText(string $text, int $formatType): string
|
||||
{
|
||||
if ($formatType === self::RAWTEXT) {
|
||||
return $text;
|
||||
}
|
||||
@@ -283,12 +296,10 @@ class ActionLogger{
|
||||
if (!$me->isAttacker()) {
|
||||
$warType = 'defense';
|
||||
$warTypeStr = '←';
|
||||
}
|
||||
else if($oppose instanceof WarUnitCity){
|
||||
} else if ($oppose instanceof WarUnitCity) {
|
||||
$warType = 'siege';
|
||||
$warTypeStr = '→';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$warType = 'attack';
|
||||
$warTypeStr = '→';
|
||||
}
|
||||
@@ -307,12 +318,13 @@ class ActionLogger{
|
||||
$this->pushGeneralActionLog($res, self::EVENT_YEAR_MONTH);
|
||||
}
|
||||
|
||||
public function getYear():int{
|
||||
public function getYear(): int
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
|
||||
public function getMonth():int{
|
||||
public function getMonth(): int
|
||||
{
|
||||
return $this->month;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@ use \sammo\{
|
||||
Util, JosaUtil, DB,
|
||||
General, GameConst,
|
||||
ActionLogger,
|
||||
LastTurn
|
||||
LastTurn,
|
||||
NotInheritedMethodException
|
||||
};
|
||||
|
||||
use function \sammo\getNationStaticInfo;
|
||||
@@ -33,16 +34,19 @@ abstract class BaseCommand{
|
||||
protected $destCity = null;
|
||||
protected $destNation = null;
|
||||
|
||||
protected $runnable = null;
|
||||
protected $reservable = null;
|
||||
protected $cachedPermissionToReserve = false;
|
||||
protected $cachedMinConditionMet = false;
|
||||
protected $cachedFullConditionMet = false;
|
||||
|
||||
protected $isArgValid=false;
|
||||
|
||||
protected $reasonNotRunnable = null;
|
||||
protected $reasonNotReservable = null;
|
||||
protected $reasonNotFullConditionMet = null;
|
||||
protected $reasonNotMinConditionMet = null;
|
||||
protected $reasonNoPermissionToReserve = null;
|
||||
|
||||
protected $runnableConstraints = null;
|
||||
protected $reservableConstraints = null;
|
||||
protected $fullConditionConstraints = null;
|
||||
protected $minConditionConstraints = null;
|
||||
protected $permissionConstraints = null;
|
||||
|
||||
protected $logger;
|
||||
|
||||
@@ -63,26 +67,33 @@ abstract class BaseCommand{
|
||||
$this->logger = $generalObj->getLogger();
|
||||
$this->env = $env;
|
||||
$this->arg = $arg;
|
||||
if (!$this->argTest()) {
|
||||
return;
|
||||
}
|
||||
$this->isArgValid = true;
|
||||
$this->init();
|
||||
|
||||
|
||||
$this->init();
|
||||
if ($this->argTest()) {
|
||||
$this->isArgValid = true;
|
||||
if(static::$reqArg){
|
||||
$this->initWithArg();
|
||||
}
|
||||
}
|
||||
else{
|
||||
$this->isArgValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function resetTestCache():void{
|
||||
$this->runnable = null;
|
||||
$this->reservable = null;
|
||||
$this->cachedFullConditionMet = false;
|
||||
$this->cachedMinConditionMet = false;
|
||||
$this->cachedPermissionToReserve = false;
|
||||
|
||||
$this->reasonNotRunnable = null;
|
||||
$this->reasonNotReservable = null;
|
||||
$this->reasonNotFullConditionMet = null;
|
||||
$this->reasonNotMinConditionMet = null;
|
||||
$this->reasonNoPermissionToReserve = null;
|
||||
}
|
||||
|
||||
protected function setCity(?array $args=null){
|
||||
protected function setCity(){
|
||||
$this->resetTestCache();
|
||||
$db = DB::db();
|
||||
if($args === null){
|
||||
$this->city = $this->generalObj->getRawCity();
|
||||
if($this->city){
|
||||
return;
|
||||
@@ -92,28 +103,12 @@ abstract class BaseCommand{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->city = $this->generalObj->getRawCity();
|
||||
$hasArgs = true;
|
||||
foreach($args as $arg){
|
||||
if(!key_exists($arg, $this->city)){
|
||||
$hasArgs = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($hasArgs){
|
||||
return;
|
||||
}
|
||||
|
||||
$this->city = $db->queryFirstRow('SELECT %l FROM city WHERE city=%i', Util::formatListOfBackticks($args), $this->generalObj->getVar('city'));
|
||||
if($this->generalObj->getRawCity() === null){
|
||||
$this->generalObj->setRawCity($this->city);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setNation(?array $args = null){
|
||||
$this->resetTestCache();
|
||||
if($args === null){
|
||||
if(!$this->nation){
|
||||
$this->nation = $this->generalObj->getStaticNation();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,7 +138,18 @@ abstract class BaseCommand{
|
||||
'gennum'=>1
|
||||
];
|
||||
|
||||
|
||||
if($this->nation && $this->nation['nation'] === $nationID){
|
||||
$allArgExists = true;
|
||||
foreach($args as $arg){
|
||||
if(!key_exists($arg, $this->nation)){
|
||||
$allArgExists = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($allArgExists){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$nation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID);
|
||||
@@ -153,27 +159,34 @@ abstract class BaseCommand{
|
||||
$nation[$arg] = $defaultValues[$arg];
|
||||
}
|
||||
}
|
||||
|
||||
if($this->nation){
|
||||
//NOTE: 이 순서 맞다! https://www.php.net/manual/en/language.operators.array.php
|
||||
$this->nation = $nation + $this->nation;
|
||||
}
|
||||
else{
|
||||
$this->nation = $nation;
|
||||
}
|
||||
}
|
||||
|
||||
protected function setDestGeneral(General $destGeneralObj){
|
||||
$this->resetTestCache();
|
||||
$this->destGeneralObj = $destGeneralObj;
|
||||
}
|
||||
|
||||
protected function setDestCity(int $cityNo, ?array $args){
|
||||
protected function setDestCity(int $cityNo, bool $onlyName=false){
|
||||
$this->resetTestCache();
|
||||
$db = DB::db();
|
||||
if($args === []){
|
||||
if($onlyName){
|
||||
$cityObj = \sammo\CityConst::byID($cityNo);
|
||||
$this->destCity = ['city'=>$cityNo, 'name'=>$cityObj->name];
|
||||
$this->destCity = [
|
||||
'city'=>$cityNo,
|
||||
'name'=>$cityObj->name,
|
||||
'region'=>$cityObj->region,
|
||||
];
|
||||
return;
|
||||
}
|
||||
if($args === null){
|
||||
$this->destCity = $db->queryFirstRow('SELECT * FROM city WHERE city=%i', $cityNo);
|
||||
return;
|
||||
}
|
||||
$this->destCity = $db->queryFirstRow('SELECT %l FROM city WHERE city=%i', Util::formatListOfBackticks($args), $cityNo);
|
||||
}
|
||||
|
||||
protected function setDestNation(int $nationID, ?array $args = null){
|
||||
@@ -208,6 +221,11 @@ abstract class BaseCommand{
|
||||
}
|
||||
|
||||
abstract protected function init();
|
||||
protected function initWithArg(){
|
||||
if(static::$reqArg){
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
}
|
||||
abstract protected function argTest():bool;
|
||||
|
||||
public function getArg():?array{
|
||||
@@ -253,13 +271,19 @@ abstract class BaseCommand{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
public function testReservable():?string{
|
||||
if($this->reservableConstraints === null){
|
||||
public function testPermissionToReserve():?string{
|
||||
if(!$this->isArgValid()){
|
||||
$this->reasonNoPermissionToReserve = '인자가 올바르지 않습니다.';
|
||||
$this->cachedPermissionToReserve = true;
|
||||
return $this->reasonNoPermissionToReserve;
|
||||
}
|
||||
|
||||
if($this->permissionConstraints === null){
|
||||
return null;
|
||||
}
|
||||
|
||||
if($this->reasonNotReservable){
|
||||
return $this->reasonNotReservable;
|
||||
if($this->reasonNoPermissionToReserve){
|
||||
return $this->reasonNoPermissionToReserve;
|
||||
}
|
||||
|
||||
$this->generalObj->unpackAux();
|
||||
@@ -274,27 +298,29 @@ abstract class BaseCommand{
|
||||
'destNation'=>$this->destNation,
|
||||
];
|
||||
|
||||
[$this->reasonConstraint, $this->reasonNotReservable] = Constraint::testAll($this->reservableConstraints??[], $constraintInput, $this->env);
|
||||
$this->reservable = $this->reasonNotReservable === null;
|
||||
return $this->reasonNotReservable;
|
||||
[$this->reasonConstraint, $this->reasonNoPermissionToReserve] = Constraint::testAll($this->permissionConstraints??[], $constraintInput, $this->env);
|
||||
$this->cachedPermissionToReserve = true;
|
||||
return $this->reasonNoPermissionToReserve;
|
||||
}
|
||||
|
||||
public function canDisplay():bool{
|
||||
return true;
|
||||
return $this->hasPermissionToReserve();
|
||||
}
|
||||
|
||||
public function testRunnable():?string{
|
||||
if(!$this->isArgValid()){
|
||||
$this->reasonNotReservable = '인자가 올바르지 않습니다.';
|
||||
$this->reservable = false;
|
||||
return $this->reasonNotReservable;
|
||||
public function testMinConditionMet():?string{
|
||||
if(!static::$reqArg){
|
||||
if($this->minConditionConstraints){
|
||||
throw new \LogicException('reqArg==false인데 minCondition이 설정됨');
|
||||
}
|
||||
if($this->runnableConstraints === null){
|
||||
throw new \InvalidArgumentException('runnableConstraits가 제대로 설정되지 않았습니다');
|
||||
return $this->testFullConditionMet();
|
||||
}
|
||||
|
||||
if($this->reasonNotRunnable){
|
||||
return $this->reasonNotRunnable;
|
||||
if($this->minConditionConstraints === null){
|
||||
throw new \InvalidArgumentException('minConditionConstraints가 제대로 설정되지 않았습니다');
|
||||
}
|
||||
|
||||
if($this->cachedMinConditionMet){
|
||||
return $this->reasonNotMinConditionMet;
|
||||
}
|
||||
|
||||
$this->generalObj->unpackAux();
|
||||
@@ -309,9 +335,42 @@ abstract class BaseCommand{
|
||||
'destNation'=>$this->destNation,
|
||||
];
|
||||
|
||||
[$this->reasonConstraint, $this->reasonNotRunnable] = Constraint::testAll($this->runnableConstraints??[], $constraintInput, $this->env);
|
||||
$this->runnable = $this->reasonNotRunnable === null;
|
||||
return $this->reasonNotRunnable;
|
||||
[$this->reasonConstraint, $this->reasonNotMinConditionMet] = Constraint::testAll($this->minConditionConstraints??[], $constraintInput, $this->env);
|
||||
$this->cachedMinConditionMet = true;
|
||||
return $this->reasonNotMinConditionMet;
|
||||
|
||||
}
|
||||
|
||||
public function testFullConditionMet():?string{
|
||||
if(!$this->isArgValid()){
|
||||
$this->reasonNotFullConditionMet = '인자가 올바르지 않습니다.';
|
||||
$this->cachedFullConditionMet = true;
|
||||
return $this->reasonNotFullConditionMet;
|
||||
}
|
||||
|
||||
if($this->fullConditionConstraints === null){
|
||||
throw new \InvalidArgumentException('fullConditionConstraints가 제대로 설정되지 않았습니다');
|
||||
}
|
||||
|
||||
if($this->cachedFullConditionMet){
|
||||
return $this->reasonNotFullConditionMet;
|
||||
}
|
||||
|
||||
$this->generalObj->unpackAux();
|
||||
$constraintInput = [
|
||||
'general'=>$this->generalObj->getRaw(),
|
||||
'city'=>$this->city,
|
||||
'nation'=>$this->nation,
|
||||
'cmd_arg'=>$this->arg,
|
||||
|
||||
'destGeneral'=>$this->destGeneralObj?$this->destGeneralObj->getRaw():null,
|
||||
'destCity'=>$this->destCity,
|
||||
'destNation'=>$this->destNation,
|
||||
];
|
||||
|
||||
[$this->reasonConstraint, $this->reasonNotFullConditionMet] = Constraint::testAll($this->fullConditionConstraints??[], $constraintInput, $this->env);
|
||||
$this->cachedFullConditionMet = true;
|
||||
return $this->reasonNotFullConditionMet;
|
||||
|
||||
}
|
||||
|
||||
@@ -350,30 +409,25 @@ abstract class BaseCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isReservable():bool{
|
||||
if($this->reservable !== null){
|
||||
return $this->reservable;
|
||||
}
|
||||
|
||||
$this->reservable = $this->testReservable() === null;
|
||||
return $this->reservable;
|
||||
public function hasPermissionToReserve():bool{
|
||||
return $this->testPermissionToReserve() === null;
|
||||
}
|
||||
|
||||
public function isArgValid():bool{
|
||||
return $this->isArgValid;
|
||||
}
|
||||
|
||||
public function isRunnable():bool {
|
||||
if($this->runnable !== null){
|
||||
return $this->runnable;
|
||||
public function hasMinConditionMet():bool {
|
||||
return $this->testMinConditionMet() === null;
|
||||
}
|
||||
|
||||
return $this->testRunnable() === null;
|
||||
public function hasFullConditionMet():bool {
|
||||
return $this->testFullConditionMet() === null;
|
||||
}
|
||||
|
||||
public function getFailString():string{
|
||||
$commandName = $this->getName();
|
||||
$failReason = $this->testRunnable();
|
||||
$failReason = $this->testFullConditionMet();
|
||||
if($failReason === null){
|
||||
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ class che_NPC능동 extends Command\GeneralCommand{
|
||||
$this->setNation();
|
||||
|
||||
|
||||
$this->reservableConstraints=[
|
||||
$this->permissionConstraints=[
|
||||
ConstraintHelper::MustBeNPC()
|
||||
];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
|
||||
];
|
||||
|
||||
@@ -70,12 +70,8 @@ class che_NPC능동 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function canDisplay():bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
@@ -22,11 +26,13 @@ use sammo\CityConst;
|
||||
|
||||
|
||||
|
||||
class che_강행 extends Command\GeneralCommand{
|
||||
class che_강행 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '강행';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -42,17 +48,21 @@ class che_강행 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
$this->setDestCity($this->arg['destCityID'], []);
|
||||
|
||||
$this->minConditionConstraints = [];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID'], true);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotSameDestCity(),
|
||||
ConstraintHelper::NearCity(3),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
@@ -60,7 +70,8 @@ class che_강행 extends Command\GeneralCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
@@ -75,29 +86,34 @@ class che_강행 extends Command\GeneralCommand{
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
$env = $this->env;
|
||||
return [$env['develcost'] * 5, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||
$josaRo = JosaUtil::pick($destCityName, '로');
|
||||
return "【{$destCityName}】{$josaRo} {$commandName}";
|
||||
}
|
||||
|
||||
public function getFailString():string{
|
||||
public function getFailString(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$failReason = $this->testRunnable();
|
||||
$failReason = $this->testFullConditionMet();
|
||||
if ($failReason === null) {
|
||||
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
|
||||
}
|
||||
@@ -106,8 +122,9 @@ class che_강행 extends Command\GeneralCommand{
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -153,7 +170,6 @@ class che_강행 extends Command\GeneralCommand{
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public function getJSFiles(): array
|
||||
@@ -183,6 +199,4 @@ class che_강행 extends Command\GeneralCommand{
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,7 +30,8 @@ class che_거병 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
$env = $this->env;
|
||||
@@ -40,7 +41,7 @@ class che_거병 extends Command\GeneralCommand{
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::BeNeutral(),
|
||||
ConstraintHelper::BeOpeningPart($relYear+1),
|
||||
ConstraintHelper::AllowJoinAction(),
|
||||
@@ -60,7 +61,7 @@ class che_거병 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
@@ -25,11 +29,13 @@ use function sammo\GetNationColors;
|
||||
use function sammo\newColor;
|
||||
|
||||
|
||||
class che_건국 extends Command\GeneralCommand{
|
||||
class che_건국 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '건국';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -55,8 +61,7 @@ class che_건국 extends Command\GeneralCommand{
|
||||
|
||||
try {
|
||||
$nationTypeClass = buildNationTypeClass($nationType);
|
||||
}
|
||||
catch(\InvalidArgumentException $e){
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -69,21 +74,31 @@ class che_건국 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
|
||||
$general = $this->generalObj;
|
||||
protected function init()
|
||||
{
|
||||
$env = $this->env;
|
||||
|
||||
$nationName = $this->arg['nationName'];
|
||||
$nationType = $this->arg['nationType'];
|
||||
$colorType = $this->arg['colorType'];
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gennum']);
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$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),
|
||||
@@ -101,20 +116,24 @@ class che_건국 extends Command\GeneralCommand{
|
||||
return "【{$nationName}】{$josaUl} 건국";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,12 @@ class che_견문 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
];
|
||||
|
||||
}
|
||||
@@ -55,7 +56,7 @@ class che_견문 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -56,24 +56,36 @@ class che_군량매매 extends Command\GeneralCommand{
|
||||
return "군량 {$this->arg['amount']}을 {$buyRiceText}";
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::ReqCityTrader($general->getVar('npc')),
|
||||
ConstraintHelper::OccupiedCity(true),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::ReqCityTrader($general->getVar('npc')),
|
||||
ConstraintHelper::OccupiedCity(true),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
|
||||
if($this->arg['buyRice']){
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralGold(1);
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralGold(1);
|
||||
}
|
||||
else{
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralRice(1);
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralRice(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +102,7 @@ class che_군량매매 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ class che_귀환 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
@@ -39,7 +40,7 @@ class che_귀환 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::NotCapital(true),
|
||||
@@ -64,7 +65,7 @@ class che_귀환 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ class che_기술연구 extends che_상업투자{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
@@ -40,7 +41,7 @@ class che_기술연구 extends che_상업투자{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -53,7 +54,7 @@ class che_기술연구 extends che_상업투자{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ class che_단련 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
@@ -37,7 +38,7 @@ class che_단련 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
ConstraintHelper::ReqGeneralValue('train', '훈련', '>=', GameConst::$defaultTrainLow),
|
||||
@@ -77,7 +78,7 @@ class che_단련 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -53,21 +53,39 @@ class che_등용 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gennum', 'scout']);
|
||||
|
||||
$relYear = $this->env['year'] - $this->env['startyear'];
|
||||
|
||||
$this->permissionConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||
];
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotOpeningPart($relYear),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], 0);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$relYear = $this->env['year'] - $this->env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '==', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotOpeningPart($relYear),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -79,7 +97,7 @@ class che_등용 extends Command\GeneralCommand{
|
||||
];
|
||||
|
||||
if($this->destGeneralObj->getVar('officer_level') == 12){
|
||||
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail('군주에게는 등용장을 보낼 수 없습니다.');
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail('군주에게는 등용장을 보낼 수 없습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +131,7 @@ class che_등용 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -70,22 +70,26 @@ class che_등용수락 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
$this->setNation(['gennum', 'scout']);
|
||||
|
||||
$this->permissionConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], 0);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID'], ['gennum', 'scout']);
|
||||
|
||||
$relYear = $this->env['year'] - $this->env['startyear'];
|
||||
|
||||
$this->reservableConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '==', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||
ConstraintHelper::NotOpeningPart($relYear),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
@@ -109,7 +113,7 @@ class che_등용수락 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ use sammo\MustNotBeReachedException;
|
||||
|
||||
class che_랜덤임관 extends Command\GeneralCommand{
|
||||
static protected $actionName = '랜덤임관';
|
||||
static public $reqArg = false;
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = null;
|
||||
@@ -61,7 +60,8 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
return true;*/
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
$env = $this->env;
|
||||
@@ -71,14 +71,14 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::BeNeutral(),
|
||||
ConstraintHelper::AllowJoinAction(),
|
||||
];
|
||||
|
||||
/*
|
||||
if($this->arg['destNationIDList']??false){
|
||||
$this->runnableConstraints[] = ConstraintHelper::ExistsAllowJoinNation($relYear, $this->arg['destNationIDList']);
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ExistsAllowJoinNation($relYear, $this->arg['destNationIDList']);
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -29,14 +29,15 @@ class che_모반시도 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -59,7 +60,7 @@ class che_모반시도 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,15 @@ class che_물자조달 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -63,7 +64,7 @@ class che_물자조달 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class che_방랑 extends Command\GeneralCommand{
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::BeLord(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::NotOpeningPart($relYear),
|
||||
@@ -63,7 +63,7 @@ class che_방랑 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -69,7 +69,7 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -128,7 +128,7 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -22,11 +26,13 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
class che_선양 extends Command\GeneralCommand{
|
||||
class che_선양 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '선양';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -50,16 +56,24 @@ class che_선양 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setNation();
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::BeLord()
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::BeLord(),
|
||||
ConstraintHelper::ExistsDestGeneral(),
|
||||
ConstraintHelper::FriendlyDestGeneral(),
|
||||
@@ -70,15 +84,18 @@ class che_선양 extends Command\GeneralCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -89,8 +106,9 @@ class che_선양 extends Command\GeneralCommand{
|
||||
return "【{$destGeneralName}】에게 {$name}";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class che_소집해제 extends Command\GeneralCommand{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
];
|
||||
|
||||
@@ -58,7 +58,7 @@ class che_소집해제 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil, Session, KVStorage,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
Session,
|
||||
KVStorage,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command,
|
||||
ServConfig
|
||||
@@ -24,7 +30,8 @@ use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
|
||||
class che_숙련전환 extends Command\GeneralCommand{
|
||||
class che_숙련전환 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '숙련전환';
|
||||
static public $reqArg = true;
|
||||
|
||||
@@ -37,7 +44,8 @@ class che_숙련전환 extends Command\GeneralCommand{
|
||||
/** @var string */
|
||||
protected $destArmTypeName;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -75,35 +83,48 @@ class che_숙련전환 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->srcArmType = $this->arg['srcArmType'];
|
||||
$this->srcArmTypeName = GameUnitConst::allType()[$this->srcArmType];
|
||||
$this->destArmType = $this->arg['destArmType'];
|
||||
$this->destArmTypeName = GameUnitConst::allType()[$this->destArmType];
|
||||
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->srcArmType = $this->arg['srcArmType'];
|
||||
$this->srcArmTypeName = GameUnitConst::allType()[$this->srcArmType];
|
||||
$this->destArmType = $this->arg['destArmType'];
|
||||
$this->destArmTypeName = GameUnitConst::allType()[$this->destArmType];
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
}
|
||||
|
||||
public function getBrief(): string
|
||||
{
|
||||
return "【{$this->srcArmTypeName}】숙련을 【{$this->destArmTypeName}】숙련으로 전환";
|
||||
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
@@ -118,21 +139,25 @@ class che_숙련전환 extends Command\GeneralCommand{
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
$env = $this->env;
|
||||
return [$env['develcost'], $env['develcost']];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class che_요양 extends Command\GeneralCommand{
|
||||
|
||||
$this->setNation();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
];
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class che_요양 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
@@ -22,11 +26,13 @@ use sammo\CityConst;
|
||||
|
||||
|
||||
|
||||
class che_이동 extends Command\GeneralCommand{
|
||||
class che_이동 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '이동';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -42,17 +48,29 @@ class che_이동 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
$this->setDestCity($this->arg['destCityID'], []);
|
||||
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID'], true);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotSameDestCity(),
|
||||
ConstraintHelper::NearCity(1),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
@@ -60,7 +78,8 @@ class che_이동 extends Command\GeneralCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
@@ -75,29 +94,34 @@ class che_이동 extends Command\GeneralCommand{
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
$env = $this->env;
|
||||
return [$env['develcost'], 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||
$josaRo = JosaUtil::pick($destCityName, '로');
|
||||
return "【{$destCityName}】{$josaRo} {$commandName}";
|
||||
}
|
||||
|
||||
public function getFailString():string{
|
||||
public function getFailString(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$failReason = $this->testRunnable();
|
||||
$failReason = $this->testFullConditionMet();
|
||||
if ($failReason === null) {
|
||||
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
|
||||
}
|
||||
@@ -106,8 +130,9 @@ class che_이동 extends Command\GeneralCommand{
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class che_인재탐색 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
@@ -51,7 +51,7 @@ class che_인재탐색 extends Command\GeneralCommand{
|
||||
if($this->nation['nation'] != 0 && $relYear < 3 && $this->nation['gennum'] >= GameConst::$initialNationGenLimit){
|
||||
$nationName = $this->nation['name'];
|
||||
$josaUn = JosaUtil::pick($nationName, '은');
|
||||
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail("현재 <D>{$nationName}</>{$josaUn} 탐색이 제한되고 있습니다.");
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail("현재 <D>{$nationName}</>{$josaUn} 탐색이 제한되고 있습니다.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class che_인재탐색 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,22 @@ class che_임관 extends Command\GeneralCommand{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->permissionConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다')
|
||||
];
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||
ConstraintHelper::BeNeutral(),
|
||||
ConstraintHelper::AllowJoinAction()
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneralID = $this->arg['destGeneralID']??null;
|
||||
$destNationID = $this->arg['destNationID']??null;
|
||||
if($destGeneralID !== null){
|
||||
@@ -92,13 +108,9 @@ class che_임관 extends Command\GeneralCommand{
|
||||
$this->setDestNation($destNationID, ['gennum', 'scout']);
|
||||
}
|
||||
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->reservableConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다')
|
||||
];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||
ConstraintHelper::BeNeutral(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
@@ -107,11 +119,6 @@ class che_임관 extends Command\GeneralCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function canDisplay(): bool
|
||||
{
|
||||
return ($this->env['join_mode']??'') != 'onlyRandom';
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
@@ -132,7 +139,7 @@ class che_임관 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,15 @@ class che_장비매매 extends Command\GeneralCommand{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::ReqCityTrader($general->getVar('npc')),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$itemType = $this->arg['itemType'];
|
||||
$itemTypeName = static::$itemMap[$itemType];
|
||||
$itemCode = $this->arg['itemCode'];
|
||||
@@ -70,7 +79,7 @@ class che_장비매매 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::ReqCityTrader($general->getVar('npc')),
|
||||
ConstraintHelper::ReqCityCapacity('secu', '치안 수치', $itemClass->getReqSecu()),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
@@ -78,15 +87,14 @@ class che_장비매매 extends Command\GeneralCommand{
|
||||
];
|
||||
|
||||
if($itemCode === 'None'){
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralValue($itemType, $itemTypeName, '!=', 'None');
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralValue($itemType, $itemTypeName, '!=', 'None');
|
||||
}
|
||||
else if($itemCode == $general->getVar($itemType)){
|
||||
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail('이미 가지고 있습니다.');
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail('이미 가지고 있습니다.');
|
||||
}
|
||||
else if($itemType != 'item' && !buildItemClass($general->getVar($itemType))->isBuyable()){
|
||||
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail('이미 진귀한 것을 가지고 있습니다.');
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail('이미 진귀한 것을 가지고 있습니다.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
@@ -128,7 +136,7 @@ class che_장비매매 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class che_전투태세 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -65,7 +65,7 @@ class che_전투태세 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -118,7 +118,7 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -119,7 +119,7 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -22,11 +26,13 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
class che_증여 extends Command\GeneralCommand{
|
||||
class che_증여 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '증여';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -71,17 +77,27 @@ class che_증여 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
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->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -89,28 +105,30 @@ class che_증여 extends Command\GeneralCommand{
|
||||
ConstraintHelper::FriendlyDestGeneral()
|
||||
];
|
||||
if ($this->arg['isGold']) {
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
|
||||
} else {
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
|
||||
}
|
||||
else{
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
return "{$name}(통솔경험)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -122,8 +140,9 @@ class che_증여 extends Command\GeneralCommand{
|
||||
return "【{$destGeneralName}】에게 {$resText} {$this->arg['amount']}을 {$name}";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class che_집합 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -65,7 +65,7 @@ class che_집합 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil, Session, KVStorage,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
Session,
|
||||
KVStorage,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command,
|
||||
ServConfig
|
||||
@@ -23,7 +29,8 @@ use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
|
||||
class che_징병 extends Command\GeneralCommand{
|
||||
class che_징병 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '징병';
|
||||
static protected $costOffset = 1;
|
||||
static public $reqArg = true;
|
||||
@@ -45,7 +52,8 @@ class che_징병 extends Command\GeneralCommand{
|
||||
static::$defaultAtmos = GameConst::$defaultAtmosLow;
|
||||
}
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -79,12 +87,23 @@ class che_징병 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
$general = $this->generalObj;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->setCity();
|
||||
$this->setNation(['tech']);
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqCityCapacity('pop', '주민', GameConst::$minAvailableRecruitPop + 100),
|
||||
ConstraintHelper::ReqCityTrust(20),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$leadership = $general->getLeadership(false);
|
||||
$currCrewType = $general->getCrewTypeObj();
|
||||
$maxCrew = $leadership * 100;
|
||||
@@ -101,7 +120,7 @@ class che_징병 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqCityCapacity('pop', '주민', GameConst::$minAvailableRecruitPop + $reqCrew),
|
||||
@@ -111,21 +130,23 @@ class che_징병 extends Command\GeneralCommand{
|
||||
ConstraintHelper::ReqGeneralCrewMargin($reqCrewType->id),
|
||||
ConstraintHelper::AvailableRecruitCrewType($reqCrewType->id)
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$crewTypeName = $this->reqCrewType->name;
|
||||
$amount = $this->reqCrew;
|
||||
$commandName = static::getName();
|
||||
return "【{$crewTypeName}】 {$amount}명 {$commandName}";
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
return "{$this->getName()}(통솔경험)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
if (!$this->isArgValid) {
|
||||
return [0, 0];
|
||||
}
|
||||
@@ -139,16 +160,19 @@ class che_징병 extends Command\GeneralCommand{
|
||||
return [$reqGold, $reqRice];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -176,8 +200,7 @@ class che_징병 extends Command\GeneralCommand{
|
||||
$general->increaseVar('crew', $reqCrew);
|
||||
$general->setVar('train', $train);
|
||||
$general->setVar('atmos', $atmos);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$logger->pushGeneralActionLog("{$crewTypeName} <C>{$reqCrewText}</>명을 {$this->getName()}했습니다. <1>$date</>");
|
||||
$general->setVar('crewtype', $reqCrewType->id);
|
||||
$general->setVar('crew', $reqCrew);
|
||||
@@ -264,8 +287,7 @@ class che_징병 extends Command\GeneralCommand{
|
||||
|
||||
if ($unit->reqTech == 0) {
|
||||
$crewObj->bgcolor = 'green';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$crewObj->bgcolor = 'limegreen';
|
||||
}
|
||||
|
||||
@@ -284,8 +306,7 @@ class che_징병 extends Command\GeneralCommand{
|
||||
$crewObj->avoid = $unit->avoid;
|
||||
if ($this->env['show_img_level'] < 2) {
|
||||
$crewObj->img = ServConfig::$sharedIconPath . "/default.jpg";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$crewObj->img = ServConfig::$gameImagePath . "/crewtype" . $unit->id . ".png";
|
||||
}
|
||||
|
||||
@@ -323,11 +344,14 @@ class che_징병 extends Command\GeneralCommand{
|
||||
|
||||
<table class='tb_layout' style='margin:auto;'>
|
||||
<thead>
|
||||
<tr><td colspan=11><div style='float:right'><input type='checkbox' id="show_unavailable_troops">불가능한 병종 표시</input></div>
|
||||
<tr>
|
||||
<td colspan=11>
|
||||
<div style='float:right'><input type='checkbox' id="show_unavailable_troops">불가능한 병종 표시</input></div>
|
||||
<?php if ($commandName == '모병') : ?>
|
||||
<div style='text-align:center;'>모병은 가격 2배의 자금이 소요됩니다.</div>
|
||||
<?php endif; ?>
|
||||
</td></tr>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=11 align=center class='bg2'>
|
||||
현재 기술력 : <?= $techLevelText ?>
|
||||
@@ -353,15 +377,11 @@ class che_징병 extends Command\GeneralCommand{
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($armTypes as [$armName, $armTypeCrews]) : ?>
|
||||
<tr><td colspan=11><?=$armName?> 계열</td></tr>
|
||||
<tr>
|
||||
<td colspan=11><?= $armName ?> 계열</td>
|
||||
</tr>
|
||||
<?php foreach ($armTypeCrews as $crewObj) : ?>
|
||||
<tr
|
||||
id="crewType<?=$crewObj->id?>"
|
||||
class="show_default_<?=$crewObj->showDefault?>"
|
||||
style='height:64px;background-color:<?=$crewObj->bgcolor?>'
|
||||
data-rice="<?=$crewObj->baseRice?>"
|
||||
data-cost="<?=$crewObj->baseCost?>"
|
||||
>
|
||||
<tr id="crewType<?= $crewObj->id ?>" class="show_default_<?= $crewObj->showDefault ?>" style='height:64px;background-color:<?= $crewObj->bgcolor ?>' data-rice="<?= $crewObj->baseRice ?>" data-cost="<?= $crewObj->baseCost ?>">
|
||||
<td style='background:#222222 no-repeat center url("<?= $crewObj->img ?>");background-size:64px'></td>
|
||||
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->name ?></td>
|
||||
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->attack ?></td>
|
||||
@@ -371,21 +391,12 @@ class che_징병 extends Command\GeneralCommand{
|
||||
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->baseCostShort ?></td>
|
||||
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->baseRiceShort ?></td>
|
||||
<td style='text-align:center;vertical-align:middle;' class='input_form' data-crewtype='<?= $crewObj->id ?>'>
|
||||
<input type=button value='절반' class='btn_half'
|
||||
><input type=button value='채우기' class='btn_fill'
|
||||
><input type=button value='가득' class='btn_full'
|
||||
><br>
|
||||
<input type=text data-crewtype='<?=$crewObj->id?>' class=form_double name=double maxlength=3 size=3
|
||||
style=text-align:right;color:white;background-color:black
|
||||
>00명
|
||||
<input type=text class=form_cost name=cost maxlength=5 size=5 readonly
|
||||
style=text-align:right;color:white;background-color:black>원
|
||||
<input type=button value='절반' class='btn_half'><input type=button value='채우기' class='btn_fill'><input type=button value='가득' class='btn_full'><br>
|
||||
<input type=text data-crewtype='<?= $crewObj->id ?>' class=form_double name=double maxlength=3 size=3 style=text-align:right;color:white;background-color:black>00명
|
||||
<input type=text class=form_cost name=cost maxlength=5 size=5 readonly style=text-align:right;color:white;background-color:black>원
|
||||
|
||||
</td>
|
||||
<td style='position:relative;height:64px;'><input
|
||||
type=submit value='<?=$commandName?>' class='submit_btn'
|
||||
style='width:100%;height:44px;margin:10px 0;display:block;position: absolute;left:0;top:0;'
|
||||
></td>
|
||||
<td style='position:relative;height:64px;'><input type=submit value='<?= $commandName ?>' class='submit_btn' style='width:100%;height:44px;margin:10px 0;display:block;position: absolute;left:0;top:0;'></td>
|
||||
<td><?= $crewObj->info ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
@@ -23,11 +27,13 @@ use sammo\CityConst;
|
||||
|
||||
|
||||
|
||||
class che_첩보 extends Command\GeneralCommand{
|
||||
class che_첩보 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '첩보';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -43,30 +49,45 @@ class che_첩보 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['tech']);
|
||||
$this->setDestCity($this->arg['destCityID'], null);
|
||||
$this->setDestNation($this->destCity['nation'], ['tech']);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotOccupiedDestCity(),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
$this->setDestNation($this->destCity['nation'], ['tech']);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotOccupiedDestCity(),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
}
|
||||
|
||||
public function getBrief(): string
|
||||
{
|
||||
$cityName = $this->destCity['name'];
|
||||
return "【{$cityName}】에 {$this->getName()} 실행";
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
@@ -81,22 +102,26 @@ class che_첩보 extends Command\GeneralCommand{
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
$env = $this->env;
|
||||
return [$env['develcost'], $env['develcost']];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getFailString():string{
|
||||
public function getFailString(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$failReason = $this->testRunnable();
|
||||
$failReason = $this->testFullConditionMet();
|
||||
if ($failReason === null) {
|
||||
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
|
||||
}
|
||||
@@ -104,8 +129,9 @@ class che_첩보 extends Command\GeneralCommand{
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>에 {$commandName} 실패.";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -157,29 +183,22 @@ class che_첩보 extends Command\GeneralCommand{
|
||||
$techDiff = floor($this->destNation['tech']) - floor($this->nation['tech']);
|
||||
if ($techDiff >= 1000) {
|
||||
$techText = '<M>↑</>압도';
|
||||
}
|
||||
else if($techDiff >= 250){
|
||||
} else if ($techDiff >= 250) {
|
||||
$techText = '<Y>▲</>우위';
|
||||
}
|
||||
else if($techDiff >= -250){
|
||||
} else if ($techDiff >= -250) {
|
||||
$techText = '<W>↕</>대등';
|
||||
}
|
||||
else if($techDiff >= -1000){
|
||||
} else if ($techDiff >= -1000) {
|
||||
$techText = '<G>▼</>열위';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$techText = '<C>↓</>미미';
|
||||
}
|
||||
$logger->pushGeneralActionLog("【<span class='ev_notice'>{$this->destNation['name']}</span>】아국대비기술:{$techText}");
|
||||
}
|
||||
|
||||
}
|
||||
else if($dist == 2){
|
||||
} else if ($dist == 2) {
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>의 정보를 어느 정도 얻었습니다. <1>$date</>");
|
||||
$logger->pushGeneralActionLog($cityBrief, ActionLogger::RAWTEXT);
|
||||
$logger->pushGeneralActionLog($cityDevel, ActionLogger::RAWTEXT);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>의 소문만 들을 수 있었습니다. <1>$date</>");
|
||||
$logger->pushGeneralActionLog($cityBrief, ActionLogger::RAWTEXT);
|
||||
}
|
||||
@@ -225,6 +244,4 @@ class che_첩보 extends Command\GeneralCommand{
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
@@ -22,11 +26,13 @@ use sammo\CityConst;
|
||||
|
||||
|
||||
|
||||
class che_출병 extends Command\GeneralCommand{
|
||||
class che_출병 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '출병';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -42,18 +48,36 @@ class che_출병 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['war', 'gennum', 'tech', 'gold', 'rice', 'color', 'type', 'level', 'capital']);
|
||||
$this->setDestCity($this->arg['destCityID'], null);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$relYear = $this->env['year'] - $this->env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotOpeningPart($relYear+1),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$relYear = $this->env['year'] - $this->env['startyear'];
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotOpeningPart($relYear),
|
||||
ConstraintHelper::NotSameDestCity(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
@@ -65,35 +89,41 @@ class che_출병 extends Command\GeneralCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
//[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
return "{$name}(통솔경험, 병종숙련, 군량↓)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, Util::round($this->generalObj->getVar('crew') / 100)];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||
$josaRo = JosaUtil::pick($destCityName, '로');
|
||||
return "【{$destCityName}】{$josaRo} {$commandName}";
|
||||
}
|
||||
|
||||
public function getFailString():string{
|
||||
public function getFailString(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$failReason = $this->testRunnable();
|
||||
$failReason = $this->testFullConditionMet();
|
||||
if ($failReason === null) {
|
||||
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
|
||||
}
|
||||
@@ -102,8 +132,9 @@ class che_출병 extends Command\GeneralCommand{
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -162,7 +193,7 @@ class che_출병 extends Command\GeneralCommand{
|
||||
|
||||
$defenderCityID = (int) Util::choiceRandom($candidateCities);
|
||||
$defenderCityName = $this->destCity['name'];
|
||||
$this->setDestCity($defenderCityID, null);
|
||||
$this->setDestCity($defenderCityID);
|
||||
$josaRo = JosaUtil::pick($defenderCityName, '로');
|
||||
|
||||
if ($attackerNationID == $defenderNationID) {
|
||||
@@ -176,8 +207,7 @@ class che_출병 extends Command\GeneralCommand{
|
||||
$josaUl = JosaUtil::pick($defenderCityName, '을');
|
||||
if ($minDist == $currDist) {
|
||||
$logger->pushGeneralActionLog("<G><b>{$finalTargetCityName}</b></>{$josaRo} 가기 위해 <G><b>{$defenderCityName}</b></>{$josaUl} 거쳐야 합니다. <1>$date</>");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$logger->pushGeneralActionLog("<G><b>{$finalTargetCityName}</b></>{$josaRo} 가는 도중 <G><b>{$defenderCityName}</b></>{$josaUl} 거치기로 합니다. <1>$date</>");
|
||||
}
|
||||
}
|
||||
@@ -227,6 +257,4 @@ class che_출병 extends Command\GeneralCommand{
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class che_하야 extends Command\GeneralCommand{
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotOpeningPart($relYear),
|
||||
ConstraintHelper::NotLord(),
|
||||
@@ -58,7 +58,7 @@ class che_하야 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class che_해산 extends Command\GeneralCommand{
|
||||
$this->setCity();
|
||||
$this->setNation(['gennum']);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::BeLord(),
|
||||
ConstraintHelper::WanderingNation(),
|
||||
];
|
||||
@@ -59,7 +59,7 @@ class che_해산 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
@@ -22,11 +25,13 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
class che_헌납 extends Command\GeneralCommand{
|
||||
class che_헌납 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '헌납';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -53,25 +58,33 @@ class che_헌납 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
if ($this->arg['isGold']) {
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
|
||||
} else {
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
|
||||
}
|
||||
else{
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getBrief(): string
|
||||
@@ -81,25 +94,30 @@ class che_헌납 extends Command\GeneralCommand{
|
||||
return "{$resText} {$this->arg['amount']}을 {$name}";
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
return "{$name}(통솔경험)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
@@ -22,14 +26,16 @@ use sammo\CityConst;
|
||||
|
||||
|
||||
|
||||
class che_화계 extends Command\GeneralCommand{
|
||||
class che_화계 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '화계';
|
||||
static public $reqArg = true;
|
||||
|
||||
static protected $statType = 'intel';
|
||||
static protected $injuryGeneral = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -45,21 +51,19 @@ class che_화계 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function calcSabotageAttackProb():float{
|
||||
protected function calcSabotageAttackProb(): float
|
||||
{
|
||||
$statType = static::$statType;
|
||||
$general = $this->generalObj;
|
||||
$nation = $this->nation;
|
||||
|
||||
if ($statType === 'leadership') {
|
||||
$genScore = $general->getLeadership();
|
||||
}
|
||||
else if($statType === 'strength'){
|
||||
} else if ($statType === 'strength') {
|
||||
$genScore = $general->getStrength();
|
||||
}
|
||||
else if($statType === 'intel'){
|
||||
} else if ($statType === 'intel') {
|
||||
$genScore = $general->getIntel();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
throw new \sammo\MustNotBeReachedException();
|
||||
}
|
||||
|
||||
@@ -68,7 +72,8 @@ class che_화계 extends Command\GeneralCommand{
|
||||
return $prob;
|
||||
}
|
||||
|
||||
protected function calcSabotageDefenceProb(array $destCityGeneralList):float{
|
||||
protected function calcSabotageDefenceProb(array $destCityGeneralList): float
|
||||
{
|
||||
$statType = static::$statType;
|
||||
$destCity = $this->destCity;
|
||||
$destNation = $this->destNation;
|
||||
@@ -83,14 +88,11 @@ class che_화계 extends Command\GeneralCommand{
|
||||
|
||||
if ($statType === 'leadership') {
|
||||
$genScore = $destGeneral->getLeadership();
|
||||
}
|
||||
else if($statType === 'strength'){
|
||||
} else if ($statType === 'strength') {
|
||||
$genScore = $destGeneral->getStrength();
|
||||
}
|
||||
else if($statType === 'intel'){
|
||||
} else if ($statType === 'intel') {
|
||||
$genScore = $destGeneral->getIntel();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
throw new \sammo\MustNotBeReachedException();
|
||||
}
|
||||
$maxGenScore = max($maxGenScore, $genScore);
|
||||
@@ -103,17 +105,35 @@ class che_화계 extends Command\GeneralCommand{
|
||||
return $prob;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setDestCity($this->arg['destCityID'], null); //xxx: 이대로라면 메인 페이지 갱신시마다 DB query를 하게 된다.
|
||||
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
$this->setDestNation($this->destCity['nation']);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -128,7 +148,8 @@ class che_화계 extends Command\GeneralCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
$statTypeBase = [
|
||||
'leadership' => '통솔경험',
|
||||
@@ -149,29 +170,34 @@ class che_화계 extends Command\GeneralCommand{
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
$env = $this->env;
|
||||
$cost = $env['develcost'] * 5;
|
||||
return [$cost, $cost];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||
return "【{$destCityName}】에 {$commandName}실행";
|
||||
}
|
||||
|
||||
public function getFailString():string{
|
||||
public function getFailString(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$failReason = $this->testRunnable();
|
||||
$failReason = $this->testFullConditionMet();
|
||||
if ($failReason === null) {
|
||||
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
|
||||
}
|
||||
@@ -179,7 +205,8 @@ class che_화계 extends Command\GeneralCommand{
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>에 {$commandName} 실패.";
|
||||
}
|
||||
|
||||
protected function affectDestCity(int $injuryCount){
|
||||
protected function affectDestCity(int $injuryCount)
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
@@ -217,8 +244,9 @@ class che_화계 extends Command\GeneralCommand{
|
||||
);
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -277,8 +305,7 @@ class che_화계 extends Command\GeneralCommand{
|
||||
|
||||
if (static::$injuryGeneral) {
|
||||
$injuryCount = \sammo\SabotageInjury($destCityGeneralList, '계략');
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$injuryCount = 0;
|
||||
}
|
||||
|
||||
@@ -337,6 +364,4 @@ class che_화계 extends Command\GeneralCommand{
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -73,7 +73,7 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ class 휴식 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
$this->runnableConstraints=[];
|
||||
protected function init()
|
||||
{
|
||||
$this->minConditionConstraints=[];
|
||||
$this->fullConditionConstraints=[];
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
|
||||
@@ -29,7 +29,6 @@ use sammo\Event\Action;
|
||||
|
||||
class che_감축 extends Command\NationCommand{
|
||||
static protected $actionName = '감축';
|
||||
static public $reqArg = false;
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = [];
|
||||
@@ -43,10 +42,10 @@ class che_감축 extends Command\NationCommand{
|
||||
$env = $this->env;
|
||||
|
||||
if($general->getNationID()===0){
|
||||
$this->reservableConstraints=[
|
||||
$this->permissionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
];
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
];
|
||||
return;
|
||||
@@ -54,13 +53,13 @@ class che_감축 extends Command\NationCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gold', 'rice', 'capset', 'capital']);
|
||||
$this->setDestCity($this->nation['capital'], null);
|
||||
$this->setDestCity($this->nation['capital']);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$origCityLevel = CityConst::byID($this->nation['capital'])->level;
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -136,7 +135,7 @@ class che_감축 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command,
|
||||
Message, MessageTarget
|
||||
Message,
|
||||
MessageTarget
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
@@ -24,11 +29,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_급습 extends Command\NationCommand{
|
||||
class che_급습 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '급습';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -51,7 +58,8 @@ class che_급습 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
@@ -59,22 +67,34 @@ class che_급습 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
|
||||
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::AvailableStrategicCommand(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestNation($this->arg['destNationID'], null);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
ConstraintHelper::AllowDiplomacyWithTerm(
|
||||
1, 12,
|
||||
1,
|
||||
12,
|
||||
'선포 12개월 이상인 상대국에만 가능합니다.'
|
||||
),
|
||||
ConstraintHelper::AvailableStrategicCommand(),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
$reqTurn = $this->getPreReqTurn() + 1;
|
||||
$postReqTurn = $this->getPostReqTurn();
|
||||
@@ -82,15 +102,18 @@ class che_급습 extends Command\NationCommand{
|
||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||
$nextTerm = Util::round(sqrt($genCount * 16) * 10);
|
||||
|
||||
@@ -98,15 +121,17 @@ class che_급습 extends Command\NationCommand{
|
||||
return $nextTerm;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||
return "【{$destNationName}】에 {$commandName}";
|
||||
}
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -199,10 +224,9 @@ class che_급습 extends Command\NationCommand{
|
||||
|
||||
$testTurn->setArg(['destNationID' => $destNation['nation']]);
|
||||
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
|
||||
if($testCommand->isRunnable()){
|
||||
if ($testCommand->hasFullConditionMet()) {
|
||||
$destNation['availableCommand'] = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$destNation['availableCommand'] = false;
|
||||
}
|
||||
|
||||
@@ -218,10 +242,7 @@ class che_급습 extends Command\NationCommand{
|
||||
배경색은 현재 급습 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
||||
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach ($nationList as $nation) : ?>
|
||||
<option
|
||||
value='<?=$nation['nation']?>'
|
||||
style='color:<?=$nation['color']?>;<?=$nation['availableCommand']?'':'background-color:red;'?>'
|
||||
>【<?=$nation['name']?> 】</option>
|
||||
<option value='<?= $nation['nation'] ?>' style='color:<?= $nation['color'] ?>;<?= $nation['availableCommand'] ? '' : 'background-color:red;' ?>'>【<?= $nation['name'] ?> 】</option>
|
||||
<?php endforeach; ?>
|
||||
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
||||
<?php
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -23,11 +27,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_몰수 extends Command\NationCommand{
|
||||
class che_몰수 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '몰수';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -72,7 +78,8 @@ class che_몰수 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
@@ -80,12 +87,26 @@ class che_몰수 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation(['gold', 'rice']);
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotOpeningPart($relYear),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation', 'imgsvr', 'picture'], 1);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
@@ -96,19 +117,23 @@ class che_몰수 extends Command\NationCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$isGold = $this->arg['isGold'];
|
||||
$amount = $this->arg['amount'];
|
||||
$amountText = number_format($amount, 0);
|
||||
@@ -119,8 +144,9 @@ class che_몰수 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,16 @@ class che_물자원조 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation(['gold', 'rice', 'surlimit']);
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destNationID = $this->arg['destNationID'];
|
||||
$this->setDestNation($destNationID, ['gold', 'rice', 'surlimit']);
|
||||
|
||||
@@ -87,13 +97,13 @@ class che_물자원조 extends Command\NationCommand{
|
||||
$limit = $this->nation['level'] * GameConst::$coefAidAmount;
|
||||
|
||||
if($goldAmount > $limit || $riceAmount > $limit){
|
||||
$this->runnableConstraints[
|
||||
$this->fullConditionConstraints[
|
||||
ConstraintHelper::AlwaysFail('작위 제한량 이상은 보낼 수 없습니다.')
|
||||
];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
@@ -128,7 +138,7 @@ class che_물자원조 extends Command\NationCommand{
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -60,12 +60,22 @@ class che_발령 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->setDestCity($this->arg['destCityID'], null);
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, 1);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -79,7 +89,7 @@ class che_발령 extends Command\NationCommand{
|
||||
|
||||
public function getFailString():string{
|
||||
$commandName = $this->getName();
|
||||
$failReason = $this->testRunnable();
|
||||
$failReason = $this->testFullConditionMet();
|
||||
if($failReason === null){
|
||||
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
|
||||
}
|
||||
@@ -109,7 +119,7 @@ class che_발령 extends Command\NationCommand{
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,20 @@ class che_백성동원 extends Command\NationCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
$this->setDestCity($this->arg['destCityID'], null);
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::AvailableStrategicCommand()
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
$this->setDestNation($this->destCity['nation']);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
||||
@@ -101,7 +111,7 @@ class che_백성동원 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -26,11 +30,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_불가침수락 extends Command\NationCommand{
|
||||
class che_불가침수락 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '불가침 수락';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -86,15 +92,23 @@ class che_불가침수락 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->permissionConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
@@ -108,18 +122,14 @@ class che_불가침수락 extends Command\NationCommand{
|
||||
|
||||
$nationID = $this->nation['nation'];
|
||||
|
||||
$this->reservableConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
|
||||
if ($reqMonth <= $currentMonth) {
|
||||
$this->runnableConstraints = [
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::AlwaysFail('이미 기한이 지났습니다.')
|
||||
];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -136,22 +146,25 @@ class che_불가침수락 extends Command\NationCommand{
|
||||
6 => '아국과 외교 진행중입니다.',
|
||||
]),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||
$year = $this->arg['year'];
|
||||
@@ -159,8 +172,9 @@ class che_불가침수락 extends Command\NationCommand{
|
||||
return "{$year}년 {$month}월까지 불가침 합의";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -186,13 +200,18 @@ class che_불가침수락 extends Command\NationCommand{
|
||||
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
|
||||
$reqMonth = $year * 12 + $month - 1;
|
||||
|
||||
$db->update('diplomacy',[
|
||||
$db->update(
|
||||
'diplomacy',
|
||||
[
|
||||
'state' => 7,
|
||||
'term' => $reqMonth - $currentMonth
|
||||
],
|
||||
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
|
||||
$nationID, $destNationID,
|
||||
$nationID, $destNationID);
|
||||
$nationID,
|
||||
$destNationID,
|
||||
$nationID,
|
||||
$destNationID
|
||||
);
|
||||
|
||||
$josaWa = JosaUtil::pick($destNationName, '와');
|
||||
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>{$josaWa} <C>$year</>년 <C>{$month}</>월까지 불가침에 성공했습니다.", ActionLogger::PLAIN);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -26,11 +30,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_불가침제의 extends Command\NationCommand{
|
||||
class che_불가침제의 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '불가침 제의';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -71,38 +77,49 @@ class che_불가침제의 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestNation($this->arg['destNationID'], null);
|
||||
|
||||
//NOTE: 개월에서 기한으로 바뀜
|
||||
$year = $this->arg['year'];
|
||||
$month = $this->arg['month'];
|
||||
|
||||
$env = $this->env;
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
|
||||
$reqMonth = $year * 12 + $month - 1;
|
||||
|
||||
$nationID = $this->nation['nation'];
|
||||
|
||||
if ($reqMonth < $currentMonth + 12) {
|
||||
$this->reservableConstraints = [
|
||||
$this->permissionConstraints = [
|
||||
ConstraintHelper::AlwaysFail('기한은 1년 이상이어야 합니다.')
|
||||
];
|
||||
|
||||
$this->runnableConstraints = [
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::AlwaysFail('기한은 1년 이상이어야 합니다.')
|
||||
];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
@@ -115,22 +132,25 @@ class che_불가침제의 extends Command\NationCommand{
|
||||
6 => '아국과 외교 진행중입니다.',
|
||||
]),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||
$year = $this->arg['year'];
|
||||
@@ -139,8 +159,9 @@ class che_불가침제의 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -245,13 +266,11 @@ class che_불가침제의 extends Command\NationCommand{
|
||||
'year' => $currYear + 1,
|
||||
'month' => 12
|
||||
]);
|
||||
if(!$testCommand->isRunnable()){
|
||||
if (!$testCommand->hasFullConditionMet()) {
|
||||
$destNation['cssBgColor'] = 'background-color:red;';
|
||||
}
|
||||
else if($diplomacyStatus[$destNation['nation']]['state'] == 7){
|
||||
} else if ($diplomacyStatus[$destNation['nation']]['state'] == 7) {
|
||||
$destNation['cssBgColor'] = 'background-color:blue;';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$destNation['cssBgColor'] = '';
|
||||
}
|
||||
|
||||
@@ -268,10 +287,7 @@ class che_불가침제의 extends Command\NationCommand{
|
||||
<br>
|
||||
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach ($nationList as $nation) : ?>
|
||||
<option
|
||||
value='<?=$nation['nation']?>'
|
||||
style='color:<?=$nation['color']?>;<?=$nation['cssBgColor']?>'
|
||||
>【<?=$nation['name']?> 】</option>
|
||||
<option value='<?= $nation['nation'] ?>' style='color:<?= $nation['color'] ?>;<?= $nation['cssBgColor'] ?>'>【<?= $nation['name'] ?> 】</option>
|
||||
<?php endforeach; ?>
|
||||
</select>에게
|
||||
<select class='formInput' name="year" id="year" size='1' style='color:white;background-color:black;'>
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -26,11 +30,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_불가침파기수락 extends Command\NationCommand{
|
||||
class che_불가침파기수락 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '불가침 파기 수락';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -67,26 +73,24 @@ class che_불가침파기수락 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->permissionConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
|
||||
$nationID = $this->nation['nation'];
|
||||
|
||||
$this->reservableConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
@@ -97,29 +101,33 @@ class che_불가침파기수락 extends Command\NationCommand{
|
||||
'불가침 중인 상대국에게만 가능합니다.'
|
||||
),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||
return "{$destNationName}국과 불가침 파기 합의";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -140,13 +148,18 @@ class che_불가침파기수락 extends Command\NationCommand{
|
||||
$logger = $general->getLogger();
|
||||
$destLogger = $this->destGeneralObj->getLogger();
|
||||
|
||||
$db->update('diplomacy',[
|
||||
$db->update(
|
||||
'diplomacy',
|
||||
[
|
||||
'state' => 2,
|
||||
'term' => 0
|
||||
],
|
||||
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
|
||||
$nationID, $destNationID,
|
||||
$nationID, $destNationID);
|
||||
$nationID,
|
||||
$destNationID,
|
||||
$nationID,
|
||||
$destNationID
|
||||
);
|
||||
|
||||
$josaYiGeneral = JosaUtil::pick($generalName, '이');
|
||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||
|
||||
@@ -60,9 +60,21 @@ class che_불가침파기제의 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestNation($this->arg['destNationID'], null);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -96,7 +108,7 @@ class che_불가침파기제의 extends Command\NationCommand{
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command,
|
||||
Message, MessageTarget
|
||||
Message,
|
||||
MessageTarget
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
@@ -24,11 +29,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_선전포고 extends Command\NationCommand{
|
||||
class che_선전포고 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '선전포고';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -51,29 +58,38 @@ class che_선전포고 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->setDestNation($this->arg['destNationID'], null);
|
||||
|
||||
if($relYear < 3 - 2){
|
||||
$this->runnableConstraints = [
|
||||
ConstraintHelper::AlwaysFail('초반제한 해제 2년전부터 가능합니다.')
|
||||
];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$startYear = $this->env['startyear'];
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::ReqEnvValue('year', '>=', $startYear + 1, '초반제한 해제 2년전부터 가능합니다.'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$startYear = $this->env['startyear'];
|
||||
|
||||
$this->setDestNation($this->arg['destNationID'], null);
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::ReqEnvValue('year', '>=', $startYear + 1, '초반제한 해제 2년전부터 가능합니다.'),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
ConstraintHelper::NearNation(),
|
||||
ConstraintHelper::DisallowDiplomacyBetweenStatus([
|
||||
@@ -86,30 +102,34 @@ class che_선전포고 extends Command\NationCommand{
|
||||
5 => '상대국이 외교 진행중입니다.'
|
||||
]),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||
return "【{$destNationName}】에 {$commandName}";
|
||||
}
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -203,10 +223,9 @@ class che_선전포고 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
$testCommand = new static($generalObj, $this->env, $this->getLastTurn(), ['destNationID' => $destNation['nation']]);
|
||||
if($testCommand->isRunnable()){
|
||||
if ($testCommand->hasFullConditionMet()) {
|
||||
$destNation['availableWar'] = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$destNation['availableWar'] = false;
|
||||
}
|
||||
|
||||
@@ -223,10 +242,7 @@ class che_선전포고 extends Command\NationCommand{
|
||||
현재 선포가 불가능한 국가는 배경색이 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
||||
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach ($nationList as $nation) : ?>
|
||||
<option
|
||||
value='<?=$nation['nation']?>'
|
||||
style='color:<?=$nation['color']?>;<?=$nation['availableWar']?'':'background-color:red;'?>'
|
||||
>【<?=$nation['name']?> 】</option>
|
||||
<option value='<?= $nation['nation'] ?>' style='color:<?= $nation['color'] ?>;<?= $nation['availableWar'] ? '' : 'background-color:red;' ?>'>【<?= $nation['name'] ?> 】</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
||||
|
||||
@@ -56,10 +56,20 @@ class che_수몰 extends Command\NationCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
$this->setDestCity($this->arg['destCityID'], null);
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::AvailableStrategicCommand(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
$this->setDestNation($this->destCity['nation']);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotNeutralDestCity(),
|
||||
@@ -101,7 +111,7 @@ class che_수몰 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_의병모집 extends Command\NationCommand{
|
||||
static protected $actionName = '의병모집';
|
||||
static public $reqArg = false;
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = null;
|
||||
@@ -41,7 +40,7 @@ class che_의병모집 extends Command\NationCommand{
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -75,7 +74,7 @@ class che_의병모집 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command,
|
||||
Message, MessageTarget
|
||||
Message,
|
||||
MessageTarget
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
@@ -24,11 +29,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_이호경식 extends Command\NationCommand{
|
||||
class che_이호경식 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '이호경식';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -51,7 +58,8 @@ class che_이호경식 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
@@ -59,9 +67,18 @@ class che_이호경식 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::AvailableStrategicCommand(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestNation($this->arg['destNationID'], null);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
@@ -71,10 +88,10 @@ class che_이호경식 extends Command\NationCommand{
|
||||
),
|
||||
ConstraintHelper::AvailableStrategicCommand(),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
$reqTurn = $this->getPreReqTurn() + 1;
|
||||
$postReqTurn = $this->getPostReqTurn();
|
||||
@@ -82,15 +99,18 @@ class che_이호경식 extends Command\NationCommand{
|
||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||
$nextTerm = Util::round(sqrt($genCount * 16) * 10);
|
||||
|
||||
@@ -98,15 +118,17 @@ class che_이호경식 extends Command\NationCommand{
|
||||
return $nextTerm;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||
return "【{$destNationName}】에 {$commandName}";
|
||||
}
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -200,10 +222,9 @@ class che_이호경식 extends Command\NationCommand{
|
||||
|
||||
$testTurn->setArg(['destNationID' => $destNation['nation']]);
|
||||
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
|
||||
if($testCommand->isRunnable()){
|
||||
if ($testCommand->hasFullConditionMet()) {
|
||||
$destNation['availableCommand'] = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$destNation['availableCommand'] = false;
|
||||
}
|
||||
|
||||
@@ -219,10 +240,7 @@ class che_이호경식 extends Command\NationCommand{
|
||||
배경색은 현재 이호경식 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
||||
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach ($nationList as $nation) : ?>
|
||||
<option
|
||||
value='<?=$nation['nation']?>'
|
||||
style='color:<?=$nation['color']?>;<?=$nation['availableCommand']?'':'background-color:red;'?>'
|
||||
>【<?=$nation['name']?> 】</option>
|
||||
<option value='<?= $nation['nation'] ?>' style='color:<?= $nation['color'] ?>;<?= $nation['availableCommand'] ? '' : 'background-color:red;' ?>'>【<?= $nation['name'] ?> 】</option>
|
||||
<?php endforeach; ?>
|
||||
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
||||
<?php
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -26,11 +30,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_종전수락 extends Command\NationCommand{
|
||||
class che_종전수락 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '종전 수락';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -67,7 +73,8 @@ class che_종전수락 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
@@ -76,17 +83,21 @@ class che_종전수락 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
|
||||
$nationID = $this->nation['nation'];
|
||||
|
||||
$this->permissionConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
|
||||
$nationID = $this->nation['nation'];
|
||||
|
||||
$this->reservableConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
@@ -97,29 +108,33 @@ class che_종전수락 extends Command\NationCommand{
|
||||
'상대국과 선포, 전쟁중이지 않습니다.'
|
||||
),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||
return "{$destNationName}국과 종전 합의";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -140,13 +155,18 @@ class che_종전수락 extends Command\NationCommand{
|
||||
$logger = $general->getLogger();
|
||||
$destLogger = $this->destGeneralObj->getLogger();
|
||||
|
||||
$db->update('diplomacy',[
|
||||
$db->update(
|
||||
'diplomacy',
|
||||
[
|
||||
'state' => 2,
|
||||
'term' => 0
|
||||
],
|
||||
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
|
||||
$nationID, $destNationID,
|
||||
$nationID, $destNationID);
|
||||
$nationID,
|
||||
$destNationID,
|
||||
$nationID,
|
||||
$destNationID
|
||||
);
|
||||
|
||||
$josaYiGeneral = JosaUtil::pick($generalName, '이');
|
||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||
|
||||
@@ -60,9 +60,20 @@ class che_종전제의 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestNation($this->arg['destNationID'], null);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -73,7 +84,6 @@ class che_종전제의 extends Command\NationCommand{
|
||||
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
||||
),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
@@ -96,7 +106,7 @@ class che_종전제의 extends Command\NationCommand{
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ use sammo\Event\Action;
|
||||
|
||||
class che_증축 extends Command\NationCommand{
|
||||
static protected $actionName = '증축';
|
||||
static public $reqArg = false;
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = [];
|
||||
@@ -42,10 +41,10 @@ class che_증축 extends Command\NationCommand{
|
||||
$env = $this->env;
|
||||
|
||||
if($general->getNationID()===0){
|
||||
$this->reservableConstraints=[
|
||||
$this->permissionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
];
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
];
|
||||
return;
|
||||
@@ -53,11 +52,11 @@ class che_증축 extends Command\NationCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gold', 'rice', 'capset', 'capital']);
|
||||
$this->setDestCity($this->nation['capital'], null);
|
||||
$this->setDestCity($this->nation['capital']);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -135,7 +134,7 @@ class che_증축 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -26,13 +30,15 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Event\Action;
|
||||
|
||||
class che_천도 extends Command\NationCommand{
|
||||
class che_천도 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '천도';
|
||||
static public $reqArg = true;
|
||||
|
||||
private $cachedDist = null;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -51,25 +57,34 @@ class che_천도 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['capset', 'gold', 'rice', 'capital']);
|
||||
$this->setDestCity($this->arg['destCityID'], null);
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
if ($this->getDistance() === null) {
|
||||
$this->runnableConstraints[
|
||||
ConstraintHelper::AlwaysFail('천도 대상으로 도달할 방법이 없습니다.')
|
||||
];
|
||||
$this->fullConditionConstraints[ConstraintHelper::AlwaysFail('천도 대상으로 도달할 방법이 없습니다.')];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::OccupiedDestCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
@@ -81,7 +96,8 @@ class che_천도 extends Command\NationCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
|
||||
$amount = number_format($this->env['develcost'] * 5);
|
||||
@@ -89,14 +105,16 @@ class che_천도 extends Command\NationCommand{
|
||||
return "{$name}/1+거리×2턴(금쌀 {$amount}×2^거리)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
$amount = $this->env['develcost'] * 5;
|
||||
$amount *= 2 ** $this->getDistance() ?? 50;
|
||||
|
||||
return [$amount, $amount];
|
||||
}
|
||||
|
||||
private function getDistance():?int{
|
||||
private function getDistance(): ?int
|
||||
{
|
||||
if ($this->cachedDist !== null) {
|
||||
return $this->cachedDist;
|
||||
}
|
||||
@@ -109,15 +127,18 @@ class che_천도 extends Command\NationCommand{
|
||||
return $distance;
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return $this->getDistance() * 2;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function addTermStack():bool{
|
||||
public function addTermStack(): bool
|
||||
{
|
||||
$lastTurn = $this->getLastTurn();
|
||||
$commandName = $this->getName();
|
||||
|
||||
@@ -160,15 +181,17 @@ class che_천도 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||
$josaRo = JosaUtil::pick($destCityName, '로');
|
||||
return "【{$destCityName}】{$josaRo} {$commandName}";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,20 @@ class che_초토화 extends Command\NationCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['surlimit', 'gold', 'rice', 'capital']);
|
||||
$this->setDestCity($this->arg['destCityID'], null);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::ReqNationValue('surlimit', '제한 턴', '==', 0, '외교제한 턴이 남아있습니다.'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::OccupiedDestCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
@@ -102,7 +113,7 @@ class che_초토화 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -20,11 +24,13 @@ use function \sammo\{
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
class che_포상 extends Command\NationCommand{
|
||||
class che_포상 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '포상';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -69,16 +75,27 @@ class che_포상 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gold', 'rice']);
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], 1);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
@@ -87,26 +104,29 @@ class che_포상 extends Command\NationCommand{
|
||||
ConstraintHelper::FriendlyDestGeneral()
|
||||
];
|
||||
if ($this->arg['isGold']) {
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqNationGold(1+GameConst::$basegold);
|
||||
}
|
||||
else{
|
||||
$this->runnableConstraints[] = ConstraintHelper::ReqNationRice(1+GameConst::$baserice);
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqNationGold(1 + GameConst::$basegold);
|
||||
} else {
|
||||
$this->fullConditionConstraints[] = ConstraintHelper::ReqNationRice(1 + GameConst::$baserice);
|
||||
}
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$isGold = $this->arg['isGold'];
|
||||
$amount = $this->arg['amount'];
|
||||
$amountText = number_format($amount, 0);
|
||||
@@ -117,8 +137,9 @@ class che_포상 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,18 @@ class che_피장파장 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::AvailableStrategicCommand(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestNation($this->arg['destNationID'], null);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
@@ -72,7 +81,6 @@ class che_피장파장 extends Command\NationCommand{
|
||||
),
|
||||
ConstraintHelper::AvailableStrategicCommand(),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
@@ -107,7 +115,7 @@ class che_피장파장 extends Command\NationCommand{
|
||||
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -200,7 +208,7 @@ class che_피장파장 extends Command\NationCommand{
|
||||
|
||||
$testTurn->setArg(['destNationID'=>$destNation['nation']]);
|
||||
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID'=>$destNation['nation']]);
|
||||
if($testCommand->isRunnable()){
|
||||
if($testCommand->hasFullConditionMet()){
|
||||
$destNation['availableCommand'] = true;
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -26,7 +26,6 @@ use sammo\Event\Action;
|
||||
|
||||
class che_필사즉생 extends Command\NationCommand{
|
||||
static protected $actionName = '필사즉생';
|
||||
static public $reqArg = false;
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = [];
|
||||
@@ -42,7 +41,7 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
||||
@@ -77,7 +76,7 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use\sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General, DummyGeneral,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
@@ -26,11 +30,13 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Event\Action;
|
||||
|
||||
class che_허보 extends Command\NationCommand{
|
||||
class che_허보 extends Command\NationCommand
|
||||
{
|
||||
static protected $actionName = '허보';
|
||||
static public $reqArg = true;
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
if ($this->arg === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -49,17 +55,28 @@ class che_허보 extends Command\NationCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
|
||||
$env = $this->env;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
$this->setDestCity($this->arg['destCityID'], null);
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::AvailableStrategicCommand(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
$this->setDestNation($this->destCity['nation']);
|
||||
|
||||
$this->runnableConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotNeutralDestCity(),
|
||||
@@ -72,7 +89,8 @@ class che_허보 extends Command\NationCommand{
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
$reqTurn = $this->getPreReqTurn() + 1;
|
||||
$postReqTurn = $this->getPostReqTurn();
|
||||
@@ -80,15 +98,18 @@ class che_허보 extends Command\NationCommand{
|
||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||
$nextTerm = Util::round(sqrt($genCount * 4) * 10);
|
||||
|
||||
@@ -96,14 +117,16 @@ class che_허보 extends Command\NationCommand{
|
||||
return $nextTerm;
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
$commandName = $this->getName();
|
||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||
return "【{$destCityName}】에 {$commandName}";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -164,7 +187,8 @@ class che_허보 extends Command\NationCommand{
|
||||
|
||||
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
||||
$destNationLogger->pushNationalHistoryLog(
|
||||
"<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국의 <G><b>{$destCityName}</b></>에 <M>허보</>를 발동", ActionLogger::PLAIN
|
||||
"<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국의 <G><b>{$destCityName}</b></>에 <M>허보</>를 발동",
|
||||
ActionLogger::PLAIN
|
||||
);
|
||||
$destNationLogger->flush();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class 휴식 extends Command\NationCommand{
|
||||
|
||||
protected function init(){
|
||||
//아무것도 하지 않음
|
||||
$this->runnableConstraints=[];
|
||||
$this->fullConditionConstraints=[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class DiplomaticMessage extends Message{
|
||||
|
||||
$this->diplomacyDetail = $commandObj->getBrief();
|
||||
|
||||
if(!$commandObj->isRunnable()){
|
||||
if(!$commandObj->hasFullConditionMet()){
|
||||
return [self::DECLINED, $commandObj->getFailString()];
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class DiplomaticMessage extends Message{
|
||||
|
||||
$this->diplomacyDetail = $commandObj->getBrief();
|
||||
|
||||
if(!$commandObj->isRunnable()){
|
||||
if(!$commandObj->hasFullConditionMet()){
|
||||
return [self::DECLINED, $commandObj->getFailString()];
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class DiplomaticMessage extends Message{
|
||||
|
||||
$this->diplomacyDetail = $commandObj->getBrief();
|
||||
|
||||
if(!$commandObj->isRunnable()){
|
||||
if(!$commandObj->hasFullConditionMet()){
|
||||
return [self::DECLINED, $commandObj->getFailString()];
|
||||
}
|
||||
|
||||
|
||||
+62
-62
@@ -344,7 +344,7 @@ class GeneralAI
|
||||
}
|
||||
|
||||
$cmd = buildNationCommandClass('che_발령', $this->general, $this->env, $lastTurn, Util::choiceRandom($troopCandidate));
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ class GeneralAI
|
||||
'destCityID'=>Util::choiceRandom($cityCandidates)['city']
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ class GeneralAI
|
||||
'destCityID'=>Util::choiceRandom($cityCandidates)['city']
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ class GeneralAI
|
||||
'destCityID'=>Util::choiceRandom($cityCandidates)['city']
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ class GeneralAI
|
||||
return null;
|
||||
}
|
||||
$cmd = buildNationCommandClass('che_발령', $this->general, $this->env, $lastTurn, Util::choiceRandom($args));
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
@@ -722,7 +722,7 @@ class GeneralAI
|
||||
'destCityID'=>Util::choiceRandomUsingWeight($cityCandidates)
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -794,7 +794,7 @@ class GeneralAI
|
||||
'destCityID'=>$destCity['city']
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -869,7 +869,7 @@ class GeneralAI
|
||||
'destCityID'=>Util::choiceRandom($cityCandidates)['city']
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -899,7 +899,7 @@ class GeneralAI
|
||||
return null;
|
||||
}
|
||||
$cmd = buildNationCommandClass('che_발령', $this->general, $this->env, $lastTurn, Util::choiceRandom($args));
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
@@ -955,7 +955,7 @@ class GeneralAI
|
||||
'destCityID'=>Util::choiceRandomUsingWeight($cityCandidates)
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1023,7 +1023,7 @@ class GeneralAI
|
||||
'destCityID'=>$destCity['city']
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1101,7 +1101,7 @@ class GeneralAI
|
||||
'che_포상', $this->general, $this->env, $lastTurn,
|
||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||
);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1203,7 +1203,7 @@ class GeneralAI
|
||||
'che_포상', $this->general, $this->env, $lastTurn,
|
||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||
);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1287,7 +1287,7 @@ class GeneralAI
|
||||
'che_포상', $this->general, $this->env, $lastTurn,
|
||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||
);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1398,7 +1398,7 @@ class GeneralAI
|
||||
'che_포상', $this->general, $this->env, $lastTurn,
|
||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||
);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1528,7 +1528,7 @@ class GeneralAI
|
||||
'che_몰수', $this->general, $this->env, $lastTurn,
|
||||
Util::choiceRandomUsingWeightPair($candidateArgs)
|
||||
);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1635,7 +1635,7 @@ class GeneralAI
|
||||
$cmd = buildNationCommandClass('che_선전포고', $this->general, $this->env, $lastTurn, [
|
||||
'destNationID' => Util::choiceRandomUsingWeight($nations)
|
||||
]);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1654,7 +1654,7 @@ class GeneralAI
|
||||
//천도를 한턴 넣었다면 계속 넣는다.
|
||||
if($lastTurn->getCommand() === '천도' && $lastTurn->getArg()['destCityID'] != $this->nation['capital']){
|
||||
$cmd = buildNationCommandClass('che_천도', $this->general, $this->env, $lastTurn, $lastTurn->getArg());
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$nationStor->setValue("last천도Trial_{$this->nation['nation']}", [$general->getVar('officer_level'), $general->getTurnTime()]);
|
||||
return $cmd;
|
||||
}
|
||||
@@ -1771,7 +1771,7 @@ class GeneralAI
|
||||
'destCityID'=>$targetCityID
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1802,13 +1802,13 @@ class GeneralAI
|
||||
if ($genType & self::t통솔장) {
|
||||
if ($develRate['trust'] < 0.95) {
|
||||
$cmd = buildGeneralCommandClass('che_주민선정', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $leadership / Util::valueFit($develRate['trust']-0.2, 0.001) * 2];
|
||||
}
|
||||
}
|
||||
if ($develRate['pop'] < 0.8) {
|
||||
$cmd = buildGeneralCommandClass('che_정착장려', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $leadership / Util::valueFit($develRate['pop'], 0.001)];
|
||||
}
|
||||
}
|
||||
@@ -1817,19 +1817,19 @@ class GeneralAI
|
||||
if($genType & self::t무장){
|
||||
if($develRate['def'] < 1){
|
||||
$cmd = buildGeneralCommandClass('che_수비강화', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $strength / Util::valueFit($develRate['def'], 0.001)];
|
||||
}
|
||||
}
|
||||
if($develRate['wall'] < 1){
|
||||
$cmd = buildGeneralCommandClass('che_성벽보수', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $strength / Util::valueFit($develRate['wall'], 0.001)];
|
||||
}
|
||||
}
|
||||
if($develRate['secu'] < 0.9){
|
||||
$cmd = buildGeneralCommandClass('che_치안강화', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $strength / Util::valueFit($develRate['comm'] / 0.8, 0.001, 1)];
|
||||
}
|
||||
}
|
||||
@@ -1838,7 +1838,7 @@ class GeneralAI
|
||||
if($genType & self::t지장){
|
||||
if (!TechLimit($env['startyear'], $env['year'], $nation['tech'])) {
|
||||
$cmd = buildGeneralCommandClass('che_기술연구', $general, $env);
|
||||
if ($cmd->isRunnable()) {
|
||||
if ($cmd->hasFullConditionMet()) {
|
||||
$nextTech = $nation['tech'] % 1000 + 1;
|
||||
if (!TechLimit($env['startyear'], $env['year'], $nation['tech'] + 1000)) {
|
||||
//한등급 이상 뒤쳐져 있다면, 조금 더 열심히 하자.
|
||||
@@ -1850,13 +1850,13 @@ class GeneralAI
|
||||
}
|
||||
if ($develRate['agri'] < 1) {
|
||||
$cmd = buildGeneralCommandClass('che_농지개간', $general, $env);
|
||||
if ($cmd->isRunnable()) {
|
||||
if ($cmd->hasFullConditionMet()) {
|
||||
$cmdList[] = [$cmd, ($isSpringSummer?1.2:0.8) * $intel / Util::valueFit($develRate['agri'], 0.001, 1)];
|
||||
}
|
||||
}
|
||||
if ($develRate['comm'] < 1) {
|
||||
$cmd = buildGeneralCommandClass('che_상업투자', $general, $env);
|
||||
if ($cmd->isRunnable()) {
|
||||
if ($cmd->hasFullConditionMet()) {
|
||||
$cmdList[] = [$cmd, ($isSpringSummer?0.8:1.2) * $intel / Util::valueFit($develRate['comm'], 0.001, 1)];
|
||||
}
|
||||
}
|
||||
@@ -1887,14 +1887,14 @@ class GeneralAI
|
||||
|
||||
if($city['trust'] < 70 && Util::randBool($leadership / GameConst::$chiefStatMin)){
|
||||
$cmd = buildGeneralCommandClass('che_주민선정', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
return $cmd;
|
||||
}
|
||||
}
|
||||
|
||||
if($city['pop'] < $this->nationPolicy->minNPCRecruitCityPopulation && Util::randBool($leadership / GameConst::$chiefStatMin / 2)){
|
||||
$cmd = buildGeneralCommandClass('che_정착장려', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
return $cmd;
|
||||
}
|
||||
}
|
||||
@@ -1927,13 +1927,13 @@ class GeneralAI
|
||||
if ($genType & self::t통솔장) {
|
||||
if ($develRate['trust'] < 0.95) {
|
||||
$cmd = buildGeneralCommandClass('che_주민선정', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $leadership / Util::valueFit($develRate['trust']-0.2, 0.001) * 2];
|
||||
}
|
||||
}
|
||||
if ($develRate['pop'] < 0.8) {
|
||||
$cmd = buildGeneralCommandClass('che_정착장려', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
if (in_array($city['front'], [1, 3])) {
|
||||
$cmdList[] = [$cmd, $leadership / Util::valueFit($develRate['pop'], 0.001)];
|
||||
}
|
||||
@@ -1947,19 +1947,19 @@ class GeneralAI
|
||||
if($genType & self::t무장){
|
||||
if($develRate['def'] < 0.5){
|
||||
$cmd = buildGeneralCommandClass('che_수비강화', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $strength / Util::valueFit($develRate['def'], 0.001) / 2];
|
||||
}
|
||||
}
|
||||
if($develRate['wall'] < 0.5){
|
||||
$cmd = buildGeneralCommandClass('che_성벽보수', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $strength / Util::valueFit($develRate['wall'], 0.001) / 2];
|
||||
}
|
||||
}
|
||||
if($develRate['secu'] < 0.5){
|
||||
$cmd = buildGeneralCommandClass('che_치안강화', $general, $env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, $strength / Util::valueFit($develRate['secu'] / 0.8, 0.001, 1) / 4];
|
||||
}
|
||||
}
|
||||
@@ -1968,7 +1968,7 @@ class GeneralAI
|
||||
if($genType & self::t지장){
|
||||
if (!TechLimit($env['startyear'], $env['year'], $nation['tech'])) {
|
||||
$cmd = buildGeneralCommandClass('che_기술연구', $general, $env);
|
||||
if ($cmd->isRunnable()) {
|
||||
if ($cmd->hasFullConditionMet()) {
|
||||
$nextTech = $nation['tech'] % 1000 + 1;
|
||||
if (!TechLimit($env['startyear'], $env['year'], $nation['tech'] + 1000)) {
|
||||
//한등급 이상 뒤쳐져 있다면, 조금 더 열심히 하자. 전쟁중이면 더더욱
|
||||
@@ -1980,7 +1980,7 @@ class GeneralAI
|
||||
}
|
||||
if ($develRate['agri'] < 0.5) {
|
||||
$cmd = buildGeneralCommandClass('che_농지개간', $general, $env);
|
||||
if ($cmd->isRunnable()) {
|
||||
if ($cmd->hasFullConditionMet()) {
|
||||
if (in_array($city['front'], [1, 3])) {
|
||||
$cmdList[] = [$cmd, ($isSpringSummer?1.2:0.8) * $intel / 4 / Util::valueFit($develRate['agri'], 0.001, 1)];
|
||||
}
|
||||
@@ -1991,7 +1991,7 @@ class GeneralAI
|
||||
}
|
||||
if ($develRate['comm'] < 0.5) {
|
||||
$cmd = buildGeneralCommandClass('che_상업투자', $general, $env);
|
||||
if ($cmd->isRunnable()) {
|
||||
if ($cmd->hasFullConditionMet()) {
|
||||
if (in_array($city['front'], [1, 3])) {
|
||||
$cmdList[] = [$cmd, ($isSpringSummer?0.8:1.2) * $intel / 4 / Util::valueFit($develRate['comm'], 0.001, 1)];
|
||||
}
|
||||
@@ -2055,7 +2055,7 @@ class GeneralAI
|
||||
'amount' => Util::valueFit(Util::toInt($general->getVar('gold') - $avgAmount), 100, GameConst::$maxResourceActionAmount)
|
||||
]
|
||||
);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
return $cmd;
|
||||
}
|
||||
}
|
||||
@@ -2067,7 +2067,7 @@ class GeneralAI
|
||||
'amount' => Util::valueFit(Util::toInt($general->getVar('rice') - $avgAmount), 100, GameConst::$maxResourceActionAmount)
|
||||
]
|
||||
);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
return $cmd;
|
||||
}
|
||||
}
|
||||
@@ -2081,7 +2081,7 @@ class GeneralAI
|
||||
'amount' => Util::valueFit(Util::toInt($general->getVar('gold') - $avgAmount), 100, GameConst::$maxResourceActionAmount)
|
||||
]
|
||||
);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
return $cmd;
|
||||
}
|
||||
}
|
||||
@@ -2093,7 +2093,7 @@ class GeneralAI
|
||||
'amount' => Util::valueFit(Util::toInt($general->getVar('rice') - $avgAmount), 100, GameConst::$maxResourceActionAmount)
|
||||
]
|
||||
);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
return $cmd;
|
||||
}
|
||||
}
|
||||
@@ -2250,7 +2250,7 @@ class GeneralAI
|
||||
|
||||
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
return $cmd;
|
||||
@@ -2269,14 +2269,14 @@ class GeneralAI
|
||||
|
||||
if($train < $this->nationPolicy->properWarTrainAtmos){
|
||||
$cmd = buildGeneralCommandClass('che_훈련', $general, $this->env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, GameConst::$maxTrainByCommand / Util::valueFit($train, 1)];
|
||||
}
|
||||
}
|
||||
|
||||
if($atmos < $this->nationPolicy->properWarTrainAtmos){
|
||||
$cmd = buildGeneralCommandClass('che_사기진작', $general, $this->env);
|
||||
if($cmd->isRunnable()){
|
||||
if($cmd->hasFullConditionMet()){
|
||||
$cmdList[] = [$cmd, GameConst::$maxAtmosByCommand / Util::valueFit($atmos, 1)];
|
||||
}
|
||||
}
|
||||
@@ -2302,7 +2302,7 @@ class GeneralAI
|
||||
return null;
|
||||
}
|
||||
$cmd = buildGeneralCommandClass('che_소집해제', $this->general, $this->env);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
return $cmd;
|
||||
@@ -2369,7 +2369,7 @@ class GeneralAI
|
||||
}
|
||||
|
||||
$cmd = buildGeneralCommandClass('che_출병', $general, $this->env, ['destCityID' => Util::choiceRandom($attackableCities)]);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2441,7 +2441,7 @@ class GeneralAI
|
||||
}
|
||||
|
||||
$cmd = buildGeneralCommandClass('che_헌납', $general, $this->env, Util::choiceRandomUsingWeightPair($args));
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
return $cmd;
|
||||
@@ -2518,7 +2518,7 @@ class GeneralAI
|
||||
]);
|
||||
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2565,7 +2565,7 @@ class GeneralAI
|
||||
]);
|
||||
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2634,7 +2634,7 @@ class GeneralAI
|
||||
'optionText' => '순간이동',
|
||||
'destCityID' => Util::choiceRandomUsingWeight($candidateCities),
|
||||
]);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2651,7 +2651,7 @@ class GeneralAI
|
||||
}
|
||||
|
||||
$cmd = buildGeneralCommandClass('che_귀환', $this->general, $this->env);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2723,7 +2723,7 @@ class GeneralAI
|
||||
$cmd = buildGeneralCommandClass('che_이동', $general, $this->env, [
|
||||
'destCityID'=>Util::choiceRandomUsingWeight($targetCity)
|
||||
]);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2756,7 +2756,7 @@ class GeneralAI
|
||||
}
|
||||
|
||||
$cmd = buildGeneralCommandClass('che_거병', $general, $this->env, null);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2766,7 +2766,7 @@ class GeneralAI
|
||||
protected function do해산(): ?GeneralCommand
|
||||
{
|
||||
$cmd = buildGeneralCommandClass('che_해산', $this->general, $this->env, null);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2782,7 +2782,7 @@ class GeneralAI
|
||||
'nationType' => $nationType,
|
||||
'colorType' => $nationColor
|
||||
]);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2796,7 +2796,7 @@ class GeneralAI
|
||||
'destGeneralID' => $db->queryFirstField('SELECT `no` FROM general WHERE nation = %i AND npc != 5 ORDER BY RAND() LIMIT 1', $this->general->getNationID())
|
||||
]);
|
||||
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2820,7 +2820,7 @@ class GeneralAI
|
||||
|
||||
if ($rulerNation) {
|
||||
$cmd = buildGeneralCommandClass('che_임관', $general, $env, ['destNationID' => $rulerNation]);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2849,7 +2849,7 @@ class GeneralAI
|
||||
|
||||
//랜임 커맨드 입력.
|
||||
$cmd = buildGeneralCommandClass('che_랜덤임관', $general, $env);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2860,7 +2860,7 @@ class GeneralAI
|
||||
$paths = array_keys(CityConst::byID($city['city'])->path);
|
||||
|
||||
$cmd = buildGeneralCommandClass('che_이동', $general, $env, ['destCityID' => Util::choiceRandom($paths)]);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2919,7 +2919,7 @@ class GeneralAI
|
||||
|
||||
|
||||
$cmd = buildGeneralCommandClass(Util::choiceRandom($candidate), $this->general, $this->env);
|
||||
if(!$cmd->isRunnable()){
|
||||
if(!$cmd->hasFullConditionMet()){
|
||||
return buildGeneralCommandClass('che_물자조달', $this->general, $this->env);
|
||||
}
|
||||
return $cmd;
|
||||
@@ -3105,7 +3105,7 @@ class GeneralAI
|
||||
}
|
||||
|
||||
if(!($reservedCommand instanceof Command\Nation\휴식)){
|
||||
if($reservedCommand->isRunnable()){
|
||||
if($reservedCommand->hasFullConditionMet()){
|
||||
$reservedCommand->reason = 'reserved';
|
||||
return $reservedCommand;
|
||||
}
|
||||
@@ -3136,7 +3136,7 @@ class GeneralAI
|
||||
}
|
||||
|
||||
public function chooseInstantNationTurn(NationCommand $reservedCommand): ?NationCommand{
|
||||
if($reservedCommand->isRunnable()){
|
||||
if($reservedCommand->hasFullConditionMet()){
|
||||
return $reservedCommand;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class ScoutMessage extends Message{
|
||||
'month'=>$this->msgOption['month']
|
||||
]);
|
||||
|
||||
if(!$commandObj->isRunnable()){
|
||||
if(!$commandObj->hasFullConditionMet()){
|
||||
$logger->pushGeneralActionLog($commandObj->getFailString());
|
||||
return self::DECLINED;
|
||||
}
|
||||
|
||||
@@ -67,8 +67,7 @@ class TurnExecutionHelper
|
||||
$general = $this->getGeneral();
|
||||
|
||||
while(true){
|
||||
$failReason = $commandObj->testRunnable();
|
||||
if($failReason){
|
||||
if($commandObj->hasFullConditionMet()){
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
$failString = $commandObj->getFailString();
|
||||
$text = "{$failString} <1>{$date}</>";
|
||||
@@ -110,8 +109,7 @@ class TurnExecutionHelper
|
||||
$commandClassName = $commandObj->getName();
|
||||
|
||||
while(true){
|
||||
$failReason = $commandObj->testRunnable();
|
||||
if($failReason){
|
||||
if($commandObj->hasFullConditionMet()){
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
$failString = $commandObj->getFailString();
|
||||
$text = "{$failString} <1>{$date}</>";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__ . '/vendor/autoload.php');
|
||||
@@ -21,6 +22,7 @@ if ($session->isLoggedIn()) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
@@ -41,7 +43,6 @@ if ($session->isLoggedIn()) {
|
||||
<meta property="og:description" content="실시간으로 진행되는 삼국지 웹게임(삼모전)입니다">
|
||||
<meta property="og:url" content="https://sam.hided.net">
|
||||
<script>
|
||||
|
||||
var oauthMode = null;
|
||||
|
||||
function getOAuthToken(mode, scope_list) {
|
||||
@@ -58,8 +59,7 @@ function getOAuthToken(mode, scope_list){
|
||||
'response_type=code';
|
||||
if (Array.isArray(scope_list)) {
|
||||
url += '&scope=' + scope_list.join(',');
|
||||
}
|
||||
else if(typeof scope_list === 'string' || scope_list instanceof String){
|
||||
} else if (typeof scope_list === 'string' || scope_list instanceof String) {
|
||||
url += '&scope=' + scope_list;
|
||||
}
|
||||
|
||||
@@ -82,8 +82,7 @@ function sendTempPasswordToKakaoTalk(){
|
||||
}).then(function(obj) {
|
||||
if (!obj.result) {
|
||||
alert(obj.reason);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
alert('임시 비밀번호가 카카오톡으로 전송되었습니다.');
|
||||
}
|
||||
});
|
||||
@@ -112,25 +111,22 @@ function doLoginUsingOAuth(){
|
||||
function postOAuthResult(result) {
|
||||
if (result == 'join') {
|
||||
window.location.href = 'oauth_kakao/join.php';
|
||||
}
|
||||
else if(result == 'req_email'){
|
||||
} else if (result == 'req_email') {
|
||||
alert('이메일 정보 공유를 허가해 주셔야 합니다.');
|
||||
}
|
||||
else if(result == 'login'){
|
||||
} else if (result == 'login') {
|
||||
console.log('로그인모드');
|
||||
if (oauthMode == 'change_pw') {
|
||||
sendTempPasswordToKakaoTalk();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
doLoginUsingOAuth();
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
alert('예외 발생!');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light">
|
||||
<a class="navbar-brand" href=".">삼국지 모의전투 HiDCHe</a>
|
||||
@@ -159,8 +155,7 @@ function postOAuthResult(result){
|
||||
<div class="form-group row">
|
||||
<label for="username" class="col-5 col-md-4 col-form-label">계정명</label>
|
||||
<div class="col-7 col-md-8">
|
||||
<input autocomplete="username" type="text" class="form-control"
|
||||
name="username" id="username" autofocus="autofocus" placeholder="계정명"/>
|
||||
<input autocomplete="username" type="text" class="form-control" name="username" id="username" autofocus="autofocus" placeholder="계정명" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -168,8 +163,7 @@ function postOAuthResult(result){
|
||||
<div class="form-group row">
|
||||
<label for="password" class="col-5 col-md-4 col-form-label">비밀번호</label>
|
||||
<div class="col-7 col-md-8">
|
||||
<input autocomplete="current-password" type="password"
|
||||
class="form-control" name="password" id="password" placeholder="비밀번호"/>
|
||||
<input autocomplete="current-password" type="password" class="form-control" name="password" id="password" placeholder="비밀번호" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -197,7 +191,8 @@ function postOAuthResult(result){
|
||||
</div>
|
||||
<div id="bottom_box">
|
||||
<div class="container"><a href="terms.2.html">개인정보처리방침</a> & <a href="terms.1.html">이용약관</a><br>© 2020 • HideD
|
||||
<br>크롬과 파이어폭스에 최적화되어있습니다.</div></div>
|
||||
<br>크롬과 파이어폭스에 최적화되어있습니다.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modalOTP" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
@@ -233,4 +228,5 @@ function postOAuthResult(result){
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+8
-6
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__ . '/vendor/autoload.php');
|
||||
@@ -23,7 +24,8 @@ if(!$username || !$password){
|
||||
]);
|
||||
}
|
||||
|
||||
function kakaoOAuthCheck(array $userInfo) : ?array {
|
||||
function kakaoOAuthCheck(array $userInfo): ?array
|
||||
{
|
||||
|
||||
if (!\kakao\KakaoKey::REST_KEY) {
|
||||
return [false, '카카오 API 앱이 등록되지 않았습니다. 관리자에게 문의해 주세요.'];
|
||||
@@ -105,10 +107,12 @@ function kakaoOAuthCheck(array $userInfo) : ?array {
|
||||
$userInfo = $RootDB->queryFirstRow(
|
||||
'SELECT `no`, `id`, `name`, `grade`, `delete_after`, `acl`, oauth_id, oauth_type, oauth_info, token_valid_until ' .
|
||||
'from member where id=%s_username AND ' .
|
||||
'pw=sha2(concat(salt, %s_password, salt), 512)',[
|
||||
'pw=sha2(concat(salt, %s_password, salt), 512)',
|
||||
[
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
]);
|
||||
]
|
||||
);
|
||||
|
||||
if (!$userInfo) {
|
||||
Json::die([
|
||||
@@ -135,15 +139,13 @@ if($userInfo['delete_after']){
|
||||
'reqOTP' => false,
|
||||
'reason' => "기간 만기로 삭제되었습니다. 재 가입을 시도해주세요."
|
||||
]);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
Json::die([
|
||||
'result' => false,
|
||||
'reqOTP' => false,
|
||||
'reason' => "삭제 요청된 계정입니다.[{$userInfo['delete_after']}]"
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$RootDB->insert('member_log', [
|
||||
|
||||
+16
-17
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
function getVersion($target=null){
|
||||
function getVersion($target = null)
|
||||
{
|
||||
if ($target) {
|
||||
$command = sprintf('git describe %s --long --tags', escapeshellarg($target));
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$command = 'git describe --long --tags';
|
||||
}
|
||||
exec($command, $output);
|
||||
@@ -15,7 +16,6 @@ function getVersion($target=null){
|
||||
$output = join('', $output);
|
||||
}
|
||||
return trim($output);
|
||||
|
||||
}
|
||||
|
||||
$session = Session::requireLogin(null)->setReadOnly();
|
||||
@@ -65,8 +65,7 @@ if($src_target){
|
||||
|
||||
if (!$allowFullUpdate || !$target) {
|
||||
$target = $src_target;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$target = $request['target'];
|
||||
}
|
||||
|
||||
@@ -146,9 +145,11 @@ if($server == $baseServerName){
|
||||
$version = getVersion();
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.orig.php',
|
||||
__DIR__.'/'.$server.'/d_setting/VersionGit.php',[
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.php',
|
||||
[
|
||||
'verionGit' => $version
|
||||
], true
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if (ServConfig::$imageRequestKey) {
|
||||
@@ -162,18 +163,15 @@ if($server == $baseServerName){
|
||||
if ($pullResult['result']) {
|
||||
$imgResult = true;
|
||||
$imgDetail = $pullResult['version'];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$imgResult = false;
|
||||
$imgDetail = $pullResult['reason'];
|
||||
}
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
$imgResult = false;
|
||||
$imgDetail = $e->getMessage();
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$imgResult = true;
|
||||
$imgDetail = 'No key';
|
||||
}
|
||||
@@ -190,7 +188,6 @@ if($server == $baseServerName){
|
||||
'imgResult' => $imgResult,
|
||||
'imgDetail' => $imgDetail,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
$command = sprintf('git archive --format=zip -o %s %s', escapeshellarg($tmpFile), escapeshellarg($targetDir));
|
||||
@@ -223,9 +220,11 @@ $zip->close();
|
||||
$version = getVersion($target);
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.orig.php',
|
||||
__DIR__.'/'.$server.'/d_setting/VersionGit.php',[
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.php',
|
||||
[
|
||||
'verionGit' => $version
|
||||
], true
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$storage->$server = [$target, $version];
|
||||
|
||||
+5
-2
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__ . '/vendor/autoload.php');
|
||||
@@ -9,8 +10,7 @@ if(key_exists('from', $_REQUEST) && is_numeric($_REQUEST['from'])){
|
||||
if ($from < 0) {
|
||||
$from = 0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$from = 0;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ $err_logs = $fdb->select('err_log', [
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
@@ -62,6 +63,7 @@ $err_logs = $fdb->select('err_log', [
|
||||
<?= WebUtil::printJS('d_shared/common_path.js') ?>
|
||||
<?= WebUtil::printJS('e_lib/bootstrap.bundle.min.js') ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<?php foreach ($err_logs as $err) : ?>
|
||||
@@ -86,4 +88,5 @@ $err_logs = $fdb->select('err_log', [
|
||||
<a href="showErrorLog.php?from=<?= $from + 100 ?>" class="btn btn-primary btn-lg active" role="button">+100</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -451,7 +451,8 @@ class JosaUtil{
|
||||
|
||||
private static $init = false;
|
||||
|
||||
private static function init(){
|
||||
private static function init()
|
||||
{
|
||||
if(JosaUtil::$init){
|
||||
return;
|
||||
}
|
||||
@@ -502,7 +503,8 @@ class JosaUtil{
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function checkCode(int $code, bool $isRo){
|
||||
private static function checkCode(int $code, bool $isRo)
|
||||
{
|
||||
JosaUtil::init();
|
||||
$jongsung = ($code - JosaUtil::KO_START_CODE) % 28;
|
||||
|
||||
@@ -517,7 +519,8 @@ class JosaUtil{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function check(string $text, string $type){
|
||||
public static function check(string $text, string $type)
|
||||
{
|
||||
JosaUtil::init();
|
||||
|
||||
$htarget = preg_replace(JosaUtil::REG_INVALID_CHAR_W_HANJA, ' ', $text);
|
||||
@@ -560,7 +563,8 @@ class JosaUtil{
|
||||
return JosaUtil::checkText($target, $isRo);
|
||||
}
|
||||
|
||||
public static function pick($text, string $wJongsung, string $woJongsung=''){
|
||||
public static function pick($text, string $wJongsung, string $woJongsung='')
|
||||
{
|
||||
/* NOTE:원본 코드와 인자 순서가 다름.
|
||||
* 원본은 pick('바람', '랑', '이랑'); 이었다면 JosaUtil::pick('바람', '이랑', '랑'); 으로 바뀜.
|
||||
* JosaUtil::pick('바람', '은', '는'); JosaUti::pick('바람', '이', '가');처럼 쓰기 위해서임.
|
||||
|
||||
Reference in New Issue
Block a user