커맨드 유효성을 2개에서 3개구성으로 변경

This commit is contained in:
2020-05-04 19:51:11 +09:00
parent f25f5008f1
commit 77248ad4d8
100 changed files with 4124 additions and 3420 deletions
+120 -82
View File
@@ -1,4 +1,5 @@
<?php
namespace sammo;
@@ -10,12 +11,42 @@ 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>";
foreach(Util::range(1, GameConst::$maxTurn) as $turnIdx){
foreach (Util::range(1, GameConst::$maxTurn) as $turnIdx) {
$turnText = $turnIdx + 1;
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
}
@@ -32,81 +63,86 @@ function turnTable() {
";
}
function chiefTurnTable() {
$turnList = [];
$turnList[] = "<option selected value='0'>1턴</option>";
foreach(Util::range(1, GameConst::$maxChiefTurn) as $turnIdx){
$turnText = $turnIdx + 1;
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
}
function chiefTurnTable()
{
$turnList = [];
$turnList[] = "<option selected value='0'>1턴</option>";
foreach (Util::range(1, GameConst::$maxChiefTurn) as $turnIdx) {
$turnText = $turnIdx + 1;
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
}
$turnText = join("\n", $turnList);
$turnText = join("\n", $turnList);
return "
return "
<select id='chiefTurnSelector' name=turn[] size=6 multiple>
{$turnText}
</select>
";
}
function displayiActionObjInfo(?iAction $action){
if($action === null){
function displayiActionObjInfo(?iAction $action)
{
if ($action === null) {
$info = '';
$text = '-';
}
else{
} else {
$info = $action->getInfo();
$text = $action->getName();
}
$templates = new \League\Plates\Engine(__DIR__.'/templates');
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
return $templates->render('tooltip', [
'text'=>$text,
'info'=>$info,
'text' => $text,
'info' => $info,
]);
}
function displayCharInfo(string $type):string{
function displayCharInfo(string $type): string
{
$class = buildPersonalityClass($type);
$info = $class->getInfo();
$text = $class->getName();
$templates = new \League\Plates\Engine(__DIR__.'/templates');
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
return $templates->render('tooltip', [
'text'=>$text,
'info'=>$info,
'text' => $text,
'info' => $info,
]);
}
function displaySpecialWarInfo(?string $type):string{
function displaySpecialWarInfo(?string $type): string
{
$class = buildGeneralSpecialWarClass($type);
$info = $class->getInfo();
$name = $class->getName();
$templates = new \League\Plates\Engine(__DIR__.'/templates');
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
return $templates->render('tooltip', [
'text'=>$name,
'info'=>$info,
'text' => $name,
'info' => $info,
]);
}
function displaySpecialDomesticInfo(?string $type):string{
function displaySpecialDomesticInfo(?string $type): string
{
$class = buildGeneralSpecialDomesticClass($type);
$info = $class->getInfo();
$name = $class->getName();
$templates = new \League\Plates\Engine(__DIR__.'/templates');
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
return $templates->render('tooltip', [
'text'=>$name,
'info'=>$info,
'text' => $name,
'info' => $info,
]);
}
function allButton(bool $seizeNPCMode) {
if($seizeNPCMode) {
function allButton(bool $seizeNPCMode)
{
if ($seizeNPCMode) {
$site = "a_npcList.php";
$call = "빙의일람";
} else {
@@ -114,13 +150,12 @@ function allButton(bool $seizeNPCMode) {
$call = "설문조사";
}
if(\file_exists(__DIR__."/d_setting/templates/allButton.php")){
$templates = new \League\Plates\Engine(__DIR__.'/d_setting/templates');
if (\file_exists(__DIR__ . "/d_setting/templates/allButton.php")) {
$templates = new \League\Plates\Engine(__DIR__ . '/d_setting/templates');
} else {
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
}
else{
$templates = new \League\Plates\Engine(__DIR__.'/templates');
}
return $templates->render('allButton', [
'call' => $call,
@@ -129,104 +164,107 @@ function allButton(bool $seizeNPCMode) {
}
function commandButton() {
function commandButton()
{
$session = Session::getInstance();
$userID = Session::getUserID();
if(!$session->isGameLoggedIn()){
if (!$session->isGameLoggedIn()) {
return '';
}
$db = DB::db();
$me = $db->queryFirstRow("select no,nation,officer_level,belong,permission,penalty from general where owner=%i", $userID);
$nation = $db->queryFirstRow("select nation,level,color,secretlimit from nation where nation=%i",$me['nation'])??[
'nation'=>0,
'level'=>0,
'secretlimit'=>99,
'color'=>'#000000'
$nation = $db->queryFirstRow("select nation,level,color,secretlimit from nation where nation=%i", $me['nation']) ?? [
'nation' => 0,
'level' => 0,
'secretlimit' => 99,
'color' => '#000000'
];
$bgColor = Util::array_get($nation['color'])?:'#000000';
$bgColor = Util::array_get($nation['color']) ?: '#000000';
$fgColor = newColor($bgColor);
$templates = new \League\Plates\Engine(__DIR__.'/templates');
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
$showSecret = false;
$permission = checkSecretPermission($me);
if($permission >= 1){
if ($permission >= 1) {
$showSecret = true;
}
else if($me['officer_level']== 0){
} else if ($me['officer_level'] == 0) {
$showSecret = false;
}
return $templates->render('commandButton', [
'bgColor'=>$bgColor,
'fgColor'=>$fgColor,
'meLevel'=>$me['officer_level'],
'nationLevel'=>$nation['level'],
'showSecret'=>$showSecret,
'permission'=>$permission,
'bgColor' => $bgColor,
'fgColor' => $fgColor,
'meLevel' => $me['officer_level'],
'nationLevel' => $nation['level'],
'showSecret' => $showSecret,
'permission' => $permission,
]);
}
function formatWounded(int $value, int $wound): string{
if($wound == 0){
function formatWounded(int $value, int $wound): string
{
if ($wound == 0) {
return "$value";
}
$woundedValue = intdiv($value * (100 - $wound), 100);
return "<font color=red>$woundedValue</font>";
}
function formatDefenceTrain(int $value): string{
if($value === 999){
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{
if($value == 0){
function formatLeadershipBonus(int $value): string
{
if ($value == 0) {
return '';
}
return "<font color=cyan>+{$value}</font>";
}
function formatName(string $name, int $npc): string{
if($npc==1){
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){
$templates = new \League\Plates\Engine(__DIR__.'/templates');
function getMapHtml(?string $mapTheme = null)
{
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
if($mapTheme === null){
if ($mapTheme === null) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$mapTheme = $gameStor->map_theme??'che';
$mapTheme = $gameStor->map_theme ?? 'che';
}
return $templates->render('map', [
'mapTheme'=>$mapTheme
'mapTheme' => $mapTheme
]);
}
function getInvitationList(array $nationList){
$templates = new \League\Plates\Engine(__DIR__.'/templates');
function getInvitationList(array $nationList)
{
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
foreach($nationList as &$nation){
foreach ($nationList as &$nation) {
$nation['textColor'] = newColor($nation['color']);
}
return $templates->render('invitationList', [
'nationList'=>$nationList
'nationList' => $nationList
]);
}
}