Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
923cac5408 | ||
|
|
23505326c7 | ||
|
|
5f1a48f523 | ||
|
|
a607d39030 | ||
|
|
96d108729e | ||
|
|
ef15adaaf8 | ||
|
|
f190b74a7e | ||
|
|
edbc2b88b6 | ||
|
|
dc000cecf1 | ||
|
|
7c95a483df | ||
|
|
27e5d73da1 | ||
|
|
6306dae92d | ||
|
|
a427ddff83 | ||
|
|
b62ee6e820 | ||
|
|
3c18666080 | ||
|
|
40968b301a | ||
|
|
05904d31fd | ||
|
|
75aeaf4ee7 | ||
|
|
ff4e67a9f6 | ||
|
|
5f672d5bd1 | ||
|
|
5cb39eba8b | ||
|
|
4d8c3c75d6 | ||
|
|
8bdd19fc06 | ||
|
|
0ec99d8ba1 | ||
|
|
929d2db5a5 | ||
|
|
a7ad77f433 | ||
|
|
9cd47d5deb | ||
|
|
3cb5691aae | ||
|
|
dce63919fa | ||
|
|
1cdbedcb96 | ||
|
|
1586712ce5 | ||
|
|
f059186494 | ||
|
|
0af0be57b0 | ||
|
|
dad2b03212 | ||
|
|
b6e307660f | ||
|
|
c21c14825a | ||
|
|
39f9c986e9 | ||
|
|
393683aebc | ||
|
|
a87fcb44a6 | ||
|
|
0a6496ddfb | ||
|
|
fa2841fac6 | ||
|
|
861e45419b | ||
|
|
15fd943456 | ||
|
|
b538bfc27e | ||
|
|
e0f32eddc4 | ||
|
|
75a704c196 | ||
|
|
6565fdbe7e | ||
|
|
6248d72852 | ||
|
|
00d1797b96 | ||
|
|
911194eba8 | ||
|
|
0fad3ae31d | ||
|
|
b6988d866a | ||
|
|
e30959a656 | ||
|
|
52eeff3466 | ||
|
|
a06ded552d | ||
|
|
e9b8a84243 | ||
|
|
1fc3cfd1f2 |
+52
-50
@@ -1,50 +1,52 @@
|
|||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/settings.json
|
!.vscode/settings.json
|
||||||
!.vscode/tasks.json
|
!.vscode/tasks.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 체섭 ignore
|
# 체섭 ignore
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
logs/*.txt
|
logs/*.txt
|
||||||
d_log/*.txt
|
d_log/*.txt
|
||||||
d_log/*.zip
|
d_log/*.zip
|
||||||
sess_*
|
sess_*
|
||||||
*/logs/*.txt
|
*/logs/*.txt
|
||||||
*/logs/*/*.txt
|
*/logs/*/*.txt
|
||||||
*/logs/preserved
|
*/logs/preserved
|
||||||
err.txt
|
err.txt
|
||||||
che/.htaccess
|
che/.htaccess
|
||||||
kwe/.htaccess
|
kwe/.htaccess
|
||||||
pwe/.htaccess
|
pwe/.htaccess
|
||||||
twe/.htaccess
|
twe/.htaccess
|
||||||
hwe/.htaccess
|
hwe/.htaccess
|
||||||
|
|
||||||
d_shared
|
d_shared
|
||||||
|
|
||||||
d_pic/*.jpg
|
d_pic/*.jpg
|
||||||
d_pic/*.gif
|
d_pic/*.gif
|
||||||
d_pic/*.png
|
d_pic/*.png
|
||||||
d_pic/uploaded_image
|
d_pic/uploaded_image
|
||||||
|
|
||||||
d_setting/*.php
|
d_setting/*.php
|
||||||
*/d_setting/*.php
|
*/d_setting/*.php
|
||||||
*/d_setting/templates/*.php
|
*/d_setting/templates/*.php
|
||||||
|
|
||||||
**/old/*
|
*/data/file_cache
|
||||||
test.php
|
|
||||||
|
**/old/*
|
||||||
/che
|
test.php
|
||||||
/kwe
|
|
||||||
/pwe
|
/che
|
||||||
/nya
|
/kwe
|
||||||
/pya
|
/pwe
|
||||||
/twe
|
/nya
|
||||||
|
/pya
|
||||||
phpinfo.php
|
/twe
|
||||||
vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/*
|
|
||||||
*.sqlite3
|
phpinfo.php
|
||||||
|
vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/*
|
||||||
|
*.sqlite3
|
||||||
|
|||||||
+2
-1
@@ -27,7 +27,8 @@
|
|||||||
"xemlock/htmlpurifier-html5": "^0.1.7",
|
"xemlock/htmlpurifier-html5": "^0.1.7",
|
||||||
"catfan/medoo": "^1.5",
|
"catfan/medoo": "^1.5",
|
||||||
"phan/phan": "^2.7",
|
"phan/phan": "^2.7",
|
||||||
"erusev/parsedown-extra": "^0.8.1"
|
"erusev/parsedown-extra": "^0.8.1",
|
||||||
|
"nette/caching": "^3.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
Generated
+208
-1
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "1c2e0182ebdf9bfe795e52a5d7fc6abd",
|
"content-hash": "ab1175c8592ba7f7756d5f02a3aa051c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brandonwamboldt/utilphp",
|
"name": "brandonwamboldt/utilphp",
|
||||||
@@ -843,6 +843,213 @@
|
|||||||
"description": "Map nested JSON structures onto PHP classes",
|
"description": "Map nested JSON structures onto PHP classes",
|
||||||
"time": "2020-04-16T18:48:43+00:00"
|
"time": "2020-04-16T18:48:43+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "nette/caching",
|
||||||
|
"version": "v3.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nette/caching.git",
|
||||||
|
"reference": "b9ecbf920f240bd1ab14900d9a77876924ad7fb4"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nette/caching/zipball/b9ecbf920f240bd1ab14900d9a77876924ad7fb4",
|
||||||
|
"reference": "b9ecbf920f240bd1ab14900d9a77876924ad7fb4",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"nette/finder": "^2.4 || ^3.0",
|
||||||
|
"nette/utils": "^2.4 || ^3.0",
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"latte/latte": "^2.4",
|
||||||
|
"nette/di": "^v3.0",
|
||||||
|
"nette/tester": "^2.0",
|
||||||
|
"tracy/tracy": "^2.4"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-pdo_sqlite": "to use SQLiteStorage or SQLiteJournal"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"classmap": [
|
||||||
|
"src/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause",
|
||||||
|
"GPL-2.0",
|
||||||
|
"GPL-3.0"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "David Grudl",
|
||||||
|
"homepage": "https://davidgrudl.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nette Community",
|
||||||
|
"homepage": "https://nette.org/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "⏱ Nette Caching: library with easy-to-use API and many cache backends.",
|
||||||
|
"homepage": "https://nette.org",
|
||||||
|
"keywords": [
|
||||||
|
"cache",
|
||||||
|
"journal",
|
||||||
|
"memcached",
|
||||||
|
"nette",
|
||||||
|
"sqlite"
|
||||||
|
],
|
||||||
|
"time": "2019-11-19T18:41:40+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nette/finder",
|
||||||
|
"version": "v2.5.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nette/finder.git",
|
||||||
|
"reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nette/finder/zipball/4ad2c298eb8c687dd0e74ae84206a4186eeaed50",
|
||||||
|
"reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"nette/utils": "^2.4 || ^3.0",
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"nette/nette": "<2.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"nette/tester": "^2.0",
|
||||||
|
"phpstan/phpstan": "^0.12",
|
||||||
|
"tracy/tracy": "^2.3"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.5-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"classmap": [
|
||||||
|
"src/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause",
|
||||||
|
"GPL-2.0",
|
||||||
|
"GPL-3.0"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "David Grudl",
|
||||||
|
"homepage": "https://davidgrudl.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nette Community",
|
||||||
|
"homepage": "https://nette.org/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "🔍 Nette Finder: find files and directories with an intuitive API.",
|
||||||
|
"homepage": "https://nette.org",
|
||||||
|
"keywords": [
|
||||||
|
"filesystem",
|
||||||
|
"glob",
|
||||||
|
"iterator",
|
||||||
|
"nette"
|
||||||
|
],
|
||||||
|
"time": "2020-01-03T20:35:40+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nette/utils",
|
||||||
|
"version": "v3.1.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nette/utils.git",
|
||||||
|
"reference": "488f58378bba71767e7831c83f9e0fa808bf83b9"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nette/utils/zipball/488f58378bba71767e7831c83f9e0fa808bf83b9",
|
||||||
|
"reference": "488f58378bba71767e7831c83f9e0fa808bf83b9",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"nette/tester": "~2.0",
|
||||||
|
"phpstan/phpstan": "^0.12",
|
||||||
|
"tracy/tracy": "^2.3"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-gd": "to use Image",
|
||||||
|
"ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()",
|
||||||
|
"ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()",
|
||||||
|
"ext-json": "to use Nette\\Utils\\Json",
|
||||||
|
"ext-mbstring": "to use Strings::lower() etc...",
|
||||||
|
"ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()",
|
||||||
|
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.1-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"classmap": [
|
||||||
|
"src/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause",
|
||||||
|
"GPL-2.0-only",
|
||||||
|
"GPL-3.0-only"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "David Grudl",
|
||||||
|
"homepage": "https://davidgrudl.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nette Community",
|
||||||
|
"homepage": "https://nette.org/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
|
||||||
|
"homepage": "https://nette.org",
|
||||||
|
"keywords": [
|
||||||
|
"array",
|
||||||
|
"core",
|
||||||
|
"datetime",
|
||||||
|
"images",
|
||||||
|
"json",
|
||||||
|
"nette",
|
||||||
|
"paginator",
|
||||||
|
"password",
|
||||||
|
"slugify",
|
||||||
|
"string",
|
||||||
|
"unicode",
|
||||||
|
"utf-8",
|
||||||
|
"utility",
|
||||||
|
"validation"
|
||||||
|
],
|
||||||
|
"time": "2020-05-27T09:58:51+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "pguardiario/phpuri",
|
"name": "pguardiario/phpuri",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
|
|||||||
+131
-130
@@ -1,131 +1,132 @@
|
|||||||
body, html{
|
body,
|
||||||
height: 100%;
|
html {
|
||||||
background-repeat: no-repeat;
|
height: 100%;
|
||||||
}
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
.main{
|
|
||||||
margin-top: 70px;
|
.main {
|
||||||
}
|
margin-top: 70px;
|
||||||
|
}
|
||||||
h1.title {
|
|
||||||
font-size: 50px;
|
h1.title {
|
||||||
font-family: 'Passion One', cursive;
|
font-size: 50px;
|
||||||
font-weight: 400;
|
font-family: 'Passion One', cursive;
|
||||||
}
|
font-weight: 400;
|
||||||
|
}
|
||||||
hr{
|
|
||||||
width: 10%;
|
hr {
|
||||||
/*color: #fff;*/
|
width: 10%;
|
||||||
}
|
/*color: #fff;*/
|
||||||
|
}
|
||||||
.form-group{
|
|
||||||
margin-bottom: 15px;
|
.form-group {
|
||||||
}
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
label{
|
|
||||||
margin-bottom: 15px;
|
label {
|
||||||
}
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
input,
|
|
||||||
input::-webkit-input-placeholder {
|
input,
|
||||||
font-size: 11px;
|
input::-webkit-input-placeholder {
|
||||||
padding-top: 3px;
|
font-size: 11px;
|
||||||
}
|
padding-top: 3px;
|
||||||
|
}
|
||||||
.main-login{
|
|
||||||
/*background-color: #fff;*/
|
.main-login {
|
||||||
/* shadows and rounded borders */
|
/*background-color: #fff;*/
|
||||||
-moz-border-radius: 2px;
|
/* shadows and rounded borders */
|
||||||
-webkit-border-radius: 2px;
|
-moz-border-radius: 2px;
|
||||||
border-radius: 2px;
|
-webkit-border-radius: 2px;
|
||||||
-moz-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
border-radius: 2px;
|
||||||
-webkit-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
-moz-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||||
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
-webkit-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||||
|
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-center{
|
.main-center {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
max-width: 330px;
|
max-width: 330px;
|
||||||
padding: 40px 40px;
|
padding: 40px 40px;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
.login_btn_group {
|
||||||
.login_btn_group{
|
margin-top: 5px;
|
||||||
margin-top: 5px;
|
}
|
||||||
}
|
|
||||||
|
.login-register {
|
||||||
.login-register{
|
font-size: 11px;
|
||||||
font-size: 11px;
|
text-align: center;
|
||||||
text-align: center;
|
}
|
||||||
}
|
|
||||||
|
.col-form-label {
|
||||||
|
text-align: center;
|
||||||
.col-form-label{
|
}
|
||||||
text-align:center;
|
|
||||||
}
|
.terms {
|
||||||
|
max-height: 200px;
|
||||||
.terms{
|
overflow-y: auto;
|
||||||
max-height: 200px; overflow-y: auto;
|
}
|
||||||
}
|
|
||||||
|
.terms pre {
|
||||||
.terms pre{
|
width: 100%;
|
||||||
width:100%;
|
white-space: pre-wrap;
|
||||||
white-space: pre-wrap; /* Since CSS 2.1 */
|
/* Since CSS 2.1 */
|
||||||
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
white-space: -moz-pre-wrap;
|
||||||
white-space: -pre-wrap; /* Opera 4-6 */
|
/* Mozilla, since 1999 */
|
||||||
white-space: -o-pre-wrap; /* Opera 7 */
|
white-space: -pre-wrap;
|
||||||
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
/* Opera 4-6 */
|
||||||
}
|
white-space: -o-pre-wrap;
|
||||||
|
/* Opera 7 */
|
||||||
.vertical-center {
|
word-wrap: break-word;
|
||||||
min-height: 100%; /* Fallback for browsers do NOT support vh unit */
|
/* Internet Explorer 5.5+ */
|
||||||
min-height: 100vh; /* These two lines are counted as one :-) */
|
}
|
||||||
|
|
||||||
display: flex;
|
.vertical-center {
|
||||||
align-items: center;
|
min-height: 100%;
|
||||||
}
|
/* Fallback for browsers do NOT support vh unit */
|
||||||
|
min-height: 100vh;
|
||||||
.full-content {
|
/* These two lines are counted as one :-) */
|
||||||
position:fixed;
|
display: flex;
|
||||||
left:0;
|
align-items: center;
|
||||||
top:0;
|
}
|
||||||
width:100%;
|
|
||||||
height:100%;
|
#login_card {
|
||||||
margin:0;
|
z-index: 801;
|
||||||
padding:0;
|
}
|
||||||
z-index:800;
|
|
||||||
}
|
#btn_kakao_login {
|
||||||
|
cursor: pointer;
|
||||||
#login_card{
|
height: 46px;
|
||||||
z-index:801;
|
width: 116px;
|
||||||
}
|
background-color: transparent;
|
||||||
|
color: transparent;
|
||||||
#btn_kakao_login{
|
border: 0;
|
||||||
cursor: pointer;
|
background-size: 100%;
|
||||||
height:46px;
|
/* To fill the dimensions of container (button), or */
|
||||||
width:116px;
|
background-repeat: no-repeat;
|
||||||
background-color: transparent;
|
background-position: bottom center;
|
||||||
color:transparent;
|
margin-top: 5px;
|
||||||
border:0;
|
background-image: url('../oauth_kakao/kakao_login_join.png');
|
||||||
background-size: 100%; /* To fill the dimensions of container (button), or */
|
}
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: bottom center;
|
#btn_kakao_login:hover {
|
||||||
margin-top:5px;
|
background-image: url('../oauth_kakao/kakao_login_join_ov.png');
|
||||||
background-image:url('../oauth_kakao/kakao_login_join.png');
|
}
|
||||||
}
|
|
||||||
|
#bottom_box .container {
|
||||||
#btn_kakao_login:hover {
|
text-align: center;
|
||||||
background-image:url('../oauth_kakao/kakao_login_join_ov.png');
|
}
|
||||||
}
|
|
||||||
|
.btn-group-xs>.btn,
|
||||||
#bottom_box{
|
.btn-xs {
|
||||||
position:fixed;
|
padding: .25rem .4rem;
|
||||||
bottom:0;
|
font-size: .875rem;
|
||||||
width:100%;
|
line-height: .5;
|
||||||
left:0;
|
border-radius: .2rem;
|
||||||
}
|
}
|
||||||
#bottom_box .container{
|
|
||||||
text-align:center;
|
#running_map {
|
||||||
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
+313
-305
@@ -1,305 +1,313 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
require(__DIR__ . '/../vendor/autoload.php');
|
require(__DIR__ . '/../vendor/autoload.php');
|
||||||
|
|
||||||
$host = Util::getPost('db_host');
|
$host = Util::getPost('db_host');
|
||||||
$port = Util::getPost('db_port', 'int');
|
$port = Util::getPost('db_port', 'int');
|
||||||
$username = Util::getPost('db_id');
|
$username = Util::getPost('db_id');
|
||||||
$password = Util::getPost('db_pw');
|
$password = Util::getPost('db_pw');
|
||||||
$dbName = Util::getPost('db_name');
|
$dbName = Util::getPost('db_name');
|
||||||
$servHost = Util::getPost('serv_host');
|
$servHost = Util::getPost('serv_host');
|
||||||
$sharedIconPath = Util::getPost('shared_icon_path');
|
$sharedIconPath = Util::getPost('shared_icon_path');
|
||||||
$gameImagePath = Util::getPost('game_image_path');
|
$gameImagePath = Util::getPost('game_image_path');
|
||||||
$imageRequestKey = Util::getPost('image_request_key');
|
$imageRequestKey = Util::getPost('image_request_key');
|
||||||
|
|
||||||
$kakaoRESTKey = Util::getPost('kakao_rest_key', 'string', '');
|
$kakaoRESTKey = Util::getPost('kakao_rest_key', 'string', '');
|
||||||
$kakaoAdminKey = Util::getPost('kakao_admin_key', 'string', '');
|
$kakaoAdminKey = Util::getPost('kakao_admin_key', 'string', '');
|
||||||
|
|
||||||
|
|
||||||
if (!$host || !$port || !$username || !$password || !$dbName || !$servHost || !$sharedIconPath || !$gameImagePath) {
|
if (!$host || !$port || !$username || !$password || !$dbName || !$servHost || !$sharedIconPath || !$gameImagePath) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => '입력 값이 올바르지 않습니다'
|
'reason' => '입력 값이 올바르지 않습니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filter_var($servHost, FILTER_VALIDATE_URL)) {
|
if (!filter_var($servHost, FILTER_VALIDATE_URL)) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => '접속 경로가 올바르지 않습니다.'
|
'reason' => '접속 경로가 올바르지 않습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(ROOT . '/d_setting/RootDB.php') && is_dir(ROOT . '/d_setting/RootDB.php')) {
|
if (file_exists(ROOT . '/d_setting/RootDB.php') && is_dir(ROOT . '/d_setting/RootDB.php')) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'd_setting/RootDB.php 가 디렉토리입니다'
|
'reason' => 'd_setting/RootDB.php 가 디렉토리입니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists('\\sammo\\RootDB')) {
|
if (class_exists('\\sammo\\RootDB')) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => '이미 RootDB.php 파일이 있습니다'
|
'reason' => '이미 RootDB.php 파일이 있습니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//파일 권한 검사
|
//파일 권한 검사
|
||||||
if (file_exists(AppConf::getUserIconPathFS()) && !is_dir(AppConf::getUserIconPathFS())) {
|
if (file_exists(AppConf::getUserIconPathFS()) && !is_dir(AppConf::getUserIconPathFS())) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => AppConf::$userIconPath . ' 이 디렉토리가 아닙니다'
|
'reason' => AppConf::$userIconPath . ' 이 디렉토리가 아닙니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(ROOT . '/d_log') && !is_dir(ROOT . '/d_log')) {
|
if (file_exists(ROOT . '/d_log') && !is_dir(ROOT . '/d_log')) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'd_log 가 디렉토리가 아닙니다'
|
'reason' => 'd_log 가 디렉토리가 아닙니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(ROOT . '/d_shared') && !is_dir(ROOT . '/d_shared')) {
|
if (file_exists(ROOT . '/d_shared') && !is_dir(ROOT . '/d_shared')) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'd_shared 가 디렉토리가 아닙니다'
|
'reason' => 'd_shared 가 디렉토리가 아닙니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(ROOT . '/d_setting') && !is_dir(ROOT . '/d_setting')) {
|
if (file_exists(ROOT . '/d_setting') && !is_dir(ROOT . '/d_setting')) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'd_shared 가 디렉토리가 아닙니다'
|
'reason' => 'd_shared 가 디렉토리가 아닙니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!file_exists(ROOT . '/d_log')
|
!file_exists(ROOT . '/d_log')
|
||||||
|| !file_exists(ROOT . '/d_shared')
|
|| !file_exists(ROOT . '/d_shared')
|
||||||
|| !file_exists(ROOT . '/d_setting')
|
|| !file_exists(ROOT . '/d_setting')
|
||||||
|| !file_exists(AppConf::getUserIconPathFS())
|
|| !file_exists(AppConf::getUserIconPathFS())
|
||||||
) {
|
) {
|
||||||
if (!is_writable(ROOT)) {
|
if (!is_writable(ROOT)) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => '하위 디렉토리 생성 권한이 없습니다'
|
'reason' => '하위 디렉토리 생성 권한이 없습니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//기본 파일 생성
|
//기본 파일 생성
|
||||||
if (!file_exists(AppConf::getUserIconPathFS())) {
|
if (!file_exists(AppConf::getUserIconPathFS())) {
|
||||||
mkdir(AppConf::getUserIconPathFS());
|
mkdir(AppConf::getUserIconPathFS());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists(ROOT . '/d_log')) {
|
if (!file_exists(ROOT . '/d_log')) {
|
||||||
mkdir(ROOT . '/d_log');
|
mkdir(ROOT . '/d_log');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists(ROOT . '/d_setting')) {
|
if (!file_exists(ROOT . '/d_setting')) {
|
||||||
mkdir(ROOT . '/d_setting');
|
mkdir(ROOT . '/d_setting');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists(ROOT . '/d_shared')) {
|
if (!file_exists(ROOT . '/d_shared')) {
|
||||||
mkdir(ROOT . '/d_shared');
|
mkdir(ROOT . '/d_shared');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!is_writable(AppConf::getUserIconPathFS())) {
|
if (!is_writable(AppConf::getUserIconPathFS())) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => AppConf::$userIconPath . ' 디렉토리의 쓰기 권한이 없습니다'
|
'reason' => AppConf::$userIconPath . ' 디렉토리의 쓰기 권한이 없습니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_writable(ROOT . '/d_log')) {
|
if (!is_writable(ROOT . '/d_log')) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'd_log 디렉토리의 쓰기 권한이 없습니다'
|
'reason' => 'd_log 디렉토리의 쓰기 권한이 없습니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_writable(ROOT . '/d_shared')) {
|
if (!is_writable(ROOT . '/d_shared')) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'd_shared 디렉토리의 쓰기 권한이 없습니다'
|
'reason' => 'd_shared 디렉토리의 쓰기 권한이 없습니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_writable(ROOT . '/d_setting')) {
|
if (!is_writable(ROOT . '/d_setting')) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'd_setting 디렉토리의 쓰기 권한이 없습니다.'
|
'reason' => 'd_setting 디렉토리의 쓰기 권한이 없습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!file_exists(ROOT . '/d_log/.htaccess')) {
|
if (!file_exists(ROOT . '/d_log/.htaccess')) {
|
||||||
@file_put_contents(ROOT . '/d_log/.htaccess', 'Deny from all');
|
@file_put_contents(ROOT . '/d_log/.htaccess', 'Deny from all');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists(ROOT . '/d_setting/.htaccess')) {
|
if (!file_exists(ROOT . '/d_setting/.htaccess')) {
|
||||||
@file_put_contents(ROOT . '/d_setting/.htaccess', 'Deny from all');
|
@file_put_contents(ROOT . '/d_setting/.htaccess', 'Deny from all');
|
||||||
}
|
}
|
||||||
|
|
||||||
//DB 접근 권한 검사
|
//DB 접근 권한 검사
|
||||||
|
|
||||||
$rootDB = new \MeekroDB($host, $username, $password, $dbName, $port, 'utf8mb4');
|
$rootDB = new \MeekroDB($host, $username, $password, $dbName, $port, 'utf8mb4');
|
||||||
$rootDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
$rootDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||||
|
|
||||||
$rootDB->throw_exception_on_nonsql_error = false;
|
$rootDB->throw_exception_on_nonsql_error = false;
|
||||||
$rootDB->nonsql_error_handler = function ($params) {
|
$rootDB->nonsql_error_handler = function ($params) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'DB 접속에 실패했습니다.'
|
'reason' => 'DB 접속에 실패했습니다.'
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
$rootDB->error_handler = function ($params) {
|
$rootDB->error_handler = function ($params) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'reason' => 'SQL을 제대로 실행하지 못했습니다. DB상태를 확인해 주세요.'
|
'reason' => 'SQL을 제대로 실행하지 못했습니다. DB상태를 확인해 주세요.'
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
$mysqli_obj = $rootDB->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨.
|
$mysqli_obj = $rootDB->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨.
|
||||||
|
|
||||||
if ($mysqli_obj->multi_query(file_get_contents(__DIR__ . '/sql/common_schema.sql'))) {
|
if ($mysqli_obj->multi_query(file_get_contents(__DIR__ . '/sql/common_schema.sql'))) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!$mysqli_obj->more_results()) {
|
if (!$mysqli_obj->more_results()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!$mysqli_obj->next_result()) {
|
if (!$mysqli_obj->next_result()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootDB->insert('system', array(
|
$rootDB->insert('system', array(
|
||||||
'REG' => 'N',
|
'REG' => 'N',
|
||||||
'LOGIN' => 'N',
|
'LOGIN' => 'N',
|
||||||
'CRT_DATE' => TimeUtil::now(),
|
'CRT_DATE' => TimeUtil::now(),
|
||||||
'MDF_DATE' => TimeUtil::now()
|
'MDF_DATE' => TimeUtil::now()
|
||||||
));
|
));
|
||||||
|
|
||||||
$globalSalt = bin2hex(random_bytes(16));
|
$globalSalt = bin2hex(random_bytes(16));
|
||||||
|
|
||||||
'@phan-var-force string $servHost';
|
'@phan-var-force string $servHost';
|
||||||
'@phan-var-force string $sharedIconPath';
|
'@phan-var-force string $sharedIconPath';
|
||||||
'@phan-var-force string $gameImagePath';
|
'@phan-var-force string $gameImagePath';
|
||||||
|
|
||||||
$sharedIconPath = WebUtil::resolveRelativePath($sharedIconPath, $servHost);
|
$sharedIconPath = WebUtil::resolveRelativePath($sharedIconPath, $servHost);
|
||||||
$gameImagePath = WebUtil::resolveRelativePath($gameImagePath, $servHost);
|
$gameImagePath = WebUtil::resolveRelativePath($gameImagePath, $servHost);
|
||||||
$imageRequestPath = WebUtil::resolveRelativePath($gameImagePath . '/../hook/git_pull.php', $servHost);
|
$imageRequestPath = WebUtil::resolveRelativePath($gameImagePath . '/../hook/git_pull.php', $servHost);
|
||||||
$imageKeyInstallPath = WebUtil::resolveRelativePath($gameImagePath . '/../hook/InstallKey.php', $servHost);
|
$imageKeyInstallPath = WebUtil::resolveRelativePath($gameImagePath . '/../hook/InstallKey.php', $servHost);
|
||||||
|
|
||||||
$result = Util::generateFileUsingSimpleTemplate(
|
$result = Util::generateFileUsingSimpleTemplate(
|
||||||
__DIR__ . '/templates/ServConfig.orig.php',
|
__DIR__ . '/templates/ServConfig.orig.php',
|
||||||
ROOT . '/d_setting/ServConfig.php',
|
ROOT . '/d_setting/ServConfig.php',
|
||||||
[
|
[
|
||||||
'serverBasePath' => $servHost,
|
'serverBasePath' => $servHost,
|
||||||
'sharedIconPath' => $sharedIconPath,
|
'sharedIconPath' => $sharedIconPath,
|
||||||
'gameImagePath' => $gameImagePath,
|
'gameImagePath' => $gameImagePath,
|
||||||
'imageRequestPath' => $imageRequestPath,
|
'imageRequestPath' => $imageRequestPath,
|
||||||
'imageRequestKey' => $imageRequestKey
|
'imageRequestKey' => $imageRequestKey,
|
||||||
],
|
'serverList' => [
|
||||||
true
|
['che', '체', 'white'],
|
||||||
);
|
['kwe', '퀘', 'yellow'],
|
||||||
|
['pwe', '풰', 'orange'],
|
||||||
if ($imageRequestKey) {
|
['twe', '퉤', 'magenta'],
|
||||||
@file_get_contents($imageKeyInstallPath . '?key=' . $imageRequestKey);
|
['nya', '냐', '#e67e22'],
|
||||||
}
|
['pya', '퍄', '#9b59b6']
|
||||||
|
]
|
||||||
if ($result !== true) {
|
],
|
||||||
Json::die([
|
true
|
||||||
'result' => false,
|
);
|
||||||
'reason' => $result
|
|
||||||
]);
|
if ($imageRequestKey) {
|
||||||
}
|
@file_get_contents($imageKeyInstallPath . '?key=' . $imageRequestKey);
|
||||||
|
}
|
||||||
$result = Util::generateFileUsingSimpleTemplate(
|
|
||||||
__DIR__ . '/templates/common_path.orig.js',
|
if ($result !== true) {
|
||||||
ROOT . '/d_shared/common_path.js',
|
Json::die([
|
||||||
[
|
'result' => false,
|
||||||
'serverBasePath' => $servHost,
|
'reason' => $result
|
||||||
'sharedIconPath' => $sharedIconPath,
|
]);
|
||||||
'gameImagePath' => $gameImagePath
|
}
|
||||||
],
|
|
||||||
true
|
$result = Util::generateFileUsingSimpleTemplate(
|
||||||
);
|
__DIR__ . '/templates/common_path.orig.js',
|
||||||
|
ROOT . '/d_shared/common_path.js',
|
||||||
$result = Util::generateFileUsingSimpleTemplate(
|
[
|
||||||
__DIR__ . '/templates/menu.orig.json',
|
'serverBasePath' => $servHost,
|
||||||
ROOT . '/d_shared/menu.json',
|
'sharedIconPath' => $sharedIconPath,
|
||||||
[],
|
'gameImagePath' => $gameImagePath
|
||||||
true
|
],
|
||||||
);
|
true
|
||||||
|
);
|
||||||
if ($result !== true) {
|
|
||||||
Json::die([
|
$result = Util::generateFileUsingSimpleTemplate(
|
||||||
'result' => false,
|
__DIR__ . '/templates/menu.orig.json',
|
||||||
'reason' => $result
|
ROOT . '/d_shared/menu.json',
|
||||||
]);
|
[],
|
||||||
}
|
true
|
||||||
|
);
|
||||||
|
|
||||||
$result = Util::generateFileUsingSimpleTemplate(
|
if ($result !== true) {
|
||||||
__DIR__ . '/templates/common.orig.css',
|
Json::die([
|
||||||
ROOT . '/d_shared/common.css',
|
'result' => false,
|
||||||
[
|
'reason' => $result
|
||||||
'serverBasePath' => $servHost,
|
]);
|
||||||
'sharedIconPath' => $sharedIconPath,
|
}
|
||||||
'gameImagePath' => $gameImagePath
|
|
||||||
],
|
|
||||||
true
|
$result = Util::generateFileUsingSimpleTemplate(
|
||||||
);
|
__DIR__ . '/templates/common.orig.css',
|
||||||
|
ROOT . '/d_shared/common.css',
|
||||||
if ($result !== true) {
|
[
|
||||||
Json::die([
|
'serverBasePath' => $servHost,
|
||||||
'result' => false,
|
'sharedIconPath' => $sharedIconPath,
|
||||||
'reason' => $result
|
'gameImagePath' => $gameImagePath
|
||||||
]);
|
],
|
||||||
}
|
true
|
||||||
|
);
|
||||||
|
|
||||||
$result = Util::generateFileUsingSimpleTemplate(
|
if ($result !== true) {
|
||||||
__DIR__ . '/templates/RootDB.orig.php',
|
Json::die([
|
||||||
ROOT . '/d_setting/RootDB.php',
|
'result' => false,
|
||||||
[
|
'reason' => $result
|
||||||
'host' => $host,
|
]);
|
||||||
'user' => $username,
|
}
|
||||||
'password' => $password,
|
|
||||||
'dbName' => $dbName,
|
|
||||||
'port' => $port,
|
$result = Util::generateFileUsingSimpleTemplate(
|
||||||
'globalSalt' => $globalSalt,
|
__DIR__ . '/templates/RootDB.orig.php',
|
||||||
]
|
ROOT . '/d_setting/RootDB.php',
|
||||||
);
|
[
|
||||||
|
'host' => $host,
|
||||||
$kakaoRedirectURI = WebUtil::resolveRelativePath('oauth_kakao/oauth.php', $servHost . '/');
|
'user' => $username,
|
||||||
|
'password' => $password,
|
||||||
Util::generateFileUsingSimpleTemplate(
|
'dbName' => $dbName,
|
||||||
__DIR__ . '/templates/KakaoKey.orig.php',
|
'port' => $port,
|
||||||
ROOT . '/d_setting/KakaoKey.php',
|
'globalSalt' => $globalSalt,
|
||||||
[
|
]
|
||||||
'REST_API_KEY' => $kakaoRESTKey,
|
);
|
||||||
'ADMIN_KEY' => $kakaoAdminKey,
|
|
||||||
'REDIRECT_URI' => $kakaoRedirectURI
|
$kakaoRedirectURI = WebUtil::resolveRelativePath('oauth_kakao/oauth.php', $servHost . '/');
|
||||||
],
|
|
||||||
true
|
Util::generateFileUsingSimpleTemplate(
|
||||||
);
|
__DIR__ . '/templates/KakaoKey.orig.php',
|
||||||
|
ROOT . '/d_setting/KakaoKey.php',
|
||||||
if ($result !== true) {
|
[
|
||||||
Json::die([
|
'REST_API_KEY' => $kakaoRESTKey,
|
||||||
'result' => false,
|
'ADMIN_KEY' => $kakaoAdminKey,
|
||||||
'reason' => $result
|
'REDIRECT_URI' => $kakaoRedirectURI
|
||||||
]);
|
],
|
||||||
}
|
true
|
||||||
|
);
|
||||||
Json::die([
|
|
||||||
'result' => true,
|
if ($result !== true) {
|
||||||
'reason' => 'success',
|
Json::die([
|
||||||
'globalSalt' => $globalSalt
|
'result' => false,
|
||||||
]);
|
'reason' => $result
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Json::die([
|
||||||
|
'result' => true,
|
||||||
|
'reason' => 'success',
|
||||||
|
'globalSalt' => $globalSalt
|
||||||
|
]);
|
||||||
|
|||||||
@@ -1,55 +1,74 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
class ServConfig
|
class ServConfig
|
||||||
{
|
{
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static $serverWebPath = '_tK_serverBasePath_';
|
public static $serverWebPath = '_tK_serverBasePath_';
|
||||||
public static $sharedIconPath = '_tK_sharedIconPath_';
|
public static $sharedIconPath = '_tK_sharedIconPath_';
|
||||||
public static $gameImagePath = "_tK_gameImagePath_";
|
public static $gameImagePath = "_tK_gameImagePath_";
|
||||||
public static $imageRequestPath = "_tK_imageRequestPath_";
|
public static $imageRequestPath = "_tK_imageRequestPath_";
|
||||||
public static $imageRequestKey = '_tK_imageRequestKey_';
|
public static $imageRequestKey = '_tK_imageRequestKey_';
|
||||||
|
private static $serverList = null;
|
||||||
public static function getSharedIconPath(string $filepath = ''): string
|
|
||||||
{
|
public static function getSharedIconPath(string $filepath = ''): string
|
||||||
if ($filepath) {
|
{
|
||||||
return static::$sharedIconPath . "/{$filepath}";
|
if ($filepath) {
|
||||||
}
|
return static::$sharedIconPath . "/{$filepath}";
|
||||||
return static::$sharedIconPath;
|
}
|
||||||
}
|
return static::$sharedIconPath;
|
||||||
|
}
|
||||||
public static function getUserIconPath(string $filepath = ''): string
|
|
||||||
{
|
public static function getUserIconPath(string $filepath = ''): string
|
||||||
return AppConf::getUserIconPathWeb($filepath);
|
{
|
||||||
}
|
return AppConf::getUserIconPathWeb($filepath);
|
||||||
|
}
|
||||||
public static function getGameImagePath(string $filepath = ''): string
|
|
||||||
{
|
public static function getGameImagePath(string $filepath = ''): string
|
||||||
if ($filepath) {
|
{
|
||||||
return static::$gameImagePath . "/{$filepath}";
|
if ($filepath) {
|
||||||
}
|
return static::$gameImagePath . "/{$filepath}";
|
||||||
return static::$gameImagePath;
|
}
|
||||||
}
|
return static::$gameImagePath;
|
||||||
|
}
|
||||||
public static function getImagePullURI(): string
|
|
||||||
{
|
public static function getImagePullURI(): string
|
||||||
$now = time();
|
{
|
||||||
$req_hash = Util::hashPassword(sprintf("%016x", $now), static::$imageRequestKey);
|
$now = time();
|
||||||
return static::$imageRequestPath . "?req={$req_hash}&time={$now}";
|
$req_hash = Util::hashPassword(sprintf("%016x", $now), static::$imageRequestKey);
|
||||||
}
|
return static::$imageRequestPath . "?req={$req_hash}&time={$now}";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 서버 주소 반환. 서버의 경로가 하부 디렉토리인 경우에 하부 디렉토리까지 포함
|
* 서버 설정 반환
|
||||||
*
|
*
|
||||||
* @return string
|
* @return \sammo\Setting[]
|
||||||
*/
|
*/
|
||||||
public static function getServerBasepath(): string
|
public static function getServerList(): array{
|
||||||
{
|
$servKeyList = [/*_tK_serverList_*/];
|
||||||
return self::$serverWebPath;
|
$servKeyList[] = ['hwe', '훼', 'red'];
|
||||||
}
|
|
||||||
}
|
if (self::$serverList === null) {
|
||||||
|
self::$serverList = [];
|
||||||
|
foreach($servKeyList as [$servKey, $servNick, $servColor]){
|
||||||
|
self::$serverList[$servKey] = new Setting(ROOT.'/'.$servKey, $servNick, $servColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self::$serverList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 서버 주소 반환. 서버의 경로가 하부 디렉토리인 경우에 하부 디렉토리까지 포함
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getServerBasepath(): string
|
||||||
|
{
|
||||||
|
return self::$serverWebPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+215
-215
@@ -1,215 +1,215 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
$type = Util::getReq('type', 'int', 9);
|
$type = Util::getReq('type', 'int', 9);
|
||||||
|
|
||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
increaseRefresh("장수일람", 2);
|
increaseRefresh("장수일람", 2);
|
||||||
|
|
||||||
$me = $db->queryFirstRow('SELECT con,turntime FROM general WHERE owner = %i', $userID);
|
$me = $db->queryFirstRow('SELECT con,turntime FROM general WHERE owner = %i', $userID);
|
||||||
|
|
||||||
$con = checkLimit($me['con']);
|
$con = checkLimit($me['con']);
|
||||||
if ($con >= 2) {
|
if ($con >= 2) {
|
||||||
printLimitMsg($me['turntime']);
|
printLimitMsg($me['turntime']);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type <= 0 || $type > 15) {
|
if ($type <= 0 || $type > 15) {
|
||||||
$type = 9;
|
$type = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ownerNameList = [];
|
$ownerNameList = [];
|
||||||
if($gameStor->isunited){
|
if($gameStor->isunited){
|
||||||
foreach(RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]){
|
foreach(RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]){
|
||||||
$ownerNameList[$ownerID] = $ownerName;
|
$ownerNameList[$ownerID] = $ownerName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=1024" />
|
<meta name="viewport" content="width=1024" />
|
||||||
<title><?=UniqueConst::$serverName?>: 장수일람</title>
|
<title><?=UniqueConst::$serverName?>: 장수일람</title>
|
||||||
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
||||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||||
<?=WebUtil::printCSS('css/common.css')?>
|
<?=WebUtil::printCSS('css/common.css')?>
|
||||||
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
||||||
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
||||||
<?=WebUtil::printJS('../d_shared/common_path.js')?>
|
<?=WebUtil::printJS('../d_shared/common_path.js')?>
|
||||||
<?=WebUtil::printJS('js/common.js')?>
|
<?=WebUtil::printJS('js/common.js')?>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
<tr><td>장 수 일 람<br><?=closeButton()?></td></tr>
|
<tr><td>장 수 일 람<br><?=closeButton()?></td></tr>
|
||||||
<tr><td><form name=form1 method=post>정렬순서 :
|
<tr><td><form name=form1 method=post>정렬순서 :
|
||||||
<select id='viewType' name='type' size=1>
|
<select id='viewType' name='type' size=1>
|
||||||
<option value=1>국가</option>
|
<option value=1>국가</option>
|
||||||
<option value=2>통솔</option>
|
<option value=2>통솔</option>
|
||||||
<option value=3>무력</option>
|
<option value=3>무력</option>
|
||||||
<option value=4>지력</option>
|
<option value=4>지력</option>
|
||||||
<option value=5>명성</option>
|
<option value=5>명성</option>
|
||||||
<option value=6>계급</option>
|
<option value=6>계급</option>
|
||||||
<option value=7>관직</option>
|
<option value=7>관직</option>
|
||||||
<option value=8>삭턴</option>
|
<option value=8>삭턴</option>
|
||||||
<option value=9>벌점</option>
|
<option value=9>벌점</option>
|
||||||
<option value=10>Lv</option>
|
<option value=10>Lv</option>
|
||||||
<option value=11>성격</option>
|
<option value=11>성격</option>
|
||||||
<option value=12>내특</option>
|
<option value=12>내특</option>
|
||||||
<option value=13>전특</option>
|
<option value=13>전특</option>
|
||||||
<option value=14>연령</option>
|
<option value=14>연령</option>
|
||||||
<option value=15>NPC</option>
|
<option value=15>NPC</option>
|
||||||
</select>
|
</select>
|
||||||
<input type=submit value='정렬하기'></form>
|
<input type=submit value='정렬하기'></form>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
$nationname = [];
|
$nationname = [];
|
||||||
$nationlevel = [];
|
$nationlevel = [];
|
||||||
$nationname[0] = "-";
|
$nationname[0] = "-";
|
||||||
foreach (getAllNationStaticInfo() as $nation) {
|
foreach (getAllNationStaticInfo() as $nation) {
|
||||||
$nationname[$nation['nation']] = $nation['name'];
|
$nationname[$nation['nation']] = $nation['name'];
|
||||||
$nationlevel[$nation['nation']] = $nation['level'];
|
$nationlevel[$nation['nation']] = $nation['level'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[$orderKey, $orderDesc] = [
|
[$orderKey, $orderDesc] = [
|
||||||
1=>['nation', false],
|
1=>['nation', false],
|
||||||
2=>['leadership', true],
|
2=>['leadership', true],
|
||||||
3=>['strength', true],
|
3=>['strength', true],
|
||||||
4=>['intel', true],
|
4=>['intel', true],
|
||||||
5=>['experience', true],
|
5=>['experience', true],
|
||||||
6=>['dedication', true],
|
6=>['dedication', true],
|
||||||
7=>['officer_level', true],
|
7=>['officer_level', true],
|
||||||
8=>['killturn', false],
|
8=>['killturn', false],
|
||||||
9=>['connect', true],
|
9=>['connect', true],
|
||||||
10=>['experience', true],
|
10=>['experience', true],
|
||||||
11=>['personal', true],
|
11=>['personal', true],
|
||||||
12=>['special', true],
|
12=>['special', true],
|
||||||
13=>['special2', true],
|
13=>['special2', true],
|
||||||
14=>['age', true],
|
14=>['age', true],
|
||||||
15=>['npc', true],
|
15=>['npc', true],
|
||||||
][$type];
|
][$type];
|
||||||
|
|
||||||
$generalList = $db->query('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect from general order by %b %l', $orderKey, $orderDesc?'desc':'');
|
$generalList = $db->query('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect from general order by %b %l', $orderKey, $orderDesc?'desc':'');
|
||||||
|
|
||||||
echo"
|
echo"
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
<tr>
|
<tr>
|
||||||
<td width=64 align=center id=bg1>얼 굴</td>
|
<td width=64 align=center id=bg1>얼 굴</td>
|
||||||
<td width=140 align=center id=bg1>이 름</td>
|
<td width=140 align=center id=bg1>이 름</td>
|
||||||
<td width=45 align=center id=bg1>연령</td>
|
<td width=45 align=center id=bg1>연령</td>
|
||||||
<td width=45 align=center id=bg1>성격</td>
|
<td width=45 align=center id=bg1>성격</td>
|
||||||
<td width=80 align=center id=bg1>특기</td>
|
<td width=80 align=center id=bg1>특기</td>
|
||||||
<td width=45 align=center id=bg1>레 벨</td>
|
<td width=45 align=center id=bg1>레 벨</td>
|
||||||
<td width=140 align=center id=bg1>국 가</td>
|
<td width=140 align=center id=bg1>국 가</td>
|
||||||
<td width=55 align=center id=bg1>명 성</td>
|
<td width=55 align=center id=bg1>명 성</td>
|
||||||
<td width=55 align=center id=bg1>계 급</td>
|
<td width=55 align=center id=bg1>계 급</td>
|
||||||
<td width=75 align=center id=bg1>관 직</td>
|
<td width=75 align=center id=bg1>관 직</td>
|
||||||
<td width=45 align=center id=bg1>통솔</td>
|
<td width=45 align=center id=bg1>통솔</td>
|
||||||
<td width=45 align=center id=bg1>무력</td>
|
<td width=45 align=center id=bg1>무력</td>
|
||||||
<td width=45 align=center id=bg1>지력</td>
|
<td width=45 align=center id=bg1>지력</td>
|
||||||
<td width=45 align=center id=bg1>삭턴</td>
|
<td width=45 align=center id=bg1>삭턴</td>
|
||||||
<td width=70 align=center id=bg1>벌점</td>
|
<td width=70 align=center id=bg1>벌점</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
foreach($generalList as $general){
|
foreach($generalList as $general){
|
||||||
$nation = $nationname[$general['nation']];
|
$nation = $nationname[$general['nation']];
|
||||||
|
|
||||||
$lbonus = calcLeadershipBonus($general['officer_level'], $nationlevel[$general['nation']]??0);
|
$lbonus = calcLeadershipBonus($general['officer_level'], $nationlevel[$general['nation']]??0);
|
||||||
if ($lbonus > 0) {
|
if ($lbonus > 0) {
|
||||||
$lbonusText = "<font color=cyan>+{$lbonus}</font>";
|
$lbonusText = "<font color=cyan>+{$lbonus}</font>";
|
||||||
} else {
|
} else {
|
||||||
$lbonusText = "";
|
$lbonusText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($general['injury'] > 0) {
|
if ($general['injury'] > 0) {
|
||||||
$leadership = intdiv($general['leadership'] * (100 - $general['injury']), 100);
|
$leadership = intdiv($general['leadership'] * (100 - $general['injury']), 100);
|
||||||
$strength = intdiv($general['strength'] * (100 - $general['injury']), 100);
|
$strength = intdiv($general['strength'] * (100 - $general['injury']), 100);
|
||||||
$intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
|
$intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
|
||||||
$leadership = "<font color=red>{$leadership}</font>{$lbonusText}";
|
$leadership = "<font color=red>{$leadership}</font>{$lbonusText}";
|
||||||
$strength = "<font color=red>{$strength}</font>";
|
$strength = "<font color=red>{$strength}</font>";
|
||||||
$intel = "<font color=red>{$intel}</font>";
|
$intel = "<font color=red>{$intel}</font>";
|
||||||
} else {
|
} else {
|
||||||
$leadership = "{$general['leadership']}{$lbonusText}";
|
$leadership = "{$general['leadership']}{$lbonusText}";
|
||||||
$strength = "{$general['strength']}";
|
$strength = "{$general['strength']}";
|
||||||
$intel = "{$general['intel']}";
|
$intel = "{$general['intel']}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($general['npc'] >= 2) {
|
if ($general['npc'] >= 2) {
|
||||||
$name = "<font color=cyan>{$general['name']}</font>";
|
$name = "<font color=cyan>{$general['name']}</font>";
|
||||||
} elseif ($general['npc'] == 1) {
|
} elseif ($general['npc'] == 1) {
|
||||||
$name = "<font color=skyblue>{$general['name']}</font>";
|
$name = "<font color=skyblue>{$general['name']}</font>";
|
||||||
} else {
|
} else {
|
||||||
$name = "{$general['name']}";
|
$name = "{$general['name']}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key_exists($general['owner'], $ownerNameList)){
|
if(key_exists($general['owner'], $ownerNameList)){
|
||||||
$name = $name.'<br><small>('.$ownerNameList[$general['owner']].')</small>';
|
$name = $name.'<br><small>('.$ownerNameList[$general['owner']].')</small>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$general['connect'] = Util::round($general['connect'], -1);
|
$general['connect'] = Util::round($general['connect'], -1);
|
||||||
|
|
||||||
$imageTemp = GetImageURL($general['imgsvr']);
|
$imageTemp = GetImageURL($general['imgsvr']);
|
||||||
echo "
|
echo "
|
||||||
<tr data-general-id='{$general['no']}'
|
<tr data-general-id='{$general['no']}'
|
||||||
data-general-wounded='{$general['injury']}'
|
data-general-wounded='{$general['injury']}'
|
||||||
data-general-leadership='{$general['leadership']}'
|
data-general-leadership='{$general['leadership']}'
|
||||||
data-general-leadership-bonus='{$lbonus}'
|
data-general-leadership-bonus='{$lbonus}'
|
||||||
data-general-strength='{$general['strength']}'
|
data-general-strength='{$general['strength']}'
|
||||||
data-general-intel='{$general['intel']}'
|
data-general-intel='{$general['intel']}'
|
||||||
data-is-npc='".($general['npc']>=2?'true':'false')."'
|
data-is-npc='".($general['npc']>=2?'true':'false')."'
|
||||||
>
|
>
|
||||||
<td align=center><img class='generalIcon' width='64' height='64' src='{$imageTemp}/{$general['picture']}'></img></td>
|
<td align=center><img class='generalIcon' width='64' height='64' src='{$imageTemp}/{$general['picture']}'></img></td>
|
||||||
<td align=center>$name</td>
|
<td align=center>$name</td>
|
||||||
<td align=center>{$general['age']}세</td>
|
<td align=center>{$general['age']}세</td>
|
||||||
<td align=center>".displayCharInfo($general['personal'])."</td>
|
<td align=center>".displayCharInfo($general['personal'])."</td>
|
||||||
<td align=center>".displaySpecialDomesticInfo($general['special'])." / ".displaySpecialWarInfo($general['special2'])."</td>
|
<td align=center>".displaySpecialDomesticInfo($general['special'])." / ".displaySpecialWarInfo($general['special2'])."</td>
|
||||||
<td align=center>Lv ".getExpLevel($general['experience'])."</td>
|
<td align=center>Lv ".getExpLevel($general['experience'])."</td>
|
||||||
<td align=center>{$nation}</td>
|
<td align=center>{$nation}</td>
|
||||||
<td align=center>".getHonor($general['experience'])."</td>
|
<td align=center>".getHonor($general['experience'])."</td>
|
||||||
<td align=center>".getDed($general['dedication'])."</td>
|
<td align=center>".getDed($general['dedication'])."</td>
|
||||||
<td align=center>";
|
<td align=center>";
|
||||||
echo getOfficerLevelText($general['officer_level']);
|
echo getOfficerLevelText($general['officer_level']);
|
||||||
echo "</td>
|
echo "</td>
|
||||||
<td align=center>$leadership</td>
|
<td align=center>$leadership</td>
|
||||||
<td align=center>$strength</td>
|
<td align=center>$strength</td>
|
||||||
<td align=center>$intel</td>
|
<td align=center>$intel</td>
|
||||||
<td align=center>{$general['killturn']}</td>
|
<td align=center>{$general['killturn']}</td>
|
||||||
<td align=center>{$general['connect']}";
|
<td align=center>{$general['connect']}";
|
||||||
echo "<br>【".getConnect($general['connect'])."】</td>
|
echo "<br>【".getConnect($general['connect'])."】</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
echo "
|
echo "
|
||||||
</table>
|
</table>
|
||||||
";
|
";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
<tr><td><?=closeButton()?></td></tr>
|
<tr><td><?=closeButton()?></td></tr>
|
||||||
<tr><td><?=banner()?></td></tr>
|
<tr><td><?=banner()?></td></tr>
|
||||||
</table>
|
</table>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#viewType").val("<?=$type?>").attr("selected", "selected");
|
$("#viewType").val("<?=$type?>").attr("selected", "selected");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+160
-154
@@ -1,154 +1,160 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
$showDieImmediatelyBtn = false;
|
$showDieImmediatelyBtn = false;
|
||||||
$availableDieImmediately = false;
|
$availableDieImmediately = false;
|
||||||
|
|
||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
$generalID = $session->generalID;
|
$generalID = $session->generalID;
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$gameStor->cacheValues(['turntime', 'opentime', 'autorun_user']);
|
||||||
increaseRefresh("내정보", 1);
|
|
||||||
|
increaseRefresh("내정보", 1);
|
||||||
$me = General::createGeneralObjFromDB($generalID);
|
|
||||||
|
$me = General::createGeneralObjFromDB($generalID);
|
||||||
$myset = $me->getVar('myset');
|
|
||||||
if ($myset > 0) {
|
$myset = $me->getVar('myset');
|
||||||
$submit = 'button';
|
if ($myset > 0) {
|
||||||
} else {
|
$submit = 'button';
|
||||||
$submit = 'hidden';
|
} else {
|
||||||
}
|
$submit = 'hidden';
|
||||||
|
}
|
||||||
$targetTime = addTurn($me->getVar('lastrefresh'), $gameStor->turnterm, 2);
|
|
||||||
if($gameStor->turntime <= $gameStor->opentime){
|
$targetTime = addTurn($me->getVar('lastrefresh'), $gameStor->turnterm, 2);
|
||||||
//서버 가오픈시 할 수 있는 행동
|
if($gameStor->turntime <= $gameStor->opentime){
|
||||||
if($me->getNPCType() == 0){
|
//서버 가오픈시 할 수 있는 행동
|
||||||
$showDieImmediatelyBtn = true;
|
if($me->getNPCType() == 0){
|
||||||
if($targetTime <= TimeUtil::now()){
|
$showDieImmediatelyBtn = true;
|
||||||
$availableDieImmediately = true;
|
if($targetTime <= TimeUtil::now()){
|
||||||
}
|
$availableDieImmediately = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$use_treatment = $me->getAuxVar('use_treatment')??10;
|
|
||||||
|
$use_treatment = $me->getAuxVar('use_treatment')??10;
|
||||||
?>
|
$use_auto_nation_turn = $me->getAuxVar('use_auto_nation_turn')??1;
|
||||||
<!DOCTYPE html>
|
?>
|
||||||
<html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<html>
|
||||||
<meta charset="UTF-8">
|
<head>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=1024" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<title><?=UniqueConst::$serverName?>: 내정보</title>
|
<meta name="viewport" content="width=1024" />
|
||||||
<script>
|
<title><?=UniqueConst::$serverName?>: 내정보</title>
|
||||||
var availableDieImmediately = <?=$availableDieImmediately?'true':'false'?>;
|
<script>
|
||||||
</script>
|
var availableDieImmediately = <?=$availableDieImmediately?'true':'false'?>;
|
||||||
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
</script>
|
||||||
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
||||||
<?=WebUtil::printJS('js/common.js')?>
|
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
||||||
<?=WebUtil::printJS('js/myPage.js')?>
|
<?=WebUtil::printJS('js/common.js')?>
|
||||||
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
<?=WebUtil::printJS('js/myPage.js')?>
|
||||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
||||||
<?=WebUtil::printCSS('css/common.css')?>
|
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||||
</head>
|
<?=WebUtil::printCSS('css/common.css')?>
|
||||||
|
</head>
|
||||||
<body>
|
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<body>
|
||||||
<tr><td>내 정 보<br><?=backButton()?></td></tr>
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
</table>
|
<tr><td>내 정 보<br><?=backButton()?></td></tr>
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
</table>
|
||||||
<tr>
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
<td width=50%>
|
<tr>
|
||||||
<?php generalInfo($me); ?>
|
<td width=50%>
|
||||||
<?php generalInfo2($me); ?>
|
<?php generalInfo($me); ?>
|
||||||
</td>
|
<?php generalInfo2($me); ?>
|
||||||
<td width=50% valign=top style="padding-left:4ch;">
|
</td>
|
||||||
토너먼트 【
|
<td width=50% valign=top style="padding-left:4ch;">
|
||||||
<input type=radio class='tnmt' name=tnmt value=0 <?=$me->getVar('tnmt')==0?"checked":""; ?>>수동참여
|
토너먼트 【
|
||||||
<input type=radio class='tnmt' name=tnmt value=1 <?=$me->getVar('tnmt')==1?"checked":""; ?>>자동참여
|
<input type=radio class='tnmt' name=tnmt value=0 <?=$me->getVar('tnmt')==0?"checked":""; ?>>수동참여
|
||||||
】<br>
|
<input type=radio class='tnmt' name=tnmt value=1 <?=$me->getVar('tnmt')==1?"checked":""; ?>>자동참여
|
||||||
∞<span style='color:orange'>개막직전 남는자리가 있을경우 랜덤하게 참여합니다.</span><br><br>
|
】<br>
|
||||||
|
∞<span style='color:orange'>개막직전 남는자리가 있을경우 랜덤하게 참여합니다.</span><br><br>
|
||||||
환약 사용 【<select id='use_treatment' name='use_treatment'>
|
|
||||||
<option value=10 <?=$use_treatment==10?"selected":""; ?>>경상</option>
|
환약 사용 【<select id='use_treatment' name='use_treatment'>
|
||||||
<option value=20 <?=$use_treatment==21?"selected":""; ?>>중상</option>
|
<option value=10 <?=($use_treatment==10)?"selected":""; ?>>경상</option>
|
||||||
<option value=40 <?=$use_treatment==41?"selected":""; ?>>심각</option>
|
<option value=21 <?=($use_treatment==21)?"selected":""; ?>>중상</option>
|
||||||
<option value=60 <?=$use_treatment==61?"selected":""; ?>>위독</option>
|
<option value=41 <?=($use_treatment==41)?"selected":""; ?>>심각</option>
|
||||||
<option value=100 <?=$use_treatment==100?"selected":""; ?>>사용안함</option>
|
<option value=61 <?=($use_treatment==61)?"selected":""; ?>>위독</option>
|
||||||
</select>】<br>
|
<option value=100 <?=($use_treatment==100)?"selected":""; ?>>사용안함</option>
|
||||||
∞<span style='color:orange'>부상을 입었을 때 환약을 사용하는 기준입니다.</span><br><br>
|
</select>】<br>
|
||||||
|
∞<span style='color:orange'>부상을 입었을 때 환약을 사용하는 기준입니다.</span><br><br>
|
||||||
수비 【<select id='defence_train' name='defence_train'>
|
<?php if(($gameStor->autorun_user['options']['chief'])??false) : ?>
|
||||||
<option value=90 <?=$me->getVar('defence_train')==90?"selected":""; ?>>☆(훈사90)</option>
|
자동 사령턴 허용 【<select id='use_auto_nation_turn' name='use_auto_nation_turn'>
|
||||||
<option value=80 <?=$me->getVar('defence_train')==80?"selected":""; ?>>◎(훈사80)</option>
|
<option value=1 <?=$use_auto_nation_turn?"selected":""; ?>>허용</option>
|
||||||
<option value=60 <?=$me->getVar('defence_train')==60?"selected":""; ?>>○(훈사60)</option>
|
<option value=0 <?=(!$use_auto_nation_turn)?"selected":""; ?>>허용 안함</option>
|
||||||
<option value=40 <?=$me->getVar('defence_train')==40?"selected":""; ?>>△(훈사40)</option>
|
</select>】<br>
|
||||||
<option value=999 <?=$me->getVar('defence_train')==999?"selected":""; ?>>×[훈련, 사기 -3]</option>
|
∞<span style='color:orange'>수뇌가 되었을 때 휴식 턴이어도 적당한 턴을 알아서 넣는 것을 허용합니다.</span><br><br>
|
||||||
</select>
|
<?php endif; ?>
|
||||||
】<br><br>
|
수비 【<select id='defence_train' name='defence_train'>
|
||||||
<input type=<?=$submit?> id='set_my_setting' name=btn style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;height:30px;font-size:13px; value=설정저장><br>
|
<?php foreach([90, 80, 60, 40] as $targetDefenceTrain): ?>
|
||||||
∞<span style='color:orange'>설정저장은 이달중 <?=$myset?>회 남았습니다.</span><br><br>
|
<option value='<?=$targetDefenceTrain?>' <?=$me->getVar('defence_train')==$targetDefenceTrain?"selected":""; ?>><?=formatDefenceTrain($targetDefenceTrain)?>(훈사<?=$targetDefenceTrain?>)</option>
|
||||||
<?php if(!($gameStor->autorun_user['limit_minutes']??false)): ?>
|
<?php endforeach; ?>
|
||||||
휴 가 신 청<br>
|
<option value=999 <?=$me->getVar('defence_train')==999?"selected":""; ?>><?=formatDefenceTrain(999)?>[훈련, 사기 -3]</option>
|
||||||
<button type="button" id='vacation' style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;height:30px;font-size:13px;>휴가 신청</button><br><br>
|
</select>
|
||||||
<?php endif; ?>
|
】<br><br>
|
||||||
<!--빙의 해제용 삭턴 조절<br>
|
<input type=<?=$submit?> id='set_my_setting' name=btn style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;height:30px;font-size:13px; value=설정저장><br>
|
||||||
<a href="b_myPage.php?detachNPC=1"><button type="button" style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;height:30px;font-size:13px;>빙의 해체 요청</button></a>-->
|
∞<span style='color:orange'>설정저장은 이달중 <?=$myset?>회 남았습니다.</span><br><br>
|
||||||
|
<?php if(!($gameStor->autorun_user['limit_minutes']??false)): ?>
|
||||||
<?php if($showDieImmediatelyBtn): ?>
|
휴 가 신 청<br>
|
||||||
가오픈 기간 내 장수 삭제 (<?=substr($targetTime, 0, 19)?> 부터)<br>
|
<button type="button" id='vacation' style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;height:30px;font-size:13px;>휴가 신청</button><br><br>
|
||||||
<a href="c_die_immediately.php" id='die_immediately'><button type="button" style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;height:30px;font-size:13px;>장수 삭제</button></a><br><br>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<!--빙의 해제용 삭턴 조절<br>
|
||||||
|
<a href="b_myPage.php?detachNPC=1"><button type="button" style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;height:30px;font-size:13px;>빙의 해체 요청</button></a>-->
|
||||||
개인용 CSS<br>
|
|
||||||
<textarea id='custom_css' style='color:white;background-color:black;width:420px;height:150px;'></textarea>
|
<?php if($showDieImmediatelyBtn): ?>
|
||||||
</td>
|
가오픈 기간 내 장수 삭제 (<?=substr($targetTime, 0, 19)?> 부터)<br>
|
||||||
</tr>
|
<a href="c_die_immediately.php" id='die_immediately'><button type="button" style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;height:30px;font-size:13px;>장수 삭제</button></a><br><br>
|
||||||
<tr>
|
<?php endif; ?>
|
||||||
<td align=center id=bg1><font color=skyblue size=3>개인 기록</font></td>
|
|
||||||
<td align=center id=bg1><font color=orange size=3>전투 기록</font></td>
|
개인용 CSS<br>
|
||||||
</tr>
|
<textarea id='custom_css' style='color:white;background-color:black;width:420px;height:150px;'></textarea>
|
||||||
<tr>
|
</td>
|
||||||
<td valign=top>
|
</tr>
|
||||||
<div id='generalActionPlate'>
|
<tr>
|
||||||
<?=formatHistoryToHTML(getGeneralActionLogRecent($generalID, 24), 'generalAction')?>
|
<td align=center id=bg1><font color=skyblue size=3>개인 기록</font></td>
|
||||||
</div>
|
<td align=center id=bg1><font color=orange size=3>전투 기록</font></td>
|
||||||
<button type="button" class="load_old_log btn btn-secondary btn-block" data-log_type="generalAction">이전 로그 불러오기</button>
|
</tr>
|
||||||
</td>
|
<tr>
|
||||||
<td valign=top>
|
<td valign=top>
|
||||||
<div id='battleDetailPlate'>
|
<div id='generalActionPlate'>
|
||||||
<?=formatHistoryToHTML(getBattleDetailLogRecent($generalID, 24), 'battleDetail')?>
|
<?=formatHistoryToHTML(getGeneralActionLogRecent($generalID, 24), 'generalAction')?>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="load_old_log btn btn-secondary btn-block" data-log_type="battleDetail">이전 로그 불러오기</button>
|
<button type="button" class="load_old_log btn btn-secondary btn-block" data-log_type="generalAction">이전 로그 불러오기</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
<td valign=top>
|
||||||
<tr>
|
<div id='battleDetailPlate'>
|
||||||
<td align=center id=bg1><font color=skyblue size=3>장수 열전</font></td>
|
<?=formatHistoryToHTML(getBattleDetailLogRecent($generalID, 24), 'battleDetail')?>
|
||||||
<td align=center id=bg1><font color=orange size=3>전투 결과</font></td>
|
</div>
|
||||||
</tr>
|
<button type="button" class="load_old_log btn btn-secondary btn-block" data-log_type="battleDetail">이전 로그 불러오기</button>
|
||||||
<tr>
|
</td>
|
||||||
<td valign=top>
|
</tr>
|
||||||
<?=formatHistoryToHTML(getGeneralHistoryLogAll($generalID))?>
|
<tr>
|
||||||
</td>
|
<td align=center id=bg1><font color=skyblue size=3>장수 열전</font></td>
|
||||||
<td valign=top>
|
<td align=center id=bg1><font color=orange size=3>전투 결과</font></td>
|
||||||
<div id='battleResultPlate'>
|
</tr>
|
||||||
<?=formatHistoryToHTML(getBattleResultRecent($generalID, 24), 'battleResult')?>
|
<tr>
|
||||||
</div>
|
<td valign=top>
|
||||||
<button type="button" class="load_old_log btn btn-secondary btn-block" data-log_type="battleResult">이전 로그 불러오기</button>
|
<?=formatHistoryToHTML(getGeneralHistoryLogAll($generalID))?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
<td valign=top>
|
||||||
</table>
|
<div id='battleResultPlate'>
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<?=formatHistoryToHTML(getBattleResultRecent($generalID, 24), 'battleResult')?>
|
||||||
<tr><td><?=backButton()?></td></tr>
|
</div>
|
||||||
<tr><td><?=banner()?></td></tr>
|
<button type="button" class="load_old_log btn btn-secondary btn-block" data-log_type="battleResult">이전 로그 불러오기</button>
|
||||||
</table>
|
</td>
|
||||||
</body>
|
</tr>
|
||||||
</html>
|
</table>
|
||||||
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
|
<tr><td><?=backButton()?></td></tr>
|
||||||
|
<tr><td><?=banner()?></td></tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|||||||
+551
-480
@@ -1,481 +1,552 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
$session = Session::requireLogin()->setReadOnly();
|
$session = Session::requireLogin()->setReadOnly();
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
$startYear = $gameStor->getValue('startyear');
|
$gameStor->cacheValues(['startyear', 'year']);
|
||||||
|
$startYear = $gameStor->startyear;
|
||||||
?>
|
$year = $gameStor->year;
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
$me = $db->queryFirstRow('SELECT no, nation, city FROM general WHERE owner =%i', Session::getUserID());
|
||||||
<head>
|
|
||||||
<title><?=UniqueConst::$serverName?>: 전투 시뮬레이터</title>
|
if($me){
|
||||||
<meta charset="UTF-8">
|
$generalID = $me['no'];
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
$nationID = $me['nation'];
|
||||||
<meta name="viewport" content="width=1100" />
|
$city = $db->queryFirstRow('SELECT city, level, def, wall FROM city WHERE city = %i', $me['city']);
|
||||||
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
}
|
||||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
else{
|
||||||
<?=WebUtil::printCSS('css/common.css')?>
|
$generalID = 0;
|
||||||
<?=WebUtil::printCSS('css/battle_simulator.css')?>
|
$nationID = 0;
|
||||||
<?=WebUtil::printJS('../d_shared/common_path.js')?>
|
$city = [
|
||||||
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
'city'=>0,
|
||||||
<?=WebUtil::printJS('../e_lib/moment.min.js')?>
|
'level'=>5,
|
||||||
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
'def'=>1000,
|
||||||
<?=WebUtil::printJS('../e_lib/download2.js')?>
|
'wall'=>1000,
|
||||||
<?=WebUtil::printJS('js/common.js')?>
|
];
|
||||||
<script>
|
}
|
||||||
var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
|
||||||
</script>
|
if($nationID){
|
||||||
<?=WebUtil::printJS('js/battle_simulator.js')?>
|
$nation = $db->queryFirstRow('SELECT level, type, tech, capital FROM nation WHERE nation = %i', $nationID);
|
||||||
</head>
|
}
|
||||||
<body>
|
else{
|
||||||
<div id="container">
|
$nation = null;
|
||||||
<div class="card mb-3">
|
}
|
||||||
<div class="card-header">
|
|
||||||
전역 설정
|
?>
|
||||||
</div>
|
<!DOCTYPE html>
|
||||||
<div class="card-body dragpad_battle">
|
<html>
|
||||||
<div class="row">
|
<head>
|
||||||
<div class="col-sm-6">
|
<title><?=UniqueConst::$serverName?>: 전투 시뮬레이터</title>
|
||||||
<div class="input-group">
|
<meta charset="UTF-8">
|
||||||
<input type="number" class="form-control" aria-describedby="text_year" value="<?=$startYear?>" disabled>
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<div class="input-group-append">
|
<meta name="viewport" content="width=1100" />
|
||||||
<span class="input-group-text">년 시작</span>
|
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
||||||
</div>
|
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||||
<input type="number" class="form-control" id="year" value="<?=$startYear+3?>" min="<?=$startYear?>">
|
<?=WebUtil::printCSS('css/common.css')?>
|
||||||
<div class="input-group-append">
|
<?=WebUtil::printCSS('css/battle_simulator.css')?>
|
||||||
<span class="input-group-text">년</span>
|
<?=WebUtil::printJS('../d_shared/common_path.js')?>
|
||||||
</div>
|
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
||||||
<input type="number" class="form-control" id="month" value="1" min="1" max="12">
|
<?=WebUtil::printJS('../e_lib/moment.min.js')?>
|
||||||
<div class="input-group-append">
|
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
||||||
<span class="input-group-text">월</span>
|
<?=WebUtil::printJS('../e_lib/download2.js')?>
|
||||||
</div>
|
<?=WebUtil::printJS('js/common.js')?>
|
||||||
</div>
|
<script>
|
||||||
</div>
|
var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
||||||
<div class="col-sm-6">
|
var city = <?=Json::encode($city)?>;
|
||||||
<div class="btn-toolbar" role="toolbar">
|
var nation = <?=Json::encode($nation)?>;
|
||||||
<div class="input-group mr-2" role="group">
|
</script>
|
||||||
<div class="input-group-prepend">
|
<?=WebUtil::printJS('js/battle_simulator.js')?>
|
||||||
<span class="input-group-text">반복 횟수</span>
|
</head>
|
||||||
</div>
|
<body>
|
||||||
<select class="custom-select" id="repeat_cnt">
|
<div id="container">
|
||||||
<option value="1">1회 (로그 표기)</option>
|
<div class="card mb-3">
|
||||||
<option value="1000">1000회 (요약 표기)</option>
|
<div class="card-header">
|
||||||
</select>
|
전역 설정
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group mr-2" role="group">
|
<div class="card-body dragpad_battle">
|
||||||
<button type="button" class="btn btn-danger btn-begin_battle">전투</button>
|
<div class="row">
|
||||||
</div>
|
<div class="col-sm-6">
|
||||||
<div class="btn-group mr-2" role="group">
|
<div class="input-group">
|
||||||
<button type="button" class="btn btn-info btn-battle-save">모두 저장</button>
|
<input type="number" class="form-control" aria-describedby="text_year" value="<?=$startYear?>" disabled>
|
||||||
<input type="file" class="form_load_battle_file" accept=".json" style="display: none;" />
|
<div class="input-group-append">
|
||||||
<button type="button" class="btn btn-primary btn-battle-load">모두 불러오기</button>
|
<span class="input-group-text">년 시작</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<input type="number" class="form-control" id="year" value="<?=$year?>" min="<?=$startYear?>">
|
||||||
</div>
|
<div class="input-group-append">
|
||||||
</div>
|
<span class="input-group-text">년</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<input type="number" class="form-control" id="month" value="1" min="1" max="12">
|
||||||
<div class="row">
|
<div class="input-group-append">
|
||||||
<div class="col-sm">
|
<span class="input-group-text">월</span>
|
||||||
<div class="card mb-2 attacker_nation">
|
</div>
|
||||||
<div class="card-header">
|
</div>
|
||||||
출병국 설정
|
</div>
|
||||||
</div>
|
<div class="col-sm-6">
|
||||||
<div class="card-body nation_detail dragpad_battle">
|
<div class="btn-toolbar" role="toolbar">
|
||||||
<div class="input-group mb-1">
|
<div class="input-group mr-2" role="group">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text">국가 성향</span>
|
<span class="input-group-text">반복 횟수</span>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_nation_type" style="width:25ch;">
|
<select class="custom-select" id="repeat_cnt">
|
||||||
<?php foreach(GameConst::$availableNationType as $typeID): ?>
|
<option value="1">1회 (로그 표기)</option>
|
||||||
<?php $nationTypeClass = buildNationTypeClass($typeID) ?>
|
<option value="1000">1000회 (요약 표기)</option>
|
||||||
<option value="<?=$typeID?>"><?=$nationTypeClass->getName()?> (<?=$nationTypeClass::$pros?>, <?=$nationTypeClass::$cons?>)</option>
|
</select>
|
||||||
<?php endforeach; ?>
|
</div>
|
||||||
</select>
|
<div class="btn-group mr-2" role="group">
|
||||||
<div class="input-group-prepend">
|
<button type="button" class="btn btn-danger btn-begin_battle">전투</button>
|
||||||
<span class="input-group-text">기술</span>
|
</div>
|
||||||
</div>
|
<div class="btn-group mr-2" role="group">
|
||||||
<input type="number" class="form-control form_tech" value="1" min="0" max="12">
|
<button type="button" class="btn btn-info btn-battle-save">모두 저장</button>
|
||||||
<div class="input-group-append">
|
<input type="file" class="form_load_battle_file" accept=".json" style="display: none;" />
|
||||||
<span class="input-group-text">등급</span>
|
<button type="button" class="btn btn-primary btn-battle-load">모두 불러오기</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group mb-3">
|
</div>
|
||||||
<div class="input-group-prepend">
|
</div>
|
||||||
<span class="input-group-text">국가 규모</span>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_nation_level">
|
<div class="row">
|
||||||
<?php foreach(getNationLevelList() as $nationLevel => [$name,$chiefCnt,$cityCnt]): ?>
|
<div class="col-sm">
|
||||||
<option value="<?=$nationLevel?>"><?=$name?></option>
|
<div class="card mb-2 attacker_nation">
|
||||||
<?php endforeach; ?>
|
<div class="card-header">
|
||||||
</select>
|
출병국 설정
|
||||||
<div class="input-group-prepend">
|
</div>
|
||||||
<span class="input-group-text">도시 규모</span>
|
<div class="card-body nation_detail dragpad_battle">
|
||||||
</div>
|
<div class="input-group mb-1">
|
||||||
<select class="custom-select form_city_level">
|
<div class="input-group-prepend">
|
||||||
<?php foreach(getCityLevelList() as $levelID => $name): ?>
|
<span class="input-group-text">국가 성향</span>
|
||||||
<option value="<?=$levelID?>"><?=$name?></option>
|
</div>
|
||||||
<?php endforeach; ?>
|
<select class="custom-select form_nation_type" style="width:25ch;">
|
||||||
</select>
|
<?php foreach(GameConst::$availableNationType as $typeID): ?>
|
||||||
<div class="input-group-prepend">
|
<?php $nationTypeClass = buildNationTypeClass($typeID) ?>
|
||||||
<span class="input-group-text">수도</span>
|
<option value="<?=$typeID?>"><?=$nationTypeClass->getName()?> (<?=$nationTypeClass::$pros?>, <?=$nationTypeClass::$cons?>)</option>
|
||||||
</div>
|
<?php endforeach; ?>
|
||||||
<div class="input-group-append btn-group btn-group-toggle" data-toggle="buttons">
|
</select>
|
||||||
<label class="btn btn-secondary">
|
<div class="input-group-prepend">
|
||||||
<input type="radio" name="is_attacker_capital" class="form_is_capital" value="1" autocomplete="off">Y
|
<span class="input-group-text">기술</span>
|
||||||
</label>
|
</div>
|
||||||
<label class="btn btn-secondary active">
|
<input type="number" class="form-control form_tech" value="1" min="0" max="12">
|
||||||
<input type="radio" name="is_attacker_capital" class="form_is_capital" value="2" autocomplete="off" checked>N
|
<div class="input-group-append">
|
||||||
</label>
|
<span class="input-group-text">등급</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
<div class="input-group mb-3">
|
||||||
<div class="input-group mb-1">
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text">국가 규모</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<select class="custom-select form_nation_level">
|
||||||
</div>
|
<?php foreach(getNationLevelList() as $nationLevel => [$name,$chiefCnt,$cityCnt]): ?>
|
||||||
<div class="card mb-2 attacker_form general_form" data-general_no='1'>
|
<option value="<?=$nationLevel?>"><?=$name?></option>
|
||||||
<div class="card-header">
|
<?php endforeach; ?>
|
||||||
<div class="float-sm-left" style="line-height:25px;">출병자 설정</div>
|
</select>
|
||||||
<div class="float-sm-right btn-toolbar" role="toolbar">
|
<div class="input-group-prepend">
|
||||||
<div class="btn-group btn-group-sm mr-2" role="group">
|
<span class="input-group-text">도시 규모</span>
|
||||||
<button type="button" class="btn btn-info btn-general-save">저장</button>
|
</div>
|
||||||
<input type="file" class="form_load_general_file" accept=".json" style="display: none;" />
|
<select class="custom-select form_city_level">
|
||||||
<button type="button" class="btn btn-primary btn-general-load">불러오기</button>
|
<?php foreach(getCityLevelList() as $levelID => $name): ?>
|
||||||
</div>
|
<option value="<?=$levelID?>"><?=$name?></option>
|
||||||
</div>
|
<?php endforeach; ?>
|
||||||
</div>
|
</select>
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
</div><!-- <div class="col-sm"> -->
|
<span class="input-group-text">수도</span>
|
||||||
<div class="col-sm defender-column">
|
</div>
|
||||||
<div class="card mb-2 defender_nation">
|
<div class="input-group-append btn-group btn-group-toggle" data-toggle="buttons">
|
||||||
<div class="card-header">
|
<label class="btn btn-secondary">
|
||||||
수비국 설정
|
<input type="radio" name="is_attacker_capital" class="form_is_capital" value="1" autocomplete="off">Y
|
||||||
</div>
|
</label>
|
||||||
<div class="card-body dragpad_battle">
|
<label class="btn btn-secondary active">
|
||||||
<div class="input-group mb-1">
|
<input type="radio" name="is_attacker_capital" class="form_is_capital" value="0" autocomplete="off">N
|
||||||
<div class="input-group-prepend">
|
</label>
|
||||||
<span class="input-group-text">국가 성향</span>
|
</div>
|
||||||
</div>
|
|
||||||
<select class="custom-select form_nation_type" style="width:25ch;">
|
</div>
|
||||||
<?php foreach(GameConst::$availableNationType as $typeID): ?>
|
<div class="input-group mb-1">
|
||||||
<?php $nationTypeObj = buildNationTypeClass($typeID) ?>
|
|
||||||
<option value="<?=$typeID?>"><?=$nationTypeObj->getName()?> (<?=$nationTypeObj::$pros?>, <?=$nationTypeObj::$cons?>)</option>
|
</div>
|
||||||
<?php endforeach; ?>
|
</div>
|
||||||
</select>
|
</div>
|
||||||
<div class="input-group-prepend">
|
<div class="card mb-2 attacker_form general_form" data-general_no='1'>
|
||||||
<span class="input-group-text">기술</span>
|
<div class="card-header">
|
||||||
</div>
|
<div class="float-sm-left" style="line-height:25px;">출병자 설정</div>
|
||||||
<input type="number" class="form-control form_tech" value="1" min="0" max="12">
|
<div class="float-sm-right btn-toolbar" role="toolbar">
|
||||||
<div class="input-group-append">
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
<span class="input-group-text">등급</span>
|
<button type="button" class="btn btn-success btn-general-import-server">서버에서 가져오기</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
<div class="input-group mb-3">
|
<button type="button" class="btn btn-info btn-general-save">저장</button>
|
||||||
<div class="input-group-prepend">
|
<input type="file" class="form_load_general_file" accept=".json" style="display: none;" />
|
||||||
<span class="input-group-text">국가 규모</span>
|
<button type="button" class="btn btn-primary btn-general-load">불러오기</button>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_nation_level">
|
</div>
|
||||||
<?php foreach(getNationLevelList() as $nationLevel => [$name,$chiefCnt,$cityCnt]): ?>
|
</div>
|
||||||
<option value="<?=$nationLevel?>"><?=$name?></option>
|
</div>
|
||||||
<?php endforeach; ?>
|
</div><!-- <div class="col-sm"> -->
|
||||||
</select>
|
<div class="col-sm defender-column">
|
||||||
<div class="input-group-prepend">
|
<div class="card mb-2 defender_nation">
|
||||||
<span class="input-group-text">도시 규모</span>
|
<div class="card-header">
|
||||||
</div>
|
수비국 설정
|
||||||
<select class="custom-select form_city_level">
|
</div>
|
||||||
<?php foreach(getCityLevelList() as $levelID => $name): ?>
|
<div class="card-body dragpad_battle">
|
||||||
<option value="<?=$levelID?>"><?=$name?></option>
|
<div class="input-group mb-1">
|
||||||
<?php endforeach; ?>
|
<div class="input-group-prepend">
|
||||||
</select>
|
<span class="input-group-text">국가 성향</span>
|
||||||
<div class="input-group-prepend">
|
</div>
|
||||||
<span class="input-group-text">수도</span>
|
<select class="custom-select form_nation_type" style="width:25ch;">
|
||||||
</div>
|
<?php foreach(GameConst::$availableNationType as $typeID): ?>
|
||||||
<div class="input-group-append btn-group btn-group-toggle" data-toggle="buttons">
|
<?php $nationTypeObj = buildNationTypeClass($typeID) ?>
|
||||||
<label class="btn btn-secondary">
|
<option value="<?=$typeID?>"><?=$nationTypeObj->getName()?> (<?=$nationTypeObj::$pros?>, <?=$nationTypeObj::$cons?>)</option>
|
||||||
<input type="radio" name="is_defender_capital" class="form_is_capital" value="1" autocomplete="off">Y
|
<?php endforeach; ?>
|
||||||
</label>
|
</select>
|
||||||
<label class="btn btn-secondary active">
|
<div class="input-group-prepend">
|
||||||
<input type="radio" name="is_defender_capital" class="form_is_capital" value="0" autocomplete="off" checked>N
|
<span class="input-group-text">기술</span>
|
||||||
</label>
|
</div>
|
||||||
</div>
|
<input type="number" class="form-control form_tech" value="1" min="0" max="12">
|
||||||
</div>
|
<div class="input-group-append">
|
||||||
<div class="input-group mb-1">
|
<span class="input-group-text">등급</span>
|
||||||
<div class="input-group-prepend">
|
</div>
|
||||||
<span class="input-group-text">수비</span>
|
</div>
|
||||||
</div>
|
<div class="input-group mb-3">
|
||||||
<input type="number" class="form-control form_def" id="city_def" value="1000" min="10" step="10">
|
<div class="input-group-prepend">
|
||||||
<div class="input-group-prepend">
|
<span class="input-group-text">국가 규모</span>
|
||||||
<span class="input-group-text">성벽</span>
|
</div>
|
||||||
</div>
|
<select class="custom-select form_nation_level">
|
||||||
<input type="number" class="form-control form_wall" id="city_wall" value="1000" min="0" step="10">
|
<?php foreach(getNationLevelList() as $nationLevel => [$name,$chiefCnt,$cityCnt]): ?>
|
||||||
</div>
|
<option value="<?=$nationLevel?>"><?=$name?></option>
|
||||||
</div>
|
<?php endforeach; ?>
|
||||||
</div>
|
</select>
|
||||||
<div class="card mb-2 defender_add_form">
|
<div class="input-group-prepend">
|
||||||
<div class="card-header">
|
<span class="input-group-text">도시 규모</span>
|
||||||
<div class="float-sm-left" style="line-height:25px;">수비자 설정</div>
|
</div>
|
||||||
<div class="float-sm-right btn-toolbar" role="toolbar">
|
<select class="custom-select form_city_level">
|
||||||
<div class="btn-group btn-group-sm mr-2" role="group">
|
<?php foreach(getCityLevelList() as $levelID => $name): ?>
|
||||||
<button type="button" class="btn btn-dark btn-reorder_defender">수비 순서대로 정렬</button>
|
<option value="<?=$levelID?>"><?=$name?></option>
|
||||||
</div>
|
<?php endforeach; ?>
|
||||||
<div class="btn-group btn-group-sm" role="group">
|
</select>
|
||||||
<button type="button" class="btn btn-success add-defender">추가</button>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">수도</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="input-group-append btn-group btn-group-toggle" data-toggle="buttons">
|
||||||
</div>
|
<label class="btn btn-secondary">
|
||||||
<div class="card mb-2 form_sample">
|
<input type="radio" name="is_defender_capital" class="form_is_capital" value="1" autocomplete="off">Y
|
||||||
<div class="card-header">
|
</label>
|
||||||
<div class="float-sm-left" style="line-height:25px;">수비자 설정</div>
|
<label class="btn btn-secondary active">
|
||||||
<div class="float-sm-right btn-toolbar" role="toolbar">
|
<input type="radio" name="is_defender_capital" class="form_is_capital" value="0" autocomplete="off">N
|
||||||
<div class="btn-group btn-group-sm mr-2" role="group">
|
</label>
|
||||||
<button type="button" class="btn btn-info btn-general-save">저장</button>
|
</div>
|
||||||
<input type="file" class="form_load_general_file" accept=".json" style="display: none;" />
|
</div>
|
||||||
<button type="button" class="btn btn-primary btn-general-load">불러오기</button>
|
<div class="input-group mb-1">
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
<div class="btn-group btn-group-sm" role="group">
|
<span class="input-group-text">수비</span>
|
||||||
<button type="button" class="btn btn-warning copy-defender">복제</button>
|
</div>
|
||||||
<button type="button" class="btn btn-danger delete-defender">제거</button>
|
<input type="number" class="form-control form_def" id="city_def" value="1000" min="10" step="10">
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">성벽</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body general_detail">
|
<input type="number" class="form-control form_wall" id="city_wall" value="1000" min="0" step="10">
|
||||||
<div class="input-group mb-3">
|
</div>
|
||||||
<div class="input-group-prepend">
|
</div>
|
||||||
<span class="input-group-text">이름</span>
|
</div>
|
||||||
</div>
|
<div class="card mb-2 defender_add_form">
|
||||||
<input type="text" class="form-control form_general_name" value="무명" style="width:15ch;">
|
<div class="card-header">
|
||||||
<div class="input-group-prepend">
|
<div class="float-sm-left" style="line-height:25px;">수비자 설정</div>
|
||||||
<span class="input-group-text">직위</span>
|
<div class="float-sm-right btn-toolbar" role="toolbar">
|
||||||
</div>
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
<select class="custom-select form_officer_level" style="width:8ch;">
|
<button type="button" class="btn btn-dark btn-reorder_defender">수비 순서대로 정렬</button>
|
||||||
<option value="1">일반</option>
|
</div>
|
||||||
<option value="4">태수</option>
|
<div class="btn-group btn-group-sm" role="group">
|
||||||
<option value="3">군사</option>
|
<button type="button" class="btn btn-success add-defender">추가</button>
|
||||||
<option value="2">종사</option>
|
</div>
|
||||||
<option value="10">무장 수뇌</option>
|
</div>
|
||||||
<option value="9">지장 수뇌</option>
|
</div>
|
||||||
<option value="11">참모</option>
|
</div>
|
||||||
<option value="12">군주</option>
|
<div class="card mb-2 form_sample">
|
||||||
</select>
|
<div class="card-header">
|
||||||
<div class="input-group-prepend">
|
<div class="float-sm-left" style="line-height:25px;">수비자 설정</div>
|
||||||
<span class="input-group-text">Level</span>
|
<div class="float-sm-right btn-toolbar" role="toolbar">
|
||||||
</div>
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
<input type="number" class="form-control form_exp_level" value="20" min="0" max="300" step="1">
|
<button type="button" class="btn btn-success btn-general-import-server">서버에서 가져오기</button>
|
||||||
|
</div>
|
||||||
</div>
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
<div class="input-group mb-1">
|
<button type="button" class="btn btn-info btn-general-save">저장</button>
|
||||||
<div class="input-group-prepend">
|
<input type="file" class="form_load_general_file" accept=".json" style="display: none;" />
|
||||||
<span class="input-group-text">통솔</span>
|
<button type="button" class="btn btn-primary btn-general-load">불러오기</button>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="form-control form_leadership" value="50" min="1" max="300" step="1">
|
<div class="btn-group btn-group-sm" role="group">
|
||||||
<div class="input-group-prepend">
|
<button type="button" class="btn btn-warning copy-defender">복제</button>
|
||||||
<span class="input-group-text">무력</span>
|
<button type="button" class="btn btn-danger delete-defender">제거</button>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="form-control form_strength" value="50" min="1" max="300" step="1">
|
</div>
|
||||||
<div class="input-group-prepend">
|
</div>
|
||||||
<span class="input-group-text">지력</span>
|
<div class="card-body general_detail">
|
||||||
</div>
|
<div class="input-group mb-3">
|
||||||
<input type="number" class="form-control form_intel" value="50" min="1" max="300" step="1">
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">이름</span>
|
||||||
<div class="input-group mb-1">
|
</div>
|
||||||
<div class="input-group-prepend">
|
<input type="text" class="form-control form_general_name" value="무명" style="width:15ch;">
|
||||||
<span class="input-group-text">명마</span>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">직위</span>
|
||||||
<select class="custom-select form_general_horse">
|
</div>
|
||||||
<option value='None'>-</option>
|
<select class="custom-select form_officer_level" style="width:8ch;">
|
||||||
<?php foreach(GameConst::$allItems['horse'] as $horseID=>$cnt): ?>
|
<option value="1">일반</option>
|
||||||
<option value="<?=$horseID?>"><?=getItemName($horseID)?></option>
|
<option value="4">태수</option>
|
||||||
<?php endforeach; ?>
|
<option value="3">군사</option>
|
||||||
</select>
|
<option value="2">종사</option>
|
||||||
<div class="input-group-prepend">
|
<option value="10">무장 수뇌</option>
|
||||||
<span class="input-group-text">무기</span>
|
<option value="9">지장 수뇌</option>
|
||||||
</div>
|
<option value="11">참모</option>
|
||||||
<select class="custom-select form_general_weap">
|
<option value="12">군주</option>
|
||||||
<option value='None'>-</option>
|
</select>
|
||||||
<?php foreach(GameConst::$allItems['weapon'] as $weaponID=>$cnt): ?>
|
<div class="input-group-prepend">
|
||||||
<option value="<?=$weaponID?>"><?=getItemName($weaponID)?></option>
|
<span class="input-group-text">Level</span>
|
||||||
<?php endforeach; ?>
|
</div>
|
||||||
</select>
|
<input type="number" class="form-control form_exp_level" value="20" min="0" max="300" step="1">
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text">서적</span>
|
</div>
|
||||||
</div>
|
<div class="input-group mb-1">
|
||||||
<select class="custom-select form_general_book">
|
<div class="input-group-prepend">
|
||||||
<option value='None'>-</option>
|
<span class="input-group-text">통솔</span>
|
||||||
<?php foreach(GameConst::$allItems['book'] as $bookID=>$cnt): ?>
|
</div>
|
||||||
<option value="<?=$bookID?>"><?=getItemName($bookID)?></option>
|
<input type="number" class="form-control form_leadership" value="50" min="1" max="300" step="1">
|
||||||
<?php endforeach; ?>
|
<div class="input-group-prepend">
|
||||||
</select>
|
<span class="input-group-text">무력</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group mb-3">
|
<input type="number" class="form-control form_strength" value="50" min="1" max="300" step="1">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text">부상</span>
|
<span class="input-group-text">지력</span>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="form-control form_injury" value="0" min="0" max="80" step="1">
|
<input type="number" class="form-control form_intel" value="50" min="1" max="300" step="1">
|
||||||
<div class="input-group-append">
|
</div>
|
||||||
<span class="input-group-text">%(<span class="injury_helptext">건강</span>)</span>
|
<div class="input-group mb-1">
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
<div class="input-group-prepend">
|
<span class="input-group-text">명마</span>
|
||||||
<span class="input-group-text">군량</span>
|
</div>
|
||||||
</div>
|
<select class="custom-select form_general_horse">
|
||||||
<input type="number" class="form-control form_rice" value="5000" min="50" max="40000" step="50">
|
<option value='None'>-</option>
|
||||||
<div class="input-group-prepend">
|
<?php foreach(GameConst::$allItems['horse'] as $horseID=>$cnt): ?>
|
||||||
<span class="input-group-text">도구</span>
|
<option value="<?=$horseID?>"><?=getItemName($horseID)?></option>
|
||||||
</div>
|
<?php endforeach; ?>
|
||||||
<select class="custom-select form_general_item">
|
</select>
|
||||||
<option value='None'>-</option>
|
<div class="input-group-prepend">
|
||||||
<?php foreach(GameConst::$allItems['item'] as $itemID=>$cnt): ?>
|
<span class="input-group-text">무기</span>
|
||||||
<option value="<?=$itemID?>"><?=getItemName($itemID)?></option>
|
</div>
|
||||||
<?php endforeach; ?>
|
<select class="custom-select form_general_weap">
|
||||||
</select>
|
<option value='None'>-</option>
|
||||||
</div>
|
<?php foreach(GameConst::$allItems['weapon'] as $weaponID=>$cnt): ?>
|
||||||
<div class="input-group mb-1">
|
<option value="<?=$weaponID?>"><?=getItemName($weaponID)?></option>
|
||||||
<div class="input-group-prepend">
|
<?php endforeach; ?>
|
||||||
<span class="input-group-text">병종</span>
|
</select>
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
<select class="custom-select form_crewtype">
|
<span class="input-group-text">서적</span>
|
||||||
<?php foreach(GameUnitConst::all() as $crewTypeID => $crewType): ?>
|
</div>
|
||||||
<?php if($crewType->armType === GameUnitConst::T_CASTLE){ continue; } ?>
|
<select class="custom-select form_general_book">
|
||||||
<option value="<?=$crewTypeID?>"><?=$crewType->name?></option>
|
<option value='None'>-</option>
|
||||||
<?php endforeach; ?>
|
<?php foreach(GameConst::$allItems['book'] as $bookID=>$cnt): ?>
|
||||||
</select>
|
<option value="<?=$bookID?>"><?=getItemName($bookID)?></option>
|
||||||
<div class="input-group-prepend">
|
<?php endforeach; ?>
|
||||||
<span class="input-group-text">병사</span>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="form-control form_crew" value="7000" min="100" step="100">
|
<div class="input-group mb-3">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text">성격</span>
|
<span class="input-group-text">부상</span>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_general_character">
|
<input type="number" class="form-control form_injury" value="0" min="0" max="80" step="1">
|
||||||
<?php foreach(getCharacterList(false) as $characterID => [$name,$info]): ?>
|
<div class="input-group-append">
|
||||||
<option value="<?=$characterID?>"><?=$name?></option>
|
<span class="input-group-text">%(<span class="injury_helptext">건강</span>)</span>
|
||||||
<?php endforeach; ?>
|
</div>
|
||||||
</select>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">군량</span>
|
||||||
<div class="input-group mb-3">
|
</div>
|
||||||
<div class="input-group-prepend">
|
<input type="number" class="form-control form_rice" value="5000" min="50" max="40000" step="50">
|
||||||
<span class="input-group-text">훈련</span>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">도구</span>
|
||||||
<input type="number" class="form-control form_train" value="100" min="40" max="<?=GameConst::$maxTrainByWar?>" step="1">
|
</div>
|
||||||
<div class="input-group-prepend">
|
<select class="custom-select form_general_item">
|
||||||
<span class="input-group-text">사기</span>
|
<option value='None'>-</option>
|
||||||
</div>
|
<?php foreach(GameConst::$allItems['item'] as $itemID=>$cnt): ?>
|
||||||
<input type="number" class="form-control form_atmos" value="100" min="40" max="<?=GameConst::$maxAtmosByWar?>" step="1">
|
<option value="<?=$itemID?>"><?=getItemName($itemID)?></option>
|
||||||
<div class="input-group-prepend">
|
<?php endforeach; ?>
|
||||||
<span class="input-group-text">전특</span>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_general_special_war">
|
<div class="input-group mb-1">
|
||||||
<?php foreach(SpecialityHelper::getSpecialWarList(false) as $specialWarID =>$specialObj): ?>
|
<div class="input-group-prepend">
|
||||||
<option value="<?=$specialWarID?>"><?=$specialObj->getName()?></option>
|
<span class="input-group-text">병종</span>
|
||||||
<?php endforeach; ?>
|
</div>
|
||||||
</select>
|
<select class="custom-select form_crewtype">
|
||||||
</div>
|
<?php foreach(GameUnitConst::all() as $crewTypeID => $crewType): ?>
|
||||||
<div class="input-group mb-1">
|
<?php if($crewType->armType === GameUnitConst::T_CASTLE){ continue; } ?>
|
||||||
<div class="input-group-prepend">
|
<option value="<?=$crewTypeID?>"><?=$crewType->name?></option>
|
||||||
<span class="input-group-text">보병숙련</span>
|
<?php endforeach; ?>
|
||||||
</div>
|
</select>
|
||||||
<select class="custom-select form_dex1">
|
<div class="input-group-prepend">
|
||||||
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
<span class="input-group-text">병사</span>
|
||||||
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
</div>
|
||||||
<?php endforeach; ?>
|
<input type="number" class="form-control form_crew" value="7000" min="100" step="100">
|
||||||
</select>
|
<div class="input-group-prepend">
|
||||||
<div class="input-group-prepend">
|
<span class="input-group-text">성격</span>
|
||||||
<span class="input-group-text">궁병숙련</span>
|
</div>
|
||||||
</div>
|
<select class="custom-select form_general_character">
|
||||||
<select class="custom-select form_dex2">
|
<?php foreach(getCharacterList(false) as $characterID => [$name,$info]): ?>
|
||||||
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
<option value="<?=$characterID?>"><?=$name?></option>
|
||||||
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
<?php endforeach; ?>
|
||||||
<?php endforeach; ?>
|
</select>
|
||||||
</select>
|
</div>
|
||||||
<div class="input-group-prepend">
|
<div class="input-group mb-3">
|
||||||
<span class="input-group-text">기병숙련</span>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">훈련</span>
|
||||||
<select class="custom-select form_dex3">
|
</div>
|
||||||
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
<input type="number" class="form-control form_train" value="100" min="40" max="<?=GameConst::$maxTrainByWar?>" step="1">
|
||||||
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
<div class="input-group-prepend">
|
||||||
<?php endforeach; ?>
|
<span class="input-group-text">사기</span>
|
||||||
</select>
|
</div>
|
||||||
</div>
|
<input type="number" class="form-control form_atmos" value="100" min="40" max="<?=GameConst::$maxAtmosByWar?>" step="1">
|
||||||
<div class="input-group mb-1">
|
<div class="input-group-prepend">
|
||||||
<div class="input-group-prepend">
|
<span class="input-group-text">전특</span>
|
||||||
<span class="input-group-text">귀병숙련</span>
|
</div>
|
||||||
</div>
|
<select class="custom-select form_general_special_war">
|
||||||
<select class="custom-select form_dex4">
|
<?php foreach(SpecialityHelper::getSpecialWarList(false) as $specialWarID =>$specialObj): ?>
|
||||||
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
<option value="<?=$specialWarID?>"><?=$specialObj->getName()?></option>
|
||||||
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
<?php endforeach; ?>
|
||||||
<?php endforeach; ?>
|
</select>
|
||||||
</select>
|
</div>
|
||||||
<div class="input-group-prepend">
|
<div class="input-group mb-1">
|
||||||
<span class="input-group-text">차병숙련</span>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">보병숙련</span>
|
||||||
<select class="custom-select form_dex5">
|
</div>
|
||||||
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
<select class="custom-select form_dex1">
|
||||||
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
||||||
<?php endforeach; ?>
|
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
||||||
</select>
|
<?php endforeach; ?>
|
||||||
<div class="input-group-prepend only_defender">
|
</select>
|
||||||
<span class="input-group-text">수비여부</span>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">궁병숙련</span>
|
||||||
<select class="custom-select form_defence_train only_defender">
|
</div>
|
||||||
<option value="80">훈사 80</option>
|
<select class="custom-select form_dex2">
|
||||||
<option value="60">훈사 60</option>
|
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
||||||
<option value="999">안함</option>
|
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
||||||
</select>
|
<?php endforeach; ?>
|
||||||
</div>
|
</select>
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">기병숙련</span>
|
||||||
|
</div>
|
||||||
|
<select class="custom-select form_dex3">
|
||||||
</div><!-- <div class="col-sm"> -->
|
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
||||||
</div>
|
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
||||||
<div class="card mb-3">
|
<?php endforeach; ?>
|
||||||
<div class="card-header">
|
</select>
|
||||||
전투 요약
|
</div>
|
||||||
</div>
|
<div class="input-group mb-3">
|
||||||
<table class="table">
|
<div class="input-group-prepend">
|
||||||
<tbody id="battle_result_summary">
|
<span class="input-group-text">귀병숙련</span>
|
||||||
<tr><th style='width:18ch;'>전투 일시</th><td id='result_datetime'></td></tr>
|
</div>
|
||||||
<tr><th>전투 횟수</th><td id='result_warcnt'></td></tr>
|
<select class="custom-select form_dex4">
|
||||||
<tr><th>전투 페이즈</th><td id='result_phase'></td></tr>
|
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
||||||
<tr><th>준 피해</th><td><span id='result_killed'>0</span><span id='result_varKilled'> (<span id='result_minKilled'>0</span> ~ <span id='result_maxKilled'>0</span>)</span></td></tr>
|
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
||||||
<tr><th>받은 피해</th><td><span id='result_dead'>0</span><span id='result_varDead'> (<span id='result_minDead'>0</span> ~ <span id='result_maxDead'>0</span>)</span></td></tr>
|
<?php endforeach; ?>
|
||||||
<tr><th>출병자 군량 소모</th><td id='result_attackerRice'></td></tr>
|
</select>
|
||||||
<tr><th>수비자 군량 소모</th><td id='result_defenderRice'></td></tr>
|
<div class="input-group-prepend">
|
||||||
<tr><th>공격자 스킬</th><td id='result_attackerSkills'></td></tr>
|
<span class="input-group-text">차병숙련</span>
|
||||||
<tr class='result_defenderSkills'><th>수비자1 스킬</th><td></td></tr>
|
</div>
|
||||||
</tbody>
|
<select class="custom-select form_dex5">
|
||||||
</table>
|
<?php foreach(getDexLevelList() as $dexLevel => [$dexAmount, $color, $name]): ?>
|
||||||
</div>
|
<option value="<?=$dexAmount?>"><?="{$name} (".number_format($dexAmount).")"?></option>
|
||||||
<div class="row">
|
<?php endforeach; ?>
|
||||||
<div class="col-sm">
|
</select>
|
||||||
<div class="card mb-3">
|
<div class="input-group-prepend only_defender">
|
||||||
<div class="card-header">
|
<span class="input-group-text">수비여부</span>
|
||||||
마지막 전투 로그
|
</div>
|
||||||
</div>
|
<select class="custom-select form_defence_train only_defender">
|
||||||
<div class="card-body" id="generalBattleResultLog">
|
<option value="90">훈사 90</option>
|
||||||
|
<option value="80">훈사 80</option>
|
||||||
</div>
|
<option value="60">훈사 60</option>
|
||||||
</div>
|
<option value="40">훈사 40</option>
|
||||||
</div>
|
<option value="999">안함</option>
|
||||||
<div class="col-sm">
|
</select>
|
||||||
<div class="card mb-3">
|
</div>
|
||||||
<div class="card-header">
|
<div class="input-group mb-1">
|
||||||
마지막 전투 상세 로그
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">전투 수</span>
|
||||||
<div class="card-body" id="generalBattleDetailLog">
|
</div>
|
||||||
|
<input type="number" class="form-control form_warnum" value="0" step="1">
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<span class="input-group-text">승리 수</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<input type="number" class="form-control form_killnum" value="0" step="1">
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
</body>
|
<span class="input-group-text">사살 수</span>
|
||||||
|
</div>
|
||||||
|
<input type="number" class="form-control form_killcrew" value="0" step="1">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div><!-- <div class="col-sm"> -->
|
||||||
|
</div>
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header">
|
||||||
|
전투 요약
|
||||||
|
</div>
|
||||||
|
<table class="table">
|
||||||
|
<tbody id="battle_result_summary">
|
||||||
|
<tr><th style='width:18ch;'>전투 일시</th><td id='result_datetime'></td></tr>
|
||||||
|
<tr><th>전투 횟수</th><td id='result_warcnt'></td></tr>
|
||||||
|
<tr><th>전투 페이즈</th><td id='result_phase'></td></tr>
|
||||||
|
<tr><th>준 피해</th><td><span id='result_killed'>0</span><span id='result_varKilled'> (<span id='result_minKilled'>0</span> ~ <span id='result_maxKilled'>0</span>)</span></td></tr>
|
||||||
|
<tr><th>받은 피해</th><td><span id='result_dead'>0</span><span id='result_varDead'> (<span id='result_minDead'>0</span> ~ <span id='result_maxDead'>0</span>)</span></td></tr>
|
||||||
|
<tr><th>출병자 군량 소모</th><td id='result_attackerRice'></td></tr>
|
||||||
|
<tr><th>수비자 군량 소모</th><td id='result_defenderRice'></td></tr>
|
||||||
|
<tr><th>공격자 스킬</th><td id='result_attackerSkills'></td></tr>
|
||||||
|
<tr class='result_defenderSkills'><th>수비자1 스킬</th><td></td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm">
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header">
|
||||||
|
마지막 전투 로그
|
||||||
|
</div>
|
||||||
|
<div class="card-body" id="generalBattleResultLog">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm">
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header">
|
||||||
|
마지막 전투 상세 로그
|
||||||
|
</div>
|
||||||
|
<div class="card-body" id="generalBattleDetailLog">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="importModal" class="modal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">장수 목록</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<select id="modalSelector"></select>
|
||||||
|
<p>타국 장수를 선택한 경우 숙련과 아이템은 0으로 초기화됩니다.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" id='importFromDB'>가져오기</button>
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">닫기</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
+2137
-2112
File diff suppressed because it is too large
Load Diff
+447
-447
@@ -1,448 +1,448 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
use sammo\Command\GeneralCommand;
|
use sammo\Command\GeneralCommand;
|
||||||
use sammo\Command\NationCommand;
|
use sammo\Command\NationCommand;
|
||||||
|
|
||||||
function getGeneralTurnBrief(General $generalObj, array $turnList) {
|
function getGeneralTurnBrief(General $generalObj, array $turnList) {
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach($turnList as $turnIdx => [$action, $arg]){
|
foreach($turnList as $turnIdx => [$action, $arg]){
|
||||||
$commandObj = buildGeneralCommandClass($action, $generalObj, [], $arg);
|
$commandObj = buildGeneralCommandClass($action, $generalObj, [], $arg);
|
||||||
$turnText = $commandObj->getBrief();
|
$turnText = $commandObj->getBrief();
|
||||||
$result[$turnIdx] = $turnText;
|
$result[$turnIdx] = $turnText;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNationTurnBrief(General $generalObj, array $turnList) {
|
function getNationTurnBrief(General $generalObj, array $turnList) {
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
$tmpTurn = new LastTurn();
|
$tmpTurn = new LastTurn();
|
||||||
foreach($turnList as $turnIdx => [$action, $arg]){
|
foreach($turnList as $turnIdx => [$action, $arg]){
|
||||||
$commandObj = buildNationCommandClass($action, $generalObj, [], $tmpTurn, $arg);
|
$commandObj = buildNationCommandClass($action, $generalObj, [], $tmpTurn, $arg);
|
||||||
$turnText = $commandObj->getBrief();
|
$turnText = $commandObj->getBrief();
|
||||||
$result[$turnIdx] = $turnText;
|
$result[$turnIdx] = $turnText;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushGeneralCommand(int $generalID, int $turnCnt=1){
|
function pushGeneralCommand(int $generalID, int $turnCnt=1){
|
||||||
if($turnCnt == 0){
|
if($turnCnt == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt < 0){
|
if($turnCnt < 0){
|
||||||
pullGeneralCommand($generalID, -$turnCnt);
|
pullGeneralCommand($generalID, -$turnCnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt >= GameConst::$maxTurn){
|
if($turnCnt >= GameConst::$maxTurn){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$db->update('general_turn', [
|
$db->update('general_turn', [
|
||||||
'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt)
|
'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt)
|
||||||
], 'general_id=%i ORDER BY turn_idx DESC', $generalID);
|
], 'general_id=%i ORDER BY turn_idx DESC', $generalID);
|
||||||
$db->update('general_turn', [
|
$db->update('general_turn', [
|
||||||
'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxTurn),
|
'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxTurn),
|
||||||
'action'=>'휴식',
|
'action'=>'휴식',
|
||||||
'arg'=>'{}',
|
'arg'=>'{}',
|
||||||
'brief'=>'휴식'
|
'brief'=>'휴식'
|
||||||
], 'general_id=%i AND turn_idx >= %i', $generalID, GameConst::$maxTurn);
|
], 'general_id=%i AND turn_idx >= %i', $generalID, GameConst::$maxTurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pullGeneralCommand(int $generalID, int $turnCnt=1){
|
function pullGeneralCommand(int $generalID, int $turnCnt=1){
|
||||||
if($turnCnt == 0){
|
if($turnCnt == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt < 0){
|
if($turnCnt < 0){
|
||||||
pushGeneralCommand($generalID, -$turnCnt);
|
pushGeneralCommand($generalID, -$turnCnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt >= GameConst::$maxTurn){
|
if($turnCnt >= GameConst::$maxTurn){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$db->update('general_turn', [
|
$db->update('general_turn', [
|
||||||
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxTurn),
|
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxTurn),
|
||||||
'action'=>'휴식',
|
'action'=>'휴식',
|
||||||
'arg'=>'{}',
|
'arg'=>'{}',
|
||||||
'brief'=>'휴식'
|
'brief'=>'휴식'
|
||||||
], 'general_id=%i AND turn_idx < %i', $generalID, $turnCnt);
|
], 'general_id=%i AND turn_idx < %i', $generalID, $turnCnt);
|
||||||
$db->update('general_turn', [
|
$db->update('general_turn', [
|
||||||
'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt)
|
'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt)
|
||||||
], 'general_id=%i ORDER BY turn_idx ASC', $generalID);
|
], 'general_id=%i ORDER BY turn_idx ASC', $generalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function repeatGeneralCommand(int $generalId, int $turnCnt){
|
function repeatGeneralCommand(int $generalId, int $turnCnt){
|
||||||
if($turnCnt <= 0){
|
if($turnCnt <= 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt >= GameConst::$maxTurn){
|
if($turnCnt >= GameConst::$maxTurn){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$reqTurn = $turnCnt;
|
$reqTurn = $turnCnt;
|
||||||
if($turnCnt * 2 > GameConst::$maxTurn){
|
if($turnCnt * 2 > GameConst::$maxTurn){
|
||||||
$reqTurn = GameConst::$maxTurn - $turnCnt;
|
$reqTurn = GameConst::$maxTurn - $turnCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
$turnList = $db->query('SELECT turn_idx, `action`, arg, brief FROM general_turn WHERE general_id=%i AND turn_idx < %i', $generalId, $reqTurn);
|
$turnList = $db->query('SELECT turn_idx, `action`, arg, brief FROM general_turn WHERE general_id=%i AND turn_idx < %i', $generalId, $reqTurn);
|
||||||
foreach($turnList as $turnItem){
|
foreach($turnList as $turnItem){
|
||||||
$turnIdx = $turnItem['turn_idx'];
|
$turnIdx = $turnItem['turn_idx'];
|
||||||
$turnTarget = iterator_to_array(Util::range($turnIdx+$turnCnt, GameConst::$maxTurn, $turnCnt));
|
$turnTarget = iterator_to_array(Util::range($turnIdx+$turnCnt, GameConst::$maxTurn, $turnCnt));
|
||||||
|
|
||||||
$db->update('general_turn', [
|
$db->update('general_turn', [
|
||||||
'action'=>$turnItem['action'],
|
'action'=>$turnItem['action'],
|
||||||
'arg'=>$turnItem['arg'],
|
'arg'=>$turnItem['arg'],
|
||||||
'brief'=>$turnItem['brief']
|
'brief'=>$turnItem['brief']
|
||||||
], 'general_id=%i AND turn_idx IN %li', $generalId, $turnTarget);
|
], 'general_id=%i AND turn_idx IN %li', $generalId, $turnTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushNationCommand(int $nationID, int $officerLevel, int $turnCnt=1){
|
function pushNationCommand(int $nationID, int $officerLevel, int $turnCnt=1){
|
||||||
if($nationID == 0){
|
if($nationID == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($officerLevel < 5){
|
if($officerLevel < 5){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt == 0){
|
if($turnCnt == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt < 0){
|
if($turnCnt < 0){
|
||||||
pullNationCommand($nationID, $officerLevel, -$turnCnt);
|
pullNationCommand($nationID, $officerLevel, -$turnCnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt >= GameConst::$maxChiefTurn){
|
if($turnCnt >= GameConst::$maxChiefTurn){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$db->update('nation_turn', [
|
$db->update('nation_turn', [
|
||||||
'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt)
|
'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt)
|
||||||
], 'nation_id=%i AND officer_level=%i ORDER BY turn_idx DESC', $nationID, $officerLevel);
|
], 'nation_id=%i AND officer_level=%i ORDER BY turn_idx DESC', $nationID, $officerLevel);
|
||||||
$db->update('nation_turn', [
|
$db->update('nation_turn', [
|
||||||
'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxChiefTurn),
|
'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxChiefTurn),
|
||||||
'action'=>'휴식',
|
'action'=>'휴식',
|
||||||
'arg'=>'{}',
|
'arg'=>'{}',
|
||||||
'brief'=>'휴식'
|
'brief'=>'휴식'
|
||||||
], 'nation_id=%i AND officer_level=%i AND turn_idx >= %i ORDER BY turn_idx ASC', $nationID, $officerLevel, GameConst::$maxChiefTurn);
|
], 'nation_id=%i AND officer_level=%i AND turn_idx >= %i ORDER BY turn_idx ASC', $nationID, $officerLevel, GameConst::$maxChiefTurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pullNationCommand(int $nationID, int $officerLevel, int $turnCnt=1){
|
function pullNationCommand(int $nationID, int $officerLevel, int $turnCnt=1){
|
||||||
if($nationID == 0){
|
if($nationID == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($officerLevel < 5){
|
if($officerLevel < 5){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt == 0){
|
if($turnCnt == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt < 0){
|
if($turnCnt < 0){
|
||||||
pushNationCommand($nationID, $officerLevel, -$turnCnt);
|
pushNationCommand($nationID, $officerLevel, -$turnCnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($turnCnt >= GameConst::$maxChiefTurn){
|
if($turnCnt >= GameConst::$maxChiefTurn){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$db->update('nation_turn', [
|
$db->update('nation_turn', [
|
||||||
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxChiefTurn),
|
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxChiefTurn),
|
||||||
'action'=>'휴식',
|
'action'=>'휴식',
|
||||||
'arg'=>'{}',
|
'arg'=>'{}',
|
||||||
'brief'=>'휴식',
|
'brief'=>'휴식',
|
||||||
], 'nation_id=%i AND officer_level=%i AND turn_idx < %i', $nationID, $officerLevel, $turnCnt);
|
], 'nation_id=%i AND officer_level=%i AND turn_idx < %i', $nationID, $officerLevel, $turnCnt);
|
||||||
$db->update('nation_turn', [
|
$db->update('nation_turn', [
|
||||||
'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt)
|
'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt)
|
||||||
], 'nation_id=%i AND officer_level=%i ORDER BY turn_idx ASC', $nationID, $officerLevel);
|
], 'nation_id=%i AND officer_level=%i ORDER BY turn_idx ASC', $nationID, $officerLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setGeneralCommand(GeneralCommand $command, array $turnList):void {
|
function _setGeneralCommand(GeneralCommand $command, array $turnList):void {
|
||||||
if(!$turnList){
|
if(!$turnList){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$generalID = $command->getGeneral()->getID();
|
$generalID = $command->getGeneral()->getID();
|
||||||
$commandName = $command->getRawClassName();
|
$commandName = $command->getRawClassName();
|
||||||
$arg = $command->getArg();
|
$arg = $command->getArg();
|
||||||
$brief = $command->getBrief();
|
$brief = $command->getBrief();
|
||||||
|
|
||||||
$db->update('general_turn', [
|
$db->update('general_turn', [
|
||||||
'action'=>$commandName,
|
'action'=>$commandName,
|
||||||
'arg'=>Json::encode($arg, JSON::EMPTY_ARRAY_IS_DICT),
|
'arg'=>Json::encode($arg, JSON::EMPTY_ARRAY_IS_DICT),
|
||||||
'brief'=>$brief
|
'brief'=>$brief
|
||||||
], 'general_id = %i AND turn_idx IN %li', $generalID, $turnList);
|
], 'general_id = %i AND turn_idx IN %li', $generalID, $turnList);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setNationCommand(NationCommand $command, array $turnList):void {
|
function _setNationCommand(NationCommand $command, array $turnList):void {
|
||||||
if(!$turnList){
|
if(!$turnList){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$nationID = $command->getNationID();
|
$nationID = $command->getNationID();
|
||||||
$officerLevel = $command->getOfficerLevel();
|
$officerLevel = $command->getOfficerLevel();
|
||||||
$commandName = $command->getRawClassName();
|
$commandName = $command->getRawClassName();
|
||||||
$arg = $command->getArg();
|
$arg = $command->getArg();
|
||||||
$brief = $command->getBrief();
|
$brief = $command->getBrief();
|
||||||
|
|
||||||
$db->update('nation_turn', [
|
$db->update('nation_turn', [
|
||||||
'action'=>$commandName,
|
'action'=>$commandName,
|
||||||
'arg'=>Json::encode($arg, JSON::EMPTY_ARRAY_IS_DICT),
|
'arg'=>Json::encode($arg, JSON::EMPTY_ARRAY_IS_DICT),
|
||||||
'brief'=>$brief
|
'brief'=>$brief
|
||||||
], 'nation_id = %i AND officer_level = %i AND turn_idx IN %li', $nationID, $officerLevel, $turnList);
|
], 'nation_id = %i AND officer_level = %i AND turn_idx IN %li', $nationID, $officerLevel, $turnList);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeArg(?array $args):?array{
|
function sanitizeArg(?array $args):?array{
|
||||||
if($args === null){
|
if($args === null){
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach($args as $key=>$value){
|
foreach($args as $key=>$value){
|
||||||
if(is_array($value)){
|
if(is_array($value)){
|
||||||
$result[$key] = sanitizeArg($value);
|
$result[$key] = sanitizeArg($value);
|
||||||
}
|
}
|
||||||
else if(is_string($value)){
|
else if(is_string($value)){
|
||||||
$result[$key] = StringUtil::neutralize(StringUtil::removeSpecialCharacter($value));
|
$result[$key] = StringUtil::neutralize(StringUtil::removeSpecialCharacter($value));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$result[$key] = $value;
|
$result[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCommandArg(?array $arg):?string{
|
function checkCommandArg(?array $arg):?string{
|
||||||
if($arg === null){
|
if($arg === null){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$defaultCheck = [
|
$defaultCheck = [
|
||||||
/*'string'=>[
|
/*'string'=>[
|
||||||
'nationName', 'optionText', 'itemType', 'nationType'
|
'nationName', 'optionText', 'itemType', 'nationType', 'commandType',
|
||||||
],*/
|
],*/
|
||||||
'integer'=>[
|
'integer'=>[
|
||||||
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
||||||
'amount', 'colorType',
|
'amount', 'colorType',
|
||||||
'srcArmType', 'destArmType', //숙련전환 전용
|
'srcArmType', 'destArmType', //숙련전환 전용
|
||||||
],
|
],
|
||||||
'boolean'=>[
|
'boolean'=>[
|
||||||
'isGold', 'buyRice',
|
'isGold', 'buyRice',
|
||||||
],
|
],
|
||||||
'between'=>[
|
'between'=>[
|
||||||
['month', [1, 12]]
|
['month', [1, 12]]
|
||||||
],
|
],
|
||||||
'min'=>[
|
'min'=>[
|
||||||
['year', 0],
|
['year', 0],
|
||||||
['destGeneralID', 1],
|
['destGeneralID', 1],
|
||||||
['destCityID', 1],
|
['destCityID', 1],
|
||||||
['destNationID', 1],
|
['destNationID', 1],
|
||||||
['amount', 1],
|
['amount', 1],
|
||||||
['crewType', 0]
|
['crewType', 0]
|
||||||
],
|
],
|
||||||
'integerArray'=>[
|
'integerArray'=>[
|
||||||
'destNationIDList', 'destGeneralIDList', 'amountList'
|
'destNationIDList', 'destGeneralIDList', 'amountList'
|
||||||
],
|
],
|
||||||
'stringWidthBetween'=>[
|
'stringWidthBetween'=>[
|
||||||
['nationName', 1, 18]
|
['nationName', 1, 18]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$v = new Validator($arg);
|
$v = new Validator($arg);
|
||||||
$v->rules($defaultCheck);
|
$v->rules($defaultCheck);
|
||||||
if (!$v->validate()){
|
if (!$v->validate()){
|
||||||
return $v->errorStr();
|
return $v->errorStr();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setGeneralCommand(int $generalID, array $rawTurnList, string $command, ?array $arg = null):array{
|
function setGeneralCommand(int $generalID, array $rawTurnList, string $command, ?array $arg = null):array{
|
||||||
|
|
||||||
$turnList = [];
|
$turnList = [];
|
||||||
foreach($rawTurnList as $turnIdx){
|
foreach($rawTurnList as $turnIdx){
|
||||||
if(!is_int($turnIdx) || $turnIdx < -3 || $turnIdx >= GameConst::$maxTurn){
|
if(!is_int($turnIdx) || $turnIdx < -3 || $turnIdx >= GameConst::$maxTurn){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'올바른 턴이 아닙니다. : '.$turnIdx,
|
'reason'=>'올바른 턴이 아닙니다. : '.$turnIdx,
|
||||||
'test'=>'turnIdx',
|
'test'=>'turnIdx',
|
||||||
'target'=>$turnIdx,
|
'target'=>$turnIdx,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if($turnIdx >= 0){
|
if($turnIdx >= 0){
|
||||||
$turnList[$turnIdx] = true;
|
$turnList[$turnIdx] = true;
|
||||||
}
|
}
|
||||||
else if($turnIdx == -1){
|
else if($turnIdx == -1){
|
||||||
//홀수
|
//홀수, 0부터 맞다.
|
||||||
foreach(Util::range(1, GameConst::$maxTurn, 2) as $subIdx){
|
foreach(Util::range(0, GameConst::$maxTurn, 2) as $subIdx){
|
||||||
$turnList[$subIdx] = true;
|
$turnList[$subIdx] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($turnIdx == -2){
|
else if($turnIdx == -2){
|
||||||
//짝수
|
//짝수, 1부터 맞다.
|
||||||
foreach(Util::range(0, GameConst::$maxTurn, 2) as $subIdx){
|
foreach(Util::range(1, GameConst::$maxTurn, 2) as $subIdx){
|
||||||
$turnList[$subIdx] = true;
|
$turnList[$subIdx] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($turnIdx == -3){
|
else if($turnIdx == -3){
|
||||||
//모두
|
//모두
|
||||||
foreach(Util::range(GameConst::$maxTurn) as $subIdx){
|
foreach(Util::range(GameConst::$maxTurn) as $subIdx){
|
||||||
$turnList[$subIdx] = true;
|
$turnList[$subIdx] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$turnList = array_keys($turnList);
|
$turnList = array_keys($turnList);
|
||||||
|
|
||||||
$arg = sanitizeArg($arg);
|
$arg = sanitizeArg($arg);
|
||||||
$argBasicTestResult = checkCommandArg($arg);
|
$argBasicTestResult = checkCommandArg($arg);
|
||||||
if($argBasicTestResult !== null){
|
if($argBasicTestResult !== null){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'턴이 입력되지 않았습니다.',
|
'reason'=>'턴이 입력되지 않았습니다.',
|
||||||
'test'=>'checkCommandArg',
|
'test'=>'checkCommandArg',
|
||||||
'target'=>'arg'
|
'target'=>'arg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$env = $gameStor->getAll();
|
$env = $gameStor->getAll();
|
||||||
$general = General::createGeneralObjFromDB($generalID);
|
$general = General::createGeneralObjFromDB($generalID);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$commandObj = buildGeneralCommandClass($command, $general, $env, $arg);
|
$commandObj = buildGeneralCommandClass($command, $general, $env, $arg);
|
||||||
}
|
}
|
||||||
catch (\InvalidArgumentException $e){
|
catch (\InvalidArgumentException $e){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>$e->getMessage(),
|
'reason'=>$e->getMessage(),
|
||||||
'test'=>'build',
|
'test'=>'build',
|
||||||
'target'=>'arg'
|
'target'=>'arg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
catch (\Exception $e){
|
catch (\Exception $e){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>$e->getCode().$e->getMessage(),
|
'reason'=>$e->getCode().$e->getMessage(),
|
||||||
'test'=>'build',
|
'test'=>'build',
|
||||||
'target'=>'arg'
|
'target'=>'arg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$commandObj->isArgValid()){
|
if(!$commandObj->isArgValid()){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'올바르지 않은 argument',
|
'reason'=>'올바르지 않은 argument',
|
||||||
'test'=>'isArgValid',
|
'test'=>'isArgValid',
|
||||||
'target'=>'arg'
|
'target'=>'arg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$commandObj->hasPermissionToReserve()){
|
if(!$commandObj->hasPermissionToReserve()){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testPermissionToReserve(),
|
'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testPermissionToReserve(),
|
||||||
'test'=>'hasPermissionToReserve',
|
'test'=>'hasPermissionToReserve',
|
||||||
'target'=>'command'
|
'target'=>'command'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
_setGeneralCommand($commandObj, $turnList);
|
_setGeneralCommand($commandObj, $turnList);
|
||||||
return [
|
return [
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNationCommand(int $generalID, array $turnList, string $command, ?array $arg = null):array{
|
function setNationCommand(int $generalID, array $turnList, string $command, ?array $arg = null):array{
|
||||||
$turnList = array_unique($turnList);
|
$turnList = array_unique($turnList);
|
||||||
foreach($turnList as $turnIdx){
|
foreach($turnList as $turnIdx){
|
||||||
if(!is_int($turnIdx) || $turnIdx < 0 || $turnIdx >= GameConst::$maxChiefTurn){
|
if(!is_int($turnIdx) || $turnIdx < 0 || $turnIdx >= GameConst::$maxChiefTurn){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'올바른 턴이 아닙니다. : '.$turnIdx,
|
'reason'=>'올바른 턴이 아닙니다. : '.$turnIdx,
|
||||||
'test'=>'turnIdx',
|
'test'=>'turnIdx',
|
||||||
'target'=>$turnIdx,
|
'target'=>$turnIdx,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$arg = sanitizeArg($arg);
|
$arg = sanitizeArg($arg);
|
||||||
$argBasicTestResult = checkCommandArg($arg);
|
$argBasicTestResult = checkCommandArg($arg);
|
||||||
if($argBasicTestResult !== null){
|
if($argBasicTestResult !== null){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'턴이 입력되지 않았습니다.',
|
'reason'=>'턴이 입력되지 않았습니다.',
|
||||||
'test'=>'checkCommandArg',
|
'test'=>'checkCommandArg',
|
||||||
'target'=>'arg'
|
'target'=>'arg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$env = $gameStor->getAll();
|
$env = $gameStor->getAll();
|
||||||
$general = General::createGeneralObjFromDB($generalID);
|
$general = General::createGeneralObjFromDB($generalID);
|
||||||
|
|
||||||
if($general->getVar('officer_level') < 5){
|
if($general->getVar('officer_level') < 5){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'수뇌가 아닙니다'
|
'reason'=>'수뇌가 아닙니다'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$commandObj = buildNationCommandClass($command, $general, $env, $general->getLastTurn(), $arg);
|
$commandObj = buildNationCommandClass($command, $general, $env, $general->getLastTurn(), $arg);
|
||||||
}
|
}
|
||||||
catch (\InvalidArgumentException $e){
|
catch (\InvalidArgumentException $e){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>$e->getMessage(),
|
'reason'=>$e->getMessage(),
|
||||||
'test'=>'build',
|
'test'=>'build',
|
||||||
'target'=>'arg'
|
'target'=>'arg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
catch (\Exception $e){
|
catch (\Exception $e){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>$e->getCode().$e->getMessage(),
|
'reason'=>$e->getCode().$e->getMessage(),
|
||||||
'test'=>'build',
|
'test'=>'build',
|
||||||
'target'=>'arg'
|
'target'=>'arg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$commandObj->isArgValid()){
|
if(!$commandObj->isArgValid()){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'올바르지 않은 argument',
|
'reason'=>'올바르지 않은 argument',
|
||||||
'test'=>'isArgValid',
|
'test'=>'isArgValid',
|
||||||
'target'=>'arg'
|
'target'=>'arg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$commandObj->hasPermissionToReserve()){
|
if(!$commandObj->hasPermissionToReserve()){
|
||||||
return [
|
return [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testPermissionToReserve(),
|
'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testPermissionToReserve(),
|
||||||
'test'=>'hasPermissionToReserve',
|
'test'=>'hasPermissionToReserve',
|
||||||
'target'=>'command'
|
'target'=>'command'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
_setNationCommand($commandObj, $turnList);
|
_setNationCommand($commandObj, $turnList);
|
||||||
return [
|
return [
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'arg_test'=>true,
|
'arg_test'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
+1139
-1138
@@ -1,1138 +1,1139 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 게임 룰에 해당하는 함수 모음
|
* 게임 룰에 해당하는 함수 모음
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getNationLevelList(): array
|
function getNationLevelList(): array
|
||||||
{
|
{
|
||||||
$table = [
|
$table = [
|
||||||
0 => ['방랑군', 2, 0],
|
0 => ['방랑군', 2, 0],
|
||||||
1 => ['호족', 2, 1],
|
1 => ['호족', 2, 1],
|
||||||
2 => ['군벌', 4, 2],
|
2 => ['군벌', 4, 2],
|
||||||
3 => ['주자사', 4, 5],
|
3 => ['주자사', 4, 5],
|
||||||
4 => ['주목', 6, 8],
|
4 => ['주목', 6, 8],
|
||||||
5 => ['공', 6, 11],
|
5 => ['공', 6, 11],
|
||||||
6 => ['왕', 8, 16],
|
6 => ['왕', 8, 16],
|
||||||
7 => ['황제', 8, 21],
|
7 => ['황제', 8, 21],
|
||||||
];
|
];
|
||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCityLevelList(): array
|
function getCityLevelList(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
1 => '수',
|
1 => '수',
|
||||||
2 => '진',
|
2 => '진',
|
||||||
3 => '관',
|
3 => '관',
|
||||||
4 => '이',
|
4 => '이',
|
||||||
5 => '소',
|
5 => '소',
|
||||||
6 => '중',
|
6 => '중',
|
||||||
7 => '대',
|
7 => '대',
|
||||||
8 => '특'
|
8 => '특'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
//한국가의 전체 전방 설정
|
//한국가의 전체 전방 설정
|
||||||
function SetNationFront($nationNo)
|
function SetNationFront($nationNo)
|
||||||
{
|
{
|
||||||
if (!$nationNo) {
|
if (!$nationNo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 도시소유 국가와 선포,교전중인 국가
|
// 도시소유 국가와 선포,교전중인 국가
|
||||||
|
|
||||||
$adj3 = [];
|
$adj3 = [];
|
||||||
$adj2 = [];
|
$adj2 = [];
|
||||||
$adj1 = [];
|
$adj1 = [];
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
foreach ($db->queryFirstColumn(
|
foreach ($db->queryFirstColumn(
|
||||||
'SELECT city FROM city JOIN diplomacy ON diplomacy.you = city.nation WHERE diplomacy.state = 0 AND me = %i',
|
'SELECT city FROM city JOIN diplomacy ON diplomacy.you = city.nation WHERE diplomacy.state = 0 AND me = %i',
|
||||||
$nationNo
|
$nationNo
|
||||||
) as $city) {
|
) as $city) {
|
||||||
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
||||||
$adj3[$adjKey] = $adjVal;
|
$adj3[$adjKey] = $adjVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
foreach ($db->queryFirstColumn(
|
foreach ($db->queryFirstColumn(
|
||||||
'SELECT city FROM city JOIN diplomacy ON diplomacy.you = city.nation WHERE diplomacy.state = 1 AND diplomacy.term <= 5 AND me = %i',
|
'SELECT city FROM city JOIN diplomacy ON diplomacy.you = city.nation WHERE diplomacy.state = 1 AND diplomacy.term <= 5 AND me = %i',
|
||||||
$nationNo
|
$nationNo
|
||||||
) as $city) {
|
) as $city) {
|
||||||
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
||||||
$adj1[$adjKey] = $adjVal;
|
$adj1[$adjKey] = $adjVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$adj3 && !$adj1) {
|
if (!$adj3 && !$adj1) {
|
||||||
//평시이면 공백지
|
//평시이면 공백지
|
||||||
//NOTE: if, else일 경우 NPC는 전쟁시에는 공백지로 출병하지 않는다는 뜻이 된다.
|
//NOTE: if, else일 경우 NPC는 전쟁시에는 공백지로 출병하지 않는다는 뜻이 된다.
|
||||||
foreach ($db->queryFirstColumn('SELECT city from city where nation=0') as $city) {
|
foreach ($db->queryFirstColumn('SELECT city from city where nation=0') as $city) {
|
||||||
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
||||||
$adj2[$adjKey] = $adjVal;
|
$adj2[$adjKey] = $adjVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'front' => 0
|
'front' => 0
|
||||||
], 'nation=%i', $nationNo);
|
], 'nation=%i', $nationNo);
|
||||||
|
|
||||||
if ($adj1) {
|
if ($adj1) {
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'front' => 1,
|
'front' => 1,
|
||||||
], 'nation=%i and city in %li', $nationNo, array_keys($adj1));
|
], 'nation=%i and city in %li', $nationNo, array_keys($adj1));
|
||||||
}
|
}
|
||||||
if ($adj2) {
|
if ($adj2) {
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'front' => 2,
|
'front' => 2,
|
||||||
], 'nation=%i and city in %li', $nationNo, array_keys($adj2));
|
], 'nation=%i and city in %li', $nationNo, array_keys($adj2));
|
||||||
}
|
}
|
||||||
if ($adj3) {
|
if ($adj3) {
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'front' => 3,
|
'front' => 3,
|
||||||
], 'nation=%i and city in %li', $nationNo, array_keys($adj3));
|
], 'nation=%i and city in %li', $nationNo, array_keys($adj3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSupply()
|
function checkSupply()
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$cities = [];
|
$cities = [];
|
||||||
foreach ($db->query('SELECT city, nation FROM city WHERE nation != 0') as $city) {
|
foreach ($db->query('SELECT city, nation FROM city WHERE nation != 0') as $city) {
|
||||||
$newCity = new \stdClass();
|
$newCity = new \stdClass();
|
||||||
$newCity->id = Util::toInt($city['city']);
|
$newCity->id = Util::toInt($city['city']);
|
||||||
$newCity->nation = Util::toInt($city['nation']);
|
$newCity->nation = Util::toInt($city['nation']);
|
||||||
$newCity->supply = false;
|
$newCity->supply = false;
|
||||||
|
|
||||||
$cities[$newCity->id] = $newCity;
|
$cities[$newCity->id] = $newCity;
|
||||||
}
|
}
|
||||||
|
|
||||||
$queue = new \SplQueue();
|
$queue = new \SplQueue();
|
||||||
foreach ($db->queryAllLists('SELECT capital, nation FROM nation WHERE `level` > 0') as list($capitalID, $nationID)) {
|
foreach ($db->queryAllLists('SELECT capital, nation FROM nation WHERE `level` > 0') as list($capitalID, $nationID)) {
|
||||||
if (!key_exists($capitalID, $cities)) {
|
if (!key_exists($capitalID, $cities)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$city = $cities[$capitalID];
|
$city = $cities[$capitalID];
|
||||||
if ($nationID != $city->nation) {
|
if ($nationID != $city->nation) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$city->supply = true;
|
$city->supply = true;
|
||||||
$queue->enqueue($city);
|
$queue->enqueue($city);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!$queue->isEmpty()) {
|
while (!$queue->isEmpty()) {
|
||||||
$cityLink = $queue->dequeue();
|
$cityLink = $queue->dequeue();
|
||||||
$city = CityConst::byID($cityLink->id);
|
$city = CityConst::byID($cityLink->id);
|
||||||
|
|
||||||
foreach (array_keys($city->path) as $connCityID) {
|
foreach (array_keys($city->path) as $connCityID) {
|
||||||
if (!key_exists($connCityID, $cities)) {
|
if (!key_exists($connCityID, $cities)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$connCity = $cities[$connCityID];
|
$connCity = $cities[$connCityID];
|
||||||
if ($connCity->nation != $cityLink->nation) {
|
if ($connCity->nation != $cityLink->nation) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($connCity->supply) {
|
if ($connCity->supply) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$connCity->supply = true;
|
$connCity->supply = true;
|
||||||
$queue->enqueue($connCity);
|
$queue->enqueue($connCity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'supply' => 1
|
'supply' => 1
|
||||||
], 'nation=0');
|
], 'nation=0');
|
||||||
|
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'supply' => 0
|
'supply' => 0
|
||||||
], 'nation!=0');
|
], 'nation!=0');
|
||||||
|
|
||||||
$supply = [];
|
$supply = [];
|
||||||
|
|
||||||
foreach ($cities as $city) {
|
foreach ($cities as $city) {
|
||||||
if ($city->supply) {
|
if ($city->supply) {
|
||||||
$supply[] = $city->id;
|
$supply[] = $city->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($supply) {
|
if ($supply) {
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'supply' => 1
|
'supply' => 1
|
||||||
], 'city IN %li', $supply);
|
], 'city IN %li', $supply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateGeneralNumber(){
|
function updateGeneralNumber(){
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
foreach($db->queryAllLists('SELECT nation, count(*) FROM general WHERE npc != 5 GROUP BY nation') as [$nationID, $gennum]){
|
foreach($db->queryAllLists('SELECT nation, count(*) FROM general WHERE npc != 5 GROUP BY nation') as [$nationID, $gennum]){
|
||||||
if($nationID === 0){
|
if($nationID === 0){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'gennum'=>$gennum
|
'gennum'=>$gennum
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
}
|
}
|
||||||
refreshNationStaticInfo();
|
refreshNationStaticInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateYearly()
|
function updateYearly()
|
||||||
{
|
{
|
||||||
//통계
|
//통계
|
||||||
checkStatistic();
|
checkStatistic();
|
||||||
}
|
}
|
||||||
|
|
||||||
//관직 변경 해제
|
//관직 변경 해제
|
||||||
function updateQuaterly()
|
function updateQuaterly()
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
//천도 제한 해제, 관직 변경 제한 해제
|
//천도 제한 해제, 관직 변경 제한 해제
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'chief_set' => 0,
|
'chief_set' => 0,
|
||||||
], true);
|
], true);
|
||||||
//관직 변경 제한 해제
|
//관직 변경 제한 해제
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'officer_set' => 0,
|
'officer_set' => 0,
|
||||||
], true);
|
], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 벌점 감소와 건국제한-1 전턴제한-1 외교제한-1, 1달마다 실행, 병사 있는 장수의 군량 감소, 수입비율 조정
|
// 벌점 감소와 건국제한-1 전턴제한-1 외교제한-1, 1달마다 실행, 병사 있는 장수의 군량 감소, 수입비율 조정
|
||||||
function preUpdateMonthly()
|
function preUpdateMonthly()
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
//연감 월결산
|
//연감 월결산
|
||||||
$result = LogHistory();
|
$result = LogHistory();
|
||||||
|
|
||||||
if ($result == false) {
|
if ($result == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['startyear', 'year', 'month']);
|
$admin = $gameStor->getValues(['startyear', 'year', 'month']);
|
||||||
$logger = new ActionLogger(0, 0, $admin['year'], $admin['month']);
|
$logger = new ActionLogger(0, 0, $admin['year'], $admin['month']);
|
||||||
|
|
||||||
//보급선 체크
|
//보급선 체크
|
||||||
checkSupply();
|
checkSupply();
|
||||||
//미보급도시 10% 감소
|
//미보급도시 10% 감소
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'pop' => $db->sqleval('pop * 0.9'),
|
'pop' => $db->sqleval('pop * 0.9'),
|
||||||
'trust' => $db->sqleval('trust * 0.9'),
|
'trust' => $db->sqleval('trust * 0.9'),
|
||||||
'agri' => $db->sqleval('agri * 0.9'),
|
'agri' => $db->sqleval('agri * 0.9'),
|
||||||
'comm' => $db->sqleval('comm * 0.9'),
|
'comm' => $db->sqleval('comm * 0.9'),
|
||||||
'secu' => $db->sqleval('secu * 0.9'),
|
'secu' => $db->sqleval('secu * 0.9'),
|
||||||
'def' => $db->sqleval('def * 0.9'),
|
'def' => $db->sqleval('def * 0.9'),
|
||||||
'wall' => $db->sqleval('wall * 0.9'),
|
'wall' => $db->sqleval('wall * 0.9'),
|
||||||
], 'supply = 0');
|
], 'supply = 0');
|
||||||
//미보급도시 장수 병 훈 사 5%감소
|
//미보급도시 장수 병 훈 사 5%감소
|
||||||
//NOTE: update inner join도 가능하지만, meekrodb 기준으로 깔끔하게.
|
//NOTE: update inner join도 가능하지만, meekrodb 기준으로 깔끔하게.
|
||||||
$unsuppliedCities = $db->query('SELECT city, nation, trust, name FROM city WHERE supply = 0');
|
$unsuppliedCities = $db->query('SELECT city, nation, trust, name FROM city WHERE supply = 0');
|
||||||
foreach (Util::arrayGroupBy($unsuppliedCities, 'nation') as $nationID => $cityList) {
|
foreach (Util::arrayGroupBy($unsuppliedCities, 'nation') as $nationID => $cityList) {
|
||||||
$cityIDList = Util::squeezeFromArray($cityList, 'city');
|
$cityIDList = Util::squeezeFromArray($cityList, 'city');
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
'crew' => $db->sqleval('crew*0.95'),
|
'crew' => $db->sqleval('crew*0.95'),
|
||||||
'atmos' => $db->sqleval('atmos*0.95'),
|
'atmos' => $db->sqleval('atmos*0.95'),
|
||||||
'train' => $db->sqleval('train*0.95'),
|
'train' => $db->sqleval('train*0.95'),
|
||||||
], 'city IN %li AND nation = %i', $cityIDList, $nationID);
|
], 'city IN %li AND nation = %i', $cityIDList, $nationID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//민심30이하 공백지 처리
|
//민심30이하 공백지 처리
|
||||||
$lostCities = [];
|
$lostCities = [];
|
||||||
foreach ($unsuppliedCities as $unsuppliedCity) {
|
foreach ($unsuppliedCities as $unsuppliedCity) {
|
||||||
if ($unsuppliedCity['trust'] >= 30) {
|
if ($unsuppliedCity['trust'] >= 30) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$lostCities[$unsuppliedCity['city']] = $unsuppliedCity;
|
$lostCities[$unsuppliedCity['city']] = $unsuppliedCity;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($lostCities) {
|
if ($lostCities) {
|
||||||
foreach ($lostCities as $lostCity) {
|
foreach ($lostCities as $lostCity) {
|
||||||
$josaYi = JosaUtil::pick($lostCity['name'], '이');
|
$josaYi = JosaUtil::pick($lostCity['name'], '이');
|
||||||
$logger->pushGlobalHistoryLog("<R><b>【고립】</b></><G><b>{$lostCity['name']}</b></>{$josaYi} 보급이 끊겨 <R>미지배</> 도시가 되었습니다.");
|
$logger->pushGlobalHistoryLog("<R><b>【고립】</b></><G><b>{$lostCity['name']}</b></>{$josaYi} 보급이 끊겨 <R>미지배</> 도시가 되었습니다.");
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
'officer_level' => 1,
|
'officer_level' => 1,
|
||||||
'officer_city' => 0
|
'officer_city' => 0
|
||||||
], 'officer_city IN %li', array_keys($lostCities));
|
], 'officer_city IN %li', array_keys($lostCities));
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'nation' => 0,
|
'nation' => 0,
|
||||||
'officer_set' => 0,
|
'officer_set' => 0,
|
||||||
'conflict' => '{}',
|
'conflict' => '{}',
|
||||||
'term' => 0,
|
'term' => 0,
|
||||||
'front' => 0
|
'front' => 0
|
||||||
], 'city IN %li', array_keys($lostCities));
|
], 'city IN %li', array_keys($lostCities));
|
||||||
}
|
}
|
||||||
|
|
||||||
//접률감소, 건국제한-1
|
//접률감소, 건국제한-1
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
'connect' => $db->sqleval('floor(connect*0.99)'),
|
'connect' => $db->sqleval('floor(connect*0.99)'),
|
||||||
'makelimit' => $db->sqleval('greatest(0, makelimit - 1)'),
|
'makelimit' => $db->sqleval('greatest(0, makelimit - 1)'),
|
||||||
], true);
|
], true);
|
||||||
//전략제한-1, 외교제한-1, 세율동기화
|
//전략제한-1, 외교제한-1, 세율동기화
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $db->sqleval('greatest(0, strategic_cmd_limit - 1)'),
|
'strategic_cmd_limit' => $db->sqleval('greatest(0, strategic_cmd_limit - 1)'),
|
||||||
'surlimit' => $db->sqleval('greatest(0, surlimit - 1)'),
|
'surlimit' => $db->sqleval('greatest(0, surlimit - 1)'),
|
||||||
'rate_tmp' => $db->sqleval('rate')
|
'rate_tmp' => $db->sqleval('rate')
|
||||||
], true);
|
], true);
|
||||||
|
|
||||||
//도시훈사 180년 60, 220년 87, 240년 100
|
//도시훈사 180년 60, 220년 87, 240년 100
|
||||||
$rate = Util::round(($admin['year'] - $admin['startyear']) / 1.5) + 60;
|
$rate = Util::round(($admin['year'] - $admin['startyear']) / 1.5) + 60;
|
||||||
if ($rate > 100) $rate = 100;
|
if ($rate > 100) $rate = 100;
|
||||||
|
|
||||||
// 20 ~ 140원
|
// 20 ~ 140원
|
||||||
$develcost = ($admin['year'] - $admin['startyear'] + 10) * 2;
|
$develcost = ($admin['year'] - $admin['startyear'] + 10) * 2;
|
||||||
$gameStor->city_rate = $rate;
|
$gameStor->city_rate = $rate;
|
||||||
$gameStor->develcost = $develcost;
|
$gameStor->develcost = $develcost;
|
||||||
|
|
||||||
//매달 사망자 수입 결산
|
//매달 사망자 수입 결산
|
||||||
processWarIncome();
|
processWarIncome();
|
||||||
|
|
||||||
//계략, 전쟁표시 해제
|
//계략, 전쟁표시 해제
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'state' => $db->sqleval(<<<EOD
|
'state' => $db->sqleval(<<<EOD
|
||||||
(CASE
|
(CASE
|
||||||
WHEN state=31 THEN 0
|
WHEN state=31 THEN 0
|
||||||
WHEN state=32 THEN 31
|
WHEN state=32 THEN 31
|
||||||
WHEN state=33 THEN 0
|
WHEN state=33 THEN 0
|
||||||
WHEN state=34 THEN 33
|
WHEN state=34 THEN 33
|
||||||
WHEN state=41 THEN 0
|
WHEN state=41 THEN 0
|
||||||
WHEN state=42 THEN 41
|
WHEN state=42 THEN 41
|
||||||
WHEN state=43 THEN 42
|
WHEN state=43 THEN 42
|
||||||
ELSE state END)
|
ELSE state END)
|
||||||
EOD),
|
EOD),
|
||||||
'term' => $db->sqleval('greatest(0, term - 1)'),
|
'term' => $db->sqleval('greatest(0, term - 1)'),
|
||||||
'conflict' => $db->sqleval('if(term = 0,%s,conflict)', '{}'),
|
'conflict' => $db->sqleval('if(term = 0,%s,conflict)', '{}'),
|
||||||
], true);
|
], true);
|
||||||
|
|
||||||
//첩보-1
|
//첩보-1
|
||||||
foreach ($db->queryAllLists("SELECT nation, spy FROM nation WHERE spy!='' AND spy!='{}'") as [$nationNo, $rawSpy]) {
|
foreach ($db->queryAllLists("SELECT nation, spy FROM nation WHERE spy!='' AND spy!='{}'") as [$nationNo, $rawSpy]) {
|
||||||
$spyInfo = Json::decode($rawSpy);
|
$spyInfo = Json::decode($rawSpy);
|
||||||
|
|
||||||
foreach ($spyInfo as $cityNo => $remainMonth) {
|
foreach ($spyInfo as $cityNo => $remainMonth) {
|
||||||
if ($remainMonth <= 1) {
|
if ($remainMonth <= 1) {
|
||||||
unset($spyInfo[$cityNo]);
|
unset($spyInfo[$cityNo]);
|
||||||
} else {
|
} else {
|
||||||
$spyInfo[$cityNo] -= 1;
|
$spyInfo[$cityNo] -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'spy' => Json::encode($spyInfo, Json::EMPTY_ARRAY_IS_DICT)
|
'spy' => Json::encode($spyInfo, Json::EMPTY_ARRAY_IS_DICT)
|
||||||
], 'nation=%i', $nationNo);
|
], 'nation=%i', $nationNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 외교 로그처리, 외교 상태 처리
|
// 외교 로그처리, 외교 상태 처리
|
||||||
function postUpdateMonthly()
|
function postUpdateMonthly()
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['startyear', 'year', 'month', 'scenario']);
|
$admin = $gameStor->getValues(['startyear', 'year', 'month', 'scenario']);
|
||||||
$globalLogger = new ActionLogger(0, 0, $admin['year'], $admin['month']);
|
$globalLogger = new ActionLogger(0, 0, $admin['year'], $admin['month']);
|
||||||
|
|
||||||
//도시 수 측정
|
//도시 수 측정
|
||||||
$cityNations = [];
|
$cityNations = [];
|
||||||
foreach ($db->queryAllLists('SELECT city, name, nation FROM city') as [$cityID, $cityName, $cityNation]) {
|
foreach ($db->queryAllLists('SELECT city, name, nation FROM city') as [$cityID, $cityName, $cityNation]) {
|
||||||
if (!key_exists($cityNation, $cityNations)) {
|
if (!key_exists($cityNation, $cityNations)) {
|
||||||
$cityNations[$cityNation] = [];
|
$cityNations[$cityNation] = [];
|
||||||
}
|
}
|
||||||
$cityNations[$cityNation][] = $cityName;
|
$cityNations[$cityNation][] = $cityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//각 국가 전월 장수수 대비 당월 장수수로 단합도 산정
|
//각 국가 전월 장수수 대비 당월 장수수로 단합도 산정
|
||||||
//각 국가 장수수를 구하고 국력 산정
|
//각 국가 장수수를 구하고 국력 산정
|
||||||
// $query = "select nation,gennum from nation where level>0";
|
// $query = "select nation,gennum from nation where level>0";
|
||||||
// 국력=
|
// 국력=
|
||||||
// 자원(국가/장수의 금,쌀)
|
// 자원(국가/장수의 금,쌀)
|
||||||
// 기술력
|
// 기술력
|
||||||
// 인구수*내정%
|
// 인구수*내정%
|
||||||
// 장수능력
|
// 장수능력
|
||||||
// 접속률
|
// 접속률
|
||||||
// 숙련도
|
// 숙련도
|
||||||
// 명성,공헌
|
// 명성,공헌
|
||||||
$nations = Util::convertArrayToDict($db->query('SELECT
|
$nations = Util::convertArrayToDict($db->query('SELECT
|
||||||
A.nation,
|
A.nation,
|
||||||
A.gennum,
|
A.gennum,
|
||||||
round((
|
round((
|
||||||
round(((A.gold+A.rice)+(select sum(gold+rice) from general where nation=A.nation))/100)
|
round(((A.gold+A.rice)+(select sum(gold+rice) from general where nation=A.nation))/100)
|
||||||
+A.tech
|
+A.tech
|
||||||
+if(A.level=0,0,(
|
+if(A.level=0,0,(
|
||||||
select round(
|
select round(
|
||||||
sum(pop)*sum(pop+agri+comm+secu+wall+def)/sum(pop_max+agri_max+comm_max+secu_max+wall_max+def_max)/100
|
sum(pop)*sum(pop+agri+comm+secu+wall+def)/sum(pop_max+agri_max+comm_max+secu_max+wall_max+def_max)/100
|
||||||
) from city where nation=A.nation and supply=1
|
) from city where nation=A.nation and supply=1
|
||||||
))
|
))
|
||||||
+(select sum(leadership+strength+intel) from general where nation=A.nation)
|
+(select sum(leadership+strength+intel) from general where nation=A.nation)
|
||||||
+(select round(sum(dex1+dex2+dex3+dex4+dex5)/1000) from general where nation=A.nation)
|
+(select round(sum(dex1+dex2+dex3+dex4+dex5)/1000) from general where nation=A.nation)
|
||||||
+(select round(sum(experience+dedication)/100) from general where nation=A.nation)
|
+(select round(sum(experience+dedication)/100) from general where nation=A.nation)
|
||||||
+(select round(avg(connect)) from general where nation=A.nation)
|
+(select round(avg(connect)) from general where nation=A.nation)
|
||||||
)/10)
|
)/10)
|
||||||
as power,
|
as power,
|
||||||
(select sum(crew) from general where nation=A.nation) as totalCrew
|
(select sum(crew) from general where nation=A.nation) as totalCrew
|
||||||
from nation A
|
from nation A
|
||||||
group by A.nation'), 'nation');
|
group by A.nation'), 'nation');
|
||||||
$maxPowerValues = KVStorage::getValuesFromInterNamespace($db, 'nation_env', 'max_power');
|
$maxPowerValues = KVStorage::getValuesFromInterNamespace($db, 'nation_env', 'max_power');
|
||||||
|
|
||||||
foreach ($nations as $nation) {
|
foreach ($nations as $nation) {
|
||||||
$nationID = $nation['nation'];
|
$nationID = $nation['nation'];
|
||||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||||
$genNum[$nationID] = $nation['gennum'];
|
$genNum[$nationID] = $nation['gennum'];
|
||||||
|
|
||||||
$powerValues = $maxPowerValues[$nationID]??[];
|
$powerValues = $maxPowerValues[$nationID]??[];
|
||||||
|
|
||||||
//약간의 랜덤치 부여 (95% ~ 105%)
|
//약간의 랜덤치 부여 (95% ~ 105%)
|
||||||
|
|
||||||
$nation['power'] = Util::round($nation['power'] * (rand() % 101 + 950) / 1000);
|
$nation['power'] = Util::round($nation['power'] * (rand() % 101 + 950) / 1000);
|
||||||
$powerValues['maxPower'] = max($powerValues['maxPower'] ?? 0, $nation['power']);
|
$powerValues['maxPower'] = max($powerValues['maxPower'] ?? 0, $nation['power']);
|
||||||
$powerValues['maxCrew'] = max($powerValues['maxCrew'] ?? 0, Util::toInt($nation['totalCrew']));
|
$powerValues['maxCrew'] = max($powerValues['maxCrew'] ?? 0, Util::toInt($nation['totalCrew']));
|
||||||
|
|
||||||
if (count($cityNations[$nationID] ?? []) > count($powerValues['maxCities'] ?? [])) {
|
if (count($cityNations[$nationID] ?? []) > count($powerValues['maxCities'] ?? [])) {
|
||||||
$powerValues['maxCities'] = $cityNations[$nationID];
|
$powerValues['maxCities'] = $cityNations[$nationID];
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'power' => $nation['power']
|
'power' => $nation['power']
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
$nationStor->max_power = $powerValues;
|
$nationStor->max_power = $powerValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 전쟁기한 세팅
|
// 전쟁기한 세팅
|
||||||
foreach($db->query('SELECT me, you, dead, term FROM diplomacy WHERE state = 0') as $dip) {
|
foreach($db->query('SELECT me, you, dead, term FROM diplomacy WHERE state = 0') as $dip) {
|
||||||
$genCount = $genNum[$dip['me']];
|
$genCount = $genNum[$dip['me']];
|
||||||
// 25% 참여율일때 두당 10턴에 4000명 소모한다고 계산
|
// 25% 참여율일때 두당 10턴에 4000명 소모한다고 계산
|
||||||
// 4000 / 10 * 0.25 = 100
|
// 4000 / 10 * 0.25 = 100
|
||||||
$term = floor($dip['dead'] / 100 / $genCount);
|
$term = floor($dip['dead'] / 100 / $genCount);
|
||||||
$dip['dead'] -= $term * 100 * $genCount;
|
$dip['dead'] -= $term * 100 * $genCount;
|
||||||
$term = Util::valueFit($dip['term'] + $term, 0, 13);
|
$term = Util::valueFit($dip['term'] + $term, 0, 13);
|
||||||
|
|
||||||
$db->update('diplomacy', [
|
$db->update('diplomacy', [
|
||||||
'term' => $term,
|
'term' => $term,
|
||||||
'dead' => $dip['dead'],
|
'dead' => $dip['dead'],
|
||||||
], 'me = %i AND you = %i', $dip['me'], $dip['you']);
|
], 'me = %i AND you = %i', $dip['me'], $dip['you']);
|
||||||
}
|
}
|
||||||
|
|
||||||
//개전국 로그
|
//개전국 로그
|
||||||
foreach($db->query('SELECT me, you FROM diplomacy WHERE state = 1 AND term <= 1 AND me < you') as $dip){
|
foreach($db->query('SELECT me, you FROM diplomacy WHERE state = 1 AND term <= 1 AND me < you') as $dip){
|
||||||
$nation1 = getNationStaticInfo($dip['me']);
|
$nation1 = getNationStaticInfo($dip['me']);
|
||||||
$name1 = $nation1['name'];
|
$name1 = $nation1['name'];
|
||||||
$nation2 = getNationStaticInfo($dip['you']);
|
$nation2 = getNationStaticInfo($dip['you']);
|
||||||
$name2 = $nation2['name'];
|
$name2 = $nation2['name'];
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($name2, '이');
|
$josaYi = JosaUtil::pick($name2, '이');
|
||||||
$josaWa = JosaUtil::pick($name1, '와');
|
$josaWa = JosaUtil::pick($name1, '와');
|
||||||
$globalLogger->pushGlobalHistoryLog("<R><b>【개전】</b></><D><b>$name1</b></>{$josaWa} <D><b>$name2</b></>{$josaYi} <R>전쟁</>을 시작합니다.");
|
$globalLogger->pushGlobalHistoryLog("<R><b>【개전】</b></><D><b>$name1</b></>{$josaWa} <D><b>$name2</b></>{$josaYi} <R>전쟁</>을 시작합니다.");
|
||||||
}
|
}
|
||||||
//휴전국 로그
|
//휴전국 로그
|
||||||
$stopWarList = [];
|
$stopWarList = [];
|
||||||
foreach($db->queryAllLists('SELECT me,you FROM diplomacy WHERE state=0 AND term <= 1 ORDER BY me desc, you desc') as [$me, $you]){
|
foreach($db->queryAllLists('SELECT me,you FROM diplomacy WHERE state=0 AND term <= 1 ORDER BY me desc, you desc') as [$me, $you]){
|
||||||
if($me < $you){
|
if($me < $you){
|
||||||
$key = "{$me}_{$you}";
|
$key = "{$me}_{$you}";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$key = "{$you}_{$me}";
|
$key = "{$you}_{$me}";
|
||||||
}
|
}
|
||||||
if(!key_exists($key, $stopWarList)){
|
if(!key_exists($key, $stopWarList)){
|
||||||
$stopWarList[$key] = true;
|
$stopWarList[$key] = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//양측 기간 모두 0이 되는 상황이면 휴전
|
//양측 기간 모두 0이 되는 상황이면 휴전
|
||||||
$nation1 = getNationStaticInfo($me);
|
$nation1 = getNationStaticInfo($me);
|
||||||
$name1 = $nation1['name'];
|
$name1 = $nation1['name'];
|
||||||
$nation2 = getNationStaticInfo($you);
|
$nation2 = getNationStaticInfo($you);
|
||||||
$name2 = $nation2['name'];
|
$name2 = $nation2['name'];
|
||||||
|
|
||||||
$josaWa = JosaUtil::pick($name1, '와');
|
$josaWa = JosaUtil::pick($name1, '와');
|
||||||
$josaYi = JosaUtil::pick($name2, '이');
|
$josaYi = JosaUtil::pick($name2, '이');
|
||||||
|
|
||||||
$globalLogger->pushGlobalHistoryLog("<R><b>【휴전】</b></><D><b>$name1</b></>{$josaWa} <D><b>$name2</b></>{$josaYi} <S>휴전</>합니다.");
|
$globalLogger->pushGlobalHistoryLog("<R><b>【휴전】</b></><D><b>$name1</b></>{$josaWa} <D><b>$name2</b></>{$josaYi} <S>휴전</>합니다.");
|
||||||
$db->update('diplomacy', [
|
$db->update('diplomacy', [
|
||||||
'state'=>2,
|
'state'=>2,
|
||||||
'term'=>0,
|
'term'=>0,
|
||||||
], '(me=%i AND you=%i) OR (you=%i AND me=%i)', $me, $you, $me, $you);
|
], '(me=%i AND you=%i) OR (you=%i AND me=%i)', $me, $you, $me, $you);
|
||||||
}
|
}
|
||||||
|
|
||||||
$globalLogger->flush();
|
$globalLogger->flush();
|
||||||
|
|
||||||
//사상자 초기화, 외교 기한-1
|
//사상자 초기화, 외교 기한-1
|
||||||
$db->update('diplomacy', [
|
$db->update('diplomacy', [
|
||||||
'dead'=>$db->sqleval('if(state!=0, 0, dead)'),
|
'dead'=>$db->sqleval('if(state!=0, 0, dead)'),
|
||||||
'term'=>$db->sqleval('greatest(0, term-1)'),
|
'term'=>$db->sqleval('greatest(0, term-1)'),
|
||||||
], true);
|
], true);
|
||||||
//불가침 끝나면 통상으로
|
//불가침 끝나면 통상으로
|
||||||
$db->update('diplomacy', [
|
$db->update('diplomacy', [
|
||||||
'state'=>2,
|
'state'=>2,
|
||||||
], 'state = 7 AND term = 0');
|
], 'state = 7 AND term = 0');
|
||||||
//선포 끝나면 교전으로
|
//선포 끝나면 교전으로
|
||||||
$db->update('diplomacy', [
|
$db->update('diplomacy', [
|
||||||
'state'=>0,
|
'state'=>0,
|
||||||
'term'=>6,
|
'term'=>6,
|
||||||
], 'state = 1 AND term = 0');
|
], 'state = 1 AND term = 0');
|
||||||
|
|
||||||
//초반이후 방랑군 자동 해체
|
//초반이후 방랑군 자동 해체
|
||||||
if ($admin['year'] >= $admin['startyear'] + 2) {
|
if ($admin['year'] >= $admin['startyear'] + 2) {
|
||||||
checkWander();
|
checkWander();
|
||||||
}
|
}
|
||||||
// 작위 업데이트
|
// 작위 업데이트
|
||||||
updateNationState();
|
updateNationState();
|
||||||
updateGeneralNumber();
|
updateGeneralNumber();
|
||||||
refreshNationStaticInfo();
|
refreshNationStaticInfo();
|
||||||
// 천통여부 검사
|
// 천통여부 검사
|
||||||
checkEmperior();
|
checkEmperior();
|
||||||
//토너먼트 개시
|
//토너먼트 개시
|
||||||
triggerTournament();
|
triggerTournament();
|
||||||
// 시스템 거래건 등록
|
// 시스템 거래건 등록
|
||||||
registerAuction();
|
registerAuction();
|
||||||
//전방설정
|
//전방설정
|
||||||
foreach (getAllNationStaticInfo() as $nation) {
|
foreach (getAllNationStaticInfo() as $nation) {
|
||||||
if ($nation['level'] <= 0) {
|
if ($nation['level'] <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SetNationFront($nation['nation']);
|
SetNationFront($nation['nation']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function checkWander()
|
function checkWander()
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['year', 'month']);
|
$admin = $gameStor->getValues(['year', 'month']);
|
||||||
|
|
||||||
$wanderers = $db->queryFirstColumn('SELECT general.`no` FROM general LEFT JOIN nation ON general.nation = nation.nation WHERE nation.`level` = 0 AND general.`officer_level` = 12');
|
$wanderers = $db->queryFirstColumn('SELECT general.`no` FROM general LEFT JOIN nation ON general.nation = nation.nation WHERE nation.`level` = 0 AND general.`officer_level` = 12');
|
||||||
|
|
||||||
foreach (General::createGeneralObjListFromDB($wanderers) as $wanderer) {
|
foreach (General::createGeneralObjListFromDB($wanderers) as $wanderer) {
|
||||||
$wanderCmd = buildGeneralCommandClass('che_해산', $wanderer, $admin);
|
$wanderCmd = buildGeneralCommandClass('che_해산', $wanderer, $admin);
|
||||||
if ($wanderCmd->hasFullConditionMet()) {
|
if ($wanderCmd->hasFullConditionMet()) {
|
||||||
$logger = $wanderer->getLogger();
|
$logger = $wanderer->getLogger();
|
||||||
$logger->pushGeneralActionLog('초반 제한후 방랑군은 자동 해산됩니다.', ActionLogger::PLAIN);
|
$logger->pushGeneralActionLog('초반 제한후 방랑군은 자동 해산됩니다.', ActionLogger::PLAIN);
|
||||||
$wanderCmd->run();
|
$wanderCmd->run();
|
||||||
}
|
$wanderCmd->setNextAvailable();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($wanderers) {
|
|
||||||
refreshNationStaticInfo();
|
if ($wanderers) {
|
||||||
}
|
refreshNationStaticInfo();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function updateNationState()
|
|
||||||
{
|
function updateNationState()
|
||||||
$db = DB::db();
|
{
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$db = DB::db();
|
||||||
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$history = array();
|
|
||||||
$admin = $gameStor->getValues(['killturn', 'year', 'month', 'fiction', 'startyear', 'show_img_level', 'turnterm', 'turntime']);
|
$history = array();
|
||||||
|
$admin = $gameStor->getValues(['killturn', 'year', 'month', 'fiction', 'startyear', 'show_img_level', 'turnterm', 'turntime']);
|
||||||
$assemblerCnts = [];
|
|
||||||
foreach ($db->queryAllLists('SELECT nation,count(no) FROM general WHERE npc = 5 GROUP BY nation') as [$nationID, $assemblerCnt]) {
|
$assemblerCnts = [];
|
||||||
$assemblerCnts[$nationID] = $assemblerCnt;
|
foreach ($db->queryAllLists('SELECT nation,count(no) FROM general WHERE npc = 5 GROUP BY nation') as [$nationID, $assemblerCnt]) {
|
||||||
};
|
$assemblerCnts[$nationID] = $assemblerCnt;
|
||||||
|
};
|
||||||
foreach ($db->query('SELECT nation,name,level,tech,aux FROM nation') as $nation) {
|
|
||||||
//TODO: level이 진관수이소중대특 체계를 벗어날 수 있음
|
foreach ($db->query('SELECT nation,name,level,tech,aux FROM nation') as $nation) {
|
||||||
$citycount = $db->queryFirstField('SELECT count(*) FROM city WHERE nation=%i AND level>=4', $nation['nation']);
|
//TODO: level이 진관수이소중대특 체계를 벗어날 수 있음
|
||||||
|
$citycount = $db->queryFirstField('SELECT count(*) FROM city WHERE nation=%i AND level>=4', $nation['nation']);
|
||||||
if ($citycount == 0) {
|
|
||||||
$nationlevel = 0; // 방랑군
|
if ($citycount == 0) {
|
||||||
} elseif ($citycount == 1) {
|
$nationlevel = 0; // 방랑군
|
||||||
$nationlevel = 1; // 호족
|
} elseif ($citycount == 1) {
|
||||||
} elseif ($citycount <= 4) {
|
$nationlevel = 1; // 호족
|
||||||
$nationlevel = 2; // 군벌
|
} elseif ($citycount <= 4) {
|
||||||
} elseif ($citycount <= 7) {
|
$nationlevel = 2; // 군벌
|
||||||
$nationlevel = 3; // 주자사
|
} elseif ($citycount <= 7) {
|
||||||
} elseif ($citycount <= 10) {
|
$nationlevel = 3; // 주자사
|
||||||
$nationlevel = 4; // 주목
|
} elseif ($citycount <= 10) {
|
||||||
} elseif ($citycount <= 15) {
|
$nationlevel = 4; // 주목
|
||||||
$nationlevel = 5; // 공
|
} elseif ($citycount <= 15) {
|
||||||
} elseif ($citycount <= 20) {
|
$nationlevel = 5; // 공
|
||||||
$nationlevel = 6; // 왕
|
} elseif ($citycount <= 20) {
|
||||||
} else {
|
$nationlevel = 6; // 왕
|
||||||
$nationlevel = 7; // 황제
|
} else {
|
||||||
}
|
$nationlevel = 7; // 황제
|
||||||
|
}
|
||||||
if ($nationlevel > $nation['level']) {
|
|
||||||
$levelDiff = $nationlevel - $nation['level'];
|
if ($nationlevel > $nation['level']) {
|
||||||
$oldLevel = $nation['level'];
|
$levelDiff = $nationlevel - $nation['level'];
|
||||||
$nation['level'] = $nationlevel;
|
$oldLevel = $nation['level'];
|
||||||
|
$nation['level'] = $nationlevel;
|
||||||
$updateVals = [
|
|
||||||
'level' => $nationlevel,
|
$updateVals = [
|
||||||
'gold'=>$db->sqleval('gold + %i', $nationlevel*1000),
|
'level' => $nationlevel,
|
||||||
'rice'=>$db->sqleval('rice + %i', $nationlevel*1000),
|
'gold'=>$db->sqleval('gold + %i', $nationlevel*1000),
|
||||||
];
|
'rice'=>$db->sqleval('rice + %i', $nationlevel*1000),
|
||||||
|
];
|
||||||
switch ($nationlevel) {
|
|
||||||
case 7:
|
switch ($nationlevel) {
|
||||||
$josaUl = JosaUtil::pick(getNationLevel($nationlevel), '을');
|
case 7:
|
||||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>{$josaUl} 자칭하였습니다.";
|
$josaUl = JosaUtil::pick(getNationLevel($nationlevel), '을');
|
||||||
pushNationHistoryLog($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>{$josaUl} 자칭"]);
|
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>{$josaUl} 자칭하였습니다.";
|
||||||
$auxVal = Json::decode($nation['aux']);
|
pushNationHistoryLog($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>{$josaUl} 자칭"]);
|
||||||
$auxVal['can_국기변경'] = 1;
|
$auxVal = Json::decode($nation['aux']);
|
||||||
$auxVal['can_국호변경'] = 1;
|
$auxVal['can_국기변경'] = 1;
|
||||||
$updateVals['aux'] = Json::encode($auxVal);
|
$auxVal['can_국호변경'] = 1;
|
||||||
break;
|
$updateVals['aux'] = Json::encode($auxVal);
|
||||||
case 6:
|
break;
|
||||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 등극하였습니다.";
|
case 6:
|
||||||
pushNationHistoryLog($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 등극"]);
|
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 등극하였습니다.";
|
||||||
break;
|
pushNationHistoryLog($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 등극"]);
|
||||||
case 5:
|
break;
|
||||||
case 4:
|
case 5:
|
||||||
case 3:
|
case 4:
|
||||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 임명되었습니다.";
|
case 3:
|
||||||
pushNationHistoryLog($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 임명됨"]);
|
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 임명되었습니다.";
|
||||||
break;
|
pushNationHistoryLog($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 임명됨"]);
|
||||||
case 2:
|
break;
|
||||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 독립하여 <Y>" . getNationLevel($nationlevel) . "</>로 나섰습니다.";
|
case 2:
|
||||||
pushNationHistoryLog($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>로 나서다"]);
|
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 독립하여 <Y>" . getNationLevel($nationlevel) . "</>로 나섰습니다.";
|
||||||
break;
|
pushNationHistoryLog($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>로 나서다"]);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
$db->update('nation', $updateVals, 'nation=%i', $nation['nation']);
|
|
||||||
|
$db->update('nation', $updateVals, 'nation=%i', $nation['nation']);
|
||||||
$turnRows = [];
|
|
||||||
foreach (Util::range(getNationChiefLevel($nation['level']), 12) as $chiefLevel) {
|
$turnRows = [];
|
||||||
foreach (Util::range(GameConst::$maxChiefTurn) as $turnIdx) {
|
foreach (Util::range(getNationChiefLevel($nation['level']), 12) as $chiefLevel) {
|
||||||
$turnRows[] = [
|
foreach (Util::range(GameConst::$maxChiefTurn) as $turnIdx) {
|
||||||
'nation_id' => $nation['nation'],
|
$turnRows[] = [
|
||||||
'officer_level' => $chiefLevel,
|
'nation_id' => $nation['nation'],
|
||||||
'turn_idx' => $turnIdx,
|
'officer_level' => $chiefLevel,
|
||||||
'action' => '휴식',
|
'turn_idx' => $turnIdx,
|
||||||
'arg' => null,
|
'action' => '휴식',
|
||||||
'brief' => '휴식'
|
'arg' => null,
|
||||||
];
|
'brief' => '휴식'
|
||||||
}
|
];
|
||||||
}
|
}
|
||||||
$db->insertIgnore('nation_turn', $turnRows);
|
}
|
||||||
|
$db->insertIgnore('nation_turn', $turnRows);
|
||||||
if ($levelDiff) {
|
|
||||||
//유니크 아이템 하나 돌리자
|
if ($levelDiff) {
|
||||||
$targetKillTurn = $admin['killturn'];
|
//유니크 아이템 하나 돌리자
|
||||||
$targetKillTurn -= 24 * 60 / $admin['turnterm'];
|
$targetKillTurn = $admin['killturn'];
|
||||||
$nationGenIDList = $db->queryFirstColumn(
|
$targetKillTurn -= 24 * 60 / $admin['turnterm'];
|
||||||
'SELECT no FROM general WHERE nation = %i AND killturn >= %i AND npc < 2',
|
$nationGenIDList = $db->queryFirstColumn(
|
||||||
$nation['nation'],
|
'SELECT no FROM general WHERE nation = %i AND killturn >= %i AND npc < 2',
|
||||||
$targetKillTurn
|
$nation['nation'],
|
||||||
);
|
$targetKillTurn
|
||||||
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong'], 2);
|
);
|
||||||
|
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong'], 2);
|
||||||
$uniqueLotteryWeightList = [];
|
|
||||||
foreach ($nationGenList as $nationGen) {
|
$uniqueLotteryWeightList = [];
|
||||||
$hasUnique = false;
|
foreach ($nationGenList as $nationGen) {
|
||||||
foreach ($nationGen->getItems() as $item) {
|
$hasUnique = false;
|
||||||
if (!$item->isBuyable()) {
|
foreach ($nationGen->getItems() as $item) {
|
||||||
$hasUnique = true;
|
if (!$item->isBuyable()) {
|
||||||
break;
|
$hasUnique = true;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
if ($hasUnique) {
|
}
|
||||||
continue;
|
if ($hasUnique) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
$score = $nationGen->getVar('belong') + 5;
|
|
||||||
|
$score = $nationGen->getVar('belong') + 5;
|
||||||
if ($nationGen->getVar('officer_level') == 12) {
|
|
||||||
$score += 200; //NOTE: 꼬우면 군주하세요.
|
if ($nationGen->getVar('officer_level') == 12) {
|
||||||
} else if ($nationGen->getVar('officer_level') == 11) {
|
$score += 200; //NOTE: 꼬우면 군주하세요.
|
||||||
$score += 70;
|
} else if ($nationGen->getVar('officer_level') == 11) {
|
||||||
} else if ($nationGen->getVar('officer_level') > 4) {
|
$score += 70;
|
||||||
$score += 35;
|
} else if ($nationGen->getVar('officer_level') > 4) {
|
||||||
}
|
$score += 35;
|
||||||
$uniqueLotteryWeightList[$nationGen->getID()] = [$nationGen, $score];
|
}
|
||||||
}
|
$uniqueLotteryWeightList[$nationGen->getID()] = [$nationGen, $score];
|
||||||
|
}
|
||||||
foreach (Util::range($levelDiff) as $idx) {
|
|
||||||
if (!$uniqueLotteryWeightList) {
|
foreach (Util::range($levelDiff) as $idx) {
|
||||||
break;
|
if (!$uniqueLotteryWeightList) {
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
/** @var General */
|
|
||||||
$winnerObj = Util::choiceRandomUsingWeightPair($uniqueLotteryWeightList);
|
/** @var General */
|
||||||
unset($uniqueLotteryWeightList[$winnerObj->getID()]);
|
$winnerObj = Util::choiceRandomUsingWeightPair($uniqueLotteryWeightList);
|
||||||
giveRandomUniqueItem($winnerObj, '작위보상');
|
unset($uniqueLotteryWeightList[$winnerObj->getID()]);
|
||||||
$winnerObj->applyDB($db);
|
giveRandomUniqueItem($winnerObj, '작위보상');
|
||||||
}
|
$winnerObj->applyDB($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$assemblerCnt = $assemblerCnts[$nation['nation']] ?? 0;
|
|
||||||
$maxAssemblerCnt = [
|
$assemblerCnt = $assemblerCnts[$nation['nation']] ?? 0;
|
||||||
1 => 0,
|
$maxAssemblerCnt = [
|
||||||
2 => 1,
|
1 => 0,
|
||||||
3 => 3,
|
2 => 1,
|
||||||
4 => 4,
|
3 => 3,
|
||||||
5 => 6,
|
4 => 4,
|
||||||
6 => 7,
|
5 => 6,
|
||||||
7 => 9
|
6 => 7,
|
||||||
][$nationlevel] ?? 0;
|
7 => 9
|
||||||
|
][$nationlevel] ?? 0;
|
||||||
if ($assemblerCnt < $maxAssemblerCnt) {
|
|
||||||
$lastAssemblerID = $gameStor->assembler_id ?? 0;
|
if ($assemblerCnt < $maxAssemblerCnt) {
|
||||||
|
$lastAssemblerID = $gameStor->assembler_id ?? 0;
|
||||||
while ($assemblerCnt < $maxAssemblerCnt) {
|
|
||||||
$lastAssemblerID += 1;
|
while ($assemblerCnt < $maxAssemblerCnt) {
|
||||||
$npcObj = new Scenario\NPC(
|
$lastAssemblerID += 1;
|
||||||
999,
|
$npcObj = new Scenario\NPC(
|
||||||
sprintf('부대장%4d', $lastAssemblerID),
|
999,
|
||||||
null,
|
sprintf('부대장%4d', $lastAssemblerID),
|
||||||
$nation['nation'],
|
null,
|
||||||
null,
|
$nation['nation'],
|
||||||
10,
|
null,
|
||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
1,
|
10,
|
||||||
$admin['year'] - 15,
|
1,
|
||||||
$admin['year'] + 15,
|
$admin['year'] - 15,
|
||||||
'은둔',
|
$admin['year'] + 15,
|
||||||
'척사'
|
'은둔',
|
||||||
);
|
'척사'
|
||||||
$npcObj->killturn = 70;
|
);
|
||||||
$npcObj->gold = 0;
|
$npcObj->killturn = 70;
|
||||||
$npcObj->rice = 0;
|
$npcObj->gold = 0;
|
||||||
$npcObj->npc = 5;
|
$npcObj->rice = 0;
|
||||||
$npcObj->build($admin);
|
$npcObj->npc = 5;
|
||||||
$npcID = $npcObj->generalID;
|
$npcObj->build($admin);
|
||||||
|
$npcID = $npcObj->generalID;
|
||||||
$db->insert('troop', [
|
|
||||||
'troop_leader' => $npcID,
|
$db->insert('troop', [
|
||||||
'name' => $npcObj->realName,
|
'troop_leader' => $npcID,
|
||||||
'nation' => $nation['nation'],
|
'name' => $npcObj->realName,
|
||||||
]);
|
'nation' => $nation['nation'],
|
||||||
$db->update('general', [
|
]);
|
||||||
'troop' => $npcID
|
$db->update('general', [
|
||||||
], 'no=%i', $npcID);
|
'troop' => $npcID
|
||||||
|
], 'no=%i', $npcID);
|
||||||
$cmd = buildGeneralCommandClass('che_집합', General::createGeneralObjFromDB($npcID), $admin);
|
|
||||||
_setGeneralCommand($cmd, iterator_to_array(Util::range(GameConst::$maxTurn)));
|
$cmd = buildGeneralCommandClass('che_집합', General::createGeneralObjFromDB($npcID), $admin);
|
||||||
$assemblerCnt += 1;
|
_setGeneralCommand($cmd, iterator_to_array(Util::range(GameConst::$maxTurn)));
|
||||||
$gameStor->assembler_id = $lastAssemblerID;
|
$assemblerCnt += 1;
|
||||||
}
|
$gameStor->assembler_id = $lastAssemblerID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pushGlobalHistoryLog($history, $admin['year'], $admin['month']);
|
}
|
||||||
}
|
pushGlobalHistoryLog($history, $admin['year'], $admin['month']);
|
||||||
|
}
|
||||||
function checkStatistic()
|
|
||||||
{
|
function checkStatistic()
|
||||||
$db = DB::db();
|
{
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$db = DB::db();
|
||||||
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$admin = $gameStor->getValues(['year', 'month']);
|
|
||||||
|
$admin = $gameStor->getValues(['year', 'month']);
|
||||||
$nationHists = [];
|
|
||||||
$specialHists = [];
|
$nationHists = [];
|
||||||
$personalHists = [];
|
$specialHists = [];
|
||||||
$specialHists2 = [];
|
$personalHists = [];
|
||||||
$crewtypeHists = [];
|
$specialHists2 = [];
|
||||||
|
$crewtypeHists = [];
|
||||||
$etc = '';
|
|
||||||
|
$etc = '';
|
||||||
$auxData = [
|
|
||||||
'generals' => [],
|
$auxData = [
|
||||||
'nations' => [],
|
'generals' => [],
|
||||||
];
|
'nations' => [],
|
||||||
|
];
|
||||||
$avgGeneral = $db->queryFirstRow(
|
|
||||||
'SELECT avg(gold) as avggold, avg(rice) as avgrice, avg(dex1+dex2+dex3+dex4) as avgdex,
|
$avgGeneral = $db->queryFirstRow(
|
||||||
max(dex1+dex2+dex3+dex4) as maxdex, avg(experience+dedication) as avgexpded, max(experience+dedication) as maxexpded
|
'SELECT avg(gold) as avggold, avg(rice) as avgrice, avg(dex1+dex2+dex3+dex4) as avgdex,
|
||||||
FROM general'
|
max(dex1+dex2+dex3+dex4) as maxdex, avg(experience+dedication) as avgexpded, max(experience+dedication) as maxexpded
|
||||||
);
|
FROM general'
|
||||||
$auxData['generals']['avg'] = $avgGeneral;
|
);
|
||||||
|
$auxData['generals']['avg'] = $avgGeneral;
|
||||||
$avgGeneral['avggold'] = Util::round($avgGeneral['avggold']);
|
|
||||||
$avgGeneral['avgrice'] = Util::round($avgGeneral['avgrice']);
|
$avgGeneral['avggold'] = Util::round($avgGeneral['avggold']);
|
||||||
$avgGeneral['avgdex'] = Util::round($avgGeneral['avgdex']);
|
$avgGeneral['avgrice'] = Util::round($avgGeneral['avgrice']);
|
||||||
$avgGeneral['avgexpded'] = Util::round($avgGeneral['avgexpded']);
|
$avgGeneral['avgdex'] = Util::round($avgGeneral['avgdex']);
|
||||||
$etc .= "평균 금/쌀 ({$avgGeneral['avggold']}/{$avgGeneral['avgrice']}), 평균/최고 숙련({$avgGeneral['avgdex']}/{$avgGeneral['maxdex']}), 평균/최고 경험공헌({$avgGeneral['avgexpded']}/{$avgGeneral['maxexpded']}), ";
|
$avgGeneral['avgexpded'] = Util::round($avgGeneral['avgexpded']);
|
||||||
|
$etc .= "평균 금/쌀 ({$avgGeneral['avggold']}/{$avgGeneral['avgrice']}), 평균/최고 숙련({$avgGeneral['avgdex']}/{$avgGeneral['maxdex']}), 평균/최고 경험공헌({$avgGeneral['avgexpded']}/{$avgGeneral['maxexpded']}), ";
|
||||||
$avgNation = $db->queryFirstRow(
|
|
||||||
'SELECT min(tech) as mintech, max(tech) as maxtech, avg(tech) as avgtech,
|
$avgNation = $db->queryFirstRow(
|
||||||
min(power) as minpower, max(power) as maxpower, avg(power) as avgpower from nation where level>0'
|
'SELECT min(tech) as mintech, max(tech) as maxtech, avg(tech) as avgtech,
|
||||||
);
|
min(power) as minpower, max(power) as maxpower, avg(power) as avgpower from nation where level>0'
|
||||||
$auxData['nations']['avg'] = $avgNation;
|
);
|
||||||
|
$auxData['nations']['avg'] = $avgNation;
|
||||||
$avgNation['mintech'] = floor($avgNation['mintech']);
|
|
||||||
$avgNation['maxtech'] = floor($avgNation['maxtech']);
|
$avgNation['mintech'] = floor($avgNation['mintech']);
|
||||||
$avgNation['avgtech'] = Util::round($avgNation['avgtech']);
|
$avgNation['maxtech'] = floor($avgNation['maxtech']);
|
||||||
$avgNation['avgpower'] = Util::round($avgNation['avgpower']);
|
$avgNation['avgtech'] = Util::round($avgNation['avgtech']);
|
||||||
$etc .= "최저/평균/최고 기술({$avgNation['mintech']}/{$avgNation['avgtech']}/{$avgNation['maxtech']}), ";
|
$avgNation['avgpower'] = Util::round($avgNation['avgpower']);
|
||||||
$etc .= "최저/평균/최고 국력({$avgNation['minpower']}/{$avgNation['avgpower']}/{$avgNation['maxpower']}), ";
|
$etc .= "최저/평균/최고 기술({$avgNation['mintech']}/{$avgNation['avgtech']}/{$avgNation['maxtech']}), ";
|
||||||
|
$etc .= "최저/평균/최고 국력({$avgNation['minpower']}/{$avgNation['avgpower']}/{$avgNation['maxpower']}), ";
|
||||||
$nationName = '';
|
|
||||||
$powerHist = '';
|
$nationName = '';
|
||||||
|
$powerHist = '';
|
||||||
$nations = Util::convertArrayToDict(
|
|
||||||
$db->query(
|
$nations = Util::convertArrayToDict(
|
||||||
'SELECT nation,name,type,power,gennum,gold+rice as goldrice from nation where level>0 order by power desc',
|
$db->query(
|
||||||
'nation'
|
'SELECT nation,name,type,power,gennum,gold+rice as goldrice from nation where level>0 order by power desc',
|
||||||
),
|
'nation'
|
||||||
'nation'
|
),
|
||||||
);
|
'nation'
|
||||||
$nationCount = count($nations);
|
);
|
||||||
|
$nationCount = count($nations);
|
||||||
$nationGeneralInfos = Util::convertArrayToDict(
|
|
||||||
$db->query(
|
$nationGeneralInfos = Util::convertArrayToDict(
|
||||||
'SELECT nation, sum(leadership+strength+intel) as abil,sum(gold+rice) as goldrice,
|
$db->query(
|
||||||
sum(dex1+dex2+dex3+dex4) as dex,sum(experience+dedication) as expded
|
'SELECT nation, sum(leadership+strength+intel) as abil,sum(gold+rice) as goldrice,
|
||||||
from general GROUP BY nation'
|
sum(dex1+dex2+dex3+dex4) as dex,sum(experience+dedication) as expded
|
||||||
),
|
from general GROUP BY nation'
|
||||||
'nation'
|
),
|
||||||
);
|
'nation'
|
||||||
|
);
|
||||||
$nationCityInfos = Util::convertArrayToDict(
|
|
||||||
$db->query('SELECT nation, count(*) as cnt, sum(pop) as pop,sum(pop_max) as pop_max from city GROUP BY nation'),
|
$nationCityInfos = Util::convertArrayToDict(
|
||||||
'nation'
|
$db->query('SELECT nation, count(*) as cnt, sum(pop) as pop,sum(pop_max) as pop_max from city GROUP BY nation'),
|
||||||
);
|
'nation'
|
||||||
|
);
|
||||||
foreach ($nations as $nationNo => &$nation) {
|
|
||||||
$general = $nationGeneralInfos[$nationNo];
|
foreach ($nations as $nationNo => &$nation) {
|
||||||
$city = $nationCityInfos[$nationNo];
|
$general = $nationGeneralInfos[$nationNo];
|
||||||
|
$city = $nationCityInfos[$nationNo];
|
||||||
$nation['generalInfo'] = $general;
|
|
||||||
$nation['cityInfo'] = $city;
|
$nation['generalInfo'] = $general;
|
||||||
|
$nation['cityInfo'] = $city;
|
||||||
$nationName .= $nation['name'] . '(' . getNationType($nation['type']) . '), ';
|
|
||||||
$powerHist .= "{$nation['name']}({$nation['power']}/{$nation['gennum']}/{$city['cnt']}/{$city['pop']}/{$city['pop_max']}/{$nation['goldrice']}/{$general['goldrice']}/{$general['abil']}/{$general['dex']}/{$general['expded']}), ";
|
$nationName .= $nation['name'] . '(' . getNationType($nation['type']) . '), ';
|
||||||
|
$powerHist .= "{$nation['name']}({$nation['power']}/{$nation['gennum']}/{$city['cnt']}/{$city['pop']}/{$city['pop_max']}/{$nation['goldrice']}/{$general['goldrice']}/{$general['abil']}/{$general['dex']}/{$general['expded']}), ";
|
||||||
if (!isset($nationHists[$nation['type']])) {
|
|
||||||
$nationHists[$nation['type']] = 0;
|
if (!isset($nationHists[$nation['type']])) {
|
||||||
}
|
$nationHists[$nation['type']] = 0;
|
||||||
$nationHists[$nation['type']]++;
|
}
|
||||||
}
|
$nationHists[$nation['type']]++;
|
||||||
unset($nation);
|
}
|
||||||
|
unset($nation);
|
||||||
$auxData['nations']['all'] = $nations;
|
|
||||||
|
$auxData['nations']['all'] = $nations;
|
||||||
$nationHist = '';
|
|
||||||
foreach (GameConst::$availableNationType as $nationType) {
|
$nationHist = '';
|
||||||
if (!Util::array_get($nationHists[$nationType])) {
|
foreach (GameConst::$availableNationType as $nationType) {
|
||||||
$nationHists[$nationType] = '-';
|
if (!Util::array_get($nationHists[$nationType])) {
|
||||||
}
|
$nationHists[$nationType] = '-';
|
||||||
$nationHist .= getNationType($nationType) . "({$nationHists[$nationType]}), ";
|
}
|
||||||
}
|
$nationHist .= getNationType($nationType) . "({$nationHists[$nationType]}), ";
|
||||||
|
}
|
||||||
$generals = $db->query('SELECT `no`,npc,personal,special,special2,crewtype FROM general');
|
|
||||||
|
$generals = $db->query('SELECT `no`,npc,personal,special,special2,crewtype FROM general');
|
||||||
$genCount = 0;
|
|
||||||
$npcCount = 0;
|
$genCount = 0;
|
||||||
$generalCount = count($generals);
|
$npcCount = 0;
|
||||||
|
$generalCount = count($generals);
|
||||||
foreach ($generals as $general) {
|
|
||||||
if (!isset($personalHists[$general['personal']])) {
|
foreach ($generals as $general) {
|
||||||
$personalHists[$general['personal']] = 0;
|
if (!isset($personalHists[$general['personal']])) {
|
||||||
}
|
$personalHists[$general['personal']] = 0;
|
||||||
|
}
|
||||||
if (!isset($specialHists[$general['special']])) {
|
|
||||||
$specialHists[$general['special']] = 0;
|
if (!isset($specialHists[$general['special']])) {
|
||||||
}
|
$specialHists[$general['special']] = 0;
|
||||||
|
}
|
||||||
if (!isset($specialHists2[$general['special2']])) {
|
|
||||||
$specialHists2[$general['special2']] = 0;
|
if (!isset($specialHists2[$general['special2']])) {
|
||||||
}
|
$specialHists2[$general['special2']] = 0;
|
||||||
|
}
|
||||||
if ($general['npc'] < 2) {
|
|
||||||
$genCount += 1;
|
if ($general['npc'] < 2) {
|
||||||
} else {
|
$genCount += 1;
|
||||||
$npcCount += 1;
|
} else {
|
||||||
}
|
$npcCount += 1;
|
||||||
|
}
|
||||||
$personalHists[$general['personal']]++;
|
|
||||||
$specialHists[$general['special']]++;
|
$personalHists[$general['personal']]++;
|
||||||
$specialHists2[$general['special2']]++;
|
$specialHists[$general['special']]++;
|
||||||
}
|
$specialHists2[$general['special2']]++;
|
||||||
|
}
|
||||||
foreach ($db->queryAllLists(
|
|
||||||
'SELECT crewtype, count(crewtype) AS cnt FROM general WHERE recent_war != NULL GROUP BY crewtype'
|
foreach ($db->queryAllLists(
|
||||||
) as [$crewtype, $cnt]) {
|
'SELECT crewtype, count(crewtype) AS cnt FROM general WHERE recent_war != NULL GROUP BY crewtype'
|
||||||
$crewtypeHists[$crewtype] = $cnt;
|
) as [$crewtype, $cnt]) {
|
||||||
}
|
$crewtypeHists[$crewtype] = $cnt;
|
||||||
|
}
|
||||||
$auxData['generals']['hists'] = [
|
|
||||||
'personal' => $personalHists,
|
$auxData['generals']['hists'] = [
|
||||||
'special' => $specialHists,
|
'personal' => $personalHists,
|
||||||
'special2' => $specialHists2,
|
'special' => $specialHists,
|
||||||
'crewtype' => $crewtypeHists,
|
'special2' => $specialHists2,
|
||||||
'userCnt' => $genCount,
|
'crewtype' => $crewtypeHists,
|
||||||
'npcCnt' => $npcCount,
|
'userCnt' => $genCount,
|
||||||
];
|
'npcCnt' => $npcCount,
|
||||||
|
];
|
||||||
$generalCountStr = "{$generalCount}({$genCount}+{$npcCount})";
|
|
||||||
|
$generalCountStr = "{$generalCount}({$genCount}+{$npcCount})";
|
||||||
$personalHistStr = join(', ', array_map(function ($histPair) {
|
|
||||||
[$histKey, $cnt] = $histPair;
|
$personalHistStr = join(', ', array_map(function ($histPair) {
|
||||||
return getGenChar($histKey) . '(' . $cnt . ')';
|
[$histKey, $cnt] = $histPair;
|
||||||
}, Util::convertDictToArray($personalHists)));
|
return getGenChar($histKey) . '(' . $cnt . ')';
|
||||||
|
}, Util::convertDictToArray($personalHists)));
|
||||||
$specialHistsStr = join(', ', array_map(function ($histPair) {
|
|
||||||
[$histKey, $cnt] = $histPair;
|
$specialHistsStr = join(', ', array_map(function ($histPair) {
|
||||||
return getGeneralSpecialDomesticName($histKey) . '(' . $cnt . ')';
|
[$histKey, $cnt] = $histPair;
|
||||||
}, Util::convertDictToArray($specialHists)));
|
return getGeneralSpecialDomesticName($histKey) . '(' . $cnt . ')';
|
||||||
|
}, Util::convertDictToArray($specialHists)));
|
||||||
$specialHists2Str = join(', ', array_map(function ($histPair) {
|
|
||||||
[$histKey, $cnt] = $histPair;
|
$specialHists2Str = join(', ', array_map(function ($histPair) {
|
||||||
return getGeneralSpecialWarName($histKey) . '(' . $cnt . ')';
|
[$histKey, $cnt] = $histPair;
|
||||||
}, Util::convertDictToArray($specialHists2)));
|
return getGeneralSpecialWarName($histKey) . '(' . $cnt . ')';
|
||||||
|
}, Util::convertDictToArray($specialHists2)));
|
||||||
$specialHistsAllStr = "$specialHistsStr // $specialHists2Str";
|
|
||||||
|
$specialHistsAllStr = "$specialHistsStr // $specialHists2Str";
|
||||||
$crewtypeHistsStr = join(', ', array_map(function ($histPair) {
|
|
||||||
[$histKey, $cnt] = $histPair;
|
$crewtypeHistsStr = join(', ', array_map(function ($histPair) {
|
||||||
return GameUnitConst::byID($histKey)->getShortName() . '(' . $cnt . ')';
|
[$histKey, $cnt] = $histPair;
|
||||||
}, Util::convertDictToArray($crewtypeHists)));
|
return GameUnitConst::byID($histKey)->getShortName() . '(' . $cnt . ')';
|
||||||
|
}, Util::convertDictToArray($crewtypeHists)));
|
||||||
$db->insert('statistic', [
|
|
||||||
'year' => $admin['year'],
|
$db->insert('statistic', [
|
||||||
'month' => $admin['month'],
|
'year' => $admin['year'],
|
||||||
'nation_count' => $nationCount,
|
'month' => $admin['month'],
|
||||||
'nation_name' => $nationName,
|
'nation_count' => $nationCount,
|
||||||
'nation_hist' => $nationHist,
|
'nation_name' => $nationName,
|
||||||
'gen_count' => $generalCountStr,
|
'nation_hist' => $nationHist,
|
||||||
'personal_hist' => $personalHistStr,
|
'gen_count' => $generalCountStr,
|
||||||
'special_hist' => $specialHistsAllStr,
|
'personal_hist' => $personalHistStr,
|
||||||
'power_hist' => $powerHist,
|
'special_hist' => $specialHistsAllStr,
|
||||||
'crewtype' => $crewtypeHistsStr,
|
'power_hist' => $powerHist,
|
||||||
'etc' => $etc,
|
'crewtype' => $crewtypeHistsStr,
|
||||||
'aux' => Json::encode($auxData)
|
'etc' => $etc,
|
||||||
]);
|
'aux' => Json::encode($auxData)
|
||||||
}
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
function convForOldGeneral(array $general, int $year, int $month)
|
|
||||||
{
|
function convForOldGeneral(array $general, int $year, int $month)
|
||||||
$general['history'] = getGeneralHistoryLogAll($general['no']);
|
{
|
||||||
return [
|
$general['history'] = getGeneralHistoryLogAll($general['no']);
|
||||||
'server_id' => UniqueConst::$serverID,
|
return [
|
||||||
'general_no' => $general['no'],
|
'server_id' => UniqueConst::$serverID,
|
||||||
'owner' => $general['owner'],
|
'general_no' => $general['no'],
|
||||||
'name' => $general['name'],
|
'owner' => $general['owner'],
|
||||||
'last_yearmonth' => $year * 100 + $month,
|
'name' => $general['name'],
|
||||||
'turntime' => $general['turntime'],
|
'last_yearmonth' => $year * 100 + $month,
|
||||||
'data' => Json::encode($general)
|
'turntime' => $general['turntime'],
|
||||||
];
|
'data' => Json::encode($general)
|
||||||
}
|
];
|
||||||
|
}
|
||||||
function storeOldGeneral(int $no, int $year, int $month)
|
|
||||||
{
|
function storeOldGeneral(int $no, int $year, int $month)
|
||||||
$db = DB::db();
|
{
|
||||||
$general = $db->queryFirstRow('SELECT * FROM general WHERE `no` = %i', $no);
|
$db = DB::db();
|
||||||
if (!$general) {
|
$general = $db->queryFirstRow('SELECT * FROM general WHERE `no` = %i', $no);
|
||||||
return;
|
if (!$general) {
|
||||||
}
|
return;
|
||||||
$data = convForOldGeneral($general, $year, $month);
|
}
|
||||||
$db->insertUpdate(
|
$data = convForOldGeneral($general, $year, $month);
|
||||||
'ng_old_generals',
|
$db->insertUpdate(
|
||||||
$data,
|
'ng_old_generals',
|
||||||
$data
|
$data,
|
||||||
);
|
$data
|
||||||
}
|
);
|
||||||
|
}
|
||||||
function storeOldGenerals(int $nation, int $year, int $month)
|
|
||||||
{
|
function storeOldGenerals(int $nation, int $year, int $month)
|
||||||
$db = DB::db();
|
{
|
||||||
foreach ($db->query('SELECT * FROM general WHERE nation = %i', $nation) as $general) {
|
$db = DB::db();
|
||||||
$data = convForOldGeneral($general, $year, $month);
|
foreach ($db->query('SELECT * FROM general WHERE nation = %i', $nation) as $general) {
|
||||||
$db->insertUpdate(
|
$data = convForOldGeneral($general, $year, $month);
|
||||||
'ng_old_generals',
|
$db->insertUpdate(
|
||||||
$data,
|
'ng_old_generals',
|
||||||
$data
|
$data,
|
||||||
);
|
$data
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function checkEmperior()
|
|
||||||
{
|
function checkEmperior()
|
||||||
$db = DB::db();
|
{
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$db = DB::db();
|
||||||
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$admin = $gameStor->getValues(['year', 'month', 'isunited', 'conlimit']);
|
|
||||||
if ($admin['isunited'] != 0) {
|
$admin = $gameStor->getValues(['year', 'month', 'isunited', 'conlimit']);
|
||||||
return;
|
if ($admin['isunited'] != 0) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
$remainNations = $db->queryFirstColumn('SELECT nation FROM nation WHERE level > 0 LIMIT 2');
|
|
||||||
|
$remainNations = $db->queryFirstColumn('SELECT nation FROM nation WHERE level > 0 LIMIT 2');
|
||||||
if (!$remainNations || count($remainNations) != 1) {
|
|
||||||
return;
|
if (!$remainNations || count($remainNations) != 1) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
$nationID = $remainNations[0];
|
|
||||||
|
$nationID = $remainNations[0];
|
||||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
|
||||||
|
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||||
$cityCnt = $db->queryFirstField('SELECT count(city) FROM city WHERE nation=%i', $nationID);
|
|
||||||
if (!$cityCnt) {
|
$cityCnt = $db->queryFirstField('SELECT count(city) FROM city WHERE nation=%i', $nationID);
|
||||||
return;
|
if (!$cityCnt) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if ($cityCnt != count(CityConst::all())) {
|
|
||||||
return;
|
if ($cityCnt != count(CityConst::all())) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
checkStatistic();
|
|
||||||
|
checkStatistic();
|
||||||
$nation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID);
|
|
||||||
$nationName = $nation['name'];
|
$nation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID);
|
||||||
|
$nationName = $nation['name'];
|
||||||
$josaYi = JosaUtil::pick($nationName, '이');
|
|
||||||
|
$josaYi = JosaUtil::pick($nationName, '이');
|
||||||
$nationLogger = new ActionLogger(0, $nationID, $admin['year'], $admin['month']);
|
|
||||||
$nationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaYi} 전토를 통일");
|
$nationLogger = new ActionLogger(0, $nationID, $admin['year'], $admin['month']);
|
||||||
|
$nationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaYi} 전토를 통일");
|
||||||
$gameStor->isunited = 2;
|
|
||||||
$gameStor->conlimit = $gameStor->conlimit * 100;
|
$gameStor->isunited = 2;
|
||||||
|
$gameStor->conlimit = $gameStor->conlimit * 100;
|
||||||
foreach ($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo) {
|
|
||||||
CheckHall($hallGeneralNo);
|
foreach ($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo) {
|
||||||
}
|
CheckHall($hallGeneralNo);
|
||||||
|
}
|
||||||
[$totalPop, $totalMaxPop] = $db->queryFirstList('SELECT SUM(pop), SUM(pop_max) FROM city');
|
|
||||||
$pop = "{$totalPop} / {$totalMaxPop}";
|
[$totalPop, $totalMaxPop] = $db->queryFirstList('SELECT SUM(pop), SUM(pop_max) FROM city');
|
||||||
$poprate = round($totalPop / $totalMaxPop * 100, 2). " %";
|
$pop = "{$totalPop} / {$totalMaxPop}";
|
||||||
|
$poprate = round($totalPop / $totalMaxPop * 100, 2). " %";
|
||||||
$chiefs = Util::convertArrayToDict(
|
|
||||||
$db->query(
|
$chiefs = Util::convertArrayToDict(
|
||||||
'SELECT no,name,picture,belong,officer_level FROM general WHERE nation=%i AND officer_level >= 5',
|
$db->query(
|
||||||
$nationID
|
'SELECT no,name,picture,belong,officer_level FROM general WHERE nation=%i AND officer_level >= 5',
|
||||||
),
|
$nationID
|
||||||
'officer_level'
|
),
|
||||||
);
|
'officer_level'
|
||||||
|
);
|
||||||
$nationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nationID);
|
|
||||||
$nation['generals'] = $nationGenerals;
|
$nationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nationID);
|
||||||
|
$nation['generals'] = $nationGenerals;
|
||||||
$tigers = $db->query(
|
|
||||||
'SELECT value, name
|
$tigers = $db->query(
|
||||||
FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no
|
'SELECT value, name
|
||||||
WHERE rank_data.nation_id = %i AND rank_data.type = "killnum" AND value > 0 ORDER BY value DESC LIMIT 5',
|
FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no
|
||||||
$nationID
|
WHERE rank_data.nation_id = %i AND rank_data.type = "killnum" AND value > 0 ORDER BY value DESC LIMIT 5',
|
||||||
); // 오호장군
|
$nationID
|
||||||
|
); // 오호장군
|
||||||
$tigerstr = join(', ', array_map(function ($arr) {
|
|
||||||
$number = number_format($arr['value']);
|
$tigerstr = join(', ', array_map(function ($arr) {
|
||||||
return "{$arr['name']}【{$number}】";
|
$number = number_format($arr['value']);
|
||||||
}, $tigers));
|
return "{$arr['name']}【{$number}】";
|
||||||
|
}, $tigers));
|
||||||
$eagles = $db->query(
|
|
||||||
'SELECT value, name
|
$eagles = $db->query(
|
||||||
FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no
|
'SELECT value, name
|
||||||
WHERE rank_data.nation_id = %i AND rank_data.type = "firenum" AND value > 0 ORDER BY value DESC LIMIT 7',
|
FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no
|
||||||
$nationID
|
WHERE rank_data.nation_id = %i AND rank_data.type = "firenum" AND value > 0 ORDER BY value DESC LIMIT 7',
|
||||||
); // 건안칠자
|
$nationID
|
||||||
|
); // 건안칠자
|
||||||
$eaglestr = join(', ', array_map(function ($arr) {
|
|
||||||
$number = number_format($arr['value']);
|
$eaglestr = join(', ', array_map(function ($arr) {
|
||||||
return "{$arr['name']}【{$number}】";
|
$number = number_format($arr['value']);
|
||||||
}, $eagles));
|
return "{$arr['name']}【{$number}】";
|
||||||
|
}, $eagles));
|
||||||
$rawGeneralList = $db->query('SELECT no, name, npc, owner FROM general WHERE nation=%i ORDER BY dedication DESC', $nationID);
|
|
||||||
foreach ($rawGeneralList as $rawGeneral) {
|
$rawGeneralList = $db->query('SELECT no, name, npc, owner FROM general WHERE nation=%i ORDER BY dedication DESC', $nationID);
|
||||||
$generalLogger = new ActionLogger($rawGeneral['no'], $nationID, $admin['year'], $admin['month']);
|
foreach ($rawGeneralList as $rawGeneral) {
|
||||||
$generalLogger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaYi} 전토를 통일하였습니다.", ActionLogger::YEAR_MONTH);
|
$generalLogger = new ActionLogger($rawGeneral['no'], $nationID, $admin['year'], $admin['month']);
|
||||||
$generalLogger->flush();
|
$generalLogger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaYi} 전토를 통일하였습니다.", ActionLogger::YEAR_MONTH);
|
||||||
}
|
$generalLogger->flush();
|
||||||
|
}
|
||||||
$gen = join(', ', array_column($rawGeneral, 'name'));
|
|
||||||
|
$gen = join(', ', array_column($rawGeneral, 'name'));
|
||||||
$stat = $db->queryFirstRow('SELECT max(nation_count) as nc, max(gen_count) as gc FROM statistic');
|
|
||||||
$genCnt = $db->queryFirstField('SELECT count(*) FROM general');
|
$stat = $db->queryFirstRow('SELECT max(nation_count) as nc, max(gen_count) as gc FROM statistic');
|
||||||
|
$genCnt = $db->queryFirstField('SELECT count(*) FROM general');
|
||||||
$statNC = "1 / {$stat['nc']}";
|
|
||||||
$statGC = "{$genCnt} / {$stat['gc']}";
|
$statNC = "1 / {$stat['nc']}";
|
||||||
$statNation = $db->queryFirstRow('SELECT nation_count,nation_name,nation_hist from statistic where nation_count=%i LIMIT 1', $stat['nc']);
|
$statGC = "{$genCnt} / {$stat['gc']}";
|
||||||
$statGeneral = $db->queryFirstRow('SELECT gen_count,personal_hist,special_hist,aux from statistic order by no desc LIMIT 1');
|
$statNation = $db->queryFirstRow('SELECT nation_count,nation_name,nation_hist from statistic where nation_count=%i LIMIT 1', $stat['nc']);
|
||||||
|
$statGeneral = $db->queryFirstRow('SELECT gen_count,personal_hist,special_hist,aux from statistic order by no desc LIMIT 1');
|
||||||
$nation = $nation;
|
|
||||||
$nation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']);
|
$nation = $nation;
|
||||||
$nation['aux'] = Json::decode($nation['aux']);
|
$nation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']);
|
||||||
$nation['msg'] = $nationStor->notice;
|
$nation['aux'] = Json::decode($nation['aux']);
|
||||||
$nation['scout_msg'] = $nationStor->scout_msg;
|
$nation['msg'] = $nationStor->notice;
|
||||||
$nation['aux'] += $nationStor->max_power;
|
$nation['scout_msg'] = $nationStor->scout_msg;
|
||||||
$nation['history'] = getNationHistoryLogAll($nation['nation']);
|
$nation['aux'] += $nationStor->max_power;
|
||||||
|
$nation['history'] = getNationHistoryLogAll($nation['nation']);
|
||||||
storeOldGenerals(0, $admin['year'], $admin['month']);
|
|
||||||
storeOldGenerals($nation['nation'], $admin['year'], $admin['month']);
|
storeOldGenerals(0, $admin['year'], $admin['month']);
|
||||||
|
storeOldGenerals($nation['nation'], $admin['year'], $admin['month']);
|
||||||
$db->insert('ng_old_nations', [
|
|
||||||
'server_id' => UniqueConst::$serverID,
|
$db->insert('ng_old_nations', [
|
||||||
'nation' => $nation['nation'],
|
'server_id' => UniqueConst::$serverID,
|
||||||
'data' => Json::encode($nation)
|
'nation' => $nation['nation'],
|
||||||
]);
|
'data' => Json::encode($nation)
|
||||||
|
]);
|
||||||
$noNationGeneral = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=0');
|
|
||||||
$db->insert('ng_old_nations', [
|
$noNationGeneral = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=0');
|
||||||
'server_id' => UniqueConst::$serverID,
|
$db->insert('ng_old_nations', [
|
||||||
'nation' => 0,
|
'server_id' => UniqueConst::$serverID,
|
||||||
'data' => Json::encode([
|
'nation' => 0,
|
||||||
'nation' => 0,
|
'data' => Json::encode([
|
||||||
'name' => '재야',
|
'nation' => 0,
|
||||||
'generals' => $noNationGeneral
|
'name' => '재야',
|
||||||
])
|
'generals' => $noNationGeneral
|
||||||
]);
|
])
|
||||||
|
]);
|
||||||
$nationHistory = getNationHistoryLogAll($nation['nation']);
|
|
||||||
|
$nationHistory = getNationHistoryLogAll($nation['nation']);
|
||||||
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games');
|
|
||||||
$serverName = UniqueConst::$serverName;
|
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games');
|
||||||
|
$serverName = UniqueConst::$serverName;
|
||||||
$db->update('ng_games', [
|
|
||||||
'winner_nation' => $nation['nation']
|
$db->update('ng_games', [
|
||||||
], 'server_id=%s', UniqueConst::$serverID);
|
'winner_nation' => $nation['nation']
|
||||||
|
], 'server_id=%s', UniqueConst::$serverID);
|
||||||
$db->insert('emperior', [
|
|
||||||
'phase' => $serverName . $serverCnt . '기',
|
$db->insert('emperior', [
|
||||||
'server_id' => UniqueConst::$serverID,
|
'phase' => $serverName . $serverCnt . '기',
|
||||||
'nation_count' => $statNC,
|
'server_id' => UniqueConst::$serverID,
|
||||||
'nation_name' => $statNation['nation_name'],
|
'nation_count' => $statNC,
|
||||||
'nation_hist' => $statNation['nation_hist'],
|
'nation_name' => $statNation['nation_name'],
|
||||||
'gen_count' => $statGC,
|
'nation_hist' => $statNation['nation_hist'],
|
||||||
'personal_hist' => $statGeneral['personal_hist'],
|
'gen_count' => $statGC,
|
||||||
'special_hist' => $statGeneral['special_hist'],
|
'personal_hist' => $statGeneral['personal_hist'],
|
||||||
'name' => $nation['name'],
|
'special_hist' => $statGeneral['special_hist'],
|
||||||
'type' => $nation['type'],
|
'name' => $nation['name'],
|
||||||
'color' => $nation['color'],
|
'type' => $nation['type'],
|
||||||
'year' => $admin['year'],
|
'color' => $nation['color'],
|
||||||
'month' => $admin['month'],
|
'year' => $admin['year'],
|
||||||
'power' => $nation['power'],
|
'month' => $admin['month'],
|
||||||
'gennum' => $nation['gennum'],
|
'power' => $nation['power'],
|
||||||
'citynum' => $cityCnt,
|
'gennum' => $nation['gennum'],
|
||||||
'pop' => $pop,
|
'citynum' => $cityCnt,
|
||||||
'poprate' => $poprate,
|
'pop' => $pop,
|
||||||
'gold' => $nation['gold'],
|
'poprate' => $poprate,
|
||||||
'rice' => $nation['rice'],
|
'gold' => $nation['gold'],
|
||||||
'l12name' => $chiefs[12]['name'],
|
'rice' => $nation['rice'],
|
||||||
'l12pic' => $chiefs[12]['picture'],
|
'l12name' => $chiefs[12]['name'],
|
||||||
'l11name' => $chiefs[11]['name'],
|
'l12pic' => $chiefs[12]['picture'],
|
||||||
'l11pic' => $chiefs[11]['picture'],
|
'l11name' => $chiefs[11]['name'],
|
||||||
'l10name' => $chiefs[10]['name'],
|
'l11pic' => $chiefs[11]['picture'],
|
||||||
'l10pic' => $chiefs[10]['picture'],
|
'l10name' => $chiefs[10]['name'],
|
||||||
'l9name' => $chiefs[9]['name'],
|
'l10pic' => $chiefs[10]['picture'],
|
||||||
'l9pic' => $chiefs[9]['picture'],
|
'l9name' => $chiefs[9]['name'],
|
||||||
'l8name' => $chiefs[8]['name'],
|
'l9pic' => $chiefs[9]['picture'],
|
||||||
'l8pic' => $chiefs[8]['picture'],
|
'l8name' => $chiefs[8]['name'],
|
||||||
'l7name' => $chiefs[7]['name'],
|
'l8pic' => $chiefs[8]['picture'],
|
||||||
'l7pic' => $chiefs[7]['picture'],
|
'l7name' => $chiefs[7]['name'],
|
||||||
'l6name' => $chiefs[6]['name'],
|
'l7pic' => $chiefs[7]['picture'],
|
||||||
'l6pic' => $chiefs[6]['picture'],
|
'l6name' => $chiefs[6]['name'],
|
||||||
'l5name' => $chiefs[5]['name'],
|
'l6pic' => $chiefs[6]['picture'],
|
||||||
'l5pic' => $chiefs[5]['picture'],
|
'l5name' => $chiefs[5]['name'],
|
||||||
'tiger' => $tigerstr,
|
'l5pic' => $chiefs[5]['picture'],
|
||||||
'eagle' => $eaglestr,
|
'tiger' => $tigerstr,
|
||||||
'gen' => $gen,
|
'eagle' => $eaglestr,
|
||||||
'history' => JSON::encode($nationHistory),
|
'gen' => $gen,
|
||||||
'aux' => $statGeneral['aux']
|
'history' => JSON::encode($nationHistory),
|
||||||
]);
|
'aux' => $statGeneral['aux']
|
||||||
|
]);
|
||||||
$history = ["<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【통일】</b></><D><b>{$nation['name']}</b></>{$josaYi} 전토를 통일하였습니다."];
|
|
||||||
pushGlobalHistoryLog($history, $admin['year'], $admin['month']);
|
$history = ["<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【통일】</b></><D><b>{$nation['name']}</b></>{$josaYi} 전토를 통일하였습니다."];
|
||||||
|
pushGlobalHistoryLog($history, $admin['year'], $admin['month']);
|
||||||
//연감 월결산
|
|
||||||
LogHistory();
|
//연감 월결산
|
||||||
}
|
LogHistory();
|
||||||
|
}
|
||||||
|
|||||||
+274
-270
@@ -1,270 +1,274 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 템플릿 생성과 관련된 함수들을 모아두는 파일
|
* 템플릿 생성과 관련된 함수들을 모아두는 파일
|
||||||
*
|
*
|
||||||
* NOTE: 아직 converter와 명확한 구분이 되어있지 않음.
|
* NOTE: 아직 converter와 명확한 구분이 되어있지 않음.
|
||||||
* TODO: legacy template들을 전부 template 폴더로 모아둘 필요 있음
|
* TODO: legacy template들을 전부 template 폴더로 모아둘 필요 있음
|
||||||
* TODO: side effect를 제거
|
* TODO: side effect를 제거
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 관리자 권한이 필요함을 출력.
|
* 관리자 권한이 필요함을 출력.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function requireAdminPermissionHTML()
|
function requireAdminPermissionHTML()
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>관리메뉴</title>
|
<title>관리메뉴</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=1024" />
|
<meta name="viewport" content="width=1024" />
|
||||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||||
<?= WebUtil::printCSS('css/common.css') ?>
|
<?= WebUtil::printCSS('css/common.css') ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
관리자가 아닙니다.<br>
|
관리자가 아닙니다.<br>
|
||||||
<?= banner() ?>
|
<?= banner() ?>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
function turnTable()
|
function turnTable()
|
||||||
{
|
{
|
||||||
|
|
||||||
$turnList = [];
|
$turnList = [];
|
||||||
$turnList[] = "<option selected value='0'>1턴</option>";
|
$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;
|
$turnText = $turnIdx + 1;
|
||||||
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
|
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$turnText = join("\n", $turnList);
|
$turnText = join("\n", $turnList);
|
||||||
|
|
||||||
return "
|
return "
|
||||||
<select id='generalTurnSelector' name=turn[] size=11 multiple>
|
<select id='generalTurnSelector' name=turn[] size=11 multiple>
|
||||||
<option value='-3'>전체</option>
|
<option value='-3'>전체</option>
|
||||||
<option value='-1'>홀턴</option>
|
<option value='-1'>홀턴</option>
|
||||||
<option value='-2'>짝턴</option>
|
<option value='-2'>짝턴</option>
|
||||||
{$turnText}
|
{$turnText}
|
||||||
</select>
|
</select>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
function chiefTurnTable()
|
function chiefTurnTable()
|
||||||
{
|
{
|
||||||
$turnList = [];
|
$turnList = [];
|
||||||
$turnList[] = "<option selected value='0'>1턴</option>";
|
$turnList[] = "<option selected value='0'>1턴</option>";
|
||||||
foreach (Util::range(1, GameConst::$maxChiefTurn) as $turnIdx) {
|
foreach (Util::range(1, GameConst::$maxChiefTurn) as $turnIdx) {
|
||||||
$turnText = $turnIdx + 1;
|
$turnText = $turnIdx + 1;
|
||||||
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
|
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$turnText = join("\n", $turnList);
|
$turnText = join("\n", $turnList);
|
||||||
|
|
||||||
return "
|
return "
|
||||||
<select id='chiefTurnSelector' name=turn[] size=6 multiple>
|
<select id='chiefTurnSelector' name=turn[] size=6 multiple>
|
||||||
{$turnText}
|
{$turnText}
|
||||||
</select>
|
</select>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayiActionObjInfo(?iAction $action)
|
function displayiActionObjInfo(?iAction $action)
|
||||||
{
|
{
|
||||||
if ($action === null) {
|
if ($action === null) {
|
||||||
$info = '';
|
$info = '';
|
||||||
$text = '-';
|
$text = '-';
|
||||||
} else {
|
} else {
|
||||||
$info = $action->getInfo();
|
$info = $action->getInfo();
|
||||||
$text = $action->getName();
|
$text = $action->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||||
|
|
||||||
return $templates->render('tooltip', [
|
return $templates->render('tooltip', [
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'info' => $info,
|
'info' => $info,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
function displayCharInfo(string $type): string
|
function displayCharInfo(string $type): string
|
||||||
{
|
{
|
||||||
$class = buildPersonalityClass($type);
|
$class = buildPersonalityClass($type);
|
||||||
$info = $class->getInfo();
|
$info = $class->getInfo();
|
||||||
$text = $class->getName();
|
$text = $class->getName();
|
||||||
|
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||||
|
|
||||||
return $templates->render('tooltip', [
|
return $templates->render('tooltip', [
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'info' => $info,
|
'info' => $info,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function displaySpecialWarInfo(?string $type): string
|
function displaySpecialWarInfo(?string $type): string
|
||||||
{
|
{
|
||||||
$class = buildGeneralSpecialWarClass($type);
|
$class = buildGeneralSpecialWarClass($type);
|
||||||
$info = $class->getInfo();
|
$info = $class->getInfo();
|
||||||
$name = $class->getName();
|
$name = $class->getName();
|
||||||
|
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||||
|
|
||||||
return $templates->render('tooltip', [
|
return $templates->render('tooltip', [
|
||||||
'text' => $name,
|
'text' => $name,
|
||||||
'info' => $info,
|
'info' => $info,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function displaySpecialDomesticInfo(?string $type): string
|
function displaySpecialDomesticInfo(?string $type): string
|
||||||
{
|
{
|
||||||
$class = buildGeneralSpecialDomesticClass($type);
|
$class = buildGeneralSpecialDomesticClass($type);
|
||||||
$info = $class->getInfo();
|
$info = $class->getInfo();
|
||||||
$name = $class->getName();
|
$name = $class->getName();
|
||||||
|
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||||
|
|
||||||
return $templates->render('tooltip', [
|
return $templates->render('tooltip', [
|
||||||
'text' => $name,
|
'text' => $name,
|
||||||
'info' => $info,
|
'info' => $info,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function allButton(bool $seizeNPCMode)
|
function allButton(bool $seizeNPCMode)
|
||||||
{
|
{
|
||||||
if ($seizeNPCMode) {
|
if ($seizeNPCMode) {
|
||||||
$site = "a_npcList.php";
|
$site = "a_npcList.php";
|
||||||
$call = "빙의일람";
|
$call = "빙의일람";
|
||||||
} else {
|
} else {
|
||||||
$site = "a_vote.php";
|
$site = "a_vote.php";
|
||||||
$call = "설문조사";
|
$call = "설문조사";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . "/d_setting/templates/allButton.php")) {
|
if (\file_exists(__DIR__ . "/d_setting/templates/allButton.php")) {
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/d_setting/templates');
|
$templates = new \League\Plates\Engine(__DIR__ . '/d_setting/templates');
|
||||||
} else {
|
} else {
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $templates->render('allButton', [
|
return $templates->render('allButton', [
|
||||||
'call' => $call,
|
'call' => $call,
|
||||||
'site' => $site
|
'site' => $site
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function commandButton()
|
function commandButton()
|
||||||
{
|
{
|
||||||
$session = Session::getInstance();
|
$session = Session::getInstance();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
if (!$session->isGameLoggedIn()) {
|
if (!$session->isGameLoggedIn()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$me = $db->queryFirstRow("select no,nation,officer_level,belong,permission,penalty from general where owner=%i", $userID);
|
$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 = $db->queryFirstRow("select nation,level,color,secretlimit from nation where nation=%i", $me['nation']) ?? [
|
||||||
'nation' => 0,
|
'nation' => 0,
|
||||||
'level' => 0,
|
'level' => 0,
|
||||||
'secretlimit' => 99,
|
'secretlimit' => 99,
|
||||||
'color' => '#000000'
|
'color' => '#000000'
|
||||||
];
|
];
|
||||||
|
|
||||||
$bgColor = Util::array_get($nation['color']) ?: '#000000';
|
$bgColor = Util::array_get($nation['color']) ?: '#000000';
|
||||||
$fgColor = newColor($bgColor);
|
$fgColor = newColor($bgColor);
|
||||||
|
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||||
$showSecret = false;
|
$showSecret = false;
|
||||||
$permission = checkSecretPermission($me);
|
$permission = checkSecretPermission($me);
|
||||||
if ($permission >= 1) {
|
if ($permission >= 1) {
|
||||||
$showSecret = true;
|
$showSecret = true;
|
||||||
} else if ($me['officer_level'] == 0) {
|
} else if ($me['officer_level'] == 0) {
|
||||||
$showSecret = false;
|
$showSecret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $templates->render('commandButton', [
|
return $templates->render('commandButton', [
|
||||||
'bgColor' => $bgColor,
|
'bgColor' => $bgColor,
|
||||||
'fgColor' => $fgColor,
|
'fgColor' => $fgColor,
|
||||||
'meLevel' => $me['officer_level'],
|
'meLevel' => $me['officer_level'],
|
||||||
'nationLevel' => $nation['level'],
|
'nationLevel' => $nation['level'],
|
||||||
'showSecret' => $showSecret,
|
'showSecret' => $showSecret,
|
||||||
'permission' => $permission,
|
'permission' => $permission,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatWounded(int $value, int $wound): string
|
function formatWounded(int $value, int $wound): string
|
||||||
{
|
{
|
||||||
if ($wound == 0) {
|
if ($wound == 0) {
|
||||||
return "$value";
|
return "$value";
|
||||||
}
|
}
|
||||||
$woundedValue = intdiv($value * (100 - $wound), 100);
|
$woundedValue = intdiv($value * (100 - $wound), 100);
|
||||||
return "<font color=red>$woundedValue</font>";
|
return "<font color=red>$woundedValue</font>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDefenceTrain(int $value): string
|
function formatDefenceTrain(int $value): string
|
||||||
{
|
{
|
||||||
if ($value === 999) {
|
if ($value === 999) {
|
||||||
return "×";
|
return "×";
|
||||||
} else if ($value >= 80) {
|
} else if ($value >= 90){
|
||||||
return "◎";
|
return "☆";
|
||||||
} else {
|
} else if ($value >= 80) {
|
||||||
return "○";
|
return "◎";
|
||||||
}
|
} else if ($value >= 60) {
|
||||||
}
|
return "○";
|
||||||
|
} else{
|
||||||
function formatLeadershipBonus(int $value): string
|
return "△";
|
||||||
{
|
}
|
||||||
if ($value == 0) {
|
}
|
||||||
return '';
|
|
||||||
}
|
function formatLeadershipBonus(int $value): string
|
||||||
return "<font color=cyan>+{$value}</font>";
|
{
|
||||||
}
|
if ($value == 0) {
|
||||||
|
return '';
|
||||||
function formatName(string $name, int $npc): string
|
}
|
||||||
{
|
return "<font color=cyan>+{$value}</font>";
|
||||||
if ($npc == 1) {
|
}
|
||||||
$name = "<font color='skyblue'>$name</font>";
|
|
||||||
} else if ($npc > 1) {
|
function formatName(string $name, int $npc): string
|
||||||
$name = "<font color='cyan'>$name</font>";
|
{
|
||||||
}
|
if ($npc == 1) {
|
||||||
return $name;
|
$name = "<font color='skyblue'>$name</font>";
|
||||||
}
|
} else if ($npc > 1) {
|
||||||
|
$name = "<font color='cyan'>$name</font>";
|
||||||
function getMapHtml(?string $mapTheme = null)
|
}
|
||||||
{
|
return $name;
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
}
|
||||||
|
|
||||||
if ($mapTheme === null) {
|
function getMapHtml(?string $mapTheme = null)
|
||||||
$db = DB::db();
|
{
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||||
$mapTheme = $gameStor->map_theme ?? 'che';
|
|
||||||
}
|
if ($mapTheme === null) {
|
||||||
|
$db = DB::db();
|
||||||
return $templates->render('map', [
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
'mapTheme' => $mapTheme
|
$mapTheme = $gameStor->map_theme ?? 'che';
|
||||||
]);
|
}
|
||||||
}
|
|
||||||
|
return $templates->render('map', [
|
||||||
function getInvitationList(array $nationList)
|
'mapTheme' => $mapTheme
|
||||||
{
|
]);
|
||||||
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
}
|
||||||
|
|
||||||
foreach ($nationList as &$nation) {
|
function getInvitationList(array $nationList)
|
||||||
$nation['textColor'] = newColor($nation['color']);
|
{
|
||||||
}
|
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
||||||
return $templates->render('invitationList', [
|
|
||||||
'nationList' => $nationList
|
foreach ($nationList as &$nation) {
|
||||||
]);
|
$nation['textColor'] = newColor($nation['color']);
|
||||||
}
|
}
|
||||||
|
return $templates->render('invitationList', [
|
||||||
|
'nationList' => $nationList
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|||||||
@@ -523,7 +523,7 @@ function selection($tnmt_type, $tnmt, $phase) {
|
|||||||
if($phase < 31) {
|
if($phase < 31) {
|
||||||
$gameStor->phase+=1;
|
$gameStor->phase+=1;
|
||||||
} else {
|
} else {
|
||||||
$gameStor->tournamemt = 4;
|
$gameStor->tournament = 4;
|
||||||
$gameStor->phase=0;
|
$gameStor->phase=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ $scenario = $gameStor->scenario_text;
|
|||||||
$nationID = $generalObj->getNationID();
|
$nationID = $generalObj->getNationID();
|
||||||
if($nationID){
|
if($nationID){
|
||||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||||
$nationStor->cacheValues(['notice', 'online_genenerals']);
|
$nationStor->cacheAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
$valid = 0;
|
$valid = 0;
|
||||||
|
|||||||
+100
-100
@@ -1,101 +1,101 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include 'lib.php';
|
include 'lib.php';
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
if (!$db->queryFirstField("SHOW TABLES LIKE 'reserved_open'")) {
|
if (!$db->queryFirstField("SHOW TABLES LIKE 'reserved_open'")) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'affected'=>0,
|
'affected'=>0,
|
||||||
'status'=>'no_reserved_table'
|
'status'=>'no_reserved_table'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$reserved = $db->queryFirstRow('SELECT `date`, options FROM reserved_open ORDER BY `date` ASC LIMIT 1');
|
$reserved = $db->queryFirstRow('SELECT `date`, options FROM reserved_open ORDER BY `date` ASC LIMIT 1');
|
||||||
|
|
||||||
if(!$reserved){
|
if(!$reserved){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'affected'=>0,
|
'affected'=>0,
|
||||||
'status'=>'no_reserved'
|
'status'=>'no_reserved'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$reservedDate = new \DateTime($reserved['date']);
|
$reservedDate = new \DateTime($reserved['date']);
|
||||||
$now = new \DateTime();
|
$now = new \DateTime();
|
||||||
|
|
||||||
|
|
||||||
$status = 'not_yet';
|
$status = 'not_yet';
|
||||||
|
|
||||||
list($isUnited, $lastTurn) = $gameStor->getValuesAsArray(['isunited', 'turntime']);
|
list($isUnited, $lastTurn) = $gameStor->getValuesAsArray(['isunited', 'turntime']);
|
||||||
if($isUnited === null || $lastTurn === null){
|
if($isUnited === null || $lastTurn === null){
|
||||||
$isUnited = 2;
|
$isUnited = 2;
|
||||||
$lastTurn = '2000-01-01';
|
$lastTurn = '2000-01-01';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($lastTurn !== null){
|
if($lastTurn !== null){
|
||||||
$lastTurn = new \DateTime($lastTurn);
|
$lastTurn = new \DateTime($lastTurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($lastTurn === null){
|
if($lastTurn === null){
|
||||||
//이미 리셋된 상태임
|
//이미 리셋된 상태임
|
||||||
}
|
}
|
||||||
else if(file_exists(__DIR__.'/.htaccess')){
|
else if(file_exists(__DIR__.'/.htaccess')){
|
||||||
//일단 서버는 닫혀 있음
|
//일단 서버는 닫혀 있음
|
||||||
}
|
}
|
||||||
else if(
|
else if(
|
||||||
$isUnited == 2 &&
|
$isUnited == 2 &&
|
||||||
$now->getTimestamp() - $lastTurn->getTimestamp() > $reservedDate->getTimestamp() - $now->getTimestamp()
|
$now->getTimestamp() - $lastTurn->getTimestamp() > $reservedDate->getTimestamp() - $now->getTimestamp()
|
||||||
){
|
){
|
||||||
//정지 상태 & 중간 넘음
|
//정지 상태 & 중간 넘음
|
||||||
AppConf::getList()[DB::prefix()]->closeServer();
|
ServConfig::getServerList()[DB::prefix()]->closeServer();
|
||||||
$status = 'closed';
|
$status = 'closed';
|
||||||
}
|
}
|
||||||
else if(
|
else if(
|
||||||
$isUnited > 0 &&
|
$isUnited > 0 &&
|
||||||
$now->getTimestamp() - $lastTurn->getTimestamp() > ($reservedDate->getTimestamp() - $now->getTimestamp()) * 2
|
$now->getTimestamp() - $lastTurn->getTimestamp() > ($reservedDate->getTimestamp() - $now->getTimestamp()) * 2
|
||||||
){
|
){
|
||||||
//천통 & 비정지 상태 & 2/3 넘음
|
//천통 & 비정지 상태 & 2/3 넘음
|
||||||
AppConf::getList()[DB::prefix()]->closeServer();
|
ServConfig::getServerList()[DB::prefix()]->closeServer();
|
||||||
$status = 'closed';
|
$status = 'closed';
|
||||||
}
|
}
|
||||||
else if($reservedDate->getTimestamp() - $now->getTimestamp() <= 60*10){
|
else if($reservedDate->getTimestamp() - $now->getTimestamp() <= 60*10){
|
||||||
//어쨌든 간에 10분 남았다면.
|
//어쨌든 간에 10분 남았다면.
|
||||||
AppConf::getList()[DB::prefix()]->closeServer();
|
ServConfig::getServerList()[DB::prefix()]->closeServer();
|
||||||
$status = 'closed';
|
$status = 'closed';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($now < $reservedDate){
|
if($now < $reservedDate){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'affected'=>0,
|
'affected'=>0,
|
||||||
'status'=>$status
|
'status'=>$status
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = Json::decode($reserved['options']);
|
$options = Json::decode($reserved['options']);
|
||||||
|
|
||||||
$result = ResetHelper::buildScenario(
|
$result = ResetHelper::buildScenario(
|
||||||
$options['turnterm'],
|
$options['turnterm'],
|
||||||
$options['sync'],
|
$options['sync'],
|
||||||
$options['scenario'],
|
$options['scenario'],
|
||||||
$options['fiction'],
|
$options['fiction'],
|
||||||
$options['extend'],
|
$options['extend'],
|
||||||
$options['npcmode'],
|
$options['npcmode'],
|
||||||
$options['show_img_level'],
|
$options['show_img_level'],
|
||||||
$options['tournament_trig'],
|
$options['tournament_trig'],
|
||||||
$options['join_mode'],
|
$options['join_mode'],
|
||||||
$options['starttime'],
|
$options['starttime'],
|
||||||
$options['autorun_user']?:null
|
$options['autorun_user']?:null
|
||||||
);
|
);
|
||||||
|
|
||||||
$result['affected']=1;
|
$result['affected']=1;
|
||||||
|
|
||||||
$prefix = DB::prefix();
|
$prefix = DB::prefix();
|
||||||
AppConf::getList()[$prefix]->openServer();
|
ServConfig::getServerList()[$prefix]->openServer();
|
||||||
|
|
||||||
Json::die($result);
|
Json::die($result);
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
include "lib.php";
|
||||||
|
include "func.php";
|
||||||
|
|
||||||
|
WebUtil::requireAJAX();
|
||||||
|
|
||||||
|
$destGeneralID = Util::getPost('destGeneralID', 'int', 0);
|
||||||
|
|
||||||
|
if(!$destGeneralID || $destGeneralID <= 0){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'올바르지 않은 장수 코드입니다'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$session = Session::requireGameLogin([])->setReadOnly();
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
|
||||||
|
increaseRefresh("시뮬레이터 추출", 1);
|
||||||
|
|
||||||
|
$userID = Session::getUserID();
|
||||||
|
$me = $db->queryFirstRow('SELECT no,nation from general where owner=%i', $userID);
|
||||||
|
$nationID = $me['nation'];
|
||||||
|
|
||||||
|
$reqColumns = [
|
||||||
|
'nation',
|
||||||
|
'name', 'officer_level', 'explevel', 'injury',
|
||||||
|
'leadership', 'horse', 'strength', 'weapon', 'intel', 'book', 'item',
|
||||||
|
'rice', 'personal', 'special2',
|
||||||
|
'crew', 'crewtype',
|
||||||
|
'atmos', 'train', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'defence_train',
|
||||||
|
];
|
||||||
|
|
||||||
|
$reqRankColumns = [
|
||||||
|
'warnum', 'killnum', 'killcrew'
|
||||||
|
];
|
||||||
|
|
||||||
|
$dummyItems = [
|
||||||
|
'officer_level'=>1,
|
||||||
|
'horse'=>'None',
|
||||||
|
'weapon'=>'None',
|
||||||
|
'book'=>'None',
|
||||||
|
'item'=>'None',
|
||||||
|
'crew'=>0,
|
||||||
|
'crewtype'=>GameUnitConst::DEFAULT_CREWTYPE,
|
||||||
|
'rice'=>10000,
|
||||||
|
'train'=>GameConst::$maxTrainByCommand,
|
||||||
|
'atmos'=>GameConst::$maxTrainByCommand,
|
||||||
|
'dex1'=>0,
|
||||||
|
'dex2'=>0,
|
||||||
|
'dex3'=>0,
|
||||||
|
'dex4'=>0,
|
||||||
|
'dex5'=>0,
|
||||||
|
'defence_train'=>80,
|
||||||
|
'warnum'=>0,
|
||||||
|
'killnum'=>0,
|
||||||
|
'killcrew'=>0,
|
||||||
|
];
|
||||||
|
|
||||||
|
$rawDestGeneral = $db->queryFirstRow('SELECT %l FROM general WHERE no=%i', Util::formatListOfBackticks($reqColumns), $destGeneralID);
|
||||||
|
|
||||||
|
if($nationID == 0 || $rawDestGeneral['nation'] != $nationID){
|
||||||
|
foreach($dummyItems as $key=>$val){
|
||||||
|
$rawDestGeneral[$key] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$rawRankValue = $db->queryAllLists('SELECT `type`, `value` FROM rank_data WHERE general_id = %i AND `type` IN %ls', $destGeneralID, $reqRankColumns);
|
||||||
|
foreach($rawRankValue as [$rankType, $rankValue]){
|
||||||
|
$rawDestGeneral[$rankType] = $rankValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(['dex1', 'dex2', 'dex3', 'dex4', 'dex5'] as $dexKey){
|
||||||
|
$dex = $rawDestGeneral[$dexKey];
|
||||||
|
$rawDestGeneral[$dexKey] = getDexLevelList()[getDexLevel($dex)][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
Json::die([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success',
|
||||||
|
'general'=>$rawDestGeneral,
|
||||||
|
]);
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
include "lib.php";
|
||||||
|
include "func.php";
|
||||||
|
|
||||||
|
//로그인 검사
|
||||||
|
$session = Session::requireGameLogin([]);
|
||||||
|
$generalID = Session::getGeneralID();
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
|
||||||
|
$rawList = Util::convertArrayToDict($db->query('SELECT no, name, npc, nation FROM general'), 'no');
|
||||||
|
$nationID = $rawList[$generalID]['nation'];
|
||||||
|
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success',
|
||||||
|
'nationID'=>$nationID,
|
||||||
|
'generalID'=>$generalID,
|
||||||
|
'column'=>['no', 'name', 'npc']
|
||||||
|
];
|
||||||
|
|
||||||
|
$resultItem = [];
|
||||||
|
foreach(Util::arrayGroupBy($rawList, 'nation') as $subNationID=>$generals){
|
||||||
|
$subNation = [];
|
||||||
|
foreach($generals as $general){
|
||||||
|
$subNation[] = [$general['no'], $general['name'], $general['npc']];
|
||||||
|
}
|
||||||
|
$resultItem[$subNationID] = $subNation;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['list'] = $resultItem;
|
||||||
|
$result['nation'] = Util::convertArrayToDict($db->query('SELECT nation, name, color FROM nation'), 'nation');
|
||||||
|
Json::die($result);
|
||||||
+109
-109
@@ -1,109 +1,109 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
|
|
||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireLogin();
|
$session = Session::requireLogin([]);
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$withToken = Util::getPost('with_token', 'bool', false);
|
$withToken = Util::getPost('with_token', 'bool', false);
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
if($session->isGameLoggedIn()){
|
if($session->isGameLoggedIn()){
|
||||||
increaseRefresh("장수일람", 2);
|
increaseRefresh("장수일람", 2);
|
||||||
|
|
||||||
$me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner=%i', $userID);
|
$me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner=%i', $userID);
|
||||||
$con = checkLimit($me['con']);
|
$con = checkLimit($me['con']);
|
||||||
if ($con >= 2) {
|
if ($con >= 2) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'접속 제한중입니다. 1턴 이내에 너무 많은 갱신을 하셨습니다.'
|
'reason'=>'접속 제한중입니다. 1턴 이내에 너무 많은 갱신을 하셨습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$availableNextCall = $session->availableNextCallGetGeneralList??'2000-01-01 00:00:00';
|
$availableNextCall = $session->availableNextCallGetGeneralList??'2000-01-01 00:00:00';
|
||||||
$now = new \DateTimeImmutable();
|
$now = new \DateTimeImmutable();
|
||||||
|
|
||||||
if($now <= new \DateTimeImmutable($availableNextCall) && $session->userGrade < 5){
|
if($now <= new \DateTimeImmutable($availableNextCall) && $session->userGrade < 5){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>"장수 리스트는 10초에 한번 갱신 가능합니다.\n다음 시간 : ".$availableNextCall
|
'reason'=>"장수 리스트는 10초에 한번 갱신 가능합니다.\n다음 시간 : ".$availableNextCall
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$availableNextCall = $now->add(new \DateInterval('PT10S'))->format('Y-m-d H:i:s');
|
$availableNextCall = $now->add(new \DateInterval('PT10S'))->format('Y-m-d H:i:s');
|
||||||
$session->availableNextCallGetGeneralList = $availableNextCall;
|
$session->availableNextCallGetGeneralList = $availableNextCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
$session->setReadOnly();
|
$session->setReadOnly();
|
||||||
|
|
||||||
$rawGeneralList = $db->queryAllLists('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,owner_name as ownerName,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect from general');
|
$rawGeneralList = $db->queryAllLists('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,owner_name as ownerName,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect from general');
|
||||||
|
|
||||||
$ownerNameList = [];
|
$ownerNameList = [];
|
||||||
if($gameStor->isunited){
|
if($gameStor->isunited){
|
||||||
foreach(RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]){
|
foreach(RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]){
|
||||||
$ownerNameList[$ownerID] = $ownerName;
|
$ownerNameList[$ownerID] = $ownerName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$generalList = [];
|
$generalList = [];
|
||||||
foreach($rawGeneralList as $rawGeneral){
|
foreach($rawGeneralList as $rawGeneral){
|
||||||
[$owner,$no,$picture,$imgsvr,$npc,$age,$nation,$special,$special2,$personal,$name,$ownerName,$injury,$leadership,$strength,$intel,$experience,$dedication,$officerLevel,$killturn,$connectCnt] = $rawGeneral;
|
[$owner,$no,$picture,$imgsvr,$npc,$age,$nation,$special,$special2,$personal,$name,$ownerName,$injury,$leadership,$strength,$intel,$experience,$dedication,$officerLevel,$killturn,$connectCnt] = $rawGeneral;
|
||||||
|
|
||||||
if(key_exists($owner, $ownerNameList)){
|
if(key_exists($owner, $ownerNameList)){
|
||||||
$ownerName = $ownerNameList[$owner];
|
$ownerName = $ownerNameList[$owner];
|
||||||
}
|
}
|
||||||
|
|
||||||
$nationArr = getNationStaticInfo($nation);
|
$nationArr = getNationStaticInfo($nation);
|
||||||
$lbonus = calcLeadershipBonus($officerLevel, $nationArr['level']);
|
$lbonus = calcLeadershipBonus($officerLevel, $nationArr['level']);
|
||||||
|
|
||||||
$generalList[] = [
|
$generalList[] = [
|
||||||
$no,
|
$no,
|
||||||
$picture,
|
$picture,
|
||||||
$imgsvr,
|
$imgsvr,
|
||||||
$npc,
|
$npc,
|
||||||
$age,
|
$age,
|
||||||
$nationArr['name'],
|
$nationArr['name'],
|
||||||
getGeneralSpecialDomesticName($special),
|
getGeneralSpecialDomesticName($special),
|
||||||
getGeneralSpecialWarName($special2),
|
getGeneralSpecialWarName($special2),
|
||||||
getGenChar($personal),
|
getGenChar($personal),
|
||||||
$name,
|
$name,
|
||||||
$npc==1?$ownerName:null,
|
$npc==1?$ownerName:null,
|
||||||
$injury,
|
$injury,
|
||||||
$leadership,
|
$leadership,
|
||||||
$lbonus,
|
$lbonus,
|
||||||
$strength,
|
$strength,
|
||||||
$intel,
|
$intel,
|
||||||
getExpLevel($experience),
|
getExpLevel($experience),
|
||||||
getHonor($experience),
|
getHonor($experience),
|
||||||
getDed($dedication),
|
getDed($dedication),
|
||||||
getOfficerLevelText($officerLevel, $nationArr['level']),
|
getOfficerLevelText($officerLevel, $nationArr['level']),
|
||||||
$killturn,
|
$killturn,
|
||||||
$connectCnt
|
$connectCnt
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = [
|
$result = [
|
||||||
'result'=>'true',
|
'result'=>'true',
|
||||||
'list'=>$generalList,
|
'list'=>$generalList,
|
||||||
];
|
];
|
||||||
|
|
||||||
if($withToken){
|
if($withToken){
|
||||||
$now = (new \DateTimeImmutable())->format('Y-m-d H:i:s');
|
$now = (new \DateTimeImmutable())->format('Y-m-d H:i:s');
|
||||||
$tokens = [];
|
$tokens = [];
|
||||||
foreach($db->query('SELECT * FROM select_npc_token WHERE `valid_until`>=%s', $now) as $token){
|
foreach($db->query('SELECT * FROM select_npc_token WHERE `valid_until`>=%s', $now) as $token){
|
||||||
$validUntil = $token['valid_until'];
|
$validUntil = $token['valid_until'];
|
||||||
|
|
||||||
foreach(Json::decode($token['pick_result']) as $pickResult){
|
foreach(Json::decode($token['pick_result']) as $pickResult){
|
||||||
$tokens[$pickResult['no']]=$pickResult['keepCnt'];
|
$tokens[$pickResult['no']]=$pickResult['keepCnt'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result['token'] = $tokens;
|
$result['token'] = $tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::die($result);
|
Json::die($result);
|
||||||
|
|||||||
+208
-208
@@ -1,209 +1,209 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
WebUtil::requireAJAX();
|
WebUtil::requireAJAX();
|
||||||
|
|
||||||
$session = Session::requireLogin([])->setReadOnly();
|
$session = Session::requireLogin([])->setReadOnly();
|
||||||
|
|
||||||
if(!class_exists('\\sammo\\DB')){
|
if(!class_exists('\\sammo\\DB')){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'DB리셋 필요'
|
'reason'=>'DB리셋 필요'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$serverName = DB::prefix();
|
$serverName = DB::prefix();
|
||||||
$serverAcl = $session->acl[$serverName]??[];
|
$serverAcl = $session->acl[$serverName]??[];
|
||||||
$allowReset = in_array('reset', $serverAcl);
|
$allowReset = in_array('reset', $serverAcl);
|
||||||
$allowFullReset = in_array('fullReset',$serverAcl);
|
$allowFullReset = in_array('fullReset',$serverAcl);
|
||||||
$allowReset |= $allowFullReset;
|
$allowReset |= $allowFullReset;
|
||||||
|
|
||||||
$reserve_open = Util::getPost('reserve_open');
|
$reserve_open = Util::getPost('reserve_open');
|
||||||
if($reserve_open && $reserve_open < date('Y-m-d H:i')){
|
if($reserve_open && $reserve_open < date('Y-m-d H:i')){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'현재 시간보다 이전 시간대를 예약 시간으로 지정했습니다.'
|
'reason'=>'현재 시간보다 이전 시간대를 예약 시간으로 지정했습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pre_reserve_open = Util::getPost('pre_reserve_open');
|
$pre_reserve_open = Util::getPost('pre_reserve_open');
|
||||||
if($pre_reserve_open && !$reserve_open){
|
if($pre_reserve_open && !$reserve_open){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'가오픈 예약을 위해선 오픈 예약을 지정해야합니다.'
|
'reason'=>'가오픈 예약을 위해선 오픈 예약을 지정해야합니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if($pre_reserve_open && $pre_reserve_open >= $reserve_open){
|
if($pre_reserve_open && $pre_reserve_open >= $reserve_open){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'가오픈 시간이 오픈 예약 시점보다 이전이어야 합니다.'
|
'reason'=>'가오픈 시간이 오픈 예약 시점보다 이전이어야 합니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($session->userGrade < 5 && !$allowReset){
|
if($session->userGrade < 5 && !$allowReset){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'관리자 아님'
|
'reason'=>'관리자 아님'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$v = new Validator($_POST);
|
$v = new Validator($_POST);
|
||||||
$v->rule('required', [
|
$v->rule('required', [
|
||||||
'turnterm',
|
'turnterm',
|
||||||
'sync',
|
'sync',
|
||||||
'scenario',
|
'scenario',
|
||||||
'fiction',
|
'fiction',
|
||||||
'extend',
|
'extend',
|
||||||
'join_mode',
|
'join_mode',
|
||||||
'npcmode',
|
'npcmode',
|
||||||
'show_img_level',
|
'show_img_level',
|
||||||
'autorun_user_minutes'
|
'autorun_user_minutes'
|
||||||
])->rule('integer', [
|
])->rule('integer', [
|
||||||
'turnterm',
|
'turnterm',
|
||||||
'sync',
|
'sync',
|
||||||
'scenario',
|
'scenario',
|
||||||
'fiction',
|
'fiction',
|
||||||
'extend',
|
'extend',
|
||||||
'npcmode',
|
'npcmode',
|
||||||
'show_img_level',
|
'show_img_level',
|
||||||
'tournament_trig',
|
'tournament_trig',
|
||||||
'autorun_user_minutes'
|
'autorun_user_minutes'
|
||||||
])->rule('in', 'join_mode', ['onlyRandom', 'full']);
|
])->rule('in', 'join_mode', ['onlyRandom', 'full']);
|
||||||
if(!$v->validate()){
|
if(!$v->validate()){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>$v->errorStr()
|
'reason'=>$v->errorStr()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowReset = true;
|
$allowReset = true;
|
||||||
if($session->userGrade < 5 && !$allowFullReset){
|
if($session->userGrade < 5 && !$allowFullReset){
|
||||||
//리셋 가능한 조건인지 테스트
|
//리셋 가능한 조건인지 테스트
|
||||||
$allowReset = false;
|
$allowReset = false;
|
||||||
|
|
||||||
if(file_exists(__DIR__.'/.htaccess')){
|
if(file_exists(__DIR__.'/.htaccess')){
|
||||||
$allowReset = true;
|
$allowReset = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
if($gameStor->isunited){
|
if($gameStor->isunited){
|
||||||
$allowReset = true;
|
$allowReset = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$allowReset){
|
if(!$allowReset){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'부족한 권한: 서버가 닫혀있거나, 천통되어 있을 경우에만 리셋 가능합니다.'
|
'reason'=>'부족한 권한: 서버가 닫혀있거나, 천통되어 있을 경우에만 리셋 가능합니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$turnterm = (int)$_POST['turnterm'];
|
$turnterm = (int)$_POST['turnterm'];
|
||||||
$sync = (int)$_POST['sync'];
|
$sync = (int)$_POST['sync'];
|
||||||
$scenario = (int)$_POST['scenario'];
|
$scenario = (int)$_POST['scenario'];
|
||||||
$fiction = (int)$_POST['fiction'];
|
$fiction = (int)$_POST['fiction'];
|
||||||
$extend = (int)$_POST['extend'];
|
$extend = (int)$_POST['extend'];
|
||||||
$npcmode = (int)$_POST['npcmode'];
|
$npcmode = (int)$_POST['npcmode'];
|
||||||
$show_img_level = (int)$_POST['show_img_level'];
|
$show_img_level = (int)$_POST['show_img_level'];
|
||||||
$tournament_trig = (int)$_POST['tournament_trig'];
|
$tournament_trig = (int)$_POST['tournament_trig'];
|
||||||
$join_mode = $_POST['join_mode'];
|
$join_mode = $_POST['join_mode'];
|
||||||
$autorun_user_minutes = (int)$_POST['autorun_user_minutes'];
|
$autorun_user_minutes = (int)$_POST['autorun_user_minutes'];
|
||||||
$autorun_user_options = [];
|
$autorun_user_options = [];
|
||||||
foreach(Util::getPost('autorun_user', 'array_string', []) as $autorun_option){
|
foreach(Util::getPost('autorun_user', 'array_string', []) as $autorun_option){
|
||||||
$autorun_user_options[$autorun_option] = 1;
|
$autorun_user_options[$autorun_option] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($autorun_user_minutes > 0 && !$autorun_user_options){
|
if($autorun_user_minutes > 0 && !$autorun_user_options){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'적어도 자동 행동 중 하나는 선택을 해야합니다.'
|
'reason'=>'적어도 자동 행동 중 하나는 선택을 해야합니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($autorun_user_minutes < 0){
|
if($autorun_user_minutes < 0){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'자동 행동 기한이 0보다 작을 수 없습니다.'
|
'reason'=>'자동 행동 기한이 0보다 작을 수 없습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$autorun_user = $autorun_user_minutes?[
|
$autorun_user = $autorun_user_minutes?[
|
||||||
'limit_minutes'=>$autorun_user_minutes,
|
'limit_minutes'=>$autorun_user_minutes,
|
||||||
'options'=>$autorun_user_options
|
'options'=>$autorun_user_options
|
||||||
]:null;
|
]:null;
|
||||||
|
|
||||||
if($reserve_open){
|
if($reserve_open){
|
||||||
$reserve_open = new \DateTime($reserve_open);
|
$reserve_open = new \DateTime($reserve_open);
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
if (!$db->queryFirstField("SHOW TABLES LIKE 'storage'")) {
|
if (!$db->queryFirstField("SHOW TABLES LIKE 'storage'")) {
|
||||||
$clearResult = ResetHelper::clearDB();
|
$clearResult = ResetHelper::clearDB();
|
||||||
if(!$clearResult['result']){
|
if(!$clearResult['result']){
|
||||||
Json::die($clearResult);
|
Json::die($clearResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$db->queryFirstField("SHOW TABLES LIKE 'reserved_open'")) {
|
if (!$db->queryFirstField("SHOW TABLES LIKE 'reserved_open'")) {
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'예약 테이블이 없음!'
|
'reason'=>'예약 테이블이 없음!'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scenarioObj = new Scenario($scenario, true);
|
$scenarioObj = new Scenario($scenario, true);
|
||||||
$open_date = $reserve_open->format('Y-m-d H:i:s');
|
$open_date = $reserve_open->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
$reserveInfo = [
|
$reserveInfo = [
|
||||||
'turnterm'=>$turnterm,
|
'turnterm'=>$turnterm,
|
||||||
'sync'=>$sync,
|
'sync'=>$sync,
|
||||||
'scenario'=>$scenario,
|
'scenario'=>$scenario,
|
||||||
'scenarioName'=>$scenarioObj->getTitle(),
|
'scenarioName'=>$scenarioObj->getTitle(),
|
||||||
'fiction'=>$fiction,
|
'fiction'=>$fiction,
|
||||||
'extend'=>$extend,
|
'extend'=>$extend,
|
||||||
'npcmode'=>$npcmode,
|
'npcmode'=>$npcmode,
|
||||||
'show_img_level'=>$show_img_level,
|
'show_img_level'=>$show_img_level,
|
||||||
'tournament_trig'=>$tournament_trig,
|
'tournament_trig'=>$tournament_trig,
|
||||||
'gameConf'=>$scenarioObj->getGameConf(),
|
'gameConf'=>$scenarioObj->getGameConf(),
|
||||||
'join_mode'=>$join_mode,
|
'join_mode'=>$join_mode,
|
||||||
'starttime'=>$open_date,
|
'starttime'=>$open_date,
|
||||||
'autorun_user'=>$autorun_user
|
'autorun_user'=>$autorun_user
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
if($pre_reserve_open){
|
if($pre_reserve_open){
|
||||||
$pre_reserve_open = new \DateTime($pre_reserve_open);
|
$pre_reserve_open = new \DateTime($pre_reserve_open);
|
||||||
$open_date = $pre_reserve_open->format('Y-m-d H:i:s');
|
$open_date = $pre_reserve_open->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db->delete('reserved_open', true);
|
$db->delete('reserved_open', true);
|
||||||
$db->insert('reserved_open', [
|
$db->insert('reserved_open', [
|
||||||
'options'=>Json::encode($reserveInfo),
|
'options'=>Json::encode($reserveInfo),
|
||||||
'date'=>$open_date
|
'date'=>$open_date
|
||||||
]);
|
]);
|
||||||
AppConf::getList()[DB::prefix()]->closeServer();
|
ServConfig::getServerList()[DB::prefix()]->closeServer();
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'예약'
|
'reason'=>'예약'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::die(ResetHelper::buildScenario(
|
Json::die(ResetHelper::buildScenario(
|
||||||
$turnterm,
|
$turnterm,
|
||||||
$sync,
|
$sync,
|
||||||
$scenario,
|
$scenario,
|
||||||
$fiction,
|
$fiction,
|
||||||
$extend,
|
$extend,
|
||||||
$npcmode,
|
$npcmode,
|
||||||
$show_img_level,
|
$show_img_level,
|
||||||
$tournament_trig,
|
$tournament_trig,
|
||||||
$join_mode,
|
$join_mode,
|
||||||
TimeUtil::now(),
|
TimeUtil::now(),
|
||||||
$autorun_user
|
$autorun_user
|
||||||
));
|
));
|
||||||
+102
-102
@@ -1,103 +1,103 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
WebUtil::requireAJAX();
|
WebUtil::requireAJAX();
|
||||||
|
|
||||||
$session = Session::requireLogin([])->setReadOnly();
|
$session = Session::requireLogin([])->setReadOnly();
|
||||||
if($session->userGrade < 6){
|
if($session->userGrade < 6){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'관리자 아님'
|
'reason'=>'관리자 아님'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fullReset = Util::getPost('full_reset', 'bool', false);
|
$fullReset = Util::getPost('full_reset', 'bool', false);
|
||||||
$host = Util::getPost('db_host');
|
$host = Util::getPost('db_host');
|
||||||
$port = Util::getPost('db_port', 'int');
|
$port = Util::getPost('db_port', 'int');
|
||||||
$username = Util::getPost('db_id');
|
$username = Util::getPost('db_id');
|
||||||
$password = Util::getPost('db_pw');
|
$password = Util::getPost('db_pw');
|
||||||
$dbName = Util::getPost('db_name');
|
$dbName = Util::getPost('db_name');
|
||||||
|
|
||||||
if(!$host || !$port || !$username || !$password || !$dbName){
|
if(!$host || !$port || !$username || !$password || !$dbName){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'입력 값이 올바르지 않습니다'
|
'reason'=>'입력 값이 올바르지 않습니다'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($fullReset && class_exists('\\sammo\\DB')){
|
if($fullReset && class_exists('\\sammo\\DB')){
|
||||||
$mysqli_obj = DB::db()->get();
|
$mysqli_obj = DB::db()->get();
|
||||||
|
|
||||||
if($mysqli_obj->multi_query(file_get_contents(__DIR__.'/sql/reset.sql'))){
|
if($mysqli_obj->multi_query(file_get_contents(__DIR__.'/sql/reset.sql'))){
|
||||||
while(true){
|
while(true){
|
||||||
if (!$mysqli_obj->more_results()) {
|
if (!$mysqli_obj->more_results()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!$mysqli_obj->next_result()){
|
if(!$mysqli_obj->next_result()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($fullReset){
|
if($fullReset){
|
||||||
FileUtil::delInDir(__DIR__."/logs");
|
FileUtil::delInDir(__DIR__."/logs");
|
||||||
FileUtil::delInDir(__DIR__."/data");
|
FileUtil::delInDir(__DIR__."/data");
|
||||||
if(file_exists(__DIR__.'/d_setting/DB.php')){
|
if(file_exists(__DIR__.'/d_setting/DB.php')){
|
||||||
@unlink(__DIR__.'/d_setting/DB.php');
|
@unlink(__DIR__.'/d_setting/DB.php');
|
||||||
}
|
}
|
||||||
if(file_exists(__DIR__.'/d_setting/UniqueConst.php')){
|
if(file_exists(__DIR__.'/d_setting/UniqueConst.php')){
|
||||||
@unlink(__DIR__.'/d_setting/UniqueConst.php');
|
@unlink(__DIR__.'/d_setting/UniqueConst.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbConnFail($params){
|
function dbConnFail($params){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'DB 접속에 실패했습니다.'
|
'reason'=>'DB 접속에 실패했습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$db = new \MeekroDB($host,$username,$password,$dbName,$port,'utf8mb4');
|
$db = new \MeekroDB($host,$username,$password,$dbName,$port,'utf8mb4');
|
||||||
$db->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
$db->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||||
|
|
||||||
$db->throw_exception_on_nonsql_error = false;
|
$db->throw_exception_on_nonsql_error = false;
|
||||||
$db->nonsql_error_handler = 'dbConnFail';
|
$db->nonsql_error_handler = 'dbConnFail';
|
||||||
|
|
||||||
|
|
||||||
$mysqli_obj = $db->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨.
|
$mysqli_obj = $db->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨.
|
||||||
|
|
||||||
$prefix = basename(__DIR__);
|
$prefix = basename(__DIR__);
|
||||||
|
|
||||||
$result = Util::generateFileUsingSimpleTemplate(
|
$result = Util::generateFileUsingSimpleTemplate(
|
||||||
__DIR__.'/d_setting/DB.orig.php',
|
__DIR__.'/d_setting/DB.orig.php',
|
||||||
__DIR__.'/d_setting/DB.php',[
|
__DIR__.'/d_setting/DB.php',[
|
||||||
'host'=>$host,
|
'host'=>$host,
|
||||||
'user'=>$username,
|
'user'=>$username,
|
||||||
'password'=>$password,
|
'password'=>$password,
|
||||||
'dbName'=>$dbName,
|
'dbName'=>$dbName,
|
||||||
'port'=>$port,
|
'port'=>$port,
|
||||||
'prefix'=>$prefix
|
'prefix'=>$prefix
|
||||||
], true
|
], true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($result !== true){
|
if($result !== true){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>$result
|
'reason'=>$result
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetHelper::clearDB();
|
ResetHelper::clearDB();
|
||||||
|
|
||||||
AppConf::getList()[$prefix]->closeServer();
|
ServConfig::getServerList()[$prefix]->closeServer();
|
||||||
|
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
]);
|
]);
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
use Nette\Caching\Cache;
|
||||||
|
|
||||||
|
include "lib.php";
|
||||||
|
include "func.php";
|
||||||
|
|
||||||
|
if(!class_exists('\\sammo\\UniqueConst')){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'서버 초기화되지 않음'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!prepareDir('data/file_cache')){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'cache 불가'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$storage = new \Nette\Caching\Storages\FileStorage('data/file_cache');
|
||||||
|
$cache = new Cache($storage);
|
||||||
|
$serverID = UniqueConst::$serverID;
|
||||||
|
|
||||||
|
$mapInfo = $cache->load("recent_map");
|
||||||
|
//로그인 검사
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
|
||||||
|
if($mapInfo && ($now - $mapInfo['timestamp'] < 600)){
|
||||||
|
$mapEtag = $mapInfo['etag'];
|
||||||
|
$mapModified = $mapInfo['timestamp'];
|
||||||
|
|
||||||
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mapModified)." GMT");
|
||||||
|
header("Etag: $mapEtag");
|
||||||
|
|
||||||
|
if (
|
||||||
|
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']??'2000-01-01') === $mapModified ||
|
||||||
|
trim($_SERVER['HTTP_IF_NONE_MATCH']??'') === $mapEtag
|
||||||
|
) {
|
||||||
|
header("HTTP/1.1 304 Not Modified");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
Json::die($mapInfo['data'], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$defaultPost = [
|
||||||
|
'year' => null,
|
||||||
|
'month' => null,
|
||||||
|
'aux' => null,
|
||||||
|
'neutralView' => true,
|
||||||
|
'showMe' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
$history = formatHistoryToHTML(getGlobalHistoryLogRecent(10));
|
||||||
|
$rawMap = getWorldMap([
|
||||||
|
'year' => null,
|
||||||
|
'month' => null,
|
||||||
|
'aux' => null,
|
||||||
|
'neutralView' => true,
|
||||||
|
'showMe' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$mapTheme = $gameStor->map_theme ?? 'che';
|
||||||
|
|
||||||
|
$rawMap['history'] = $history;
|
||||||
|
$rawMap['theme'] = $mapTheme;
|
||||||
|
|
||||||
|
$etag = hash('sha256', $serverID.$now);
|
||||||
|
$map = [
|
||||||
|
'etag'=>$etag,
|
||||||
|
'timestamp'=>$now,
|
||||||
|
'data'=>$rawMap,
|
||||||
|
];
|
||||||
|
$cache->save("recent_map", $map);
|
||||||
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s", $now)." GMT");
|
||||||
|
header("Etag: $etag");
|
||||||
|
|
||||||
|
Json::die($map['data'], 0);
|
||||||
+360
-359
@@ -1,360 +1,361 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
WebUtil::requireAJAX();
|
WebUtil::requireAJAX();
|
||||||
|
|
||||||
$action = Util::getPost('action');
|
$action = Util::getPost('action');
|
||||||
$officerLevel = Util::getPost('officerLevel', 'int');
|
$officerLevel = Util::getPost('officerLevel', 'int');
|
||||||
$destGeneralID = Util::getPost('destGeneralID', 'int');
|
$destGeneralID = Util::getPost('destGeneralID', 'int');
|
||||||
$destCityID = Util::getPost('destCityID', 'int');
|
$destCityID = Util::getPost('destCityID', 'int');
|
||||||
|
|
||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$gameStor->cacheValues(['startyear','year','month','scenario']);
|
$gameStor->cacheValues(['startyear','year','month','scenario']);
|
||||||
|
|
||||||
$me = $db->queryFirstRow('SELECT no,nation,officer_level from general where owner=%i', $userID);
|
$me = $db->queryFirstRow('SELECT no,nation,officer_level from general where owner=%i', $userID);
|
||||||
$myOfficerLevel = $me['officer_level'];
|
$myOfficerLevel = $me['officer_level'];
|
||||||
$nationID = $me['nation'];
|
$nationID = $me['nation'];
|
||||||
|
|
||||||
//수뇌가 아니면 아무것도 할 수 없음
|
//수뇌가 아니면 아무것도 할 수 없음
|
||||||
if($myOfficerLevel < 5){
|
if($myOfficerLevel < 5){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'수뇌가 아닙니다.'
|
'reason'=>'수뇌가 아닙니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action === '추방' && $destGeneralID==0){
|
if($action === '추방' && $destGeneralID==0){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'장수가 지정되지 않았습니다.'
|
'reason'=>'장수가 지정되지 않았습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($destGeneralID==0){
|
if($destGeneralID==0){
|
||||||
$general = new DummyGeneral(true);
|
$general = new DummyGeneral(true);
|
||||||
}
|
$general->setVar('nation', $nationID);
|
||||||
else{
|
}
|
||||||
$general = General::createGeneralObjFromDB($destGeneralID, [
|
else{
|
||||||
'name', 'leadership', 'strength', 'intel', 'gold','rice',
|
$general = General::createGeneralObjFromDB($destGeneralID, [
|
||||||
'troop','officer_level','npc','picture','imgsvr',
|
'name', 'leadership', 'strength', 'intel', 'gold','rice',
|
||||||
'permission','penalty','belong', 'crewtype',
|
'troop','officer_level','npc','picture','imgsvr',
|
||||||
'experience', 'dedication', 'betray', 'dedlevel', 'explevel', 'makelimit',
|
'permission','penalty','belong', 'crewtype',
|
||||||
], 1);
|
'experience', 'dedication', 'betray', 'dedlevel', 'explevel', 'makelimit',
|
||||||
|
], 1);
|
||||||
if($general instanceof DummyGeneral){
|
|
||||||
Json::die([
|
if($general instanceof DummyGeneral){
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>'올바르지 않은 장수입니다.'
|
'result'=>false,
|
||||||
]);
|
'reason'=>'올바르지 않은 장수입니다.'
|
||||||
}
|
]);
|
||||||
|
}
|
||||||
if($nationID != $general->getNationID()){
|
|
||||||
Json::die([
|
if($nationID != $general->getNationID()){
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>'아국 장수가 아닙니다'
|
'result'=>false,
|
||||||
]);
|
'reason'=>'아국 장수가 아닙니다'
|
||||||
}
|
]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if($officerLevel == 12){
|
|
||||||
Json::die([
|
if($officerLevel == 12){
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>'군주를 대상으로 할 수 없습니다.'
|
'result'=>false,
|
||||||
]);
|
'reason'=>'군주를 대상으로 할 수 없습니다.'
|
||||||
}
|
]);
|
||||||
|
}
|
||||||
function do수뇌임명(General $general, int $targetOfficerLevel):?string{
|
|
||||||
$generalID = $general->getID();
|
function do수뇌임명(General $general, int $targetOfficerLevel):?string{
|
||||||
$nationID = $general->getNationID();
|
$generalID = $general->getID();
|
||||||
|
$nationID = $general->getNationID();
|
||||||
$db = DB::db();
|
|
||||||
|
$db = DB::db();
|
||||||
[$chiefSet, $nationLevel] = $db->queryFirstList('SELECT chief_set,level FROM nation WHERE nation = %i',$nationID);
|
|
||||||
|
[$chiefSet, $nationLevel] = $db->queryFirstList('SELECT chief_set,level FROM nation WHERE nation = %i',$nationID);
|
||||||
// 임명가능 레벨
|
|
||||||
$lv = getNationChiefLevel($nationLevel);
|
// 임명가능 레벨
|
||||||
|
$lv = getNationChiefLevel($nationLevel);
|
||||||
if($targetOfficerLevel < $lv){
|
|
||||||
return '임명불가능한 관직입니다.';
|
if($targetOfficerLevel < $lv){
|
||||||
}
|
return '임명불가능한 관직입니다.';
|
||||||
|
}
|
||||||
if(isOfficerSet($chiefSet, $targetOfficerLevel)){
|
|
||||||
return '지금은 임명할 수 없습니다.';
|
if(isOfficerSet($chiefSet, $targetOfficerLevel)){
|
||||||
}
|
return '지금은 임명할 수 없습니다.';
|
||||||
|
}
|
||||||
//기존 장수 일반으로
|
|
||||||
$db->update('general', [
|
//기존 장수 일반으로
|
||||||
'officer_level'=>1,
|
$db->update('general', [
|
||||||
'officer_city'=>0,
|
'officer_level'=>1,
|
||||||
], 'nation=%i AND officer_level=%i AND no!=%i', $nationID, $targetOfficerLevel, $generalID);
|
'officer_city'=>0,
|
||||||
|
], 'nation=%i AND officer_level=%i AND no!=%i', $nationID, $targetOfficerLevel, $generalID);
|
||||||
if($targetOfficerLevel === 11){
|
|
||||||
|
if($targetOfficerLevel === 11){
|
||||||
}
|
|
||||||
else if($targetOfficerLevel % 2 == 0){
|
}
|
||||||
if($general->getVar('strength') < GameConst::$chiefStatMin){
|
else if($targetOfficerLevel % 2 == 0){
|
||||||
return '무력이 부족합니다.';
|
if($general->getVar('strength') < GameConst::$chiefStatMin){
|
||||||
}
|
return '무력이 부족합니다.';
|
||||||
|
}
|
||||||
}
|
|
||||||
else{
|
}
|
||||||
if($general->getVar('intel') < GameConst::$chiefStatMin){
|
else{
|
||||||
return '지력이 부족합니다.';
|
if($general->getVar('intel') < GameConst::$chiefStatMin){
|
||||||
}
|
return '지력이 부족합니다.';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//신임 장수
|
|
||||||
$general->setVar('officer_level', $targetOfficerLevel);
|
//신임 장수
|
||||||
$general->setVar('officer_city', 0);
|
$general->setVar('officer_level', $targetOfficerLevel);
|
||||||
$db->update('nation', [
|
$general->setVar('officer_city', 0);
|
||||||
'chief_set'=> $db->sqleval('chief_set | %i', doOfficerSet(0, $targetOfficerLevel)),
|
$db->update('nation', [
|
||||||
], 'nation=%i', $nationID);
|
'chief_set'=> $db->sqleval('chief_set | %i', doOfficerSet(0, $targetOfficerLevel)),
|
||||||
$general->applyDB($db);
|
], 'nation=%i', $nationID);
|
||||||
|
$general->applyDB($db);
|
||||||
return null;
|
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
function do도시임명(General $general, int $cityID, int $targetOfficerLevel):?string{
|
|
||||||
$nationID = $general->getNationID();
|
function do도시임명(General $general, int $cityID, int $targetOfficerLevel):?string{
|
||||||
|
$nationID = $general->getNationID();
|
||||||
$db = DB::db();
|
|
||||||
|
$db = DB::db();
|
||||||
if(CityConst::byID($cityID) === null){
|
|
||||||
return '올바르지 않은 도시입니다';
|
if(CityConst::byID($cityID) === null){
|
||||||
}
|
return '올바르지 않은 도시입니다';
|
||||||
|
}
|
||||||
$officerSet = $db->queryFirstField('SELECT officer_set FROM city WHERE nation=%i AND city=%i', $nationID, $cityID);
|
|
||||||
if($officerSet === null){
|
$officerSet = $db->queryFirstField('SELECT officer_set FROM city WHERE nation=%i AND city=%i', $nationID, $cityID);
|
||||||
return '아국 도시가 아닙니다';
|
if($officerSet === null){
|
||||||
}
|
return '아국 도시가 아닙니다';
|
||||||
|
}
|
||||||
if(isOfficerSet($officerSet, $targetOfficerLevel)){
|
|
||||||
return '이미 다른 장수가 임명되어있습니다';
|
if(isOfficerSet($officerSet, $targetOfficerLevel)){
|
||||||
}
|
return '이미 다른 장수가 임명되어있습니다';
|
||||||
|
}
|
||||||
//기존 장수 일반으로
|
|
||||||
$db->update('general', [
|
//기존 장수 일반으로
|
||||||
'officer_level'=>1,
|
$db->update('general', [
|
||||||
'officer_city'=>0,
|
'officer_level'=>1,
|
||||||
], 'officer_level=%i AND officer_city=%i AND no!=%i', $targetOfficerLevel, $cityID, $general->getID());
|
'officer_city'=>0,
|
||||||
|
], 'officer_level=%i AND officer_city=%i AND no!=%i', $targetOfficerLevel, $cityID, $general->getID());
|
||||||
if($general instanceof DummyGeneral){
|
|
||||||
return null;
|
if($general instanceof DummyGeneral){
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
if($targetOfficerLevel === 4 && $general->getVar('strength') < GameConst::$chiefStatMin){
|
|
||||||
return '무력이 부족합니다.';
|
if($targetOfficerLevel === 4 && $general->getVar('strength') < GameConst::$chiefStatMin){
|
||||||
}
|
return '무력이 부족합니다.';
|
||||||
|
}
|
||||||
if($targetOfficerLevel === 3 && $general->getVar('intel') < GameConst::$chiefStatMin){
|
|
||||||
return '지력이 부족합니다.';
|
if($targetOfficerLevel === 3 && $general->getVar('intel') < GameConst::$chiefStatMin){
|
||||||
}
|
return '지력이 부족합니다.';
|
||||||
|
}
|
||||||
//신임 장수
|
|
||||||
$db->update('city', [
|
//신임 장수
|
||||||
'officer_set'=>$db->sqleval('officer_set | %i', doOfficerSet(0, $targetOfficerLevel)),
|
$db->update('city', [
|
||||||
], 'city=%i AND nation=%i', $cityID, $nationID);
|
'officer_set'=>$db->sqleval('officer_set | %i', doOfficerSet(0, $targetOfficerLevel)),
|
||||||
$general->setVar('officer_level', $targetOfficerLevel);
|
], 'city=%i AND nation=%i', $cityID, $nationID);
|
||||||
$general->setVar('officer_city', $cityID);
|
$general->setVar('officer_level', $targetOfficerLevel);
|
||||||
$general->applyDB($db);
|
$general->setVar('officer_city', $cityID);
|
||||||
|
$general->applyDB($db);
|
||||||
return null;
|
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
function do추방(General $general, int $myOfficerLevel):?string{
|
|
||||||
$generalID = $general->getID();
|
function do추방(General $general, int $myOfficerLevel):?string{
|
||||||
$generalName = $general->getVar('name');
|
$generalID = $general->getID();
|
||||||
$nationID = $general->getNationID();
|
$generalName = $general->getVar('name');
|
||||||
|
$nationID = $general->getNationID();
|
||||||
|
|
||||||
|
|
||||||
//추방할사람이 외교권자이면 불가
|
|
||||||
$permission = checkSecretPermission($general->getRaw());
|
//추방할사람이 외교권자이면 불가
|
||||||
if($permission == 4){
|
$permission = checkSecretPermission($general->getRaw());
|
||||||
return '외교권자는 추방할 수 없습니다.';
|
if($permission == 4){
|
||||||
}
|
return '외교권자는 추방할 수 없습니다.';
|
||||||
|
}
|
||||||
$db = DB::db();
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$db = DB::db();
|
||||||
$env = $gameStor->getValues(['startyear','year','month','scenario']);
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$env = $gameStor->getValues(['startyear','year','month','scenario']);
|
||||||
$nation = $db->queryFirstRow('SELECT name,chief_set,color FROM nation WHERE nation=%i', $nationID);
|
|
||||||
$nationName = $nation['name'];
|
$nation = $db->queryFirstRow('SELECT name,chief_set,color FROM nation WHERE nation=%i', $nationID);
|
||||||
|
$nationName = $nation['name'];
|
||||||
$logger = $general->getLogger();
|
|
||||||
|
$logger = $general->getLogger();
|
||||||
//이미 지정했다면 무시
|
|
||||||
if(isOfficerSet($nation['chief_set'], $myOfficerLevel) || ($myOfficerLevel == 0 && $myOfficerLevel == 12)) {
|
//이미 지정했다면 무시
|
||||||
return '이미 추방 권한을 사용했습니다.';
|
if(isOfficerSet($nation['chief_set'], $myOfficerLevel) || ($myOfficerLevel == 0 && $myOfficerLevel == 12)) {
|
||||||
}
|
return '이미 추방 권한을 사용했습니다.';
|
||||||
$gold = 0;
|
}
|
||||||
$rice = 0;
|
$gold = 0;
|
||||||
// 금쌀1000이상은 남김
|
$rice = 0;
|
||||||
if($general->getVar('gold') > GameConst::$defaultGold) {
|
// 금쌀1000이상은 남김
|
||||||
$gold = $general->getVar('gold') - GameConst::$defaultGold;
|
if($general->getVar('gold') > GameConst::$defaultGold) {
|
||||||
$general->setVar('gold', GameConst::$defaultGold);
|
$gold = $general->getVar('gold') - GameConst::$defaultGold;
|
||||||
}
|
$general->setVar('gold', GameConst::$defaultGold);
|
||||||
if($general->getVar('rice') > GameConst::$defaultRice) {
|
}
|
||||||
$rice = $general->getVar('rice') - GameConst::$defaultRice;
|
if($general->getVar('rice') > GameConst::$defaultRice) {
|
||||||
$general->setVar('rice', GameConst::$defaultRice);
|
$rice = $general->getVar('rice') - GameConst::$defaultRice;
|
||||||
}
|
$general->setVar('rice', GameConst::$defaultRice);
|
||||||
|
}
|
||||||
$general->setVar('nation', 0);
|
|
||||||
$general->setVar('officer_level', 0);
|
$general->setVar('nation', 0);
|
||||||
$general->setVar('officer_city', 0);
|
$general->setVar('officer_level', 0);
|
||||||
$general->setVar('belong', 0);
|
$general->setVar('officer_city', 0);
|
||||||
$oldMakeLimit = $general->getVar('makelimit');
|
$general->setVar('belong', 0);
|
||||||
$general->setVar('makelimit', 12);
|
$oldMakeLimit = $general->getVar('makelimit');
|
||||||
$general->setVar('permission', 'normal');
|
$general->setVar('makelimit', 12);
|
||||||
|
$general->setVar('permission', 'normal');
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
|
||||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <D><b>{$nationName}</b></>에서 <R>추방</>당했습니다.");
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
$logger->pushGeneralActionLog("<D><b>{$nationName}</b></>에서 <R>추방</>당했습니다.", ActionLogger::PLAIN);
|
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <D><b>{$nationName}</b></>에서 <R>추방</>당했습니다.");
|
||||||
|
$logger->pushGeneralActionLog("<D><b>{$nationName}</b></>에서 <R>추방</>당했습니다.", ActionLogger::PLAIN);
|
||||||
// 명성/공헌 N*10%감소
|
|
||||||
if($env['year'] <= $env['startyear'] && $general->getNPCType() < 2){
|
// 명성/공헌 N*10%감소
|
||||||
$general->setVar('makelimit', $oldMakeLimit);
|
if($env['year'] <= $env['startyear'] && $general->getNPCType() < 2){
|
||||||
}
|
$general->setVar('makelimit', $oldMakeLimit);
|
||||||
else{
|
}
|
||||||
$betrayCnt = $general->getVar('betray');
|
else{
|
||||||
$general->addExperience(-$general->getVar('experience')*0.1*$betrayCnt);
|
$betrayCnt = $general->getVar('betray');
|
||||||
$general->addDedication(-$general->getVar('dedication')*0.1*$betrayCnt);
|
$general->addExperience(-$general->getVar('experience')*0.1*$betrayCnt);
|
||||||
$general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt);
|
$general->addDedication(-$general->getVar('dedication')*0.1*$betrayCnt);
|
||||||
}
|
$general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt);
|
||||||
|
}
|
||||||
//부대장일 경우
|
|
||||||
if($general->getVar('troop') == $generalID){
|
//부대장일 경우
|
||||||
// 모두 탈퇴
|
if($general->getVar('troop') == $generalID){
|
||||||
$db->update('general', [
|
// 모두 탈퇴
|
||||||
'troop'=>0,
|
$db->update('general', [
|
||||||
], 'troop = %i', $generalID);
|
'troop'=>0,
|
||||||
$db->delete('troop', 'troop_leader=%i', $generalID);
|
], 'troop = %i', $generalID);
|
||||||
}
|
$db->delete('troop', 'troop_leader=%i', $generalID);
|
||||||
$general->setVar('troop', 0);
|
}
|
||||||
|
$general->setVar('troop', 0);
|
||||||
if($general->getNPCType() >= 2 && ($env['scenario'] < 100 || Util::randBool(0.01))) {
|
|
||||||
|
if($general->getNPCType() >= 2 && ($env['scenario'] < 100 || Util::randBool(0.01))) {
|
||||||
$str = Util::choiceRandom([
|
|
||||||
'날 버리다니... 곧 전장에서 복수해주겠다...',
|
$str = Util::choiceRandom([
|
||||||
'추방이라... 내가 무얼 잘못했단 말인가...',
|
'날 버리다니... 곧 전장에서 복수해주겠다...',
|
||||||
'어디 추방해가면서 잘되나 보자... 꼭 복수하겠다...',
|
'추방이라... 내가 무얼 잘못했단 말인가...',
|
||||||
'인덕이 제일이거늘... 추방이 웬말인가... 저주한다!',
|
'어디 추방해가면서 잘되나 보자... 꼭 복수하겠다...',
|
||||||
'날 추방했으니 그 복수로 적국에 정보를 팔아 넘겨야겠군요. 그럼 이만.'
|
'인덕이 제일이거늘... 추방이 웬말인가... 저주한다!',
|
||||||
]);
|
'날 추방했으니 그 복수로 적국에 정보를 팔아 넘겨야겠군요. 그럼 이만.'
|
||||||
|
]);
|
||||||
$src = new MessageTarget(
|
|
||||||
$generalID,
|
$src = new MessageTarget(
|
||||||
$generalName,
|
$generalID,
|
||||||
$nationID,
|
$generalName,
|
||||||
$nation['name'],
|
$nationID,
|
||||||
$nation['color'],
|
$nation['name'],
|
||||||
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
$nation['color'],
|
||||||
);
|
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
||||||
$msg = new Message(
|
);
|
||||||
Message::MSGTYPE_PUBLIC,
|
$msg = new Message(
|
||||||
$src,
|
Message::MSGTYPE_PUBLIC,
|
||||||
$src,
|
$src,
|
||||||
$str,
|
$src,
|
||||||
new \DateTime(),
|
$str,
|
||||||
new \DateTime('9999-12-31'),
|
new \DateTime(),
|
||||||
[]
|
new \DateTime('9999-12-31'),
|
||||||
);
|
[]
|
||||||
$msg->send();
|
);
|
||||||
}
|
$msg->send();
|
||||||
|
}
|
||||||
if($env['year'] < $env['startyear']+3) {
|
|
||||||
//초반엔 군주 부상 증가(엔장 임관지양)
|
if($env['year'] < $env['startyear']+3) {
|
||||||
$db->update('general', [
|
//초반엔 군주 부상 증가(엔장 임관지양)
|
||||||
'injury'=>$db->sqleval('least(injury + 1, %i)', 80),
|
$db->update('general', [
|
||||||
], 'nation=%i AND officer_level=12', $nationID);
|
'injury'=>$db->sqleval('least(injury + 1, %i)', 80),
|
||||||
|
], 'nation=%i AND officer_level=12', $nationID);
|
||||||
$db->update('nation', [
|
|
||||||
'gennum'=>$db->sqleval('gennum - %i', $general->getNPCType()!=5?1:0),
|
$db->update('nation', [
|
||||||
'gold'=>$db->sqleval('gold + %i', $gold),
|
'gennum'=>$db->sqleval('gennum - %i', $general->getNPCType()!=5?1:0),
|
||||||
'rice'=>$db->sqleval('rice + %i', $rice),
|
'gold'=>$db->sqleval('gold + %i', $gold),
|
||||||
], 'nation = %i', $nationID);
|
'rice'=>$db->sqleval('rice + %i', $rice),
|
||||||
} else {
|
], 'nation = %i', $nationID);
|
||||||
//이번분기는 추방불가(초반 제외)
|
} else {
|
||||||
$db->update('nation', [
|
//이번분기는 추방불가(초반 제외)
|
||||||
'chief_set'=>$db->sqleval('chief_set | %i', doOfficerSet(0, $myOfficerLevel)),
|
$db->update('nation', [
|
||||||
'gennum'=>$db->sqleval('gennum - %i', $general->getNPCType()!=5?1:0),
|
'chief_set'=>$db->sqleval('chief_set | %i', doOfficerSet(0, $myOfficerLevel)),
|
||||||
'gold'=>$db->sqleval('gold + %i', $gold),
|
'gennum'=>$db->sqleval('gennum - %i', $general->getNPCType()!=5?1:0),
|
||||||
'rice'=>$db->sqleval('rice + %i', $rice),
|
'gold'=>$db->sqleval('gold + %i', $gold),
|
||||||
], 'nation = %i', $nationID);
|
'rice'=>$db->sqleval('rice + %i', $rice),
|
||||||
}
|
], 'nation = %i', $nationID);
|
||||||
|
}
|
||||||
$logger->pushGeneralHistoryLog("<D>{$nation['name']}</>에서 추방됨");
|
|
||||||
$general->applyDB($db);
|
$logger->pushGeneralHistoryLog("<D>{$nation['name']}</>에서 추방됨");
|
||||||
|
$general->applyDB($db);
|
||||||
return null;
|
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if($action == "임명") {
|
|
||||||
if(2 <= $officerLevel && $officerLevel <= 4){
|
if($action == "임명") {
|
||||||
if(!$destCityID){
|
if(2 <= $officerLevel && $officerLevel <= 4){
|
||||||
Json::die([
|
if(!$destCityID){
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>'도시가 지정되지 않았습니다.'
|
'result'=>false,
|
||||||
]);
|
'reason'=>'도시가 지정되지 않았습니다.'
|
||||||
}
|
]);
|
||||||
$result = do도시임명($general, $destCityID, $officerLevel);
|
}
|
||||||
if($result !== null){
|
$result = do도시임명($general, $destCityID, $officerLevel);
|
||||||
Json::die([
|
if($result !== null){
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>$result
|
'result'=>false,
|
||||||
]);
|
'reason'=>$result
|
||||||
}
|
]);
|
||||||
Json::die([
|
}
|
||||||
'result'=>true,
|
Json::die([
|
||||||
'reason'=>'success'
|
'result'=>true,
|
||||||
]);
|
'reason'=>'success'
|
||||||
}
|
]);
|
||||||
|
}
|
||||||
if(5 <= $officerLevel && $officerLevel < 12){
|
|
||||||
$result = do수뇌임명($general, $officerLevel);
|
if(5 <= $officerLevel && $officerLevel < 12){
|
||||||
if($result !== null){
|
$result = do수뇌임명($general, $officerLevel);
|
||||||
Json::die([
|
if($result !== null){
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>$result
|
'result'=>false,
|
||||||
]);
|
'reason'=>$result
|
||||||
}
|
]);
|
||||||
Json::die([
|
}
|
||||||
'result'=>true,
|
Json::die([
|
||||||
'reason'=>'success'
|
'result'=>true,
|
||||||
]);
|
'reason'=>'success'
|
||||||
}
|
]);
|
||||||
|
}
|
||||||
Json::die([
|
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>'올바르지 않은 지정입니다.'
|
'result'=>false,
|
||||||
]);
|
'reason'=>'올바르지 않은 지정입니다.'
|
||||||
}
|
]);
|
||||||
|
}
|
||||||
if($action == "추방") {
|
|
||||||
$result = do추방($general, $myOfficerLevel);
|
if($action == "추방") {
|
||||||
if($result !== null){
|
$result = do추방($general, $myOfficerLevel);
|
||||||
Json::die([
|
if($result !== null){
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>$result
|
'result'=>false,
|
||||||
]);
|
'reason'=>$result
|
||||||
}
|
]);
|
||||||
Json::die([
|
}
|
||||||
'result'=>true,
|
Json::die([
|
||||||
'reason'=>'success'
|
'result'=>true,
|
||||||
]);
|
'reason'=>'success'
|
||||||
}
|
]);
|
||||||
|
}
|
||||||
Json::die([
|
|
||||||
'result'=>false,
|
Json::die([
|
||||||
'reason'=>'올바르지 않은 명령입니다.'
|
'result'=>false,
|
||||||
|
'reason'=>'올바르지 않은 명령입니다.'
|
||||||
]);
|
]);
|
||||||
+81
-76
@@ -1,77 +1,82 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
WebUtil::requireAJAX();
|
WebUtil::requireAJAX();
|
||||||
|
|
||||||
$session = Session::requireGameLogin([])->setReadOnly();
|
$session = Session::requireGameLogin([])->setReadOnly();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
$generalID = $session->generalID;
|
$generalID = $session->generalID;
|
||||||
|
|
||||||
increaseRefresh("내정보 수정", 0);
|
increaseRefresh("내정보 수정", 0);
|
||||||
|
|
||||||
$action = Util::getPost('action');
|
$action = Util::getPost('action');
|
||||||
$tnmt = Util::getPost('tnmt', 'int', 1);
|
$tnmt = Util::getPost('tnmt', 'int', 1);
|
||||||
$defence_train = Util::getPost('defence_train', 'int', 80);
|
$defence_train = Util::getPost('defence_train', 'int', 80);
|
||||||
$use_treatment = Util::getPost('use_treatment', 'int', 10);
|
$use_treatment = Util::getPost('use_treatment', 'int', 10);
|
||||||
//$detachNPC = Util::getPost('detachNPC', 'bool');
|
$use_auto_nation_turn = Util::getPost('use_auto_nation_turn', 'int', 1);
|
||||||
$detachNPC = false;
|
//$detachNPC = Util::getPost('detachNPC', 'bool');
|
||||||
|
$detachNPC = false;
|
||||||
if ($defence_train <= 40) {
|
|
||||||
$defence_train = 40;
|
if ($defence_train <= 40) {
|
||||||
}
|
$defence_train = 40;
|
||||||
|
}
|
||||||
if($defence_train <= 90){
|
|
||||||
$defence_train = Util::round($defence_train, -1);
|
if($defence_train <= 90){
|
||||||
}
|
$defence_train = Util::round($defence_train, -1);
|
||||||
else{
|
}
|
||||||
$defence_train = 999;
|
else{
|
||||||
}
|
$defence_train = 999;
|
||||||
|
}
|
||||||
if($tnmt < 0 || $tnmt > 1){
|
|
||||||
$tnmt = 1;
|
if($tnmt < 0 || $tnmt > 1){
|
||||||
}
|
$tnmt = 1;
|
||||||
|
}
|
||||||
$db = DB::db();
|
|
||||||
$me = General::createGeneralObjFromDB($generalID);
|
$db = DB::db();
|
||||||
|
$me = General::createGeneralObjFromDB($generalID);
|
||||||
|
|
||||||
if($defence_train != $me->getVar('defence_train')){
|
|
||||||
if($defence_train == 999){
|
if($defence_train != $me->getVar('defence_train')){
|
||||||
$me->increaseVar('myset', -1);
|
if($defence_train == 999){
|
||||||
$me->setVar('defence_train', $defence_train);
|
$me->increaseVar('myset', -1);
|
||||||
$me->increaseVar('train', -3);
|
$me->setVar('defence_train', $defence_train);
|
||||||
$me->increaseVar('atmos', -3);
|
$me->increaseVar('train', -3);
|
||||||
}
|
$me->increaseVar('atmos', -3);
|
||||||
else{
|
}
|
||||||
$me->increaseVar('myset', -1);
|
else{
|
||||||
$me->setVar('defence_train', $defence_train);
|
$me->increaseVar('myset', -1);
|
||||||
}
|
$me->setVar('defence_train', $defence_train);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$me->setAuxVar('use_treatment', Util::valueFit($use_treatment, 10, 100));
|
|
||||||
|
$me->setAuxVar('use_treatment', Util::valueFit($use_treatment, 10, 100));
|
||||||
if($me->getVar('tnmt') != $tnmt){
|
|
||||||
$me->setVar('tnmt', $tnmt);
|
if($use_auto_nation_turn != $me->getAuxVar('use_auto_nation_turn')){
|
||||||
}
|
$me->setAuxVar('use_auto_nation_turn', $use_auto_nation_turn);
|
||||||
|
}
|
||||||
if($me->getNPCType() == 1 && $detachNPC){
|
|
||||||
$turnterm = $gameStor->turnterm;
|
if($me->getVar('tnmt') != $tnmt){
|
||||||
|
$me->setVar('tnmt', $tnmt);
|
||||||
if($turnterm < 10){
|
}
|
||||||
$targetKillTurn = 30 / $turnterm;
|
|
||||||
}
|
if($me->getNPCType() == 1 && $detachNPC){
|
||||||
else{
|
$turnterm = $gameStor->turnterm;
|
||||||
$targetKillTurn = 60 / $turnterm;
|
|
||||||
}
|
if($turnterm < 10){
|
||||||
$me->setVar('killturn', $targetKillTurn);
|
$targetKillTurn = 30 / $turnterm;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
$me->applyDB($db);
|
$targetKillTurn = 60 / $turnterm;
|
||||||
|
}
|
||||||
Json::die([
|
$me->setVar('killturn', $targetKillTurn);
|
||||||
'result'=>true,
|
}
|
||||||
'reason'=>'success'
|
|
||||||
|
$me->applyDB($db);
|
||||||
|
|
||||||
|
Json::die([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success'
|
||||||
]);
|
]);
|
||||||
+465
-451
@@ -1,451 +1,465 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
WebUtil::requireAJAX();
|
WebUtil::requireAJAX();
|
||||||
|
|
||||||
$session = Session::requireLogin([])->setReadOnly();
|
$session = Session::requireLogin([])->setReadOnly();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
increaseRefresh("시뮬레이터", 0);
|
increaseRefresh("시뮬레이터", 0);
|
||||||
|
|
||||||
$query = Util::getPost('query');
|
$query = Util::getPost('query');
|
||||||
if($query === null){
|
if($query === null){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'입력값이 없습니다.'
|
'reason'=>'입력값이 없습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = Util::getPost('action');
|
$action = Util::getPost('action');
|
||||||
if($action === null || !in_array($action, ['reorder', 'battle'])){
|
if($action === null || !in_array($action, ['reorder', 'battle'])){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'원하는 동작이 지정되지 않았습니다.'
|
'reason'=>'원하는 동작이 지정되지 않았습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = Json::decode($query);
|
$query = Json::decode($query);
|
||||||
if($query === null){
|
if($query === null){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'올바르지 않은 JSON입니다.'
|
'reason'=>'올바르지 않은 JSON입니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaultCheck = [
|
$defaultCheck = [
|
||||||
'required'=>[
|
'required'=>[
|
||||||
'attackerGeneral', 'attackerCity', 'attackerNation',
|
'attackerGeneral', 'attackerCity', 'attackerNation',
|
||||||
'defenderGenerals', 'defenderCity', 'defenderNation',
|
'defenderGenerals', 'defenderCity', 'defenderNation',
|
||||||
'year', 'month', 'repeatCnt'
|
'year', 'month', 'repeatCnt'
|
||||||
],
|
],
|
||||||
'integer'=>[
|
'integer'=>[
|
||||||
'year','month','repeatCnt'
|
'year','month','repeatCnt'
|
||||||
],
|
],
|
||||||
'between'=>[
|
'between'=>[
|
||||||
['month', [1, 12]]
|
['month', [1, 12]]
|
||||||
],
|
],
|
||||||
'in'=>[
|
'in'=>[
|
||||||
['repeatCnt', [1, 1000]]
|
['repeatCnt', [1, 1000]]
|
||||||
],
|
],
|
||||||
'min'=>[
|
'min'=>[
|
||||||
['year', 0]
|
['year', 0]
|
||||||
],
|
],
|
||||||
'array'=>[
|
'array'=>[
|
||||||
'attackerGeneral', 'attackerCity', 'attackerNation',
|
'attackerGeneral', 'attackerCity', 'attackerNation',
|
||||||
'defenderGenerals', 'defenderCity', 'defenderNation'
|
'defenderGenerals', 'defenderCity', 'defenderNation'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$v = new Validator($query);
|
$v = new Validator($query);
|
||||||
$v->rules($defaultCheck);
|
$v->rules($defaultCheck);
|
||||||
if(!$v->validate()){
|
if(!$v->validate()){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>$v->errorStr()
|
'reason'=>$v->errorStr()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$year = $query['year'];
|
$year = $query['year'];
|
||||||
$month = $query['month'];
|
$month = $query['month'];
|
||||||
$repeatCnt = $query['repeatCnt'];
|
$repeatCnt = $query['repeatCnt'];
|
||||||
|
|
||||||
$rawAttacker = $query['attackerGeneral'];
|
$rawAttacker = $query['attackerGeneral'];
|
||||||
$rawAttacker['turntime'] = TimeUtil::now();
|
$rawAttacker['turntime'] = TimeUtil::now();
|
||||||
$rawAttackerCity = $query['attackerCity'];
|
$rawAttackerCity = $query['attackerCity'];
|
||||||
$rawAttackerNation = $query['attackerNation'];
|
$rawAttackerNation = $query['attackerNation'];
|
||||||
|
|
||||||
$rawDefenderList = $query['defenderGenerals'];
|
$rawDefenderList = $query['defenderGenerals'];
|
||||||
$rawDefenderCity = $query['defenderCity'];
|
$rawDefenderCity = $query['defenderCity'];
|
||||||
$rawDefenderNation = $query['defenderNation'];
|
$rawDefenderNation = $query['defenderNation'];
|
||||||
|
|
||||||
|
|
||||||
$generalCheck = [
|
$generalCheck = [
|
||||||
'required'=>[
|
'required'=>[
|
||||||
'no', 'name', 'nation', 'turntime', 'personal', 'special2', 'crew', 'crewtype', 'atmos', 'train',
|
'no', 'name', 'nation', 'turntime', 'personal', 'special2', 'crew', 'crewtype', 'atmos', 'train',
|
||||||
'intel', 'intel_exp', 'book', 'strength', 'strength_exp', 'weapon', 'injury', 'leadership', 'leadership_exp', 'horse', 'item',
|
'intel', 'intel_exp', 'book', 'strength', 'strength_exp', 'weapon', 'injury', 'leadership', 'leadership_exp', 'horse', 'item',
|
||||||
'explevel', 'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5',
|
'explevel', 'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5',
|
||||||
'recent_war'
|
'recent_war', 'warnum', 'killnum', 'killcrew',
|
||||||
],
|
],
|
||||||
'integer'=>[
|
'integer'=>[
|
||||||
'no', 'nation', 'crew', 'crewtype', 'atmos', 'train',
|
'no', 'nation', 'crew', 'crewtype', 'atmos', 'train',
|
||||||
'intel', 'intel_exp', 'strength', 'strength_exp', 'injury', 'leadership', 'leadership_exp',
|
'intel', 'intel_exp', 'strength', 'strength_exp', 'injury', 'leadership', 'leadership_exp',
|
||||||
'explevel', 'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5',
|
'explevel', 'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5',
|
||||||
],
|
'warnum', 'killnum', 'killcrew',
|
||||||
'min'=>[
|
],
|
||||||
['no', 1],
|
'min'=>[
|
||||||
['nation', 1],
|
['no', 1],
|
||||||
['crew', 0],
|
['nation', 1],
|
||||||
['intel', 0],
|
['crew', 0],
|
||||||
['strength', 0],
|
['intel', 0],
|
||||||
['leadership', 0],
|
['strength', 0],
|
||||||
['experience', 0],
|
['leadership', 0],
|
||||||
['gold', 0],
|
['experience', 0],
|
||||||
['rice', 0],
|
['gold', 0],
|
||||||
['dex1', 0],
|
['rice', 0],
|
||||||
['dex2', 0],
|
['dex1', 0],
|
||||||
['dex3', 0],
|
['dex2', 0],
|
||||||
['dex4', 0],
|
['dex3', 0],
|
||||||
['dex5', 0],
|
['dex4', 0],
|
||||||
],
|
['dex5', 0],
|
||||||
'between'=>[
|
['warnum', 0],
|
||||||
['train', [40, GameConst::$maxTrainByWar]],
|
['killnum', 0],
|
||||||
['atmos', [40, GameConst::$maxAtmosByWar]],
|
['killcrew', 0],
|
||||||
['explevel', [0, 300]],
|
],
|
||||||
['injury', [0, 80]],
|
'between'=>[
|
||||||
['officer_level', [1, 12]]
|
['train', [40, GameConst::$maxTrainByWar]],
|
||||||
],
|
['atmos', [40, GameConst::$maxAtmosByWar]],
|
||||||
'in'=>[
|
['explevel', [0, 300]],
|
||||||
['personal', array_merge(GameConst::$availablePersonality, GameConst::$optionalPersonality)],
|
['injury', [0, 80]],
|
||||||
['special2', array_merge(GameConst::$availableSpecialWar, GameConst::$optionalSpecialWar)],
|
['officer_level', [1, 12]]
|
||||||
['crewtype', array_keys(GameUnitConst::all())],
|
],
|
||||||
['horse', array_merge(array_keys(GameConst::$allItems['horse']), ['None'])],
|
'in'=>[
|
||||||
['weapon', array_merge(array_keys(GameConst::$allItems['weapon']), ['None'])],
|
['personal', array_merge(GameConst::$availablePersonality, GameConst::$optionalPersonality)],
|
||||||
['book', array_merge(array_keys(GameConst::$allItems['book']), ['None'])],
|
['special2', array_merge(GameConst::$availableSpecialWar, GameConst::$optionalSpecialWar)],
|
||||||
['item', array_merge(array_keys(GameConst::$allItems['item']), ['None'])],
|
['crewtype', array_keys(GameUnitConst::all())],
|
||||||
]
|
['horse', array_merge(array_keys(GameConst::$allItems['horse']), ['None'])],
|
||||||
];
|
['weapon', array_merge(array_keys(GameConst::$allItems['weapon']), ['None'])],
|
||||||
|
['book', array_merge(array_keys(GameConst::$allItems['book']), ['None'])],
|
||||||
$v = new Validator($rawAttacker);
|
['item', array_merge(array_keys(GameConst::$allItems['item']), ['None'])],
|
||||||
$v->rules($generalCheck);
|
]
|
||||||
if(!$v->validate()){
|
];
|
||||||
Json::die([
|
|
||||||
'result'=>false,
|
$v = new Validator($rawAttacker);
|
||||||
'reason'=>'[출병자]'.$v->errorStr()
|
$v->rules($generalCheck);
|
||||||
]);
|
if(!$v->validate()){
|
||||||
}
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
$defenderList = [];
|
'reason'=>'[출병자]'.$v->errorStr()
|
||||||
foreach($rawDefenderList as $idx=>$rawDefenderGeneral){
|
]);
|
||||||
$v = new Validator($rawDefenderGeneral);
|
}
|
||||||
$v->rules($generalCheck);
|
|
||||||
if(!$v->validate()){
|
$defenderList = [];
|
||||||
$idx+=1;
|
foreach($rawDefenderList as $idx=>$rawDefenderGeneral){
|
||||||
Json::die([
|
$v = new Validator($rawDefenderGeneral);
|
||||||
'result'=>false,
|
$v->rules($generalCheck);
|
||||||
'reason'=>"[수비자{$idx}]".$v->errorStr()
|
if(!$v->validate()){
|
||||||
]);
|
$idx+=1;
|
||||||
}
|
Json::die([
|
||||||
$defenderList[] = new General($rawDefenderGeneral, null, $rawDefenderCity, $rawAttackerNation, $year, $month, true);
|
'result'=>false,
|
||||||
}
|
'reason'=>"[수비자{$idx}]".$v->errorStr()
|
||||||
|
]);
|
||||||
|
}
|
||||||
$cityCheck = [
|
|
||||||
'required'=>[
|
$defenderList[] = new General($rawDefenderGeneral, extractRankVar($rawDefenderGeneral), $rawDefenderCity, $rawAttackerNation, $year, $month, true);
|
||||||
'city', 'nation', 'supply', 'name',
|
}
|
||||||
'pop', 'agri', 'comm', 'secu', 'def', 'wall',
|
|
||||||
'trust', 'level',
|
|
||||||
'pop_max', 'agri_max', 'comm_max', 'secu_max', 'def_max', 'wall_max',
|
$cityCheck = [
|
||||||
'dead', 'state', 'conflict',
|
'required'=>[
|
||||||
],
|
'city', 'nation', 'supply', 'name',
|
||||||
'numeric'=>[
|
'pop', 'agri', 'comm', 'secu', 'def', 'wall',
|
||||||
'pop', 'agri', 'comm', 'secu', 'def', 'wall', 'trust', 'dead'
|
'trust', 'level',
|
||||||
],
|
'pop_max', 'agri_max', 'comm_max', 'secu_max', 'def_max', 'wall_max',
|
||||||
'integer'=>[
|
'dead', 'state', 'conflict',
|
||||||
'city', 'nation', 'supply',
|
],
|
||||||
'pop_max', 'agri_max', 'comm_max', 'secu_max', 'def_max', 'wall_max',
|
'numeric'=>[
|
||||||
'state',
|
'pop', 'agri', 'comm', 'secu', 'def', 'wall', 'trust', 'dead'
|
||||||
],
|
],
|
||||||
'min'=>[
|
'integer'=>[
|
||||||
['def', 0],
|
'city', 'nation', 'supply',
|
||||||
['wall', 0],
|
'pop_max', 'agri_max', 'comm_max', 'secu_max', 'def_max', 'wall_max',
|
||||||
['trust', 0],
|
'state',
|
||||||
['pop', 0],
|
],
|
||||||
['comm', 0],
|
'min'=>[
|
||||||
['secu', 0],
|
['def', 0],
|
||||||
['city', 1],
|
['wall', 0],
|
||||||
['nation', 0]
|
['trust', 0],
|
||||||
],
|
['pop', 0],
|
||||||
'in'=>[
|
['comm', 0],
|
||||||
['level', array_keys(getCityLevelList())]
|
['secu', 0],
|
||||||
]
|
['city', 1],
|
||||||
];
|
['nation', 0]
|
||||||
|
],
|
||||||
$v = new Validator($rawAttackerCity);
|
'in'=>[
|
||||||
$v->rules($cityCheck);
|
['level', array_keys(getCityLevelList())]
|
||||||
if(!$v->validate()){
|
]
|
||||||
Json::die([
|
];
|
||||||
'result'=>false,
|
|
||||||
'reason'=>'[출병도시]'.$v->errorStr()
|
$v = new Validator($rawAttackerCity);
|
||||||
]);
|
$v->rules($cityCheck);
|
||||||
}
|
if(!$v->validate()){
|
||||||
|
Json::die([
|
||||||
$v = new Validator($rawDefenderCity);
|
'result'=>false,
|
||||||
$v->rules($cityCheck);
|
'reason'=>'[출병도시]'.$v->errorStr()
|
||||||
if(!$v->validate()){
|
]);
|
||||||
Json::die([
|
}
|
||||||
'result'=>false,
|
|
||||||
'reason'=>'[수비도시]'.$v->errorStr()
|
$v = new Validator($rawDefenderCity);
|
||||||
]);
|
$v->rules($cityCheck);
|
||||||
}
|
if(!$v->validate()){
|
||||||
|
Json::die([
|
||||||
$nationCheck = [
|
'result'=>false,
|
||||||
'required'=>[
|
'reason'=>'[수비도시]'.$v->errorStr()
|
||||||
'type', 'tech', 'level', 'capital',
|
]);
|
||||||
'nation', 'name', 'gold', 'rice', 'gennum'
|
}
|
||||||
],
|
|
||||||
'integer'=>[
|
$nationCheck = [
|
||||||
'level', 'capital', 'nation', 'gennum',
|
'required'=>[
|
||||||
],
|
'type', 'tech', 'level', 'capital',
|
||||||
'numeric'=>[
|
'nation', 'name', 'gold', 'rice', 'gennum'
|
||||||
'tech', 'gold', 'rice'
|
],
|
||||||
],
|
'integer'=>[
|
||||||
'min'=>[
|
'level', 'capital', 'nation', 'gennum',
|
||||||
['tech', 0],
|
],
|
||||||
['gold', 0],
|
'numeric'=>[
|
||||||
['rice', 0],
|
'tech', 'gold', 'rice'
|
||||||
['gennum', 1],
|
],
|
||||||
],
|
'min'=>[
|
||||||
'in'=>[
|
['tech', 0],
|
||||||
['type', GameConst::$availableNationType],
|
['gold', 0],
|
||||||
['level', array_keys(getNationLevelList())]
|
['rice', 0],
|
||||||
]
|
['gennum', 1],
|
||||||
];
|
],
|
||||||
|
'in'=>[
|
||||||
$v = new Validator($rawAttackerNation);
|
['type', GameConst::$availableNationType],
|
||||||
$v->rules($nationCheck);
|
['level', array_keys(getNationLevelList())]
|
||||||
if(!$v->validate()){
|
]
|
||||||
Json::die([
|
];
|
||||||
'result'=>false,
|
|
||||||
'reason'=>'[출병국]'.$v->errorStr()
|
$v = new Validator($rawAttackerNation);
|
||||||
]);
|
$v->rules($nationCheck);
|
||||||
}
|
if(!$v->validate()){
|
||||||
|
Json::die([
|
||||||
$v = new Validator($rawDefenderNation);
|
'result'=>false,
|
||||||
$v->rules($nationCheck);
|
'reason'=>'[출병국]'.$v->errorStr()
|
||||||
if(!$v->validate()){
|
]);
|
||||||
Json::die([
|
}
|
||||||
'result'=>false,
|
|
||||||
'reason'=>'[수비국]'.$v->errorStr()
|
$v = new Validator($rawDefenderNation);
|
||||||
]);
|
$v->rules($nationCheck);
|
||||||
}
|
if(!$v->validate()){
|
||||||
|
Json::die([
|
||||||
if($action == 'reorder'){
|
'result'=>false,
|
||||||
usort($defenderList, function(General $lhs, General $rhs){
|
'reason'=>'[수비국]'.$v->errorStr()
|
||||||
return -(extractBattleOrder($lhs) <=> extractBattleOrder($rhs));
|
]);
|
||||||
});
|
}
|
||||||
|
|
||||||
$order = [];
|
if($action == 'reorder'){
|
||||||
foreach($defenderList as $defenderGeneral){
|
usort($defenderList, function(General $lhs, General $rhs){
|
||||||
$order[] = $defenderGeneral->getID();
|
return -(extractBattleOrder($lhs) <=> extractBattleOrder($rhs));
|
||||||
}
|
});
|
||||||
|
|
||||||
Json::die([
|
$order = [];
|
||||||
'result'=>true,
|
foreach($defenderList as $defenderGeneral){
|
||||||
'reason'=>'success',
|
$order[] = $defenderGeneral->getID();
|
||||||
'order'=>$order
|
}
|
||||||
]);
|
|
||||||
}
|
Json::die([
|
||||||
|
'result'=>true,
|
||||||
usort($defenderList, function(General $lhs, General $rhs){
|
'reason'=>'success',
|
||||||
return -(extractBattleOrder($lhs) <=> extractBattleOrder($rhs));
|
'order'=>$order
|
||||||
});
|
]);
|
||||||
|
}
|
||||||
$rawDefenderList = array_map(function(General $general){
|
|
||||||
return $general->getRaw();
|
usort($defenderList, function(General $lhs, General $rhs){
|
||||||
}, $defenderList);
|
return -(extractBattleOrder($lhs) <=> extractBattleOrder($rhs));
|
||||||
unset($defenderList);
|
});
|
||||||
|
|
||||||
$db = DB::db();
|
$rawDefenderList = array_map(function(General $general){
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
return $general->getRaw();
|
||||||
$startYear = $gameStor->startyear;
|
}, $defenderList);
|
||||||
$cityRate = Util::round(($year - $startYear) / 1.5) + 60;
|
unset($defenderList);
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
function simulateBattle(
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$rawAttacker, $rawAttackerCity, $rawAttackerNation,
|
$startYear = $gameStor->startyear;
|
||||||
$rawDefenderList, $rawDefenderCity, $rawDefenderNation,
|
$cityRate = Util::round(($year - $startYear) / 1.5) + 60;
|
||||||
$startYear, $year, $month, $cityRate
|
|
||||||
){
|
function extractRankVar(array $rawVal):array{
|
||||||
$attacker = new WarUnitGeneral(
|
$rankVars = [];
|
||||||
new General($rawAttacker, null, $rawAttackerCity, $rawAttackerNation, $year, $month),
|
foreach($rawVal as $rawKey=>$rawVal){
|
||||||
$rawAttackerNation,
|
if(key_exists($rawKey, General::RANK_COLUMN)){
|
||||||
true
|
$rankVars[$rawKey] = $rawVal;
|
||||||
);
|
}
|
||||||
$city = new WarUnitCity($rawDefenderCity, $rawDefenderNation, $year, $month, $cityRate);
|
}
|
||||||
|
return $rankVars;
|
||||||
$iterDefender = new \ArrayIterator($rawDefenderList);
|
}
|
||||||
$iterDefender->rewind();
|
|
||||||
|
function simulateBattle(
|
||||||
$battleResult = [];
|
$rawAttacker, $rawAttackerCity, $rawAttackerNation,
|
||||||
|
$rawDefenderList, $rawDefenderCity, $rawDefenderNation,
|
||||||
$attackerRice = $rawAttacker['rice'];
|
$startYear, $year, $month, $cityRate
|
||||||
$defenderRice = 0;
|
){
|
||||||
|
$attacker = new WarUnitGeneral(
|
||||||
$getNextDefender = function(?WarUnit $prevDefender, bool $reqNext)
|
new General($rawAttacker, extractRankVar($rawAttacker), $rawAttackerCity, $rawAttackerNation, $year, $month),
|
||||||
use ($iterDefender, $rawDefenderCity, $rawDefenderNation, $year, $month, &$battleResult, &$defenderRice) {
|
$rawAttackerNation,
|
||||||
if($prevDefender !== null){
|
true
|
||||||
$prevDefender->getLogger()->rollback();
|
);
|
||||||
$battleResult[] = $prevDefender;
|
$city = new WarUnitCity($rawDefenderCity, $rawDefenderNation, $year, $month, $cityRate);
|
||||||
if($prevDefender instanceof WarUnitGeneral){
|
|
||||||
$defenderRice -= $prevDefender->getVar('rice');
|
$iterDefender = new \ArrayIterator($rawDefenderList);
|
||||||
}
|
$iterDefender->rewind();
|
||||||
}
|
|
||||||
|
$battleResult = [];
|
||||||
if(!$reqNext){
|
|
||||||
return null;
|
$attackerRice = $rawAttacker['rice'];
|
||||||
}
|
$defenderRice = 0;
|
||||||
|
|
||||||
if(!$iterDefender->valid()){
|
$getNextDefender = function(?WarUnit $prevDefender, bool $reqNext)
|
||||||
return null;
|
use ($iterDefender, $rawDefenderCity, $rawDefenderNation, $year, $month, &$battleResult, &$defenderRice) {
|
||||||
}
|
if($prevDefender !== null){
|
||||||
|
$prevDefender->getLogger()->rollback();
|
||||||
$defenderObj = new General($iterDefender->current(), null, $rawDefenderCity, $rawDefenderNation, $year, $month);
|
$battleResult[] = $prevDefender;
|
||||||
if(extractBattleOrder($defenderObj) <= 0){
|
if($prevDefender instanceof WarUnitGeneral){
|
||||||
return null;
|
$defenderRice -= $prevDefender->getVar('rice');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$defenderRice += $defenderObj->getVar('rice');
|
|
||||||
|
if(!$reqNext){
|
||||||
$retVal = new WarUnitGeneral(
|
return null;
|
||||||
$defenderObj,
|
}
|
||||||
$rawDefenderNation,
|
|
||||||
false
|
if(!$iterDefender->valid()){
|
||||||
);
|
return null;
|
||||||
$iterDefender->next();
|
}
|
||||||
return $retVal;
|
|
||||||
};
|
$defenderObj = new General($iterDefender->current(), extractRankVar($iterDefender->current()), $rawDefenderCity, $rawDefenderNation, $year, $month);
|
||||||
|
if(extractBattleOrder($defenderObj) <= 0){
|
||||||
$conquerCity = processWar_NG($attacker, $getNextDefender, $city, $year - $startYear);
|
return null;
|
||||||
|
}
|
||||||
$rawDefenderCity = $city->getRaw();
|
|
||||||
$updateAttackerNation = [];
|
$defenderRice += $defenderObj->getVar('rice');
|
||||||
$updateDefenderNation = [];
|
|
||||||
|
$retVal = new WarUnitGeneral(
|
||||||
$attackerRice -= $attacker->getVar('rice');
|
$defenderObj,
|
||||||
|
$rawDefenderNation,
|
||||||
if($city->getPhase() > 0){
|
false
|
||||||
$rice = $city->getKilled() / 100 * 0.8;
|
);
|
||||||
$rice *= $city->getCrewType()->rice;
|
$iterDefender->next();
|
||||||
$rice *= getTechCost($rawDefenderNation['tech']);
|
return $retVal;
|
||||||
$rice *= $cityRate / 100 - 0.2;
|
};
|
||||||
Util::setRound($rice);
|
|
||||||
|
$conquerCity = processWar_NG($attacker, $getNextDefender, $city, $year - $startYear);
|
||||||
$defenderRice += $rice;
|
|
||||||
}
|
$rawDefenderCity = $city->getRaw();
|
||||||
|
$updateAttackerNation = [];
|
||||||
$totalDead = $attacker->getKilled() + $attacker->getDead();
|
$updateDefenderNation = [];
|
||||||
$attackerCityDead = $totalDead * 0.4;
|
|
||||||
$defenderCityDead = $totalDead * 0.6;
|
$attackerRice -= $attacker->getVar('rice');
|
||||||
|
|
||||||
return [$attacker, $city, $battleResult, $conquerCity, $attackerRice, $defenderRice];
|
if($city->getPhase() > 0){
|
||||||
}
|
$rice = $city->getKilled() / 100 * 0.8;
|
||||||
|
$rice *= $city->getCrewType()->rice;
|
||||||
$lastWarLog = [];
|
$rice *= getTechCost($rawDefenderNation['tech']);
|
||||||
|
$rice *= $cityRate / 100 - 0.2;
|
||||||
$attackerKilled = 0;
|
Util::setRound($rice);
|
||||||
$attackerDead = 0;
|
|
||||||
|
$defenderRice += $rice;
|
||||||
$attackerMaxKilled = 0;
|
}
|
||||||
$attackerMinKilled = PHP_INT_MAX;
|
|
||||||
|
$totalDead = $attacker->getKilled() + $attacker->getDead();
|
||||||
$attackerMaxDead = 0;
|
$attackerCityDead = $totalDead * 0.4;
|
||||||
$attackerMinDead = PHP_INT_MAX;
|
$defenderCityDead = $totalDead * 0.6;
|
||||||
|
|
||||||
|
return [$attacker, $city, $battleResult, $conquerCity, $attackerRice, $defenderRice];
|
||||||
$attackerAvgRice = 0;
|
}
|
||||||
$defenderAvgRice = 0;
|
|
||||||
|
$lastWarLog = [];
|
||||||
$avgPhase = 0;
|
|
||||||
$avgWar = 0;
|
$attackerKilled = 0;
|
||||||
|
$attackerDead = 0;
|
||||||
$attackerActivatedSkills = [];
|
|
||||||
$defendersActivatedSkills = [];
|
$attackerMaxKilled = 0;
|
||||||
|
$attackerMinKilled = PHP_INT_MAX;
|
||||||
foreach(Util::range($repeatCnt) as $repeatIdx){
|
|
||||||
/** @var WarUnit $attacker */
|
$attackerMaxDead = 0;
|
||||||
[$attacker, $city, $battleResult, $conquerCity, $attackerRice, $defenderRice] = simulateBattle(
|
$attackerMinDead = PHP_INT_MAX;
|
||||||
$rawAttacker, $rawAttackerCity, $rawAttackerNation,
|
|
||||||
$rawDefenderList, $rawDefenderCity, $rawDefenderNation,
|
|
||||||
$startYear, $year, $month, $cityRate
|
$attackerAvgRice = 0;
|
||||||
);
|
$defenderAvgRice = 0;
|
||||||
$lastWarLog = Util::mapWithKey(function($key, $values){
|
|
||||||
return ConvertLog(join('<br>', $values));
|
$avgPhase = 0;
|
||||||
}, $attacker->getLogger()->rollback());
|
$avgWar = 0;
|
||||||
|
|
||||||
$avgPhase += $attacker->getPhase() / $repeatCnt;
|
$attackerActivatedSkills = [];
|
||||||
|
$defendersActivatedSkills = [];
|
||||||
$killed = $attacker->getKilled();
|
|
||||||
$dead = $attacker->getDead();
|
foreach(Util::range($repeatCnt) as $repeatIdx){
|
||||||
|
/** @var WarUnit $attacker */
|
||||||
$attackerKilled += $killed / $repeatCnt;
|
[$attacker, $city, $battleResult, $conquerCity, $attackerRice, $defenderRice] = simulateBattle(
|
||||||
$attackerDead += $dead / $repeatCnt;
|
$rawAttacker, $rawAttackerCity, $rawAttackerNation,
|
||||||
|
$rawDefenderList, $rawDefenderCity, $rawDefenderNation,
|
||||||
$attackerMaxKilled = max($attackerMaxKilled, $killed);
|
$startYear, $year, $month, $cityRate
|
||||||
$attackerMinKilled = min($attackerMinKilled, $killed);
|
);
|
||||||
|
$lastWarLog = Util::mapWithKey(function($key, $values){
|
||||||
$attackerMaxDead = max($attackerMaxDead, $dead);
|
return ConvertLog(join('<br>', $values));
|
||||||
$attackerMinDead = min($attackerMinDead, $dead);
|
}, $attacker->getLogger()->rollback());
|
||||||
|
|
||||||
$attackerAvgRice += $attackerRice / $repeatCnt;
|
$avgPhase += $attacker->getPhase() / $repeatCnt;
|
||||||
$defenderAvgRice += $defenderRice / $repeatCnt;
|
|
||||||
|
$killed = $attacker->getKilled();
|
||||||
$avgWar += count($battleResult) / $repeatCnt;
|
$dead = $attacker->getDead();
|
||||||
|
|
||||||
foreach($attacker->getActivatedSkillLog() as $skillName => $skillCnt){
|
$attackerKilled += $killed / $repeatCnt;
|
||||||
if(!key_exists($skillName, $attackerActivatedSkills)){
|
$attackerDead += $dead / $repeatCnt;
|
||||||
$attackerActivatedSkills[$skillName] = $skillCnt / $repeatCnt;
|
|
||||||
}
|
$attackerMaxKilled = max($attackerMaxKilled, $killed);
|
||||||
else{
|
$attackerMinKilled = min($attackerMinKilled, $killed);
|
||||||
$attackerActivatedSkills[$skillName] += $skillCnt / $repeatCnt;
|
|
||||||
}
|
$attackerMaxDead = max($attackerMaxDead, $dead);
|
||||||
}
|
$attackerMinDead = min($attackerMinDead, $dead);
|
||||||
|
|
||||||
foreach($battleResult as $idx=>$defender){
|
$attackerAvgRice += $attackerRice / $repeatCnt;
|
||||||
while($idx >= count($defendersActivatedSkills)){
|
$defenderAvgRice += $defenderRice / $repeatCnt;
|
||||||
$defendersActivatedSkills[] = [];
|
|
||||||
}
|
$avgWar += count($battleResult) / $repeatCnt;
|
||||||
|
|
||||||
$activatedSkills = &$defendersActivatedSkills[$idx];
|
foreach($attacker->getActivatedSkillLog() as $skillName => $skillCnt){
|
||||||
foreach($defender->getActivatedSkillLog() as $skillName => $skillCnt){
|
if(!key_exists($skillName, $attackerActivatedSkills)){
|
||||||
if(!key_exists($skillName, $activatedSkills)){
|
$attackerActivatedSkills[$skillName] = $skillCnt / $repeatCnt;
|
||||||
$activatedSkills[$skillName] = $skillCnt / $repeatCnt;
|
}
|
||||||
}
|
else{
|
||||||
else{
|
$attackerActivatedSkills[$skillName] += $skillCnt / $repeatCnt;
|
||||||
$activatedSkills[$skillName] += $skillCnt / $repeatCnt;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
foreach($battleResult as $idx=>$defender){
|
||||||
}
|
while($idx >= count($defendersActivatedSkills)){
|
||||||
}
|
$defendersActivatedSkills[] = [];
|
||||||
|
}
|
||||||
Json::die([
|
|
||||||
'result'=>true,
|
$activatedSkills = &$defendersActivatedSkills[$idx];
|
||||||
'datetime'=>$rawAttacker['turntime'],
|
foreach($defender->getActivatedSkillLog() as $skillName => $skillCnt){
|
||||||
'reason'=>'success',
|
if(!key_exists($skillName, $activatedSkills)){
|
||||||
'lastWarLog'=>$lastWarLog,
|
$activatedSkills[$skillName] = $skillCnt / $repeatCnt;
|
||||||
'avgWar'=>$avgWar,
|
}
|
||||||
'phase'=>$avgPhase,
|
else{
|
||||||
'killed'=>$attackerKilled,
|
$activatedSkills[$skillName] += $skillCnt / $repeatCnt;
|
||||||
'maxKilled'=>$attackerMaxKilled,
|
}
|
||||||
'minKilled'=>$attackerMinKilled,
|
}
|
||||||
'dead'=>$attackerDead,
|
|
||||||
'maxDead'=>$attackerMaxDead,
|
}
|
||||||
'minDead'=>$attackerMinDead,
|
}
|
||||||
'attackerRice'=>$attackerAvgRice,
|
|
||||||
'defenderRice'=>$defenderAvgRice,
|
Json::die([
|
||||||
'attackerSkills'=>$attackerActivatedSkills,
|
'result'=>true,
|
||||||
'defendersSkills'=>$defendersActivatedSkills,
|
'datetime'=>$rawAttacker['turntime'],
|
||||||
]);
|
'reason'=>'success',
|
||||||
|
'lastWarLog'=>$lastWarLog,
|
||||||
|
'avgWar'=>$avgWar,
|
||||||
|
'phase'=>$avgPhase,
|
||||||
|
'killed'=>$attackerKilled,
|
||||||
|
'maxKilled'=>$attackerMaxKilled,
|
||||||
|
'minKilled'=>$attackerMinKilled,
|
||||||
|
'dead'=>$attackerDead,
|
||||||
|
'maxDead'=>$attackerMaxDead,
|
||||||
|
'minDead'=>$attackerMinDead,
|
||||||
|
'attackerRice'=>$attackerAvgRice,
|
||||||
|
'defenderRice'=>$defenderAvgRice,
|
||||||
|
'attackerSkills'=>$attackerActivatedSkills,
|
||||||
|
'defendersSkills'=>$defendersActivatedSkills,
|
||||||
|
]);
|
||||||
|
|||||||
+931
-799
@@ -1,800 +1,932 @@
|
|||||||
jQuery(function($){
|
jQuery(function($) {
|
||||||
|
|
||||||
|
|
||||||
var $generalForm = $('.form_sample .general_detail');
|
var $generalForm = $('.form_sample .general_detail');
|
||||||
var $defenderHeaderForm = $('.form_sample .card-header');
|
var $defenderHeaderForm = $('.form_sample .card-header');
|
||||||
var $defenderColumn = $('.defender-column');
|
var $defenderColumn = $('.defender-column');
|
||||||
|
|
||||||
var defenderNoList = {};
|
var defenderNoList = {};
|
||||||
|
|
||||||
var $attackerCard = $('.attacker_form');
|
var $attackerCard = $('.attacker_form');
|
||||||
|
|
||||||
var initBasicEvent = function(){
|
var initBasicEvent = function() {
|
||||||
|
|
||||||
$('.form_injury').change(function(){
|
if (window.nation) {
|
||||||
var $this = $(this);
|
$('.form_city_level').val(window.city.level);
|
||||||
var $general = getGeneralDetail($this);
|
$('.form_def').val(parseInt(window.city.def));
|
||||||
var $helptext = $general.find('.injury_helptext');
|
$('.form_wall').val(parseInt(window.city.wall));
|
||||||
|
$('.form_nation_type').val(window.nation.type);
|
||||||
var injury = parseInt($this.val());
|
$('.form_nation_level').val(window.nation.level);
|
||||||
//FIXME: PHP 코드와 항상 일치하도록 변경
|
$('.form_tech').val(parseInt(window.nation.tech / 1000));
|
||||||
var text = '건강';
|
if (window.nation.capital == window.city.city) {
|
||||||
var color = 'white';
|
$('.attacker_nation .form_is_capital:first').click();
|
||||||
if(injury > 60){
|
$('.defender_nation .form_is_capital:first').click();
|
||||||
text = '위독';
|
} else {
|
||||||
color = 'red';
|
$('.attacker_nation .form_is_capital:last').click();
|
||||||
}
|
$('.defender_nation .form_is_capital:last').click();
|
||||||
else if(injury > 40){
|
}
|
||||||
text = '심각';
|
} else {
|
||||||
color = 'magenta';
|
$('.attacker_nation .form_is_capital:last').click();
|
||||||
}
|
$('.defender_nation .form_is_capital:last').click();
|
||||||
else if(injury > 20){
|
}
|
||||||
text = '중상';
|
|
||||||
color = 'orange';
|
$('.form_injury').change(function() {
|
||||||
}
|
var $this = $(this);
|
||||||
else if(injury > 0){
|
var $general = getGeneralDetail($this);
|
||||||
text = '경상';
|
var $helptext = $general.find('.injury_helptext');
|
||||||
color = 'yellow';
|
|
||||||
}
|
var injury = parseInt($this.val());
|
||||||
$helptext.html(text).css('color', color);
|
//FIXME: PHP 코드와 항상 일치하도록 변경
|
||||||
});
|
var text = '건강';
|
||||||
|
var color = 'white';
|
||||||
$('.export_general').click(function(){
|
if (injury > 60) {
|
||||||
var $btn = $(this);
|
text = '위독';
|
||||||
var $general = getGeneralDetail($btn);
|
color = 'red';
|
||||||
|
} else if (injury > 40) {
|
||||||
var values = exportGeneralInfo($general);
|
text = '심각';
|
||||||
console.log(values);
|
color = 'magenta';
|
||||||
});
|
} else if (injury > 20) {
|
||||||
$('.delete-defender').click(function(){
|
text = '중상';
|
||||||
var $card = getGeneralFrame($(this));
|
color = 'orange';
|
||||||
deleteDefender($card);
|
} else if (injury > 0) {
|
||||||
});
|
text = '경상';
|
||||||
$('.copy-defender').click(function(){
|
color = 'yellow';
|
||||||
var $card = getGeneralFrame($(this));
|
}
|
||||||
copyDefender($card);
|
$helptext.html(text).css('color', color);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.add-defender').click(function(){
|
$('.export_general').click(function() {
|
||||||
addDefender();
|
var $btn = $(this);
|
||||||
});
|
var $general = getGeneralDetail($btn);
|
||||||
|
|
||||||
$('.btn-general-load').click(function(){
|
var values = exportGeneralInfo($general);
|
||||||
var $file = $(this).prev();
|
console.log(values);
|
||||||
$file[0].click();
|
});
|
||||||
})
|
$('.delete-defender').click(function() {
|
||||||
|
var $card = getGeneralFrame($(this));
|
||||||
$('.form_load_general_file').on('change', function(e){
|
deleteDefender($card);
|
||||||
e.preventDefault();
|
});
|
||||||
var $this = $(this);
|
$('.copy-defender').click(function() {
|
||||||
var $card = getGeneralFrame($this);
|
var $card = getGeneralFrame($(this));
|
||||||
|
copyDefender($card);
|
||||||
var files = e.target.files;
|
});
|
||||||
|
|
||||||
importGeneralInfoByFile(files, $card);
|
$('.add-defender').click(function() {
|
||||||
return false;
|
addDefender();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn-general-save').click(function(){
|
$('.btn-general-load').click(function() {
|
||||||
var $this = $(this);
|
var $file = $(this).prev();
|
||||||
var $general = getGeneralDetail($this);
|
$file[0].click();
|
||||||
var generalData = exportGeneralInfo($general);
|
})
|
||||||
|
|
||||||
var filename = "general_{0}.json".format(generalData.name);
|
$('.form_load_general_file').on('change', function(e) {
|
||||||
var saveData = JSON.stringify({
|
e.preventDefault();
|
||||||
objType:'general',
|
var $this = $(this);
|
||||||
data:generalData
|
var $card = getGeneralFrame($this);
|
||||||
}, null, 4);
|
|
||||||
|
var files = e.target.files;
|
||||||
download(saveData, filename, 'application/json');
|
|
||||||
});
|
importGeneralInfoByFile(files, $card);
|
||||||
|
return false;
|
||||||
$('.btn-battle-load').click(function(){
|
});
|
||||||
var $file = $(this).prev();
|
|
||||||
$file[0].click();
|
$('.btn-general-import-server').click(function() {
|
||||||
})
|
var $this = $(this);
|
||||||
|
var $card = getGeneralFrame($this);
|
||||||
$('.form_load_battle_file').on('change', function(e){
|
|
||||||
e.preventDefault();
|
var $modal = $('#importModal');
|
||||||
var $this = $(this);
|
$modal.data('target', $card);
|
||||||
var files = e.target.files;
|
$modal.modal('show');
|
||||||
|
});
|
||||||
importBattleInfoByFile(files);
|
|
||||||
return false;
|
$('.btn-general-save').click(function() {
|
||||||
});
|
var $this = $(this);
|
||||||
|
var $general = getGeneralDetail($this);
|
||||||
$('.btn-battle-save').click(function(){
|
var generalData = exportGeneralInfo($general);
|
||||||
var battleData = exportAllData();
|
|
||||||
var filename = "battle_{0}.json".format(moment().format('YYYYMMDD_hhmmss'));
|
var filename = "general_{0}.json".format(generalData.name);
|
||||||
var saveData = JSON.stringify({
|
var saveData = JSON.stringify({
|
||||||
objType:'battle',
|
objType: 'general',
|
||||||
data:battleData
|
data: generalData
|
||||||
}, null, 4);
|
}, null, 4);
|
||||||
|
|
||||||
download(saveData, filename, 'application/json');
|
download(saveData, filename, 'application/json');
|
||||||
})
|
});
|
||||||
|
|
||||||
var $generals = $('.general_detail');
|
$('.btn-battle-load').click(function() {
|
||||||
$generals.bind('dragover dragleave', function(e) {
|
var $file = $(this).prev();
|
||||||
e.stopPropagation()
|
$file[0].click();
|
||||||
e.preventDefault()
|
})
|
||||||
})
|
|
||||||
$generals.bind('drop', function(e){
|
$('.form_load_battle_file').on('change', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $card = getGeneralFrame($this);
|
var files = e.target.files;
|
||||||
|
|
||||||
var files = e.originalEvent.dataTransfer.files;
|
importBattleInfoByFile(files);
|
||||||
|
return false;
|
||||||
importGeneralInfoByFile(files, $card);
|
});
|
||||||
return false;
|
|
||||||
});
|
$('.btn-battle-save').click(function() {
|
||||||
|
var battleData = exportAllData();
|
||||||
var $battlePad = $('.dragpad_battle');
|
var filename = "battle_{0}.json".format(moment().format('YYYYMMDD_hhmmss'));
|
||||||
$battlePad.bind('dragover dragleave', function(e) {
|
var saveData = JSON.stringify({
|
||||||
e.stopPropagation()
|
objType: 'battle',
|
||||||
e.preventDefault()
|
data: battleData
|
||||||
})
|
}, null, 4);
|
||||||
$battlePad.bind('drop', function(e){
|
|
||||||
e.preventDefault();
|
download(saveData, filename, 'application/json');
|
||||||
|
})
|
||||||
var files = e.originalEvent.dataTransfer.files;
|
|
||||||
|
var $generals = $('.general_detail');
|
||||||
importBattleInfoByFile(files);
|
$generals.bind('dragover dragleave', function(e) {
|
||||||
return false;
|
e.stopPropagation()
|
||||||
});
|
e.preventDefault()
|
||||||
}
|
})
|
||||||
|
$generals.bind('drop', function(e) {
|
||||||
var importGeneralInfo = function($general, data){
|
e.preventDefault();
|
||||||
var setVal = function(query, val){
|
var $this = $(this);
|
||||||
$general.find(query).val(val).change();
|
var $card = getGeneralFrame($this);
|
||||||
}
|
|
||||||
|
var files = e.originalEvent.dataTransfer.files;
|
||||||
setVal('.form_general_name', data.name);
|
|
||||||
|
importGeneralInfoByFile(files, $card);
|
||||||
setVal('.form_officer_level', data.officer_level);
|
return false;
|
||||||
setVal('.form_exp_level', data.explevel);
|
});
|
||||||
setVal('.form_injury', data.injury);
|
|
||||||
|
var $battlePad = $('.dragpad_battle');
|
||||||
setVal('.form_leadership', data.leadership);
|
$battlePad.bind('dragover dragleave', function(e) {
|
||||||
setVal('.form_general_horse', data.horse);
|
e.stopPropagation()
|
||||||
setVal('.form_strength', data.strength);
|
e.preventDefault()
|
||||||
setVal('.form_general_weap', data.weapon);
|
})
|
||||||
setVal('.form_intel', data.intel);
|
$battlePad.bind('drop', function(e) {
|
||||||
setVal('.form_general_book', data.book);
|
e.preventDefault();
|
||||||
setVal('.form_general_item', data.item);
|
|
||||||
|
var files = e.originalEvent.dataTransfer.files;
|
||||||
setVal('.form_injury', data.injury);
|
|
||||||
|
importBattleInfoByFile(files);
|
||||||
setVal('.form_rice', data.rice);
|
return false;
|
||||||
|
});
|
||||||
setVal('.form_general_character', data.personal);
|
}
|
||||||
setVal('.form_general_special_war', data.special2);
|
|
||||||
|
var importGeneralInfo = function($general, data) {
|
||||||
setVal('.form_crew', data.crew);
|
var setVal = function(query, val) {
|
||||||
setVal('.form_crewtype', data.crewtype);
|
$general.find(query).val(val).change();
|
||||||
setVal('.form_atmos', data.atmos);
|
}
|
||||||
setVal('.form_train', data.train);
|
|
||||||
|
setVal('.form_general_name', data.name);
|
||||||
setVal('.form_dex1', data.dex1);
|
|
||||||
setVal('.form_dex2', data.dex2);
|
setVal('.form_officer_level', data.officer_level);
|
||||||
setVal('.form_dex3', data.dex3);
|
setVal('.form_exp_level', data.explevel);
|
||||||
setVal('.form_dex4', data.dex4);
|
|
||||||
setVal('.form_dex5', data.dex5);
|
setVal('.form_leadership', data.leadership);
|
||||||
setVal('.form_defence_train', data.defence_train);
|
setVal('.form_general_horse', data.horse);
|
||||||
|
setVal('.form_strength', data.strength);
|
||||||
if(!setGeneralNo($general, data.no)){
|
setVal('.form_general_weap', data.weapon);
|
||||||
setGeneralNo($general, generateNewGeneralNo());
|
setVal('.form_intel', data.intel);
|
||||||
}
|
setVal('.form_general_book', data.book);
|
||||||
}
|
setVal('.form_general_item', data.item);
|
||||||
|
|
||||||
var exportGeneralInfo = function($general){
|
setVal('.form_injury', data.injury);
|
||||||
var getInt = function(query){
|
|
||||||
return parseInt($general.find(query).val());
|
setVal('.form_rice', data.rice);
|
||||||
}
|
|
||||||
|
setVal('.form_general_character', data.personal);
|
||||||
var getVal = function(query){
|
setVal('.form_general_special_war', data.special2);
|
||||||
return $general.find(query).val();
|
|
||||||
}
|
setVal('.form_crew', data.crew);
|
||||||
|
setVal('.form_crewtype', data.crewtype);
|
||||||
return {
|
setVal('.form_atmos', data.atmos);
|
||||||
no:getGeneralNo($general),
|
setVal('.form_train', data.train);
|
||||||
name:getVal('.form_general_name'),
|
|
||||||
officer_level:getInt('.form_officer_level'),
|
setVal('.form_dex1', data.dex1);
|
||||||
explevel:getInt('.form_exp_level'),
|
setVal('.form_dex2', data.dex2);
|
||||||
|
setVal('.form_dex3', data.dex3);
|
||||||
leadership:getInt('.form_leadership'),
|
setVal('.form_dex4', data.dex4);
|
||||||
horse:getVal('.form_general_horse'),
|
setVal('.form_dex5', data.dex5);
|
||||||
strength:getInt('.form_strength'),
|
setVal('.form_defence_train', data.defence_train);
|
||||||
weapon:getVal('.form_general_weap'),
|
|
||||||
intel:getInt('.form_intel'),
|
setVal('.form_warnum', data.warnum);
|
||||||
book:getVal('.form_general_book'),
|
setVal('.form_killnum', data.killnum);
|
||||||
item:getVal('.form_general_item'),
|
setVal('.form_killcrew', data.killcrew);
|
||||||
|
|
||||||
injury:getInt('.form_injury'),
|
if (!setGeneralNo($general, data.no)) {
|
||||||
|
setGeneralNo($general, generateNewGeneralNo());
|
||||||
rice:getInt('.form_rice'),
|
}
|
||||||
|
}
|
||||||
personal:getVal('.form_general_character'),
|
|
||||||
special2:getVal('.form_general_special_war'),
|
var exportGeneralInfo = function($general) {
|
||||||
|
var getInt = function(query) {
|
||||||
crew:getInt('.form_crew'),
|
return parseInt($general.find(query).val());
|
||||||
crewtype:getInt('.form_crewtype'),
|
}
|
||||||
atmos:getInt('.form_atmos'),
|
|
||||||
train:getInt('.form_train'),
|
var getVal = function(query) {
|
||||||
|
return $general.find(query).val();
|
||||||
dex1:getInt('.form_dex1'),
|
}
|
||||||
dex2:getInt('.form_dex2'),
|
|
||||||
dex3:getInt('.form_dex3'),
|
return {
|
||||||
dex4:getInt('.form_dex4'),
|
no: getGeneralNo($general),
|
||||||
dex5:getInt('.form_dex5'),
|
name: getVal('.form_general_name'),
|
||||||
defence_train:getInt('.form_defence_train'),
|
officer_level: getInt('.form_officer_level'),
|
||||||
};
|
explevel: getInt('.form_exp_level'),
|
||||||
}
|
|
||||||
|
leadership: getInt('.form_leadership'),
|
||||||
var importBattleInfoByFile = function(files){
|
horse: getVal('.form_general_horse'),
|
||||||
if(files === null){
|
strength: getInt('.form_strength'),
|
||||||
alert('파일 에러!');
|
weapon: getVal('.form_general_weap'),
|
||||||
return false;
|
intel: getInt('.form_intel'),
|
||||||
}
|
book: getVal('.form_general_book'),
|
||||||
|
item: getVal('.form_general_item'),
|
||||||
if(files.length < 1){
|
|
||||||
alert("파일 에러!");
|
injury: getInt('.form_injury'),
|
||||||
return false;
|
|
||||||
}
|
rice: getInt('.form_rice'),
|
||||||
|
|
||||||
|
personal: getVal('.form_general_character'),
|
||||||
var file = files[0];
|
special2: getVal('.form_general_special_war'),
|
||||||
if(file.size > 1024*1024){
|
|
||||||
alert('파일이 너무 큽니다!');
|
crew: getInt('.form_crew'),
|
||||||
return false;
|
crewtype: getInt('.form_crewtype'),
|
||||||
}
|
atmos: getInt('.form_atmos'),
|
||||||
if(file.type === ''){
|
train: getInt('.form_train'),
|
||||||
alert('폴더를 업로드할 수 없습니다!');
|
|
||||||
return false;
|
dex1: getInt('.form_dex1'),
|
||||||
}
|
dex2: getInt('.form_dex2'),
|
||||||
|
dex3: getInt('.form_dex3'),
|
||||||
var reader = new FileReader();
|
dex4: getInt('.form_dex4'),
|
||||||
reader.onload = function(){
|
dex5: getInt('.form_dex5'),
|
||||||
var battleData = {};
|
|
||||||
try {
|
defence_train: getInt('.form_defence_train'),
|
||||||
battleData = JSON.parse(reader.result);
|
|
||||||
} catch(e) {
|
warnum: getInt('.form_warnum'),
|
||||||
alert('올바르지 않은 파일 형식입니다');
|
killnum: getInt('.form_killnum'),
|
||||||
return false;
|
killcrew: getInt('.form_killcrew'),
|
||||||
}
|
|
||||||
|
};
|
||||||
if(!('objType' in battleData)){
|
}
|
||||||
alert('파일 형식을 확인할 수 없습니다');
|
|
||||||
return false;
|
var importBattleInfoByFile = function(files) {
|
||||||
}
|
if (files === null) {
|
||||||
|
alert('파일 에러!');
|
||||||
if(battleData.objType != 'battle'){
|
return false;
|
||||||
alert('전투 데이터가 아닙니다');
|
}
|
||||||
return false;
|
|
||||||
}
|
if (files.length < 1) {
|
||||||
|
alert("파일 에러!");
|
||||||
importBattleInfo(battleData.data);
|
return false;
|
||||||
return true;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
var file = files[0];
|
||||||
|
if (file.size > 1024 * 1024) {
|
||||||
reader.readAsText(file);
|
alert('파일이 너무 큽니다!');
|
||||||
}
|
return false;
|
||||||
catch(e) {
|
}
|
||||||
alert('파일을 읽는데 실패했습니다.');
|
if (file.type === '') {
|
||||||
return false;
|
alert('폴더를 업로드할 수 없습니다!');
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
var reader = new FileReader();
|
||||||
|
reader.onload = function() {
|
||||||
var importGeneralInfoByFile = function(files, $card){
|
var battleData = {};
|
||||||
if($card === undefined){
|
try {
|
||||||
$card = addDefender();
|
battleData = JSON.parse(reader.result);
|
||||||
}
|
} catch (e) {
|
||||||
|
alert('올바르지 않은 파일 형식입니다');
|
||||||
if(files === null){
|
return false;
|
||||||
alert('파일 에러!');
|
}
|
||||||
return false;
|
|
||||||
}
|
if (!('objType' in battleData)) {
|
||||||
|
alert('파일 형식을 확인할 수 없습니다');
|
||||||
if(files.length < 1){
|
return false;
|
||||||
alert("파일 에러!");
|
}
|
||||||
return false;
|
|
||||||
}
|
if (battleData.objType != 'battle') {
|
||||||
|
alert('전투 데이터가 아닙니다');
|
||||||
|
return false;
|
||||||
var file = files[0];
|
}
|
||||||
if(file.size > 1024*1024){
|
|
||||||
alert('파일이 너무 큽니다!');
|
importBattleInfo(battleData.data);
|
||||||
return false;
|
return true;
|
||||||
}
|
};
|
||||||
if(file.type === ''){
|
|
||||||
alert('폴더를 업로드할 수 없습니다!');
|
try {
|
||||||
return false;
|
|
||||||
}
|
reader.readAsText(file);
|
||||||
|
} catch (e) {
|
||||||
var reader = new FileReader();
|
alert('파일을 읽는데 실패했습니다.');
|
||||||
reader.onload = function(){
|
return false;
|
||||||
var generalData = {};
|
}
|
||||||
try {
|
|
||||||
generalData = JSON.parse(reader.result);
|
return true;
|
||||||
} catch(e) {
|
}
|
||||||
alert('올바르지 않은 파일 형식입니다');
|
|
||||||
return false;
|
var importGeneralInfoByFile = function(files, $card) {
|
||||||
}
|
if ($card === undefined) {
|
||||||
|
$card = addDefender();
|
||||||
if(!('objType' in generalData)){
|
}
|
||||||
alert('파일 형식을 확인할 수 없습니다');
|
|
||||||
return false;
|
if (files === null) {
|
||||||
}
|
alert('파일 에러!');
|
||||||
|
return false;
|
||||||
if(generalData.objType == 'battle'){
|
}
|
||||||
importBattleInfo(generalData.data);
|
|
||||||
return true;
|
if (files.length < 1) {
|
||||||
}
|
alert("파일 에러!");
|
||||||
if(generalData.objType != 'general'){
|
return false;
|
||||||
alert('장수 데이터가 아닙니다');
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
var file = files[0];
|
||||||
$card.find('.form_load_general_file').val('');
|
if (file.size > 1024 * 1024) {
|
||||||
|
alert('파일이 너무 큽니다!');
|
||||||
importGeneralInfo($card, generalData.data);
|
return false;
|
||||||
return true;
|
}
|
||||||
};
|
if (file.type === '') {
|
||||||
|
alert('폴더를 업로드할 수 없습니다!');
|
||||||
try {
|
return false;
|
||||||
|
}
|
||||||
reader.readAsText(file);
|
|
||||||
}
|
var reader = new FileReader();
|
||||||
catch(e) {
|
reader.onload = function() {
|
||||||
alert('파일을 읽는데 실패했습니다.');
|
var generalData = {};
|
||||||
return false;
|
try {
|
||||||
}
|
generalData = JSON.parse(reader.result);
|
||||||
|
} catch (e) {
|
||||||
return true;
|
alert('올바르지 않은 파일 형식입니다');
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
var extendGeneralInfoForDB = function(generalData){
|
|
||||||
|
if (!('objType' in generalData)) {
|
||||||
var dbVal = {
|
alert('파일 형식을 확인할 수 없습니다');
|
||||||
nation: (generalData.no)<=1 ? 1 : 2,
|
return false;
|
||||||
city: (generalData.no)<=1 ? 1 : 3,
|
}
|
||||||
turntime:'2018-08-26 12:00',
|
|
||||||
special:defaultSpecialDomestic,
|
if (generalData.objType == 'battle') {
|
||||||
leadership_exp:0,
|
importBattleInfo(generalData.data);
|
||||||
strength_exp:0,
|
return true;
|
||||||
intel_exp:0,
|
}
|
||||||
|
if (generalData.objType != 'general') {
|
||||||
gold:10000,
|
alert('장수 데이터가 아닙니다');
|
||||||
|
return false;
|
||||||
dedication:0,
|
}
|
||||||
|
|
||||||
recent_war:'2018-08-26 12:00',
|
$card.find('.form_load_general_file').val('');
|
||||||
experience:Math.pow(generalData.explevel, 2),
|
|
||||||
};
|
importGeneralInfo($card, generalData.data);
|
||||||
|
return true;
|
||||||
return $.extend({}, generalData, dbVal);
|
};
|
||||||
}
|
|
||||||
|
try {
|
||||||
var getGeneralFrame = function($btn){
|
|
||||||
var $card = $btn.closest('.general_form');
|
reader.readAsText(file);
|
||||||
return $card;
|
} catch (e) {
|
||||||
}
|
alert('파일을 읽는데 실패했습니다.');
|
||||||
|
return false;
|
||||||
var getGeneralDetail = function($btn){
|
}
|
||||||
var $card = getGeneralFrame($btn);
|
|
||||||
var $general = $card.find('.general_detail');
|
return true;
|
||||||
return $general;
|
}
|
||||||
}
|
|
||||||
|
var extendGeneralInfoForDB = function(generalData) {
|
||||||
var getGeneralNo = function($btn){
|
|
||||||
return parseInt(getGeneralFrame($btn).data('general_no'));
|
var dbVal = {
|
||||||
}
|
nation: (generalData.no) <= 1 ? 1 : 2,
|
||||||
|
city: (generalData.no) <= 1 ? 1 : 3,
|
||||||
var setGeneralNo = function($btn, value){
|
turntime: '2018-08-26 12:00',
|
||||||
if(value == 1){
|
special: defaultSpecialDomestic,
|
||||||
//1번은 무조건 공격자임
|
leadership_exp: 0,
|
||||||
return false;
|
strength_exp: 0,
|
||||||
}
|
intel_exp: 0,
|
||||||
if(value in defenderNoList){
|
|
||||||
return false;
|
gold: 10000,
|
||||||
}
|
|
||||||
var $card = getGeneralFrame($btn);
|
dedication: 0,
|
||||||
$card.data('general_no', value);
|
|
||||||
defenderNoList[value] = $card;
|
recent_war: '2018-08-26 12:00',
|
||||||
return true;
|
experience: Math.pow(generalData.explevel, 2),
|
||||||
}
|
};
|
||||||
|
|
||||||
var generateNewGeneralNo = function(){
|
return $.extend({}, generalData, dbVal);
|
||||||
while(true){
|
}
|
||||||
var newGeneralNo = parseInt(Math.random()*(1<<24))+2;
|
|
||||||
if(newGeneralNo in defenderNoList){
|
var getGeneralFrame = function($btn) {
|
||||||
continue;
|
var $card = $btn.closest('.general_form');
|
||||||
}
|
return $card;
|
||||||
return newGeneralNo;
|
}
|
||||||
}
|
|
||||||
}
|
var getGeneralDetail = function($btn) {
|
||||||
|
var $card = getGeneralFrame($btn);
|
||||||
var deleteGeneralNo = function($btn){
|
var $general = $card.find('.general_detail');
|
||||||
var $card = getGeneralFrame($btn);
|
return $general;
|
||||||
$card.removeData('general_no');
|
}
|
||||||
var generalNo = getGeneralNo($card);
|
|
||||||
delete defenderNoList[generalNo];
|
var getGeneralNo = function($btn) {
|
||||||
}
|
return parseInt(getGeneralFrame($btn).data('general_no'));
|
||||||
|
}
|
||||||
var addDefender = function($cardAfter){
|
|
||||||
var $newCard = $('<div class="card mb-2 defender_form general_form"></div>');
|
var setGeneralNo = function($btn, value) {
|
||||||
|
if (value == 1) {
|
||||||
if($cardAfter === undefined){
|
//1번은 무조건 공격자임
|
||||||
$defenderColumn.append($newCard);
|
return false;
|
||||||
}
|
}
|
||||||
else{
|
if (value in defenderNoList) {
|
||||||
$cardAfter.after($newCard);
|
return false;
|
||||||
}
|
}
|
||||||
|
var $card = getGeneralFrame($btn);
|
||||||
$newCard.append($defenderHeaderForm.clone(true,true));
|
$card.data('general_no', value);
|
||||||
$newCard.append($generalForm.clone(true,true));
|
defenderNoList[value] = $card;
|
||||||
|
return true;
|
||||||
$newGeneral = getGeneralDetail($newCard);
|
}
|
||||||
setGeneralNo($newCard, generateNewGeneralNo());
|
|
||||||
|
var generateNewGeneralNo = function() {
|
||||||
return $newCard;
|
while (true) {
|
||||||
}
|
var newGeneralNo = parseInt(Math.random() * (1 << 24)) + 2;
|
||||||
|
if (newGeneralNo in defenderNoList) {
|
||||||
var deleteDefender = function($card){
|
continue;
|
||||||
deleteGeneralNo($card);
|
}
|
||||||
$card.detach();
|
return newGeneralNo;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var copyDefender = function($card){
|
|
||||||
var $general = getGeneralDetail($card);
|
var deleteGeneralNo = function($btn) {
|
||||||
|
var $card = getGeneralFrame($btn);
|
||||||
var generalData = exportGeneralInfo($general);
|
$card.removeData('general_no');
|
||||||
var $newObj = addDefender($card);
|
var generalNo = getGeneralNo($card);
|
||||||
importGeneralInfo(getGeneralDetail($newObj), generalData);
|
delete defenderNoList[generalNo];
|
||||||
}
|
}
|
||||||
|
|
||||||
var importBattleInfo = function(battleData){
|
var addDefender = function($cardAfter) {
|
||||||
|
var $newCard = $('<div class="card mb-2 defender_form general_form"></div>');
|
||||||
$('.form_load_battle_file').val('');
|
|
||||||
console.log(battleData);
|
if ($cardAfter === undefined) {
|
||||||
|
$defenderColumn.append($newCard);
|
||||||
var $attackerNation = $('.attacker_nation');
|
} else {
|
||||||
var $defenderNation = $('.defender_nation');
|
$cardAfter.after($newCard);
|
||||||
|
}
|
||||||
var attackerGeneral = battleData.attackerGeneral;
|
|
||||||
var attackerCity = battleData.attackerCity;
|
$newCard.append($defenderHeaderForm.clone(true, true));
|
||||||
var attackerNation = battleData.attackerNation;
|
$newCard.append($generalForm.clone(true, true));
|
||||||
|
|
||||||
var defenderGenerals = battleData.defenderGenerals;
|
$newGeneral = getGeneralDetail($newCard);
|
||||||
var defenderCity = battleData.defenderCity;
|
setGeneralNo($newCard, generateNewGeneralNo());
|
||||||
var defenderNation = battleData.defenderNation;
|
|
||||||
|
return $newCard;
|
||||||
$('#year').val(battleData.year);
|
}
|
||||||
$('#month').val(battleData.month);
|
|
||||||
$('#repeat_cnt').val(battleData.repeatCnt);
|
var deleteDefender = function($card) {
|
||||||
|
deleteGeneralNo($card);
|
||||||
$('.delete-defender').click();
|
$card.detach();
|
||||||
|
}
|
||||||
$attackerNation.find('.form_nation_type').val(attackerNation.type);
|
|
||||||
$attackerNation.find('.form_tech').val(Math.floor(attackerNation.tech/1000));
|
var copyDefender = function($card) {
|
||||||
$attackerNation.find('.form_nation_level').val(attackerNation.level);
|
var $general = getGeneralDetail($card);
|
||||||
if(attackerNation.capital == 1){
|
|
||||||
$attackerNation.find('.form_is_capital:first').click();
|
var generalData = exportGeneralInfo($general);
|
||||||
}
|
var $newObj = addDefender($card);
|
||||||
else{
|
importGeneralInfo(getGeneralDetail($newObj), generalData);
|
||||||
$attackerNation.find('.form_is_capital:last').click();
|
}
|
||||||
}
|
|
||||||
$attackerNation.find('.form_city_level').val(attackerCity.level);
|
var importBattleInfo = function(battleData) {
|
||||||
|
|
||||||
importGeneralInfo($('.attacker_form'), attackerGeneral);
|
$('.form_load_battle_file').val('');
|
||||||
|
console.log(battleData);
|
||||||
$defenderNation.find('.form_nation_type').val(defenderNation.type);
|
|
||||||
$defenderNation.find('.form_tech').val(Math.floor(defenderNation.tech/1000));
|
var $attackerNation = $('.attacker_nation');
|
||||||
$defenderNation.find('.form_nation_level').val(defenderNation.level);
|
var $defenderNation = $('.defender_nation');
|
||||||
if(defenderNation.capital == 1){
|
|
||||||
$defenderNation.find('.form_is_capital:first').click();
|
var attackerGeneral = battleData.attackerGeneral;
|
||||||
}
|
var attackerCity = battleData.attackerCity;
|
||||||
else{
|
var attackerNation = battleData.attackerNation;
|
||||||
$defenderNation.find('.form_is_capital:last').click();
|
|
||||||
}
|
var defenderGenerals = battleData.defenderGenerals;
|
||||||
$defenderNation.find('.form_city_level').val(defenderCity.level);
|
var defenderCity = battleData.defenderCity;
|
||||||
$('#city_def').val(defenderCity.def);
|
var defenderNation = battleData.defenderNation;
|
||||||
$('#city_wall').val(defenderCity.wall);
|
|
||||||
|
$('#year').val(battleData.year);
|
||||||
$.each(defenderGenerals, function(idx, defenderGeneral){
|
$('#month').val(battleData.month);
|
||||||
var $card = addDefender();
|
$('#repeat_cnt').val(battleData.repeatCnt);
|
||||||
importGeneralInfo($card, defenderGeneral);
|
|
||||||
});
|
$('.delete-defender').click();
|
||||||
}
|
|
||||||
|
$attackerNation.find('.form_nation_type').val(attackerNation.type);
|
||||||
var exportAllData = function(){
|
$attackerNation.find('.form_tech').val(Math.floor(attackerNation.tech / 1000));
|
||||||
var $attackerNation = $('.attacker_nation');
|
$attackerNation.find('.form_nation_level').val(attackerNation.level);
|
||||||
var $defenderNation = $('.defender_nation');
|
if (attackerNation.capital == 1) {
|
||||||
|
$attackerNation.find('.form_is_capital:first').click();
|
||||||
var attackerGeneral = exportGeneralInfo($('.attacker_form'));
|
} else {
|
||||||
|
$attackerNation.find('.form_is_capital:last').click();
|
||||||
var attackerCity = {
|
}
|
||||||
level:parseInt($attackerNation.find('.form_city_level').val()),
|
$attackerNation.find('.form_city_level').val(attackerCity.level);
|
||||||
};
|
|
||||||
|
importGeneralInfo($('.attacker_form'), attackerGeneral);
|
||||||
var attackerNation = {
|
|
||||||
type:$attackerNation.find('.form_nation_type').val(),
|
$defenderNation.find('.form_nation_type').val(defenderNation.type);
|
||||||
tech:parseInt($attackerNation.find('.form_tech').val()) * 1000,
|
$defenderNation.find('.form_tech').val(Math.floor(defenderNation.tech / 1000));
|
||||||
level:parseInt($attackerNation.find('.form_nation_level').val()),
|
$defenderNation.find('.form_nation_level').val(defenderNation.level);
|
||||||
capital:$attackerNation.find('.form_is_capital:checked').val()=='1'?1:2,
|
if (defenderNation.capital == 1) {
|
||||||
}
|
$defenderNation.find('.form_is_capital:first').click();
|
||||||
|
} else {
|
||||||
var defenderGenerals = $('.defender_form').map(function(){
|
$defenderNation.find('.form_is_capital:last').click();
|
||||||
return exportGeneralInfo($(this));
|
}
|
||||||
}).toArray();
|
$defenderNation.find('.form_city_level').val(defenderCity.level);
|
||||||
|
$('#city_def').val(defenderCity.def);
|
||||||
var defenderCity = {
|
$('#city_wall').val(defenderCity.wall);
|
||||||
def: parseInt($('#city_def').val()),
|
|
||||||
wall: parseInt($('#city_wall').val()),
|
$.each(defenderGenerals, function(idx, defenderGeneral) {
|
||||||
level:parseInt($defenderNation.find('.form_city_level').val()),
|
var $card = addDefender();
|
||||||
};
|
importGeneralInfo($card, defenderGeneral);
|
||||||
|
});
|
||||||
var defenderNation = {
|
}
|
||||||
type:$defenderNation.find('.form_nation_type').val(),
|
|
||||||
tech:parseInt($defenderNation.find('.form_tech').val()) * 1000,
|
var exportAllData = function() {
|
||||||
level:parseInt($defenderNation.find('.form_nation_level').val()),
|
var $attackerNation = $('.attacker_nation');
|
||||||
capital:$defenderNation.find('.form_is_capital:checked').val()=='1'?3:4,
|
var $defenderNation = $('.defender_nation');
|
||||||
}
|
|
||||||
|
var attackerGeneral = exportGeneralInfo($('.attacker_form'));
|
||||||
var year = parseInt($('#year').val());
|
|
||||||
var month = parseInt($('#month').val());
|
var attackerCity = {
|
||||||
var repeatCnt = parseInt($('#repeat_cnt').val());
|
level: parseInt($attackerNation.find('.form_city_level').val()),
|
||||||
|
};
|
||||||
return {
|
|
||||||
attackerGeneral:attackerGeneral,
|
var attackerNation = {
|
||||||
attackerCity:attackerCity,
|
type: $attackerNation.find('.form_nation_type').val(),
|
||||||
attackerNation:attackerNation,
|
tech: parseInt($attackerNation.find('.form_tech').val()) * 1000,
|
||||||
|
level: parseInt($attackerNation.find('.form_nation_level').val()),
|
||||||
defenderGenerals:defenderGenerals,
|
capital: $attackerNation.find('.form_is_capital:checked').val() == '1' ? 1 : 2,
|
||||||
defenderCity:defenderCity,
|
}
|
||||||
defenderNation:defenderNation,
|
|
||||||
|
var defenderGenerals = $('.defender_form').map(function() {
|
||||||
year:year,
|
return exportGeneralInfo($(this));
|
||||||
month:month,
|
}).toArray();
|
||||||
repeatCnt:repeatCnt,
|
|
||||||
};
|
var defenderCity = {
|
||||||
}
|
def: parseInt($('#city_def').val()),
|
||||||
|
wall: parseInt($('#city_wall').val()),
|
||||||
var extendAllDataForDB = function(allData){
|
level: parseInt($defenderNation.find('.form_city_level').val()),
|
||||||
var defaultNation = {
|
};
|
||||||
nation:0,
|
|
||||||
name:'재야',
|
var defenderNation = {
|
||||||
capital:0,
|
type: $defenderNation.find('.form_nation_type').val(),
|
||||||
level:0,
|
tech: parseInt($defenderNation.find('.form_tech').val()) * 1000,
|
||||||
gold:0,
|
level: parseInt($defenderNation.find('.form_nation_level').val()),
|
||||||
rice:2000,
|
capital: $defenderNation.find('.form_is_capital:checked').val() == '1' ? 3 : 4,
|
||||||
type:'None',
|
}
|
||||||
tech:0,
|
|
||||||
gennum:200,
|
var year = parseInt($('#year').val());
|
||||||
};
|
var month = parseInt($('#month').val());
|
||||||
|
var repeatCnt = parseInt($('#repeat_cnt').val());
|
||||||
var defaultCity = {
|
|
||||||
nation:0,
|
return {
|
||||||
supply:1,
|
attackerGeneral: attackerGeneral,
|
||||||
name:'도시',
|
attackerCity: attackerCity,
|
||||||
|
attackerNation: attackerNation,
|
||||||
pop:500000,
|
|
||||||
agri:10000,
|
defenderGenerals: defenderGenerals,
|
||||||
comm:10000,
|
defenderCity: defenderCity,
|
||||||
secu:10000,
|
defenderNation: defenderNation,
|
||||||
def:1000,
|
|
||||||
wall:1000,
|
year: year,
|
||||||
|
month: month,
|
||||||
trust:100,
|
repeatCnt: repeatCnt,
|
||||||
|
};
|
||||||
pop_max:600000,
|
}
|
||||||
agri_max:12000,
|
|
||||||
comm_max:12000,
|
var extendAllDataForDB = function(allData) {
|
||||||
secu_max:10000,
|
var defaultNation = {
|
||||||
def_max:12000,
|
nation: 0,
|
||||||
wall_max:12000,
|
name: '재야',
|
||||||
|
capital: 0,
|
||||||
dead:0,
|
level: 0,
|
||||||
|
gold: 0,
|
||||||
state:0,
|
rice: 2000,
|
||||||
|
type: 'None',
|
||||||
conflict:'{}',
|
tech: 0,
|
||||||
};
|
gennum: 200,
|
||||||
|
};
|
||||||
var attackerNation = $.extend({}, defaultNation, allData.attackerNation);
|
|
||||||
attackerNation.nation = 1;
|
var defaultCity = {
|
||||||
attackerNation.name = '출병국';
|
nation: 0,
|
||||||
|
supply: 1,
|
||||||
var attackerCity = $.extend({}, defaultCity, allData.attackerCity);
|
name: '도시',
|
||||||
attackerCity.nation = 1;
|
|
||||||
attackerCity.city = 1;
|
pop: 500000,
|
||||||
|
agri: 10000,
|
||||||
var attackerGeneral = extendGeneralInfoForDB(allData.attackerGeneral);
|
comm: 10000,
|
||||||
if(2 <= attackerGeneral.officer_level && attackerGeneral.officer_level <= 4){
|
secu: 10000,
|
||||||
attackerGeneral.officer_city = 1;
|
def: 1000,
|
||||||
}
|
wall: 1000,
|
||||||
else{
|
|
||||||
attackerGeneral.officer_city = 0;
|
trust: 100,
|
||||||
}
|
|
||||||
|
pop_max: 600000,
|
||||||
var defenderNation = $.extend({}, defaultNation, allData.defenderNation);
|
agri_max: 12000,
|
||||||
defenderNation.nation = 2;
|
comm_max: 12000,
|
||||||
defenderNation.name = '수비국';
|
secu_max: 10000,
|
||||||
|
def_max: 12000,
|
||||||
var defenderCity = $.extend({}, defaultCity, allData.defenderCity);
|
wall_max: 12000,
|
||||||
defenderCity.nation = 2;
|
|
||||||
defenderCity.city = 3;
|
dead: 0,
|
||||||
defenderCity.wall_max = defenderCity.wall/5*6;
|
|
||||||
defenderCity.def_max = defenderCity.def/5*6;
|
state: 0,
|
||||||
|
|
||||||
var defenderGenerals = [];
|
conflict: '{}',
|
||||||
$.each(allData.defenderGenerals, function(){
|
};
|
||||||
var defenderGeneral = extendGeneralInfoForDB(this);
|
|
||||||
if(2 <= defenderGeneral.officer_level && defenderGeneral.officer_level <= 4){
|
var attackerNation = $.extend({}, defaultNation, allData.attackerNation);
|
||||||
defenderGeneral.officer_city = 3;
|
attackerNation.nation = 1;
|
||||||
}
|
attackerNation.name = '출병국';
|
||||||
else{
|
|
||||||
defenderGeneral.officer_city = 0;
|
var attackerCity = $.extend({}, defaultCity, allData.attackerCity);
|
||||||
}
|
attackerCity.nation = 1;
|
||||||
|
attackerCity.city = 1;
|
||||||
defenderGenerals.push(defenderGeneral);
|
|
||||||
});
|
var attackerGeneral = extendGeneralInfoForDB(allData.attackerGeneral);
|
||||||
|
if (2 <= attackerGeneral.officer_level && attackerGeneral.officer_level <= 4) {
|
||||||
|
attackerGeneral.officer_city = 1;
|
||||||
return $.extend({}, allData, {
|
} else {
|
||||||
attackerGeneral:attackerGeneral,
|
attackerGeneral.officer_city = 0;
|
||||||
attackerCity:attackerCity,
|
}
|
||||||
attackerNation:attackerNation,
|
|
||||||
|
var defenderNation = $.extend({}, defaultNation, allData.defenderNation);
|
||||||
defenderGenerals:defenderGenerals,
|
defenderNation.nation = 2;
|
||||||
defenderCity:defenderCity,
|
defenderNation.name = '수비국';
|
||||||
defenderNation:defenderNation,
|
|
||||||
});
|
var defenderCity = $.extend({}, defaultCity, allData.defenderCity);
|
||||||
}
|
defenderCity.nation = 2;
|
||||||
|
defenderCity.city = 3;
|
||||||
var parseSkillCount = function(skills){
|
defenderCity.wall_max = parseInt(defenderCity.wall / 5 * 6);
|
||||||
var result = [];
|
defenderCity.def_max = parseInt(defenderCity.def / 5 * 6);
|
||||||
$.each(skills, function(key, value){
|
|
||||||
result.push("{0}({1}회)".format(key, toPretty(value)));
|
var defenderGenerals = [];
|
||||||
})
|
$.each(allData.defenderGenerals, function() {
|
||||||
|
var defenderGeneral = extendGeneralInfoForDB(this);
|
||||||
if(result.length == 0){
|
if (2 <= defenderGeneral.officer_level && defenderGeneral.officer_level <= 4) {
|
||||||
return '-';
|
defenderGeneral.officer_city = 3;
|
||||||
}
|
} else {
|
||||||
return result.join(', ');
|
defenderGeneral.officer_city = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var toPretty = function(number){
|
defenderGenerals.push(defenderGeneral);
|
||||||
if(isInt(number)){
|
});
|
||||||
number = parseInt(number);
|
|
||||||
}
|
|
||||||
else{
|
return $.extend({}, allData, {
|
||||||
number = parseFloat(number).toFixed(2);
|
attackerGeneral: attackerGeneral,
|
||||||
}
|
attackerCity: attackerCity,
|
||||||
return numberWithCommas(number);
|
attackerNation: attackerNation,
|
||||||
}
|
|
||||||
|
defenderGenerals: defenderGenerals,
|
||||||
var showBattleResult = function(result){
|
defenderCity: defenderCity,
|
||||||
$('#result_datetime').html(result.datetime);
|
defenderNation: defenderNation,
|
||||||
$('#result_warcnt').html(toPretty(result.avgWar));
|
});
|
||||||
$('#result_phase').html(toPretty(result.phase));
|
}
|
||||||
$('#result_killed').html(toPretty(result.killed));
|
|
||||||
if(result.minKilled != result.maxKilled){
|
var parseSkillCount = function(skills) {
|
||||||
$('#result_maxKilled').html(toPretty(result.maxKilled));
|
var result = [];
|
||||||
$('#result_minKilled').html(toPretty(result.minKilled));
|
$.each(skills, function(key, value) {
|
||||||
$('#result_varKilled').show();
|
result.push("{0}({1}회)".format(key, toPretty(value)));
|
||||||
}
|
})
|
||||||
else{
|
|
||||||
$('#result_varKilled').hide();
|
if (result.length == 0) {
|
||||||
}
|
return '-';
|
||||||
$('#result_dead').html(toPretty(result.dead));
|
}
|
||||||
if(result.minDead != result.maxDead){
|
return result.join(', ');
|
||||||
$('#result_maxDead').html(toPretty(result.maxDead));
|
}
|
||||||
$('#result_minDead').html(toPretty(result.minDead));
|
|
||||||
$('#result_varDead').show();
|
var toPretty = function(number) {
|
||||||
}
|
if (isInt(number)) {
|
||||||
else{
|
number = parseInt(number);
|
||||||
$('#result_varDead').hide();
|
} else {
|
||||||
}
|
number = parseFloat(number).toFixed(2);
|
||||||
|
}
|
||||||
$('#result_attackerRice').html(toPretty(result.attackerRice));
|
return numberWithCommas(number);
|
||||||
$('#result_defenderRice').html(toPretty(result.defenderRice));
|
}
|
||||||
$('#result_attackerSkills').html(parseSkillCount(result.attackerSkills));
|
|
||||||
|
var showBattleResult = function(result) {
|
||||||
$('.result_defenderSkills').detach();
|
$('#result_datetime').html(result.datetime);
|
||||||
|
$('#result_warcnt').html(toPretty(result.avgWar));
|
||||||
var $summary = $('#battle_result_summary');
|
$('#result_phase').html(toPretty(result.phase));
|
||||||
|
$('#result_killed').html(toPretty(result.killed));
|
||||||
$.each(result.defendersSkills, function(idx, defenderSkills){
|
if (result.minKilled != result.maxKilled) {
|
||||||
console.log(defenderSkills);
|
$('#result_maxKilled').html(toPretty(result.maxKilled));
|
||||||
var $result = $("<tr class='result_defenderSkills'><th>수비자{0} 스킬</th><td></td></tr>".format(idx + 1));
|
$('#result_minKilled').html(toPretty(result.minKilled));
|
||||||
$result.find('td').html(parseSkillCount(defenderSkills));
|
$('#result_varKilled').show();
|
||||||
$summary.append($result);
|
} else {
|
||||||
});
|
$('#result_varKilled').hide();
|
||||||
|
}
|
||||||
$('#generalBattleResultLog').html(result.lastWarLog.generalBattleResultLog);
|
$('#result_dead').html(toPretty(result.dead));
|
||||||
$('#generalBattleDetailLog').html(result.lastWarLog.generalBattleDetailLog);
|
if (result.minDead != result.maxDead) {
|
||||||
|
$('#result_maxDead').html(toPretty(result.maxDead));
|
||||||
}
|
$('#result_minDead').html(toPretty(result.minDead));
|
||||||
|
$('#result_varDead').show();
|
||||||
var beginBattle = function(){
|
} else {
|
||||||
var data = extendAllDataForDB(exportAllData());
|
$('#result_varDead').hide();
|
||||||
console.log(data);
|
}
|
||||||
$.ajax({
|
|
||||||
type:'post',
|
$('#result_attackerRice').html(toPretty(result.attackerRice));
|
||||||
url:'j_simulate_battle.php',
|
$('#result_defenderRice').html(toPretty(result.defenderRice));
|
||||||
dataType:'json',
|
$('#result_attackerSkills').html(parseSkillCount(result.attackerSkills));
|
||||||
data:{
|
|
||||||
action:'battle',
|
$('.result_defenderSkills').detach();
|
||||||
query:JSON.stringify(data),
|
|
||||||
}
|
var $summary = $('#battle_result_summary');
|
||||||
}).then(function(result){
|
|
||||||
console.log(result);
|
$.each(result.defendersSkills, function(idx, defenderSkills) {
|
||||||
if(!result.result){
|
console.log(defenderSkills);
|
||||||
alert(result.reason);
|
var $result = $("<tr class='result_defenderSkills'><th>수비자{0} 스킬</th><td></td></tr>".format(idx + 1));
|
||||||
return;
|
$result.find('td').html(parseSkillCount(defenderSkills));
|
||||||
}
|
$summary.append($result);
|
||||||
showBattleResult(result);
|
});
|
||||||
|
|
||||||
}, function(result){
|
$('#generalBattleResultLog').html(result.lastWarLog.generalBattleResultLog);
|
||||||
alert('전투 개시 실패!');
|
$('#generalBattleDetailLog').html(result.lastWarLog.generalBattleDetailLog);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var beginBattle = function() {
|
||||||
var reorderDefender = function(defenderOrder){
|
var data = extendAllDataForDB(exportAllData());
|
||||||
$.each(defenderOrder, function(idx, generalNo){
|
console.log(data);
|
||||||
|
$.ajax({
|
||||||
if(!(generalNo in defenderNoList)){
|
type: 'post',
|
||||||
//음..?
|
url: 'j_simulate_battle.php',
|
||||||
alert("{0}이 수비자 리스트에 없습니다. 버그인 듯 합니다.".format(generalNo));
|
dataType: 'json',
|
||||||
return true;
|
data: {
|
||||||
}
|
action: 'battle',
|
||||||
|
query: JSON.stringify(data),
|
||||||
var $defenderObj = defenderNoList[generalNo];
|
}
|
||||||
$defenderObj.detach();
|
}).then(function(result) {
|
||||||
$defenderColumn.append($defenderObj);
|
console.log(result);
|
||||||
})
|
if (!result.result) {
|
||||||
}
|
alert(result.reason);
|
||||||
|
return;
|
||||||
var requestReorderDefender = function(){
|
}
|
||||||
var data = extendAllDataForDB(exportAllData());
|
showBattleResult(result);
|
||||||
console.log(data);
|
|
||||||
$.ajax({
|
}, function(result) {
|
||||||
type:'post',
|
alert('전투 개시 실패!');
|
||||||
url:'j_simulate_battle.php',
|
});
|
||||||
dataType:'json',
|
}
|
||||||
data:{
|
|
||||||
action:'reorder',
|
|
||||||
query:JSON.stringify(data),
|
var reorderDefender = function(defenderOrder) {
|
||||||
}
|
$.each(defenderOrder, function(idx, generalNo) {
|
||||||
}).then(function(result){
|
|
||||||
console.log(result);
|
if (!(generalNo in defenderNoList)) {
|
||||||
if(!result.result){
|
//음..?
|
||||||
alert(result.reason);
|
alert("{0}이 수비자 리스트에 없습니다. 버그인 듯 합니다.".format(generalNo));
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
reorderDefender(result.order);
|
|
||||||
|
var $defenderObj = defenderNoList[generalNo];
|
||||||
}, function(result){
|
$defenderObj.detach();
|
||||||
alert('재정렬 실패!');
|
$defenderColumn.append($defenderObj);
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
initBasicEvent();
|
var requestReorderDefender = function() {
|
||||||
$attackerCard.append($generalForm.clone(true,true));
|
var data = extendAllDataForDB(exportAllData());
|
||||||
addDefender();
|
console.log(data);
|
||||||
|
$.ajax({
|
||||||
$('.btn-begin_battle').click(function(){
|
type: 'post',
|
||||||
beginBattle();
|
url: 'j_simulate_battle.php',
|
||||||
});
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
$('.btn-reorder_defender').click(function(){
|
action: 'reorder',
|
||||||
requestReorderDefender();
|
query: JSON.stringify(data),
|
||||||
})
|
}
|
||||||
|
}).then(function(result) {
|
||||||
|
console.log(result);
|
||||||
|
if (!result.result) {
|
||||||
|
alert(result.reason);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reorderDefender(result.order);
|
||||||
|
|
||||||
|
}, function(result) {
|
||||||
|
alert('재정렬 실패!');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var initGeneralList = false;
|
||||||
|
|
||||||
|
$('#importFromDB').click(function() {
|
||||||
|
var generalID = $('#modalSelector').val();
|
||||||
|
console.log(generalID);
|
||||||
|
|
||||||
|
|
||||||
|
$.post({
|
||||||
|
url: 'j_export_simulator_object.php',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
destGeneralID: generalID
|
||||||
|
}
|
||||||
|
}).then(function(data) {
|
||||||
|
|
||||||
|
if (!data.result) {
|
||||||
|
alert(data.reason);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $modal = $('#importModal');
|
||||||
|
var $card = $modal.data('target');
|
||||||
|
importGeneralInfo($card, data.general);
|
||||||
|
|
||||||
|
$modal.modal('hide');
|
||||||
|
}, errUnknown);
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#importModal').on('show.bs.modal', function(e) {
|
||||||
|
if (!initGeneralList) {
|
||||||
|
var $list = $('#modalSelector');
|
||||||
|
|
||||||
|
var addNation = function(generalList, nationName, color) {
|
||||||
|
|
||||||
|
generalList.sort(function(lhs, rhs) {
|
||||||
|
if (lhs.npc != rhs.npc) {
|
||||||
|
return lhs.npc - rhs.npc;
|
||||||
|
}
|
||||||
|
if (lhs.name < rhs.name) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (lhs.name > rhs.name) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
var $optGroup = $('<optgroup label="{0}"></optgroup>'.format(nationName));
|
||||||
|
$optGroup.css('background-color', color);
|
||||||
|
$optGroup.css('color', isBrightColor(color) ? 'black' : 'white');
|
||||||
|
|
||||||
|
$.each(generalList, function(idx, general) {
|
||||||
|
$item = $('<option value="{0}">{1}</option>'.format(general.no, general.name));
|
||||||
|
if (general.npc) {
|
||||||
|
$item.css('color', getNpcColor(general.npc));
|
||||||
|
} else {
|
||||||
|
$item.css('color', 'white');
|
||||||
|
}
|
||||||
|
$item.css('background-color', 'black');
|
||||||
|
$optGroup.append($item);
|
||||||
|
|
||||||
|
});
|
||||||
|
$list.append($optGroup);
|
||||||
|
}
|
||||||
|
$.post({
|
||||||
|
url: 'j_get_basic_general_list.php',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
req: 2,
|
||||||
|
}
|
||||||
|
}).then(function(data) {
|
||||||
|
if (!data.result) {
|
||||||
|
alert(data.reason);
|
||||||
|
$('#importModal').modal('hide');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nations = data.nation;
|
||||||
|
var myNationID = data.nationID;
|
||||||
|
|
||||||
|
$list.empty();
|
||||||
|
//자국 먼저
|
||||||
|
|
||||||
|
if (0 in data.list) {
|
||||||
|
nations[0] = {
|
||||||
|
nation: 0,
|
||||||
|
name: '재야',
|
||||||
|
color: '#000000'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
addNation(combineArray(data.list[myNationID], data.column), nations[myNationID].name, nations[myNationID].color);
|
||||||
|
|
||||||
|
for (var nationID in data.list) {
|
||||||
|
if (nationID == myNationID) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
addNation(combineArray(data.list[nationID], data.column), nations[nationID].name, nations[nationID].color);
|
||||||
|
}
|
||||||
|
initGeneralList = true;
|
||||||
|
}, errUnknown);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
initBasicEvent();
|
||||||
|
$attackerCard.append($generalForm.clone(true, true));
|
||||||
|
addDefender();
|
||||||
|
|
||||||
|
$('.btn-begin_battle').click(function() {
|
||||||
|
beginBattle();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btn-reorder_defender').click(function() {
|
||||||
|
requestReorderDefender();
|
||||||
|
})
|
||||||
});
|
});
|
||||||
+194
-200
@@ -1,201 +1,195 @@
|
|||||||
function changePermission(isAmbassador, rawGeneralList){
|
function changePermission(isAmbassador, rawGeneralList) {
|
||||||
console.log(isAmbassador);
|
console.log(isAmbassador);
|
||||||
console.log(rawGeneralList);
|
console.log(rawGeneralList);
|
||||||
|
|
||||||
var generalList = [];
|
var generalList = [];
|
||||||
$.each(rawGeneralList, function(idx, value){
|
$.each(rawGeneralList, function(idx, value) {
|
||||||
generalList.push(parseInt(value.id));
|
generalList.push(parseInt(value.id));
|
||||||
})
|
})
|
||||||
|
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_general_set_permission.php',
|
url: 'j_general_set_permission.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
isAmbassador:isAmbassador,
|
isAmbassador: isAmbassador,
|
||||||
genlist:generalList
|
genlist: generalList
|
||||||
},
|
},
|
||||||
}).then(function(data){
|
}).then(function(data) {
|
||||||
if(!data){
|
if (!data) {
|
||||||
alert('변경하지 못했습니다.');
|
alert('변경하지 못했습니다.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!data.result){
|
if (!data.result) {
|
||||||
alert('변경하지 못했습니다. : '+data.reason);
|
alert('변경하지 못했습니다. : ' + data.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
alert('변경했습니다.');
|
alert('변경했습니다.');
|
||||||
location.reload();
|
location.reload();
|
||||||
}, errUnknown);
|
}, errUnknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function(){
|
$(function() {
|
||||||
$('#selectAmbassador').select2({
|
$('#selectAmbassador').select2({
|
||||||
theme: 'bootstrap4',
|
theme: 'bootstrap4',
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
language: "ko",
|
language: "ko",
|
||||||
width:300,
|
width: 300,
|
||||||
maximumSelectionLength: 2,
|
maximumSelectionLength: 2,
|
||||||
containerCss: {
|
containerCss: {
|
||||||
display: "inline-block !important;",
|
display: "inline-block !important;",
|
||||||
color: 'white !important'
|
color: 'white !important'
|
||||||
},
|
},
|
||||||
data:candidateAmbassadors,
|
data: candidateAmbassadors,
|
||||||
//containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
//containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||||
dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#selectAuditor').select2({
|
$('#selectAuditor').select2({
|
||||||
theme: 'bootstrap4',
|
theme: 'bootstrap4',
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
language: "ko",
|
language: "ko",
|
||||||
width:300,
|
width: 300,
|
||||||
maximumSelectionLength: 2,
|
maximumSelectionLength: 2,
|
||||||
containerCss: {
|
containerCss: {
|
||||||
display: "inline-block !important;",
|
display: "inline-block !important;",
|
||||||
color: 'white !important'
|
color: 'white !important'
|
||||||
},
|
},
|
||||||
data:candidateAuditors,
|
data: candidateAuditors,
|
||||||
//containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
//containerCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||||
dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
dropdownCssClass: 'simple-select2-align-center bg-secondary text-secondary',
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#changeAmbassador').click(function(){
|
$('#changeAmbassador').click(function() {
|
||||||
if(!confirm('외교권자를 변경할까요?')){
|
if (!confirm('외교권자를 변경할까요?')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
changePermission(true, $('#selectAmbassador').select2('data'));
|
changePermission(true, $('#selectAmbassador').select2('data'));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#changeAuditor').click(function(){
|
$('#changeAuditor').click(function() {
|
||||||
if(!confirm('조언자를 변경할까요?')){
|
if (!confirm('조언자를 변경할까요?')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
changePermission(false, $('#selectAuditor').select2('data'));
|
changePermission(false, $('#selectAuditor').select2('data'));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btn_kick').click(function(){
|
$('#btn_kick').click(function() {
|
||||||
var $kickSelect = $('#genlist_kick option:selected');
|
var $kickSelect = $('#genlist_kick option:selected');
|
||||||
var generalID = $kickSelect.val();
|
var generalID = $kickSelect.val();
|
||||||
if(!generalID){
|
if (!generalID) {
|
||||||
alert('장수를 선택해주세요');
|
alert('장수를 선택해주세요');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var generalName = $kickSelect.data('name');
|
var generalName = $kickSelect.data('name');
|
||||||
if(!confirm('{0}를 추방하시겠습니까?'.format(generalName))){
|
if (!confirm('{0}를 추방하시겠습니까?'.format(generalName))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_myBossInfo.php',
|
url: 'j_myBossInfo.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
action:'추방',
|
action: '추방',
|
||||||
destGeneralID:generalID
|
destGeneralID: generalID
|
||||||
},
|
},
|
||||||
}).then(function(data){
|
}).then(function(data) {
|
||||||
if(!data){
|
if (!data) {
|
||||||
alert('추방하지 못했습니다.');
|
alert('추방하지 못했습니다.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!data.result){
|
if (!data.result) {
|
||||||
alert('추방하지 못했습니다. : '+data.reason);
|
alert('추방하지 못했습니다. : ' + data.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
alert('{0}를 추방했습니다.'.format(generalName));
|
alert('{0}를 추방했습니다.'.format(generalName));
|
||||||
location.reload();
|
location.reload();
|
||||||
}, errUnknown);
|
}, errUnknown);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn_appoint').click(function(){
|
$('.btn_appoint').click(function() {
|
||||||
var $btn = $(this);
|
var $btn = $(this);
|
||||||
var officerLevel = $btn.data('officer_level');
|
var officerLevel = $btn.data('officer_level');
|
||||||
var officerLevelText = $btn.data('officer_level_text');
|
var officerLevelText = $btn.data('officer_level_text');
|
||||||
var cityID = 0;
|
var cityID = 0;
|
||||||
var cityName = '_';
|
var cityName = '_';
|
||||||
var $generalSelect = $('#genlist_{0} option:selected'.format(officerLevel));
|
var $generalSelect = $('#genlist_{0} option:selected'.format(officerLevel));
|
||||||
var $citySelect = $('#citylist_{0} option:selected'.format(officerLevel));
|
var $citySelect = $('#citylist_{0} option:selected'.format(officerLevel));
|
||||||
|
|
||||||
var generalID = $generalSelect.val();
|
var generalID = parseInt($generalSelect.val());
|
||||||
var generalName = $generalSelect.data('name');
|
var generalName = $generalSelect.data('name');
|
||||||
var generalOfficerLevel = $generalSelect.data('officer_level');
|
var generalOfficerLevel = $generalSelect.data('officer_level');
|
||||||
|
|
||||||
|
|
||||||
if(officerLevel >= 5){
|
if (officerLevel >= 5) {
|
||||||
if(generalID == 0){
|
if (generalID == 0) {
|
||||||
if(!confirm('{0}직을 비우시겠습니까?'.format(officerLevelText))){
|
if (!confirm('{0}직을 비우시겠습니까?'.format(officerLevelText))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else if (generalOfficerLevel >= 5) {
|
||||||
else if(generalOfficerLevel >= 5){
|
if (!confirm('이미 수뇌인 {0}을(를) {1}직에 임명하시겠습니까?'.format(generalName, officerLevelText))) {
|
||||||
if(!confirm('이미 수뇌인 {0}을(를) {1}직에 임명하시겠습니까?'.format(generalName, officerLevelText))){
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
if (!confirm('{0}을(를) {1}직에 임명하시겠습니까?'.format(generalName, officerLevelText))) {
|
||||||
else{
|
return false;
|
||||||
if(!confirm('{0}을(를) {1}직에 임명하시겠습니까?'.format(generalName, officerLevelText))){
|
}
|
||||||
return false;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
cityID = $citySelect.val();
|
||||||
}
|
if (!cityID) {
|
||||||
else{
|
alert('도시를 선택해주세요');
|
||||||
cityID = $citySelect.val();
|
return false;
|
||||||
if(!cityID){
|
}
|
||||||
alert('도시를 선택해주세요');
|
cityName = $citySelect.find('option:selected .name_field').text();
|
||||||
return false;
|
|
||||||
}
|
if (generalID == 0) {
|
||||||
cityName = $citySelect.find('option:selected .name_field').text();
|
if (!confirm('{0} {1}직을 비우시겠습니까?'.format(cityName, officerLevelText))) {
|
||||||
|
return false;
|
||||||
if(generalID == 0){
|
}
|
||||||
if(!confirm('{0} {1}직을 비우시겠습니까?'.format(cityName, officerLevelText))){
|
} else if (generalOfficerLevel >= 5) {
|
||||||
return false;
|
if (!confirm('수뇌인 {0}을(를) {1} {2}직에 임명하시겠습니까?'.format(generalName, cityName, officerLevelText))) {
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
else if(generalOfficerLevel >= 5){
|
} else {
|
||||||
if(!confirm('수뇌인 {0}을(를) {1} {2}직에 임명하시겠습니까?'.format(generalName, cityName, officerLevelText))){
|
if (!confirm('{0}을(를) {1} {2}직에 임명하시겠습니까?'.format(generalName, cityName, officerLevelText))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
}
|
||||||
if(!confirm('{0}을(를) {1} {2}직에 임명하시겠습니까?'.format(generalName, cityName, officerLevelText))){
|
|
||||||
return false;
|
$.post({
|
||||||
}
|
url: 'j_myBossInfo.php',
|
||||||
}
|
dataType: 'json',
|
||||||
}
|
data: {
|
||||||
|
action: '임명',
|
||||||
$.post({
|
destGeneralID: generalID,
|
||||||
url:'j_myBossInfo.php',
|
destCityID: cityID,
|
||||||
dataType:'json',
|
officerLevel: officerLevel
|
||||||
data:{
|
},
|
||||||
action:'임명',
|
}).then(function(data) {
|
||||||
destGeneralID:generalID,
|
if (!data) {
|
||||||
destCityID:cityID,
|
alert('임명하지 못했습니다.');
|
||||||
officerLevel:officerLevel
|
return false;
|
||||||
},
|
}
|
||||||
}).then(function(data){
|
if (!data.result) {
|
||||||
if(!data){
|
alert('임명하지 못했습니다. : ' + data.reason);
|
||||||
alert('임명하지 못했습니다.');
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
if(!data.result){
|
if (generalID) {
|
||||||
alert('임명하지 못했습니다. : '+data.reason);
|
alert('{0}을(를) 임명했습니다.'.format(generalName));
|
||||||
return false;
|
} else {
|
||||||
}
|
alert('관직을 비웠습니다.');
|
||||||
|
}
|
||||||
if(generalID){
|
|
||||||
alert('{0}을(를) 임명했습니다.'.format(generalName));
|
location.reload();
|
||||||
}
|
}, errUnknown);
|
||||||
else{
|
|
||||||
alert('관직을 비웠습니다.');
|
})
|
||||||
}
|
|
||||||
|
|
||||||
location.reload();
|
|
||||||
}, errUnknown);
|
|
||||||
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
+129
-103
@@ -3,8 +3,8 @@
|
|||||||
* @see https://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
* @see https://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
||||||
* @param {string} string escape하고자 하는 문자열
|
* @param {string} string escape하고자 하는 문자열
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
var escapeHtml = (function (string) {
|
var escapeHtml = (function(string) {
|
||||||
var entityMap = {
|
var entityMap = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
'<': '<',
|
'<': '<',
|
||||||
@@ -32,58 +32,70 @@ function isInt(n) {
|
|||||||
return +n === n && !(n % 1);
|
return +n === n && !(n % 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
;(function(ns){
|
;
|
||||||
|
(function(ns) {
|
||||||
//https://gist.github.com/demouth/3217440
|
//https://gist.github.com/demouth/3217440
|
||||||
/**
|
/**
|
||||||
* mb_strwidth
|
* mb_strwidth
|
||||||
* @param String
|
* @param String
|
||||||
* @return int
|
* @return int
|
||||||
* @see http://php.net/manual/ja/function.mb-strwidth.php
|
* @see http://php.net/manual/ja/function.mb-strwidth.php
|
||||||
*/
|
*/
|
||||||
var mb_strwidth = function(str){
|
var mb_strwidth = function(str) {
|
||||||
var i=0,l=str.length,c='',length=0;
|
var i = 0,
|
||||||
for(;i<l;i++){
|
l = str.length,
|
||||||
c=str.charCodeAt(i);
|
c = '',
|
||||||
if(0x0000<=c&&c<=0x0019){
|
length = 0;
|
||||||
length += 0;
|
for (; i < l; i++) {
|
||||||
}else if(0x0020<=c&&c<=0x1FFF){
|
c = str.charCodeAt(i);
|
||||||
length += 1;
|
if (0x0000 <= c && c <= 0x0019) {
|
||||||
}else if(0x2000<=c&&c<=0xFF60){
|
length += 0;
|
||||||
length += 2;
|
} else if (0x0020 <= c && c <= 0x1FFF) {
|
||||||
}else if(0xFF61<=c&&c<=0xFF9F){
|
length += 1;
|
||||||
length += 1;
|
} else if (0x2000 <= c && c <= 0xFF60) {
|
||||||
}else if(0xFFA0<=c){
|
length += 2;
|
||||||
length += 2;
|
} else if (0xFF61 <= c && c <= 0xFF9F) {
|
||||||
}
|
length += 1;
|
||||||
}
|
} else if (0xFFA0 <= c) {
|
||||||
return length;
|
length += 2;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
/**
|
return length;
|
||||||
* mb_strimwidth
|
};
|
||||||
* @param String
|
|
||||||
* @param int
|
/**
|
||||||
* @param int
|
* mb_strimwidth
|
||||||
* @param String
|
* @param String
|
||||||
* @return String
|
* @param int
|
||||||
* @see http://www.php.net/manual/ja/function.mb-strimwidth.php
|
* @param int
|
||||||
*/
|
* @param String
|
||||||
var mb_strimwidth = function(str,start,width,trimmarker){
|
* @return String
|
||||||
if(typeof trimmarker === 'undefined') trimmarker='';
|
* @see http://www.php.net/manual/ja/function.mb-strimwidth.php
|
||||||
var trimmakerWidth = mb_strwidth(trimmarker),i=start,l=str.length,trimmedLength=0,trimmedStr='';
|
*/
|
||||||
for(;i<l;i++){
|
var mb_strimwidth = function(str, start, width, trimmarker) {
|
||||||
var charCode=str.charCodeAt(i),c=str.charAt(i),charWidth=mb_strwidth(c),next=str.charAt(i+1),nextWidth=mb_strwidth(next);
|
if (typeof trimmarker === 'undefined') trimmarker = '';
|
||||||
trimmedLength += charWidth;
|
var trimmakerWidth = mb_strwidth(trimmarker),
|
||||||
trimmedStr += c;
|
i = start,
|
||||||
if(trimmedLength+trimmakerWidth+nextWidth>width){
|
l = str.length,
|
||||||
trimmedStr += trimmarker;
|
trimmedLength = 0,
|
||||||
break;
|
trimmedStr = '';
|
||||||
}
|
for (; i < l; i++) {
|
||||||
}
|
var charCode = str.charCodeAt(i),
|
||||||
return trimmedStr;
|
c = str.charAt(i),
|
||||||
};
|
charWidth = mb_strwidth(c),
|
||||||
ns.mb_strwidth = mb_strwidth;
|
next = str.charAt(i + 1),
|
||||||
ns.mb_strimwidth = mb_strimwidth;
|
nextWidth = mb_strwidth(next);
|
||||||
|
trimmedLength += charWidth;
|
||||||
|
trimmedStr += c;
|
||||||
|
if (trimmedLength + trimmakerWidth + nextWidth > width) {
|
||||||
|
trimmedStr += trimmarker;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return trimmedStr;
|
||||||
|
};
|
||||||
|
ns.mb_strwidth = mb_strwidth;
|
||||||
|
ns.mb_strimwidth = mb_strimwidth;
|
||||||
})(window);
|
})(window);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +105,7 @@ function isInt(n) {
|
|||||||
*/
|
*/
|
||||||
function convertDictById(arr) {
|
function convertDictById(arr) {
|
||||||
var result = {};
|
var result = {};
|
||||||
arr.forEach(function (v, i) {
|
arr.forEach(function(v, i) {
|
||||||
result[v.id] = v;
|
result[v.id] = v;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
@@ -106,7 +118,7 @@ function convertDictById(arr) {
|
|||||||
*/
|
*/
|
||||||
function convertSet(arr) {
|
function convertSet(arr) {
|
||||||
var result = {};
|
var result = {};
|
||||||
arr.forEach(function (v) {
|
arr.forEach(function(v) {
|
||||||
result[v] = true;
|
result[v] = true;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
@@ -115,10 +127,10 @@ function convertSet(arr) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {0}, {1}, {2}형태로 포맷해주는 함수
|
* {0}, {1}, {2}형태로 포맷해주는 함수
|
||||||
*/
|
*/
|
||||||
String.prototype.format = function() {
|
String.prototype.format = function() {
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
return this.replace(/{(\d+)}/g, function(match, number) {
|
return this.replace(/{(\d+)}/g, function(match, number) {
|
||||||
return (typeof args[number] != 'undefined') ? args[number] : match;
|
return (typeof args[number] != 'undefined') ? args[number] : match;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -134,12 +146,11 @@ function hexToRgb(hex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isBrightColor(color){
|
function isBrightColor(color) {
|
||||||
color = hexToRgb(color);
|
color = hexToRgb(color);
|
||||||
if ((color.r*0.299 + color.g*0.587 + color.b*0.114) > 140){
|
if ((color.r * 0.299 + color.g * 0.587 + color.b * 0.114) > 140) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,7 +188,7 @@ function numberWithCommas(x) {
|
|||||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
function linkifyStrWithOpt(text){
|
function linkifyStrWithOpt(text) {
|
||||||
return linkifyStr(text, {});
|
return linkifyStr(text, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +199,14 @@ function linkifyStrWithOpt(text){
|
|||||||
* @param {object} options
|
* @param {object} options
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
var TemplateEngine = function (html, options) {
|
var TemplateEngine = function(html, options) {
|
||||||
var re = /<%(.+?)%>/g,
|
var re = /<%(.+?)%>/g,
|
||||||
reExp = /(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,
|
reExp = /(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,
|
||||||
code = 'with(obj) { var r=[];\n',
|
code = 'with(obj) { var r=[];\n',
|
||||||
cursor = 0,
|
cursor = 0,
|
||||||
result,
|
result,
|
||||||
match;
|
match;
|
||||||
var add = function (line, js) {
|
var add = function(line, js) {
|
||||||
js ? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
|
js ? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
|
||||||
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
|
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
|
||||||
return add;
|
return add;
|
||||||
@@ -208,82 +219,97 @@ var TemplateEngine = function (html, options) {
|
|||||||
}
|
}
|
||||||
add(html.substr(cursor, html.length - cursor));
|
add(html.substr(cursor, html.length - cursor));
|
||||||
code = (code + 'return r.join(""); }').replace(/[\r\t\n]/g, ' ');
|
code = (code + 'return r.join(""); }').replace(/[\r\t\n]/g, ' ');
|
||||||
try { result = new Function('obj', code).apply(options, [options]); }
|
try { result = new Function('obj', code).apply(options, [options]); } catch (err) { console.error("'" + err.message + "'", " in \n\nCode:\n", code, "\n"); }
|
||||||
catch (err) { console.error("'" + err.message + "'", " in \n\nCode:\n", code, "\n"); }
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIconPath(imgsvr, picture){
|
function getIconPath(imgsvr, picture) {
|
||||||
// ../d_shared/common_path.js 필요
|
// ../d_shared/common_path.js 필요
|
||||||
if(!imgsvr){
|
if (!imgsvr) {
|
||||||
return pathConfig.sharedIcon+'/'+picture;
|
return pathConfig.sharedIcon + '/' + picture;
|
||||||
}
|
} else {
|
||||||
else{
|
return pathConfig.root + '/d_pic/' + picture;
|
||||||
return pathConfig.root+'/d_pic/'+picture;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function activeFlip($obj){
|
function activeFlip($obj) {
|
||||||
var $result;
|
var $result;
|
||||||
if($obj === undefined){
|
if ($obj === undefined) {
|
||||||
$result = $('img[data-flip]');
|
$result = $('img[data-flip]');
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$result = $obj.find('img[data-flip]');
|
$result = $obj.find('img[data-flip]');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result.each(function(){
|
$result.each(function() {
|
||||||
activeFlipItem($(this));
|
activeFlipItem($(this));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function activeFlipItem($img){
|
function combineObject(item, columnList) {
|
||||||
|
var newItem = {};
|
||||||
|
for (var columnIdx in columnList) {
|
||||||
|
var columnName = columnList[columnIdx];
|
||||||
|
newItem[columnName] = item[columnIdx];
|
||||||
|
}
|
||||||
|
return newItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
function combineArray(array, columnList) {
|
||||||
|
var result = [];
|
||||||
|
for (var key in array) {
|
||||||
|
var item = array[key];
|
||||||
|
result[key] = combineObject(item, columnList);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function activeFlipItem($img) {
|
||||||
var imageList = [];
|
var imageList = [];
|
||||||
imageList.push($img.attr('src'));
|
imageList.push($img.attr('src'));
|
||||||
$.each($img.data('flip').split(','), function(idx, value){
|
$.each($img.data('flip').split(','), function(idx, value) {
|
||||||
var value = $.trim(value);
|
var value = $.trim(value);
|
||||||
if(!value){
|
if (!value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
imageList.push(value);
|
imageList.push(value);
|
||||||
});
|
});
|
||||||
if(imageList.length <= 1){
|
if (imageList.length <= 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$img.data('computed_flip_array', imageList);
|
$img.data('computed_flip_array', imageList);
|
||||||
$img.data('computed_flip_idx', 0);
|
$img.data('computed_flip_idx', 0);
|
||||||
|
|
||||||
$img.click(function(){
|
$img.click(function() {
|
||||||
var arr = $img.data('computed_flip_array');
|
var arr = $img.data('computed_flip_array');
|
||||||
var idx = $img.data('computed_flip_idx');
|
var idx = $img.data('computed_flip_idx');
|
||||||
idx = (idx + 1)%(arr.length);
|
idx = (idx + 1) % (arr.length);
|
||||||
$img.attr('src', arr[idx]);
|
$img.attr('src', arr[idx]);
|
||||||
$img.data('computed_flip_idx', idx);
|
$img.data('computed_flip_idx', idx);
|
||||||
});
|
});
|
||||||
$img.css('cursor','pointer');
|
$img.css('cursor', 'pointer');
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery(function($){
|
jQuery(function($) {
|
||||||
$('.obj_tooltip').mouseover(function(){
|
$('.obj_tooltip').mouseover(function() {
|
||||||
var $objTooltip = $(this);
|
var $objTooltip = $(this);
|
||||||
if($objTooltip.data('setObjTooltip')){
|
if ($objTooltip.data('setObjTooltip')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tooltipClassText = $objTooltip.data('tooltip-class');
|
var tooltipClassText = $objTooltip.data('tooltip-class');
|
||||||
if(!tooltipClassText){
|
if (!tooltipClassText) {
|
||||||
tooltipClassText = '';
|
tooltipClassText = '';
|
||||||
}
|
}
|
||||||
var template = '<div class="tooltip {0}" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>'
|
var template = '<div class="tooltip {0}" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>'
|
||||||
.format(tooltipClassText);
|
.format(tooltipClassText);
|
||||||
|
|
||||||
$objTooltip.tooltip({
|
$objTooltip.tooltip({
|
||||||
title:function(){
|
title: function() {
|
||||||
return $.trim($(this).find('.tooltiptext').html());
|
return $.trim($(this).find('.tooltiptext').html());
|
||||||
},
|
},
|
||||||
template:template,
|
template: template,
|
||||||
html:true
|
html: true
|
||||||
}).tooltip('show');
|
}).tooltip('show');
|
||||||
|
|
||||||
$objTooltip.data('setObjTooltip', true);
|
$objTooltip.data('setObjTooltip', true);
|
||||||
@@ -297,21 +323,21 @@ jQuery(function($){
|
|||||||
activeFlip();
|
activeFlip();
|
||||||
|
|
||||||
var customCSS = localStorage.getItem('sam_customCSS');
|
var customCSS = localStorage.getItem('sam_customCSS');
|
||||||
if(customCSS){
|
if (customCSS) {
|
||||||
var $style = $('<style type="text/css"></style>');
|
var $style = $('<style type="text/css"></style>');
|
||||||
$style.text(customCSS);
|
$style.text(customCSS);
|
||||||
$style.appendTo($('head'));
|
$style.appendTo($('head'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function errUnknown(){
|
function errUnknown() {
|
||||||
alert('작업을 실패했습니다.');
|
alert('작업을 실패했습니다.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function errUnknownToast(){
|
function errUnknownToast() {
|
||||||
$.toast({
|
$.toast({
|
||||||
title: '에러!',
|
title: '에러!',
|
||||||
content: '작업을 실패했습니다.',
|
content: '작업을 실패했습니다.',
|
||||||
@@ -320,8 +346,8 @@ function errUnknownToast(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function quickReject(errMsg){
|
function quickReject(errMsg) {
|
||||||
if(errMsg === undefined){
|
if (errMsg === undefined) {
|
||||||
errMsg = '작업을 실패했습니다.';
|
errMsg = '작업을 실패했습니다.';
|
||||||
}
|
}
|
||||||
var deferred = $.Deferred();
|
var deferred = $.Deferred();
|
||||||
@@ -329,8 +355,8 @@ function quickReject(errMsg){
|
|||||||
return deferred.promise();
|
return deferred.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
function nl2br(text){
|
function nl2br(text) {
|
||||||
return text.replace(/\n/g,"<br>");
|
return text.replace(/\n/g, "<br>");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
function br2nl (text) {
|
function br2nl (text) {
|
||||||
@@ -338,11 +364,11 @@ function br2nl (text) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getNpcColor(npcType){
|
function getNpcColor(npcType) {
|
||||||
if(npcType >= 2){
|
if (npcType >= 2) {
|
||||||
return 'cyan';
|
return 'cyan';
|
||||||
}
|
}
|
||||||
if(npcType == 1){
|
if (npcType == 1) {
|
||||||
return 'skyblue';
|
return 'skyblue';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+685
-653
@@ -1,654 +1,686 @@
|
|||||||
|
function is_touch_device() {
|
||||||
function is_touch_device() {
|
var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
|
||||||
var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
|
var mq = function(query) {
|
||||||
var mq = function(query) {
|
return window.matchMedia(query).matches;
|
||||||
return window.matchMedia(query).matches;
|
}
|
||||||
}
|
|
||||||
|
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch) {
|
||||||
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch) {
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// include the 'heartz' as a way to have a non matching MQ to help terminate the join
|
||||||
// include the 'heartz' as a way to have a non matching MQ to help terminate the join
|
// https://git.io/vznFH
|
||||||
// https://git.io/vznFH
|
var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
|
||||||
var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
|
return mq(query);
|
||||||
return mq(query);
|
}
|
||||||
}
|
|
||||||
|
function reloadWorldMap(option, drawTarget) {
|
||||||
function reloadWorldMap(option){
|
if (drawTarget === undefined || drawTarget === null) {
|
||||||
var $world_map = $('.world_map');
|
drawTarget = '.world_map'
|
||||||
|
}
|
||||||
if($world_map.length == 0){
|
var $world_map = $(drawTarget);
|
||||||
return;
|
|
||||||
}
|
if ($world_map.length == 0) {
|
||||||
|
return;
|
||||||
var defaultOption = {
|
}
|
||||||
isDetailMap:true, //복잡 지도, 단순 지도
|
|
||||||
clickableAll:false, //어떤 경우든 클릭을 가능하게 함. 해당 동작의 동작 가능성 여부와는 별도.
|
var defaultOption = {
|
||||||
selectCallback:null, //callback을 지정시 clickable과 관계 없이 해당 함수를 실행.
|
isDetailMap: true, //복잡 지도, 단순 지도
|
||||||
hrefTemplate:'#', //도시가 클릭가능할 경우 지정할 href값. {0}은 도시 id로 변환됨
|
clickableAll: false, //어떤 경우든 클릭을 가능하게 함. 해당 동작의 동작 가능성 여부와는 별도.
|
||||||
useCachedMap:false, //맵 캐시를 사용
|
selectCallback: null, //callback을 지정시 clickable과 관계 없이 해당 함수를 실행.
|
||||||
|
hrefTemplate: '#', //도시가 클릭가능할 경우 지정할 href값. {0}은 도시 id로 변환됨
|
||||||
//아래부터는 post query에 들어갈 녀석
|
useCachedMap: false, //맵 캐시를 사용
|
||||||
year:null, //year값, 연감등에 사용
|
|
||||||
month:null, //month값, 연감등에 사용
|
//아래부터는 post query에 들어갈 녀석
|
||||||
aux:null, //기타 넣고 싶은 값을 입력
|
year: null, //year값, 연감등에 사용
|
||||||
neutralView:false, //clickable, 소속 국가, 첩보 여부 등을 반환여부를 설정
|
month: null, //month값, 연감등에 사용
|
||||||
showMe:true, //반환 값에 본인이 위치한 도시 값을 반환하도록 설정. neutralView와 별개
|
aux: null, //기타 넣고 싶은 값을 입력
|
||||||
targetJson:'j_map.php',
|
neutralView: false, //clickable, 소속 국가, 첩보 여부 등을 반환여부를 설정
|
||||||
|
showMe: true, //반환 값에 본인이 위치한 도시 값을 반환하도록 설정. neutralView와 별개
|
||||||
//기타 보조 값
|
|
||||||
startYear:null,
|
targetJson: 'j_map.php',
|
||||||
};
|
reqType: 'post',
|
||||||
|
dynamicMapTheme: false,
|
||||||
option = $.extend(defaultOption, option);
|
callback: null,
|
||||||
|
|
||||||
var useCachedMap = option.useCachedMap;
|
//기타 보조 값
|
||||||
var isDetailMap = option.isDetailMap;
|
startYear: null,
|
||||||
var clickableAll = option.clickableAll;
|
};
|
||||||
var selectCallback = option.selectCallback;
|
|
||||||
var hrefTemplate = option.hrefTemplate;
|
option = $.extend(defaultOption, option);
|
||||||
|
|
||||||
var cityPosition = getCityPosition();
|
var useCachedMap = option.useCachedMap;
|
||||||
|
var isDetailMap = option.isDetailMap;
|
||||||
var storedOldMapKey = 'sam.{0}.map'.format(serverNick);
|
var clickableAll = option.clickableAll;
|
||||||
var storedStartYear = 'sam.{0}.startYear'.format(serverNick);
|
var selectCallback = option.selectCallback;
|
||||||
//OBJ : startYear, year, month, cityList, nationList, spyList, shownByGeneralList, myCity
|
var hrefTemplate = option.hrefTemplate;
|
||||||
|
|
||||||
function checkReturnObject(obj){
|
var cityPosition = getCityPosition();
|
||||||
if(!obj.result){
|
|
||||||
var obj = $.Deferred();
|
var storedOldMapKey = 'sam.{0}.map'.format(serverNick);
|
||||||
obj.reject('fail');
|
var storedStartYear = 'sam.{0}.startYear'.format(serverNick);
|
||||||
return obj.promise();
|
//OBJ : startYear, year, month, cityList, nationList, spyList, shownByGeneralList, myCity
|
||||||
}
|
|
||||||
|
function checkReturnObject(obj) {
|
||||||
if(!$.isNumeric(obj.startYear)
|
if (!obj.result) {
|
||||||
||!$.isNumeric(obj.year)
|
var obj = $.Deferred();
|
||||||
||!$.isNumeric(obj.month)
|
obj.reject('fail');
|
||||||
){
|
return obj.promise();
|
||||||
var obj = $.Deferred();
|
}
|
||||||
obj.reject('fail');
|
|
||||||
return obj.promise();
|
if (!$.isNumeric(obj.startYear) ||
|
||||||
}
|
!$.isNumeric(obj.year) ||
|
||||||
|
!$.isNumeric(obj.month)
|
||||||
if(useCachedMap){
|
) {
|
||||||
localStorage.setItem(storedOldMapKey, JSON.stringify([serverID, obj]));
|
var obj = $.Deferred();
|
||||||
localStorage.setItem(storedStartYear, JSON.stringify(obj.startYear));
|
obj.reject('fail');
|
||||||
}
|
return obj.promise();
|
||||||
|
}
|
||||||
$world_map.removeClass('draw_required');
|
|
||||||
|
if (useCachedMap) {
|
||||||
return obj;
|
localStorage.setItem(storedOldMapKey, JSON.stringify([serverID, obj]));
|
||||||
}
|
localStorage.setItem(storedStartYear, JSON.stringify(obj.startYear));
|
||||||
|
}
|
||||||
function setMapBackground(obj){
|
|
||||||
var startYear = obj.startYear;
|
$world_map.removeClass('draw_required');
|
||||||
var year = obj.year;
|
|
||||||
var month = obj.month;
|
return obj;
|
||||||
|
}
|
||||||
if(isDetailMap){
|
|
||||||
$world_map.addClass('map_detail').removeClass('map_basic');
|
|
||||||
}
|
|
||||||
else{
|
function setMapBackground(obj) {
|
||||||
$world_map.addClass('map_basic').removeClass('map_detail');
|
function setTheme() {
|
||||||
}
|
var oldTheme = $world_map.data('currentTheme');
|
||||||
|
var newTheme = obj.theme;
|
||||||
var $map_title = $('.map_title_text');
|
if (oldTheme === newTheme) {
|
||||||
if(year < startYear + 1){
|
return;
|
||||||
$map_title.css('color', 'magenta');
|
}
|
||||||
}
|
if (oldTheme) {
|
||||||
else if(year < startYear + 2){
|
$world_map.removeClass('map_theme_' + oldTheme);
|
||||||
$map_title.css('color', 'orange');
|
}
|
||||||
}
|
$world_map.addClass('map_theme_' + newTheme);
|
||||||
else if(year < startYear + 3){
|
$world_map.data('currentTheme', newTheme);
|
||||||
$map_title.css('color', 'yellow');
|
}
|
||||||
}
|
if (option.dynamicMapTheme) {
|
||||||
|
setTheme();
|
||||||
$map_title_tooltip = $('.map_title .tooltiptext');
|
}
|
||||||
$map_title_tooltip.empty();
|
var startYear = obj.startYear;
|
||||||
|
var year = obj.year;
|
||||||
var tooltipTexts = [];
|
var month = obj.month;
|
||||||
if(year < startYear + 3){
|
|
||||||
var startYearText = [];
|
if (isDetailMap) {
|
||||||
var remainYear = startYear + 3 - year;
|
$world_map.addClass('map_detail').removeClass('map_basic');
|
||||||
var remainMonth = 12 - month + 1;
|
} else {
|
||||||
if(remainMonth > 0){
|
$world_map.addClass('map_basic').removeClass('map_detail');
|
||||||
remainYear -= 1;
|
}
|
||||||
}
|
|
||||||
if(remainYear){
|
var $map_title = $('.map_title_text');
|
||||||
startYearText.push('{0}년'.format(remainYear));
|
if (year < startYear + 1) {
|
||||||
}
|
$map_title.css('color', 'magenta');
|
||||||
if(remainMonth){
|
} else if (year < startYear + 2) {
|
||||||
startYearText.push('{0}개월'.format(remainMonth));
|
$map_title.css('color', 'orange');
|
||||||
}
|
} else if (year < startYear + 3) {
|
||||||
|
$map_title.css('color', 'yellow');
|
||||||
tooltipTexts.push('초반제한 기간 : {0} ({1}년)'.format(startYearText.join(' '), startYear + 3));
|
}
|
||||||
}
|
|
||||||
|
$map_title_tooltip = $('.map_title .tooltiptext');
|
||||||
var currentTechLimit = Math.floor(Math.max(0, year - startYear) / 5) + 1;
|
$map_title_tooltip.empty();
|
||||||
var nextTechLimitYear = currentTechLimit * 5 + startYear;
|
|
||||||
|
var tooltipTexts = [];
|
||||||
tooltipTexts.push('기술등급 제한 : {0}등급 ({1}년 해제)'.format(currentTechLimit, nextTechLimitYear, currentTechLimit+1));
|
if (year < startYear + 3) {
|
||||||
$map_title_tooltip.html(tooltipTexts.join('<br>'));
|
var startYearText = [];
|
||||||
|
var remainYear = startYear + 3 - year;
|
||||||
$world_map.removeClass('map_string map_summer map_fall map_winter');
|
var remainMonth = 12 - month + 1;
|
||||||
if(month <= 3){
|
if (remainMonth > 0) {
|
||||||
$world_map.addClass('map_spring');
|
remainYear -= 1;
|
||||||
}
|
}
|
||||||
else if(month <= 6){
|
if (remainYear) {
|
||||||
$world_map.addClass('map_summer');
|
startYearText.push('{0}년'.format(remainYear));
|
||||||
}
|
}
|
||||||
else if(month <= 9){
|
if (remainMonth) {
|
||||||
$world_map.addClass('map_fall');
|
startYearText.push('{0}개월'.format(remainMonth));
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$world_map.addClass('map_winter');
|
tooltipTexts.push('초반제한 기간 : {0} ({1}년)'.format(startYearText.join(' '), startYear + 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
$map_title.html('{0}年 {1}月'.format(year, month));
|
var currentTechLimit = Math.floor(Math.max(0, year - startYear) / 5) + 1;
|
||||||
|
var nextTechLimitYear = currentTechLimit * 5 + startYear;
|
||||||
return obj;
|
|
||||||
}
|
tooltipTexts.push('기술등급 제한 : {0}등급 ({1}년 해제)'.format(currentTechLimit, nextTechLimitYear, currentTechLimit + 1));
|
||||||
|
$map_title_tooltip.html(tooltipTexts.join('<br>'));
|
||||||
function convertCityObjs(obj){
|
|
||||||
//원본 Obj는 굉장히 간소하게 온다, Object 형태로 변환해서 사용한다.
|
$world_map.removeClass('map_string map_summer map_fall map_winter');
|
||||||
|
if (month <= 3) {
|
||||||
function toCityObj(arr){
|
$world_map.addClass('map_spring');
|
||||||
return {
|
} else if (month <= 6) {
|
||||||
id:arr[0],
|
$world_map.addClass('map_summer');
|
||||||
level:arr[1],
|
} else if (month <= 9) {
|
||||||
state:arr[2],
|
$world_map.addClass('map_fall');
|
||||||
nationId:(arr[3]>0)?arr[3]:null,
|
} else {
|
||||||
region:arr[4],
|
$world_map.addClass('map_winter');
|
||||||
supply:(arr[5]!=0)
|
}
|
||||||
};
|
|
||||||
}
|
$map_title.html('{0}年 {1}月'.format(year, month));
|
||||||
|
|
||||||
function toNationObj(arr){
|
return obj;
|
||||||
return {
|
}
|
||||||
id:arr[0],
|
|
||||||
name:arr[1],
|
function convertCityObjs(obj) {
|
||||||
color:arr[2],
|
//원본 Obj는 굉장히 간소하게 온다, Object 형태로 변환해서 사용한다.
|
||||||
capital:arr[3]
|
|
||||||
};
|
function toCityObj(arr) {
|
||||||
}
|
return {
|
||||||
|
id: arr[0],
|
||||||
var cityList = obj.cityList.map(toCityObj);
|
level: arr[1],
|
||||||
var nationList = obj.nationList.map(toNationObj);
|
state: arr[2],
|
||||||
nationList = convertDictById(nationList); //array of object -> dict
|
nationId: (arr[3] > 0) ? arr[3] : null,
|
||||||
|
region: arr[4],
|
||||||
var spyList = obj.spyList;
|
supply: (arr[5] != 0)
|
||||||
var shownByGeneralList = convertSet(obj.shownByGeneralList);//Array -> Set
|
};
|
||||||
|
}
|
||||||
var myCity = obj.myCity;
|
|
||||||
var myNation = obj.myNation;
|
function toNationObj(arr) {
|
||||||
|
return {
|
||||||
|
id: arr[0],
|
||||||
function mergePositionInfo(city){
|
name: arr[1],
|
||||||
var id = city.id;
|
color: arr[2],
|
||||||
if(!(id in cityPosition)){
|
capital: arr[3]
|
||||||
return city;
|
};
|
||||||
}
|
}
|
||||||
var xy_val = cityPosition[id];
|
|
||||||
city.name = xy_val[0];
|
var cityList = obj.cityList.map(toCityObj);
|
||||||
city.x = xy_val[1];
|
var nationList = obj.nationList.map(toNationObj);
|
||||||
city.y = xy_val[2];
|
nationList = convertDictById(nationList); //array of object -> dict
|
||||||
return city;
|
|
||||||
}
|
var spyList = obj.spyList;
|
||||||
|
var shownByGeneralList = convertSet(obj.shownByGeneralList); //Array -> Set
|
||||||
function mergeNationInfo(city){
|
|
||||||
//nationId 값으로 isCapital, color, nation을 통합
|
var myCity = obj.myCity;
|
||||||
|
var myNation = obj.myNation;
|
||||||
var nationId = city.nationId;
|
|
||||||
if(nationId === null || !(nationId in nationList)){
|
|
||||||
city.nationId = null;
|
function mergePositionInfo(city) {
|
||||||
city.nation = null;
|
var id = city.id;
|
||||||
city.color = null;
|
if (!(id in cityPosition)) {
|
||||||
city.isCapital = false;
|
return city;
|
||||||
return city;
|
}
|
||||||
}
|
var xy_val = cityPosition[id];
|
||||||
|
city.name = xy_val[0];
|
||||||
var nationObj = nationList[nationId];
|
city.x = xy_val[1];
|
||||||
city.nation = nationObj.name;
|
city.y = xy_val[2];
|
||||||
city.color = nationObj.color;
|
return city;
|
||||||
city.isCapital = (nationObj.capital == city.id);
|
}
|
||||||
|
|
||||||
return city;
|
function mergeNationInfo(city) {
|
||||||
}
|
//nationId 값으로 isCapital, color, nation을 통합
|
||||||
|
|
||||||
function mergeClickable(city){
|
var nationId = city.nationId;
|
||||||
//clickable = (remainSpy << 3) | (ourCity << 2) | (shownByGeneral << 1) | clickableAll
|
if (nationId === null || !(nationId in nationList)) {
|
||||||
var id = city.id;
|
city.nationId = null;
|
||||||
var nationId = city.nationId;
|
city.nation = null;
|
||||||
var clickable = 0;
|
city.color = null;
|
||||||
if(id in spyList){
|
city.isCapital = false;
|
||||||
clickable |= spyList[id] << 3;
|
return city;
|
||||||
}
|
}
|
||||||
if(myNation !== null && nationId == myNation){
|
|
||||||
clickable |= 4;
|
var nationObj = nationList[nationId];
|
||||||
}
|
city.nation = nationObj.name;
|
||||||
if(shownByGeneralList.hasOwnProperty(id)){
|
city.color = nationObj.color;
|
||||||
clickable |= 2;
|
city.isCapital = (nationObj.capital == city.id);
|
||||||
}
|
|
||||||
if(myCity !== null && id == myCity){
|
return city;
|
||||||
clickable |= 2;
|
}
|
||||||
}
|
|
||||||
if(clickableAll){
|
function mergeClickable(city) {
|
||||||
clickable |= 1;
|
//clickable = (remainSpy << 3) | (ourCity << 2) | (shownByGeneral << 1) | clickableAll
|
||||||
}
|
var id = city.id;
|
||||||
|
var nationId = city.nationId;
|
||||||
|
var clickable = 0;
|
||||||
city.clickable = clickable;
|
if (id in spyList) {
|
||||||
return city;
|
clickable |= spyList[id] << 3;
|
||||||
}
|
}
|
||||||
|
if (myNation !== null && nationId == myNation) {
|
||||||
cityList = cityList
|
clickable |= 4;
|
||||||
.map(mergePositionInfo)
|
}
|
||||||
.map(mergeNationInfo)
|
if (shownByGeneralList.hasOwnProperty(id)) {
|
||||||
.map(mergeClickable)
|
clickable |= 2;
|
||||||
.map(formatCityInfo);
|
}
|
||||||
|
if (myCity !== null && id == myCity) {
|
||||||
return {
|
clickable |= 2;
|
||||||
'cityList' : cityList,
|
}
|
||||||
'myCity' : myCity
|
if (clickableAll) {
|
||||||
};
|
clickable |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawDetailWorldMap(obj){
|
|
||||||
|
city.clickable = clickable;
|
||||||
var $map_body = $('.world_map .map_body');
|
return city;
|
||||||
|
}
|
||||||
var cityList = obj.cityList;
|
|
||||||
var myCity = obj.myCity;
|
cityList = cityList
|
||||||
|
.map(mergePositionInfo)
|
||||||
cityList.forEach(function(city){
|
.map(mergeNationInfo)
|
||||||
var id = city.id;
|
.map(mergeClickable)
|
||||||
$('.city_base_{0}'.format(id)).detach();
|
.map(formatCityInfo);
|
||||||
//이전 도시는 지운다.
|
|
||||||
|
return {
|
||||||
var $cityObj = $('<div class="city_base city_base_{0}"></div>'.format(id));
|
'cityList': cityList,
|
||||||
$cityObj.addClass('city_level_{0}'.format(city.level));
|
'myCity': myCity
|
||||||
$cityObj.data('obj', city).css({'left':city.x-20,'top':city.y-15});
|
};
|
||||||
|
}
|
||||||
if('color' in city && city.color !== null){
|
|
||||||
var $bgObj = $('<div class="city_bg"></div>');
|
function drawDetailWorldMap(obj) {
|
||||||
$cityObj.append($bgObj);
|
|
||||||
$bgObj.css({'background-image':'url({0}/b{1}.png)'.format(pathConfig.gameImage, convColorValue(city.color))});
|
var $map_body = $(drawTarget + ' .map_body');
|
||||||
}
|
|
||||||
|
var cityList = obj.cityList;
|
||||||
var $linkObj = $('<a class="city_link"></a>');
|
var myCity = obj.myCity;
|
||||||
$linkObj.data({'text':city.text,'nation':city.nation,'id':city.id});
|
|
||||||
$cityObj.append($linkObj);
|
cityList.forEach(function(city) {
|
||||||
|
var id = city.id;
|
||||||
var $imgObj = $('<div class="city_img"><img src="{0}/cast_{1}.gif"><div class="city_filler"></div></div>'.format(pathConfig.gameImage, city.level));
|
$('.city_base_{0}'.format(id)).detach();
|
||||||
$linkObj.append($imgObj);
|
//이전 도시는 지운다.
|
||||||
|
|
||||||
|
var $cityObj = $('<div class="city_base city_base_{0}"></div>'.format(id));
|
||||||
|
$cityObj.addClass('city_level_{0}'.format(city.level));
|
||||||
if(city.state > 0){
|
$cityObj.data('obj', city).css({ 'left': city.x - 20, 'top': city.y - 15 });
|
||||||
var $stateObj = $('<div class="city_state"><img src="{0}/event{1}.gif"></div>'.format(pathConfig.gameImage, city.state));
|
|
||||||
$linkObj.append($stateObj);
|
if ('color' in city && city.color !== null) {
|
||||||
}
|
var $bgObj = $('<div class="city_bg"></div>');
|
||||||
|
$cityObj.append($bgObj);
|
||||||
if(city.nationId && city.nationId > 0){
|
$bgObj.css({ 'background-image': 'url({0}/b{1}.png)'.format(pathConfig.gameImage, convColorValue(city.color)) });
|
||||||
var flagType = city.supply?'f':'d';
|
}
|
||||||
var $flagObj = $('<div class="city_flag"><img src="{0}/{1}{2}.gif"></div>'.format(pathConfig.gameImage, flagType, convColorValue(city.color)));
|
|
||||||
if(city.isCapital){
|
var $linkObj = $('<a class="city_link"></a>');
|
||||||
var $capitalObj = $('<div class="city_capital"><img src="{0}/event51.gif"></div>'.format(pathConfig.gameImage));
|
$linkObj.data({ 'text': city.text, 'nation': city.nation, 'id': city.id });
|
||||||
$flagObj.append($capitalObj);
|
$cityObj.append($linkObj);
|
||||||
}
|
|
||||||
$imgObj.append($flagObj);
|
var $imgObj = $('<div class="city_img"><img src="{0}/cast_{1}.gif"><div class="city_filler"></div></div>'.format(pathConfig.gameImage, city.level));
|
||||||
}
|
$linkObj.append($imgObj);
|
||||||
|
|
||||||
var $nameObj = $('<span class="city_detail_name">{0}</span>'.format(city.name));
|
|
||||||
$imgObj.append($nameObj);
|
|
||||||
|
if (city.state > 0) {
|
||||||
|
var $stateObj = $('<div class="city_state"><img src="{0}/event{1}.gif"></div>'.format(pathConfig.gameImage, city.state));
|
||||||
$map_body.append($cityObj);
|
$linkObj.append($stateObj);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
if (city.nationId && city.nationId > 0) {
|
||||||
|
var flagType = city.supply ? 'f' : 'd';
|
||||||
$world_map.find('.city_base_{0} .city_filler'.format(myCity)).addClass('my_city');
|
var $flagObj = $('<div class="city_flag"><img src="{0}/{1}{2}.gif"></div>'.format(pathConfig.gameImage, flagType, convColorValue(city.color)));
|
||||||
|
if (city.isCapital) {
|
||||||
return obj;
|
var $capitalObj = $('<div class="city_capital"><img src="{0}/event51.gif"></div>'.format(pathConfig.gameImage));
|
||||||
}
|
$flagObj.append($capitalObj);
|
||||||
|
}
|
||||||
function drawBasicWorldMap(obj){
|
$imgObj.append($flagObj);
|
||||||
|
}
|
||||||
var $map_body = $('.world_map .map_body');
|
|
||||||
|
var $nameObj = $('<span class="city_detail_name">{0}</span>'.format(city.name));
|
||||||
var cityList = obj.cityList;
|
$imgObj.append($nameObj);
|
||||||
var myCity = obj.myCity;
|
|
||||||
|
|
||||||
cityList.forEach(function(city){
|
$map_body.append($cityObj);
|
||||||
var id = city.id;
|
|
||||||
$('.city_base_{0}'.format(id)).detach();
|
|
||||||
//이전 도시는 지운다.
|
});
|
||||||
|
|
||||||
var $cityObj = $('<div class="city_base city_base_{0}"></div>'.format(id));
|
$world_map.find('.city_base_{0} .city_filler'.format(myCity)).addClass('my_city');
|
||||||
$cityObj.addClass('city_level_{0}'.format(city.level));
|
|
||||||
$cityObj.data('obj', city).css({'left':city.x-20,'top':city.y-15});
|
return obj;
|
||||||
|
}
|
||||||
var $linkObj = $('<a class="city_link"></a>');
|
|
||||||
$linkObj.data({'text':city.text,'nation':city.nation,'id':city.id});
|
function drawBasicWorldMap(obj) {
|
||||||
$cityObj.append($linkObj);
|
|
||||||
|
var $map_body = $(drawTarget + ' .map_body');
|
||||||
var $imgObj = $('<div class="city_img"><div class="city_filler"></div></div>');
|
|
||||||
if('color' in city && city.color !== null){
|
var cityList = obj.cityList;
|
||||||
$imgObj.css({'background-color':city.color});
|
var myCity = obj.myCity;
|
||||||
}
|
|
||||||
$linkObj.append($imgObj);
|
cityList.forEach(function(city) {
|
||||||
|
var id = city.id;
|
||||||
if(city.state > 0){
|
$('.city_base_{0}'.format(id)).detach();
|
||||||
var state_text = 'wrong';
|
//이전 도시는 지운다.
|
||||||
if(city.state < 10){
|
|
||||||
state_text = 'good';
|
var $cityObj = $('<div class="city_base city_base_{0}"></div>'.format(id));
|
||||||
}
|
$cityObj.addClass('city_level_{0}'.format(city.level));
|
||||||
else if(city.state < 40){
|
$cityObj.data('obj', city).css({ 'left': city.x - 20, 'top': city.y - 15 });
|
||||||
state_text = 'bad';
|
|
||||||
}
|
var $linkObj = $('<a class="city_link"></a>');
|
||||||
else if(city.state < 50){
|
$linkObj.data({ 'text': city.text, 'nation': city.nation, 'id': city.id });
|
||||||
state_text = 'war';
|
$cityObj.append($linkObj);
|
||||||
}
|
|
||||||
|
var $imgObj = $('<div class="city_img"><div class="city_filler"></div></div>');
|
||||||
var $stateObj = $('<div class="city_state city_state_{0}"></div>'.format(state_text));
|
if ('color' in city && city.color !== null) {
|
||||||
$imgObj.append($stateObj);
|
$imgObj.css({ 'background-color': city.color });
|
||||||
}
|
}
|
||||||
|
$linkObj.append($imgObj);
|
||||||
//단순 표기에서는 깃발 여부가 없음
|
|
||||||
if(city.isCapital){
|
if (city.state > 0) {
|
||||||
var $capitalObj = $('<div class="city_capital"></div>');
|
var state_text = 'wrong';
|
||||||
$imgObj.append($capitalObj);
|
if (city.state < 10) {
|
||||||
}
|
state_text = 'good';
|
||||||
|
} else if (city.state < 40) {
|
||||||
var $nameObj = $('<span class="city_detail_name">{0}</span>'.format(city.name));
|
state_text = 'bad';
|
||||||
$imgObj.append($nameObj);
|
} else if (city.state < 50) {
|
||||||
|
state_text = 'war';
|
||||||
$map_body.append($cityObj);
|
}
|
||||||
});
|
|
||||||
|
var $stateObj = $('<div class="city_state city_state_{0}"></div>'.format(state_text));
|
||||||
$world_map.find('.city_base_{0} .city_filler'.format(myCity)).addClass('my_city');
|
$imgObj.append($stateObj);
|
||||||
|
}
|
||||||
return obj;
|
|
||||||
}
|
//단순 표기에서는 깃발 여부가 없음
|
||||||
|
if (city.isCapital) {
|
||||||
function setMouseWork(obj){
|
var $capitalObj = $('<div class="city_capital"></div>');
|
||||||
var $tooltip = $('.world_map .city_tooltip');
|
$imgObj.append($capitalObj);
|
||||||
var $tooltip_city = $tooltip.find('.city_name');
|
}
|
||||||
var $tooltip_nation = $tooltip.find('.nation_name');
|
|
||||||
|
var $nameObj = $('<span class="city_detail_name">{0}</span>'.format(city.name));
|
||||||
var $objs = $('.world_map .city_link');
|
$imgObj.append($nameObj);
|
||||||
|
|
||||||
var $map_body = $('.world_map .map_body');
|
$map_body.append($cityObj);
|
||||||
|
});
|
||||||
//터치스크린 탭
|
|
||||||
|
$world_map.find('.city_base_{0} .city_filler'.format(myCity)).addClass('my_city');
|
||||||
if(!option.neutralView && is_touch_device()){
|
|
||||||
$objs.on('touchstart', function(e){
|
return obj;
|
||||||
if(window.sam_toggleSingleTap){
|
}
|
||||||
return true;
|
|
||||||
}
|
function setMouseWork(obj) {
|
||||||
var $this = $(this);
|
var $tooltip = $(drawTarget + ' .city_tooltip');
|
||||||
|
var $tooltip_city = $tooltip.find('.city_name');
|
||||||
var touchMode = $this.data('touchMode');
|
var $tooltip_nation = $tooltip.find('.nation_name');
|
||||||
if($tooltip_city.data('target') != $this.data('id')){
|
|
||||||
$this.data('touchMode', 1);
|
var $objs = $(drawTarget + ' .city_link');
|
||||||
}
|
|
||||||
else if(touchMode === undefined){
|
var $map_body = $(drawTarget + ' .map_body');
|
||||||
$this.data('touchMode', 1);
|
|
||||||
}
|
//터치스크린 탭
|
||||||
else{
|
|
||||||
$this.data('touchMode', touchMode + 1);
|
if (!option.neutralView && is_touch_device()) {
|
||||||
}
|
$objs.on('touchstart', function(e) {
|
||||||
$map_body.data('touchMode', 1);
|
if (window.sam_toggleSingleTap) {
|
||||||
|
return true;
|
||||||
$tooltip_city.data('target', $this.data('id'));
|
}
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
});
|
var touchMode = $this.data('touchMode');
|
||||||
|
if ($tooltip_city.data('target') != $this.data('id')) {
|
||||||
$objs.on('touchend', function(e){
|
$this.data('touchMode', 1);
|
||||||
if(window.sam_toggleSingleTap){
|
} else if (touchMode === undefined) {
|
||||||
return true;
|
$this.data('touchMode', 1);
|
||||||
}
|
} else {
|
||||||
var $this = $(this);
|
$this.data('touchMode', touchMode + 1);
|
||||||
var position = $this.parent().position();
|
}
|
||||||
$tooltip_city.html($this.data('text'));
|
$map_body.data('touchMode', 1);
|
||||||
|
|
||||||
var nation_text = $this.data('nation');
|
$tooltip_city.data('target', $this.data('id'));
|
||||||
if(nation_text){
|
|
||||||
$tooltip_nation.html(nation_text).show();
|
|
||||||
}
|
});
|
||||||
else{
|
|
||||||
$tooltip_nation.html('').hide();
|
$objs.on('touchend', function(e) {
|
||||||
}
|
if (window.sam_toggleSingleTap) {
|
||||||
|
return true;
|
||||||
$tooltip.css({'top': position.top + 25, 'left': position.left + 35}).show();
|
}
|
||||||
|
var $this = $(this);
|
||||||
var touchMode = $this.data('touchMode');
|
var position = $this.parent().position();
|
||||||
if(touchMode <= 1){
|
$tooltip_city.html($this.data('text'));
|
||||||
return false;
|
|
||||||
}
|
var nation_text = $this.data('nation');
|
||||||
|
if (nation_text) {
|
||||||
//xxx: touchend 다음 click 이벤트가 갈 수도 있고, 안 갈 수도 있다.
|
$tooltip_nation.html(nation_text).show();
|
||||||
$this.data('touchMode', 0);
|
} else {
|
||||||
});
|
$tooltip_nation.html('').hide();
|
||||||
|
}
|
||||||
$map_body.on('touchend',function(e){
|
|
||||||
if(window.sam_toggleSingleTap){
|
var left = position.left;
|
||||||
return true;
|
var top = position.top;
|
||||||
}
|
|
||||||
//위의 touchend bind에 해당하지 않는 경우 -> 빈 지도 터치
|
var scale = $map_body.data('scale');
|
||||||
$tooltip.hide();
|
if (scale) {
|
||||||
});
|
left /= scale;
|
||||||
|
top /= scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Mouse over 모드 작동
|
$tooltip.css({ 'top': top + 25, 'left': left + 35 }).show();
|
||||||
|
|
||||||
$map_body.on('mousemove', function(e){
|
var touchMode = $this.data('touchMode');
|
||||||
if($(this).data('touchMode')){
|
if (touchMode <= 1) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parentOffset = $map_body.offset();
|
//xxx: touchend 다음 click 이벤트가 갈 수도 있고, 안 갈 수도 있다.
|
||||||
var relX = e.pageX - parentOffset.left;
|
$this.data('touchMode', 0);
|
||||||
var relY = e.pageY - parentOffset.top;
|
});
|
||||||
|
|
||||||
$tooltip.css({'top': relY + 10, 'left': relX + 10});
|
$map_body.on('touchend', function(e) {
|
||||||
});
|
if (window.sam_toggleSingleTap) {
|
||||||
|
return true;
|
||||||
$objs.on('mouseenter', function(e){
|
}
|
||||||
if($map_body.data('touchMode')){
|
//위의 touchend bind에 해당하지 않는 경우 -> 빈 지도 터치
|
||||||
return true;
|
$tooltip.hide();
|
||||||
}
|
});
|
||||||
|
|
||||||
var $this = $(this);
|
}
|
||||||
|
|
||||||
$tooltip_city.data('target', $this.data('id'));
|
//Mouse over 모드 작동
|
||||||
$tooltip_city.html($this.data('text'));
|
|
||||||
var nation_text = $this.data('nation');
|
$map_body.on('mousemove', function(e) {
|
||||||
if(nation_text){
|
if ($(this).data('touchMode')) {
|
||||||
$tooltip_nation.html(nation_text).show();
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$tooltip_nation.html('').hide();
|
var rect = this.getBoundingClientRect();
|
||||||
}
|
var left = (e.clientX - rect.left - this.clientLeft + this.scrollLeft);
|
||||||
|
var top = (e.clientY - rect.top - this.clientTop + this.scrollTop);
|
||||||
$tooltip.show();
|
|
||||||
});
|
var scale = $map_body.data('scale');
|
||||||
|
if (scale) {
|
||||||
$objs.on('mouseleave', function(event){
|
left /= scale;
|
||||||
$tooltip.hide();
|
top /= scale;
|
||||||
});
|
}
|
||||||
|
|
||||||
$objs.on('click', function(e){
|
$tooltip.css({ 'top': top + 10, 'left': left + 10 });
|
||||||
//xxx: touchend 다음 click 이벤트가 갈 수도 있고, 안 갈 수도 있다.
|
});
|
||||||
var touchMode = $(this).data('touchMode');
|
|
||||||
if(touchMode === undefined){
|
$objs.on('mouseenter', function(e) {
|
||||||
return;
|
if ($map_body.data('touchMode')) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
if(touchMode === 1){
|
|
||||||
return false;
|
var $this = $(this);
|
||||||
}
|
|
||||||
});
|
$tooltip_city.data('target', $this.data('id'));
|
||||||
|
$tooltip_city.html($this.data('text'));
|
||||||
|
var nation_text = $this.data('nation');
|
||||||
return obj;
|
if (nation_text) {
|
||||||
}
|
$tooltip_nation.html(nation_text).show();
|
||||||
|
} else {
|
||||||
function setCityClickable(obj){
|
$tooltip_nation.html('').hide();
|
||||||
|
}
|
||||||
obj.cityList.forEach(function(city){
|
|
||||||
var $cityLink = $world_map.find('.city_base_{0} .city_link'.format(city.id));
|
$tooltip.show();
|
||||||
|
});
|
||||||
if('clickable' in city && city.clickable > 0){
|
|
||||||
$cityLink.attr('href',hrefTemplate.format(city.id));
|
$objs.on('mouseleave', function(event) {
|
||||||
}
|
$tooltip.hide();
|
||||||
|
});
|
||||||
if(selectCallback){
|
|
||||||
$cityLink.click(function(){
|
$objs.on('click', function(e) {
|
||||||
return selectCallback(city);
|
//xxx: touchend 다음 click 이벤트가 갈 수도 있고, 안 갈 수도 있다.
|
||||||
});
|
var touchMode = $(this).data('touchMode');
|
||||||
}
|
if (touchMode === undefined) {
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
return obj;
|
|
||||||
}
|
if (touchMode === 1) {
|
||||||
|
return false;
|
||||||
function saveCityInfo(obj){
|
}
|
||||||
$world_map.data('cityInfo', obj);
|
});
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
return obj;
|
||||||
var $hideCityNameBtn = $world_map.find('.map_toggle_cityname');
|
}
|
||||||
if(localStorage.getItem('sam.hideMapCityName') == 'yes'){
|
|
||||||
$world_map.addClass('hide_cityname');
|
function setCityClickable(obj) {
|
||||||
$hideCityNameBtn.addClass('active').attr('aria-pressed', 'true');
|
|
||||||
}
|
obj.cityList.forEach(function(city) {
|
||||||
|
var $cityLink = $world_map.find('.city_base_{0} .city_link'.format(city.id));
|
||||||
$hideCityNameBtn.click(function(){
|
|
||||||
//이전 상태 확인
|
if ('clickable' in city && city.clickable > 0) {
|
||||||
var state = !$hideCityNameBtn.hasClass('active');
|
$cityLink.attr('href', hrefTemplate.format(city.id));
|
||||||
if(state){
|
}
|
||||||
$world_map.addClass('hide_cityname');
|
|
||||||
localStorage.setItem('sam.hideMapCityName', 'yes');
|
if (selectCallback) {
|
||||||
}
|
$cityLink.click(function() {
|
||||||
else{
|
return selectCallback(city);
|
||||||
$world_map.removeClass('hide_cityname');
|
});
|
||||||
localStorage.setItem('sam.hideMapCityName', 'no');
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
return obj;
|
||||||
var $toggleSingleTapBtn = $world_map.find('.map_toggle_single_tap');
|
}
|
||||||
if(localStorage.getItem('sam.toggleSingleTap') == 'yes'){
|
|
||||||
window.sam_toggleSingleTap = true;
|
function saveCityInfo(obj) {
|
||||||
$toggleSingleTapBtn.addClass('active').attr('aria-pressed', 'true');
|
$world_map.data('cityInfo', obj);
|
||||||
}
|
return obj;
|
||||||
else{
|
}
|
||||||
window.sam_toggleSingleTap = false;
|
|
||||||
}
|
var $hideCityNameBtn = $world_map.find('.map_toggle_cityname');
|
||||||
|
if (localStorage.getItem('sam.hideMapCityName') == 'yes') {
|
||||||
var $map_body = $('.world_map .map_body');
|
$world_map.addClass('hide_cityname');
|
||||||
|
$hideCityNameBtn.addClass('active').attr('aria-pressed', 'true');
|
||||||
$toggleSingleTapBtn.click(function(){
|
}
|
||||||
//이전 상태 확인
|
|
||||||
var state = !$toggleSingleTapBtn.hasClass('active');
|
$hideCityNameBtn.click(function() {
|
||||||
if(state){
|
//이전 상태 확인
|
||||||
$map_body.removeData('touchMode');
|
var state = !$hideCityNameBtn.hasClass('active');
|
||||||
localStorage.setItem('sam.toggleSingleTap', 'yes');
|
if (state) {
|
||||||
window.sam_toggleSingleTap = true;
|
$world_map.addClass('hide_cityname');
|
||||||
}
|
localStorage.setItem('sam.hideMapCityName', 'yes');
|
||||||
else{
|
} else {
|
||||||
localStorage.setItem('sam.toggleSingleTap', 'no');
|
$world_map.removeClass('hide_cityname');
|
||||||
window.sam_toggleSingleTap = false;
|
localStorage.setItem('sam.hideMapCityName', 'no');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(isDetailMap){
|
var $toggleSingleTapBtn = $world_map.find('.map_toggle_single_tap');
|
||||||
$world_map.addClass('map_detail');
|
if (localStorage.getItem('sam.toggleSingleTap') == 'yes') {
|
||||||
}
|
window.sam_toggleSingleTap = true;
|
||||||
else{
|
$toggleSingleTapBtn.addClass('active').attr('aria-pressed', 'true');
|
||||||
$world_map.removeClass('map_datail');
|
} else {
|
||||||
}
|
window.sam_toggleSingleTap = false;
|
||||||
|
}
|
||||||
//deferred mode of jQuery. != promise-then.
|
|
||||||
var deferred = $.ajax({
|
var $map_body = $(drawTarget + ' .map_body');
|
||||||
url: option.targetJson,
|
|
||||||
type: 'post',
|
$toggleSingleTapBtn.click(function() {
|
||||||
dataType:'json',
|
//이전 상태 확인
|
||||||
data: {
|
var state = !$toggleSingleTapBtn.hasClass('active');
|
||||||
data: JSON.stringify({
|
if (state) {
|
||||||
neutralView:option.neutralView,
|
$map_body.removeData('touchMode');
|
||||||
year:option.year,
|
localStorage.setItem('sam.toggleSingleTap', 'yes');
|
||||||
month:option.month,
|
window.sam_toggleSingleTap = true;
|
||||||
showMe:option.showMe,
|
} else {
|
||||||
aux:option.aux
|
localStorage.setItem('sam.toggleSingleTap', 'no');
|
||||||
})
|
window.sam_toggleSingleTap = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
deferred
|
if (isDetailMap) {
|
||||||
.then(checkReturnObject)
|
$world_map.addClass('map_detail');
|
||||||
.then(setMapBackground)
|
} else {
|
||||||
.then(convertCityObjs)
|
$world_map.removeClass('map_datail');
|
||||||
.then(isDetailMap?drawDetailWorldMap:drawBasicWorldMap)
|
}
|
||||||
.then(setMouseWork)
|
|
||||||
.then(setCityClickable)
|
//deferred mode of jQuery. != promise-then.
|
||||||
.then(saveCityInfo);
|
var deferred = $.ajax({
|
||||||
|
url: option.targetJson,
|
||||||
if($world_map.hasClass('draw_required')){
|
type: option.reqType,
|
||||||
if(useCachedMap){
|
dataType: 'json',
|
||||||
//일단 불러옴
|
ifModified: true,
|
||||||
do{
|
data: {
|
||||||
var storedMap = localStorage.getItem(storedOldMapKey);
|
data: JSON.stringify({
|
||||||
if(!storedMap){
|
neutralView: option.neutralView,
|
||||||
break;
|
year: option.year,
|
||||||
}
|
month: option.month,
|
||||||
storedMap = JSON.parse(storedMap);
|
showMe: option.showMe,
|
||||||
var storedServerID = storedMap[0];
|
aux: option.aux
|
||||||
if(storedServerID != serverID){
|
})
|
||||||
break;
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
storedMap = storedMap[1];
|
var rawObject = null;
|
||||||
storedMap = setMapBackground(storedMap);
|
|
||||||
storedMap = convertCityObjs(storedMap);
|
deferred
|
||||||
if(isDetailMap){
|
.then(function(data) {
|
||||||
storedMap = drawDetailWorldMap(storedMap);
|
rawObject = data;
|
||||||
}
|
return data;
|
||||||
else{
|
})
|
||||||
storedMap = drawBasicWorldMap(storedMap);
|
.then(checkReturnObject)
|
||||||
}
|
.then(setMapBackground)
|
||||||
storedMap = setMouseWork(storedMap);
|
.then(convertCityObjs)
|
||||||
storedMap = setCityClickable(storedMap);
|
.then(isDetailMap ? drawDetailWorldMap : drawBasicWorldMap)
|
||||||
storedMap = saveCityInfo(storedMap);
|
.then(setMouseWork)
|
||||||
}while(false);
|
.then(setCityClickable)
|
||||||
}
|
.then(saveCityInfo)
|
||||||
else if(option.year && option.month){
|
.then(function(data) {
|
||||||
var startYear = localStorage.getItem(storedStartYear);
|
if (option.callback) {
|
||||||
if(startYear){
|
option.callback(data, rawObject);
|
||||||
startYear = JSON.parse(startYear);
|
}
|
||||||
}
|
|
||||||
else{
|
});
|
||||||
startYear = option.year;
|
|
||||||
}
|
if ($world_map.hasClass('draw_required')) {
|
||||||
var tmp = {
|
if (useCachedMap) {
|
||||||
year : option.year,
|
//일단 불러옴
|
||||||
month : option.month,
|
do {
|
||||||
startYear : startYear
|
var storedMap = localStorage.getItem(storedOldMapKey);
|
||||||
};
|
if (!storedMap) {
|
||||||
setMapBackground(tmp);
|
break;
|
||||||
}
|
}
|
||||||
|
storedMap = JSON.parse(storedMap);
|
||||||
|
var storedServerID = storedMap[0];
|
||||||
}
|
if (storedServerID != serverID) {
|
||||||
}
|
break;
|
||||||
$(function(){
|
}
|
||||||
if(is_touch_device()){
|
|
||||||
$('.map_body .map_toggle_single_tap').show();
|
storedMap = storedMap[1];
|
||||||
}
|
storedMap = setMapBackground(storedMap);
|
||||||
|
storedMap = convertCityObjs(storedMap);
|
||||||
|
if (isDetailMap) {
|
||||||
|
storedMap = drawDetailWorldMap(storedMap);
|
||||||
|
} else {
|
||||||
|
storedMap = drawBasicWorldMap(storedMap);
|
||||||
|
}
|
||||||
|
storedMap = setMouseWork(storedMap);
|
||||||
|
storedMap = setCityClickable(storedMap);
|
||||||
|
storedMap = saveCityInfo(storedMap);
|
||||||
|
} while (false);
|
||||||
|
} else if (option.year && option.month) {
|
||||||
|
var startYear = localStorage.getItem(storedStartYear);
|
||||||
|
if (startYear) {
|
||||||
|
startYear = JSON.parse(startYear);
|
||||||
|
} else {
|
||||||
|
startYear = option.year;
|
||||||
|
}
|
||||||
|
var tmp = {
|
||||||
|
year: option.year,
|
||||||
|
month: option.month,
|
||||||
|
startYear: startYear
|
||||||
|
};
|
||||||
|
setMapBackground(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(function() {
|
||||||
|
if (is_touch_device()) {
|
||||||
|
$('.map_body .map_toggle_single_tap').show();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
+166
-165
@@ -1,166 +1,167 @@
|
|||||||
jQuery(function($){
|
jQuery(function($) {
|
||||||
|
|
||||||
|
|
||||||
var initCustomCSSForm = function(){
|
var initCustomCSSForm = function() {
|
||||||
var lastTimeOut = null;
|
var lastTimeOut = null;
|
||||||
var $obj = $('#custom_css');
|
var $obj = $('#custom_css');
|
||||||
var key = 'sam_customCSS';
|
var key = 'sam_customCSS';
|
||||||
|
|
||||||
var text = localStorage.getItem(key);
|
var text = localStorage.getItem(key);
|
||||||
if(text){
|
if (text) {
|
||||||
$obj.val(text);
|
$obj.val(text);
|
||||||
console.log(text);
|
console.log(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($obj.on('change keyup paste', function(){
|
if ($obj.on('change keyup paste', function() {
|
||||||
var newText = $obj.val();
|
var newText = $obj.val();
|
||||||
if(text == newText){
|
if (text == newText) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(lastTimeOut){
|
if (lastTimeOut) {
|
||||||
clearTimeout(lastTimeOut);
|
clearTimeout(lastTimeOut);
|
||||||
}
|
}
|
||||||
$obj.css('background-color', '#222222');
|
$obj.css('background-color', '#222222');
|
||||||
lastTimeOut = setTimeout(function(){
|
lastTimeOut = setTimeout(function() {
|
||||||
text = $obj.val();
|
text = $obj.val();
|
||||||
localStorage.setItem(key, text);
|
localStorage.setItem(key, text);
|
||||||
$obj.css('background-color', 'black');
|
$obj.css('background-color', 'black');
|
||||||
}, 500);
|
}, 500);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.load_old_log').click(function(){
|
$('.load_old_log').click(function() {
|
||||||
var $thisBtn = $(this);
|
var $thisBtn = $(this);
|
||||||
var logType = $thisBtn.data('log_type');
|
var logType = $thisBtn.data('log_type');
|
||||||
var $last = $('.log_{0}:last'.format(logType));
|
var $last = $('.log_{0}:last'.format(logType));
|
||||||
var reqTo = null;
|
var reqTo = null;
|
||||||
if($last.length){
|
if ($last.length) {
|
||||||
reqTo = $last.data('seq');
|
reqTo = $last.data('seq');
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_general_log_old.php',
|
url: 'j_general_log_old.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
to:reqTo,
|
to: reqTo,
|
||||||
type:logType
|
type: logType
|
||||||
}
|
}
|
||||||
}).then(function(data){
|
}).then(function(data) {
|
||||||
if(!data){
|
if (!data) {
|
||||||
return quickReject('로그를 받아오지 못했습니다.');
|
return quickReject('로그를 받아오지 못했습니다.');
|
||||||
}
|
}
|
||||||
if(!data.result){
|
if (!data.result) {
|
||||||
return quickReject('로그를 받아오지 못했습니다. : '+data.reason);
|
return quickReject('로그를 받아오지 못했습니다. : ' + data.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
var keys = Object.keys(data.log);
|
var keys = Object.keys(data.log);
|
||||||
if(keys.length > 1 && keys[0] < keys[1]){
|
if (keys.length > 1 && keys[0] < keys[1]) {
|
||||||
keys.reverse();
|
keys.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(keys == 0){
|
if (keys == 0) {
|
||||||
$thisBtn.hide();
|
$thisBtn.hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = [];
|
var html = [];
|
||||||
$.each(keys, function(_, key){
|
$.each(keys, function(_, key) {
|
||||||
if($('#log_{0}_{1}'.format(logType, key)).length){
|
if ($('#log_{0}_{1}'.format(logType, key)).length) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var item = data.log[key];
|
var item = data.log[key];
|
||||||
html.push("<div class='log_{0}' id='log_{0}_{1}' data-seq='{1}'>{2}</div>".format(logType, key, item));
|
html.push("<div class='log_{0}' id='log_{0}_{1}' data-seq='{1}'>{2}</div>".format(logType, key, item));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#{0}Plate'.format(logType)).append(html);
|
$('#{0}Plate'.format(logType)).append(html);
|
||||||
}, errUnknown)
|
}, errUnknown)
|
||||||
.fail(function(reason){
|
.fail(function(reason) {
|
||||||
alert(reason);
|
alert(reason);
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
initCustomCSSForm();
|
initCustomCSSForm();
|
||||||
|
|
||||||
|
|
||||||
$('#die_immediately').click(function(){
|
$('#die_immediately').click(function() {
|
||||||
if(!confirm('정말로 삭제하시겠습니까?')){
|
if (!confirm('정말로 삭제하시겠습니까?')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_die_immediately.php',
|
url: 'j_die_immediately.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
}).then(function(data){
|
}).then(function(data) {
|
||||||
if(!data){
|
if (!data) {
|
||||||
return quickReject('실패했습니다.');
|
return quickReject('실패했습니다.');
|
||||||
}
|
}
|
||||||
if(!data.result){
|
if (!data.result) {
|
||||||
return quickReject(data.reason);
|
return quickReject(data.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
location.replace('..');
|
location.replace('..');
|
||||||
|
|
||||||
}, errUnknown)
|
}, errUnknown)
|
||||||
.fail(function(reason){
|
.fail(function(reason) {
|
||||||
alert(reason);
|
alert(reason);
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#vacation').click(function(){
|
$('#vacation').click(function() {
|
||||||
if(!confirm('휴가 기능을 신청할까요?')){
|
if (!confirm('휴가 기능을 신청할까요?')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_vacation.php',
|
url: 'j_vacation.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
}).then(function(data){
|
}).then(function(data) {
|
||||||
if(!data){
|
if (!data) {
|
||||||
return quickReject('실패했습니다.');
|
return quickReject('실패했습니다.');
|
||||||
}
|
}
|
||||||
if(!data.result){
|
if (!data.result) {
|
||||||
return quickReject(data.reason);
|
return quickReject(data.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|
||||||
}, errUnknown)
|
}, errUnknown)
|
||||||
.fail(function(reason){
|
.fail(function(reason) {
|
||||||
alert(reason);
|
alert(reason);
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#set_my_setting').click(function(){
|
$('#set_my_setting').click(function() {
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_set_my_setting.php',
|
url: 'j_set_my_setting.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
tnmt:$('.tnmt:checked').val(),
|
tnmt: $('.tnmt:checked').val(),
|
||||||
defence_train:$('#defence_train').val(),
|
defence_train: $('#defence_train').val(),
|
||||||
use_treatment:$('#use_treatment').val(),
|
use_treatment: $('#use_treatment').val(),
|
||||||
}
|
use_auto_nation_turn: $('#use_auto_nation_turn').val(),
|
||||||
}).then(function(data){
|
}
|
||||||
if(!data){
|
}).then(function(data) {
|
||||||
return quickReject('실패했습니다.');
|
if (!data) {
|
||||||
}
|
return quickReject('실패했습니다.');
|
||||||
if(!data.result){
|
}
|
||||||
return quickReject(data.reason);
|
if (!data.result) {
|
||||||
}
|
return quickReject(data.reason);
|
||||||
|
}
|
||||||
location.reload();
|
|
||||||
|
location.reload();
|
||||||
}, errUnknown)
|
|
||||||
.fail(function(reason){
|
}, errUnknown)
|
||||||
alert(reason);
|
.fail(function(reason) {
|
||||||
location.reload();
|
alert(reason);
|
||||||
});
|
location.reload();
|
||||||
return false;
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
return false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -35,7 +35,7 @@ jQuery(function($) {
|
|||||||
//checkCommandArg 참고
|
//checkCommandArg 참고
|
||||||
var availableArgumentList = {
|
var availableArgumentList = {
|
||||||
'string': [
|
'string': [
|
||||||
'nationName', 'optionText', 'itemType', 'nationType', 'itemCode',
|
'nationName', 'optionText', 'itemType', 'nationType', 'itemCode', 'commandType',
|
||||||
],
|
],
|
||||||
'int': [
|
'int': [
|
||||||
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
||||||
@@ -73,9 +73,11 @@ jQuery(function($) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'integerArray': function($obj) {
|
'integerArray': function($obj) {
|
||||||
return $obj.map(function() {
|
var result = [];
|
||||||
return parseInt($(this).val());
|
$obj.each(function() {
|
||||||
|
result.push(parseInt($(this).val()));
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+352
-359
@@ -1,360 +1,353 @@
|
|||||||
var templateGeneralCard =
|
var templateGeneralCard =
|
||||||
'<div class="general_card">\
|
'<div class="general_card">\
|
||||||
<h4 class="bg1 with_border"><%name%></h4>\
|
<h4 class="bg1 with_border"><%name%></h4>\
|
||||||
<h4><img src="<%iconPath%>" height=64 width=64></h4>\
|
<h4><img src="<%iconPath%>" height=64 width=64></h4>\
|
||||||
<p><%leadership%> / <%strength%> / <%intel%><br>\
|
<p><%leadership%> / <%strength%> / <%intel%><br>\
|
||||||
<%nation%><br>\
|
<%nation%><br>\
|
||||||
<%personalText%><br>\
|
<%personalText%><br>\
|
||||||
<%specialText%> / <%special2Text%></p>\
|
<%specialText%> / <%special2Text%></p>\
|
||||||
<button type="subject" class="with_skin with_border select_btn" data-name="<%name%>" value="<%no%>" name="pick">빙의하기</button>\
|
<button type="subject" class="with_skin with_border select_btn" data-name="<%name%>" value="<%no%>" name="pick">빙의하기</button>\
|
||||||
<label><input <%keepCnt?"":disabled="disabled"%> type="checkbox" value="<%no%>" name="keep[]" class="keep_select">보관(<%keepCnt%>회)</label>\
|
<label><input <%keepCnt?"":disabled="disabled"%> type="checkbox" value="<%no%>" name="keep[]" class="keep_select">보관(<%keepCnt%>회)</label>\
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
var templateSpecial =
|
var templateSpecial =
|
||||||
'<span class="obj_tooltip" data-toggle="tooltip" data-placement="top"><%text%>\
|
'<span class="obj_tooltip" data-toggle="tooltip" data-placement="top"><%text%>\
|
||||||
<span class="tooltiptext">\
|
<span class="tooltiptext">\
|
||||||
<%info%>\
|
<%info%>\
|
||||||
</span>\
|
</span>\
|
||||||
</span>\
|
</span>\
|
||||||
';
|
';
|
||||||
|
|
||||||
var templateGeneralRow =
|
var templateGeneralRow =
|
||||||
'<tr>\
|
'<tr>\
|
||||||
<td><img class="generalIcon" width="64" height="64" src="<%iconPath%>"></td>\
|
<td><img class="generalIcon" width="64" height="64" src="<%iconPath%>"></td>\
|
||||||
<td style="<%userCSS%>"><%name%><%nameAux%></td>\
|
<td style="<%userCSS%>"><%name%><%nameAux%></td>\
|
||||||
<td><%age%>세</td>\
|
<td><%age%>세</td>\
|
||||||
<td><%personalWithTooltip%></td>\
|
<td><%personalWithTooltip%></td>\
|
||||||
<td><%specialDomesticWithTooltip%> / <%speicalWarWithTooltip%></td>\
|
<td><%specialDomesticWithTooltip%> / <%speicalWarWithTooltip%></td>\
|
||||||
<td>Lv <%explevel%></td>\
|
<td>Lv <%explevel%></td>\
|
||||||
<td><%nation%></td>\
|
<td><%nation%></td>\
|
||||||
<td><%experience%></td>\
|
<td><%experience%></td>\
|
||||||
<td><%dedication%></td>\
|
<td><%dedication%></td>\
|
||||||
<td><%officerLevel%></td>\
|
<td><%officerLevel%></td>\
|
||||||
<td><%total%></td>\
|
<td><%total%></td>\
|
||||||
<td><%leadership%></td>\
|
<td><%leadership%></td>\
|
||||||
<td><%strength%></td>\
|
<td><%strength%></td>\
|
||||||
<td><%intel%></td>\
|
<td><%intel%></td>\
|
||||||
<td><%killturn%></td>\
|
<td><%killturn%></td>\
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
function pickGeneral(){
|
function pickGeneral() {
|
||||||
$btn = $(this);
|
$btn = $(this);
|
||||||
|
|
||||||
if (!confirm('빙의할까요? : {0}'.format($btn.data('name')))) {
|
if (!confirm('빙의할까요? : {0}'.format($btn.data('name')))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_select_npc.php',
|
url: 'j_select_npc.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
pick:$btn.val()
|
pick: $btn.val()
|
||||||
}
|
}
|
||||||
}).then(function(result){
|
}).then(function(result) {
|
||||||
if(!result.result){
|
if (!result.result) {
|
||||||
alert(result.reason);
|
alert(result.reason);
|
||||||
location.refresh();
|
location.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
alert('빙의에 성공했습니다.');
|
alert('빙의에 성공했습니다.');
|
||||||
location.href = './';
|
location.href = './';
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateOutdateTimer(){
|
function updateOutdateTimer() {
|
||||||
var $validUntilText = $('#valid_until_text');
|
var $validUntilText = $('#valid_until_text');
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
var validUntil = $validUntilText.data('until');
|
var validUntil = $validUntilText.data('until');
|
||||||
if(validUntil <= 0){
|
if (validUntil <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (validUntil < now) {
|
||||||
else if(validUntil < now){
|
$validUntilText.data('until', 0);
|
||||||
$validUntilText.data('until',0);
|
$('#valid_until').hide();
|
||||||
$('#valid_until').hide();
|
$('#outdate_token').show();
|
||||||
$('#outdate_token').show();
|
return;
|
||||||
return;
|
} else if (validUntil - now <= 30000) {
|
||||||
}
|
$validUntilText.css('color', "rgb(255, {0}, {0})".format(255 * (validUntil - now) / 30000));
|
||||||
else if(validUntil - now <= 30000){
|
}
|
||||||
$validUntilText.css('color', "rgb(255, {0}, {0})".format(255*(validUntil - now)/30000));
|
|
||||||
}
|
setTimeout(updateOutdateTimer, 1000);
|
||||||
|
}
|
||||||
setTimeout(updateOutdateTimer, 1000);
|
|
||||||
}
|
function updatePickMoreTimer() {
|
||||||
|
var $btn = $('#btn_pick_more');
|
||||||
function updatePickMoreTimer(){
|
|
||||||
var $btn = $('#btn_pick_more');
|
var now = Date.now();
|
||||||
|
var remain = ($btn.data('available') - now) / 1000;
|
||||||
var now = Date.now();
|
if (remain <= 0) {
|
||||||
var remain = ($btn.data('available') - now) / 1000;
|
$btn.prop('disabled', false)
|
||||||
if(remain <= 0){
|
$btn.html('다른 장수 보기');
|
||||||
$btn.prop('disabled', false)
|
return;
|
||||||
$btn.html('다른 장수 보기');
|
}
|
||||||
return;
|
|
||||||
}
|
$btn.html('다른 장수 보기({0}초)'.format(Math.ceil(remain)));
|
||||||
|
|
||||||
$btn.html('다른 장수 보기({0}초)'.format(Math.ceil(remain)));
|
setTimeout(updatePickMoreTimer, 250);
|
||||||
|
}
|
||||||
setTimeout(updatePickMoreTimer, 250);
|
|
||||||
}
|
function printGenerals(value) {
|
||||||
|
$('.card_holder').empty();
|
||||||
function printGenerals(value){
|
$('#valid_until').show();
|
||||||
$('.card_holder').empty();
|
$('#valid_until_text').html(value.validUntil).data('until', (new Date(value.validUntil)).getTime()).css('color', 'white');
|
||||||
$('#valid_until').show();
|
$('#outdate_token').hide();
|
||||||
$('#valid_until_text').html(value.validUntil).data('until', (new Date(value.validUntil)).getTime()).css('color','white');
|
var time = Date.now() + value.pickMoreSeconds * 1000;
|
||||||
$('#outdate_token').hide();
|
$('#btn_pick_more').data('available', time).prop('disabled', true);
|
||||||
var time = Date.now() + value.pickMoreSeconds*1000;
|
|
||||||
$('#btn_pick_more').data('available', time).prop('disabled',true);
|
var pick = $.map(value.pick, function(value, key) {
|
||||||
|
return value;
|
||||||
var pick = $.map(value.pick, function(value, key) {
|
});
|
||||||
return value;
|
|
||||||
});
|
pick.sort(function(lhs, rhs) {
|
||||||
|
var lsum = lhs.leadership + lhs.strength + lhs.intel;
|
||||||
pick.sort(function(lhs, rhs){
|
var rsum = rhs.leadership + rhs.strength + rhs.intel;
|
||||||
var lsum = lhs.leadership+lhs.strength+lhs.intel;
|
return lsum - rsum;
|
||||||
var rsum = rhs.leadership+rhs.strength+rhs.intel;
|
});
|
||||||
return lsum - rsum;
|
|
||||||
});
|
$.each(pick, function(idx, cardData) {
|
||||||
|
cardData.iconPath = getIconPath(cardData.imgsvr, cardData.picture);
|
||||||
$.each(pick, function(idx, cardData){
|
if (cardData.special in specialInfo) {
|
||||||
cardData.iconPath = getIconPath(cardData.imgsvr, cardData.picture);
|
cardData.specialText = TemplateEngine(templateSpecial, {
|
||||||
if(cardData.special in specialInfo){
|
text: cardData.special,
|
||||||
cardData.specialText = TemplateEngine(templateSpecial, {
|
info: specialInfo[cardData.special]
|
||||||
text:cardData.special,
|
});
|
||||||
info:specialInfo[cardData.special]
|
} else {
|
||||||
});
|
cardData.specialText = cardData.special;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
cardData.specialText = cardData.special;
|
if (cardData.special2 in specialInfo) {
|
||||||
}
|
cardData.special2Text = TemplateEngine(templateSpecial, {
|
||||||
|
text: cardData.special2,
|
||||||
if(cardData.special2 in specialInfo){
|
info: specialInfo[cardData.special2]
|
||||||
cardData.special2Text = TemplateEngine(templateSpecial, {
|
});
|
||||||
text:cardData.special2,
|
} else {
|
||||||
info:specialInfo[cardData.special2]
|
cardData.special2Text = cardData.special2;
|
||||||
});
|
}
|
||||||
}
|
|
||||||
else{
|
if (cardData.personal in characterInfo) {
|
||||||
cardData.special2Text = cardData.special2;
|
cardData.personalText = TemplateEngine(templateSpecial, {
|
||||||
}
|
text: cardData.personal,
|
||||||
|
info: characterInfo[cardData.personal]
|
||||||
if(cardData.personal in characterInfo){
|
});
|
||||||
cardData.personalText = TemplateEngine(templateSpecial, {
|
} else {
|
||||||
text:cardData.personal,
|
cardData.personalText = cardData.personal;
|
||||||
info:characterInfo[cardData.personal]
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
else{
|
var $card = $(TemplateEngine(templateGeneralCard, cardData));
|
||||||
cardData.personalText = cardData.personal;
|
|
||||||
}
|
$('.card_holder').append($card);
|
||||||
|
$card.find('.select_btn').click(pickGeneral);
|
||||||
|
$card.find('.obj_tooltip').tooltip({
|
||||||
var $card = $(TemplateEngine(templateGeneralCard, cardData));
|
title: function() {
|
||||||
|
return $.trim($(this).find('.tooltiptext').html());
|
||||||
$('.card_holder').append($card);
|
},
|
||||||
$card.find('.select_btn').click(pickGeneral);
|
html: true
|
||||||
$card.find('.obj_tooltip').tooltip({
|
});
|
||||||
title:function(){
|
});
|
||||||
return $.trim($(this).find('.tooltiptext').html());
|
|
||||||
},
|
updatePickMoreTimer();
|
||||||
html:true
|
updateOutdateTimer();
|
||||||
});
|
}
|
||||||
});
|
|
||||||
|
function printGeneralList(value) {
|
||||||
updatePickMoreTimer();
|
var tokenList = value.token;
|
||||||
updateOutdateTimer();
|
var generalList = $.map(value.list, function(general) {
|
||||||
}
|
general = {
|
||||||
|
no: general[0],
|
||||||
function printGeneralList(value){
|
picture: general[1],
|
||||||
var tokenList = value.token;
|
imgsvr: general[2],
|
||||||
var generalList = $.map(value.list, function(general){
|
npc: general[3],
|
||||||
general = {
|
age: general[4],
|
||||||
no:general[0],
|
nation: general[5],
|
||||||
picture:general[1],
|
special: general[6],
|
||||||
imgsvr:general[2],
|
special2: general[7],
|
||||||
npc:general[3],
|
personal: general[8],
|
||||||
age:general[4],
|
name: general[9],
|
||||||
nation:general[5],
|
ownerName: general[10],
|
||||||
special:general[6],
|
injury: general[11],
|
||||||
special2:general[7],
|
leadership: general[12],
|
||||||
personal:general[8],
|
lbonus: general[13],
|
||||||
name:general[9],
|
strength: general[14],
|
||||||
ownerName:general[10],
|
intel: general[15],
|
||||||
injury:general[11],
|
explevel: general[16],
|
||||||
leadership:general[12],
|
experience: general[17],
|
||||||
lbonus:general[13],
|
dedication: general[18],
|
||||||
strength:general[14],
|
officerLevel: general[19],
|
||||||
intel:general[15],
|
killturn: general[20],
|
||||||
explevel:general[16],
|
connect: general[21],
|
||||||
experience:general[17],
|
reserved: 0
|
||||||
dedication:general[18],
|
};
|
||||||
officerLevel:general[19],
|
if (general.npc < 2) {
|
||||||
killturn:general[20],
|
general.reserved = 2;
|
||||||
connect:general[21],
|
}
|
||||||
reserved:0
|
if (general.no in tokenList) {
|
||||||
};
|
general.reserved = 1;
|
||||||
if(general.npc < 2){
|
}
|
||||||
general.reserved = 2;
|
|
||||||
}
|
general.userCSS = "";
|
||||||
if(general.no in tokenList){
|
general.nameAux = "";
|
||||||
general.reserved = 1;
|
|
||||||
}
|
if (general.reserved == 1) {
|
||||||
|
general.userCSS = 'color:violet';
|
||||||
general.userCSS = "";
|
} else if (general.npc >= 2) {
|
||||||
general.nameAux = "";
|
general.userCSS = 'color:cyan';
|
||||||
|
} else if (general.npc == 1) {
|
||||||
if(general.reserved == 1){
|
general.userCSS = 'color:skyblue';
|
||||||
general.userCSS = 'color:violet';
|
}
|
||||||
}
|
|
||||||
else if(general.npc >= 2){
|
if (general.ownerName) {
|
||||||
general.userCSS = 'color:cyan';
|
general.nameAux += '<br><small>({0})</small>'.format(general.ownerName);
|
||||||
}
|
}
|
||||||
else if(general.npc == 1){
|
|
||||||
general.userCSS = 'color:skyblue';
|
if (general.reserved == 1) {
|
||||||
}
|
general.nameAux += '<br><small>({0}회)</small>'.format(tokenList[general.no]);
|
||||||
|
}
|
||||||
if(general.ownerName){
|
|
||||||
general.nameAux += '<br><small>({0})</small>'.format(general.ownerName);
|
|
||||||
}
|
general.total = general.leadership + general.strength + general.intel;
|
||||||
|
general.iconPath = getIconPath(general.imgsvr, general.picture);
|
||||||
if(general.reserved == 1){
|
|
||||||
general.nameAux += '<br><small>({0}회)</small>'.format(tokenList[general.no]);
|
general.specialDomesticWithTooltip = TemplateEngine(templateSpecial, {
|
||||||
}
|
text: general.special,
|
||||||
|
info: specialInfo[general.special]
|
||||||
|
});
|
||||||
general.total = general.leadership + general.strength + general.intel;
|
|
||||||
general.iconPath = getIconPath(general.imgsvr, general.picture);
|
general.speicalWarWithTooltip = TemplateEngine(templateSpecial, {
|
||||||
|
text: general.special2,
|
||||||
general.specialDomesticWithTooltip = TemplateEngine(templateSpecial, {
|
info: specialInfo[general.special2]
|
||||||
text:general.special,
|
});
|
||||||
info:specialInfo[general.special]
|
|
||||||
});
|
general.personalWithTooltip = TemplateEngine(templateSpecial, {
|
||||||
|
text: general.personal,
|
||||||
general.speicalWarWithTooltip = TemplateEngine(templateSpecial, {
|
info: characterInfo[general.personal]
|
||||||
text:general.special2,
|
});
|
||||||
info:specialInfo[general.special2]
|
|
||||||
});
|
return general;
|
||||||
|
});
|
||||||
general.personalWithTooltip = TemplateEngine(templateSpecial, {
|
|
||||||
text:general.personal,
|
generalList.sort(function(lhs, rhs) {
|
||||||
info:characterInfo[general.personal]
|
if (lhs.reserved > rhs.reserved) {
|
||||||
});
|
return -1;
|
||||||
|
}
|
||||||
return general;
|
if (lhs.reserved < rhs.reserved) {
|
||||||
});
|
return 1;
|
||||||
|
}
|
||||||
generalList.sort(function(lhs, rhs){
|
if (lhs.total != rhs.total) {
|
||||||
if(lhs.reserved > rhs.reserved){
|
return rhs.total - lhs.total;
|
||||||
return -1;
|
}
|
||||||
}
|
if (lhs.leadership != rhs.leadership) {
|
||||||
if(lhs.reserved < rhs.reserved){
|
return rhs.leadership - lhs.total;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
if(lhs.total != rhs.total){
|
if (lhs.name < rhs.name) {
|
||||||
return rhs.total - lhs.total;
|
return -1;
|
||||||
}
|
}
|
||||||
if(lhs.leadership != rhs.leadership){
|
if (lhs.name > rhs.name) {
|
||||||
return rhs.leadership - lhs.total;
|
return 1;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
if(lhs.name < rhs.name){
|
});
|
||||||
return -1;
|
|
||||||
}
|
window.generalList = generalList;
|
||||||
if(lhs.name > rhs.name){
|
_printGeneralList(true);
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
return 0;
|
function _printGeneralList(clear) {
|
||||||
});
|
var $generalTable = $('#general_list');
|
||||||
|
if (clear) {
|
||||||
window.generalList = generalList;
|
$generalTable.empty();
|
||||||
_printGeneralList(true);
|
$generalTable.data('lastIdx', 0);
|
||||||
}
|
$('#row_print_more').show();
|
||||||
|
}
|
||||||
function _printGeneralList(clear){
|
|
||||||
var $generalTable = $('#general_list');
|
generalList = window.generalList;
|
||||||
if(clear){
|
|
||||||
$generalTable.empty();
|
var idxFrom = $generalTable.data('lastIdx');
|
||||||
$generalTable.data('lastIdx', 0);
|
var idxTo = Math.min(idxFrom + 50, generalList.length);
|
||||||
$('#row_print_more').show();
|
$generalTable.data('lastIdx', idxTo);
|
||||||
}
|
|
||||||
|
for (var idx = idxFrom; idx < idxFrom + 50; idx++) {
|
||||||
generalList = window.generalList;
|
var general = generalList[idx];
|
||||||
|
$generalTable.append(TemplateEngine(templateGeneralRow, general));
|
||||||
var idxFrom = $generalTable.data('lastIdx');
|
}
|
||||||
var idxTo = Math.min(idxFrom + 50, generalList.length);
|
|
||||||
$generalTable.data('lastIdx', idxTo);
|
if (idxTo == generalList.length) {
|
||||||
|
$('#row_print_more').hide();
|
||||||
for(var idx = idxFrom; idx < idxFrom + 50; idx++){
|
}
|
||||||
var general = generalList[idx];
|
|
||||||
$generalTable.append(TemplateEngine(templateGeneralRow, general));
|
$generalTable.find('.obj_tooltip').tooltip({
|
||||||
}
|
title: function() {
|
||||||
|
return $.trim($(this).find('.tooltiptext').html());
|
||||||
if(idxTo == generalList.length){
|
},
|
||||||
$('#row_print_more').hide();
|
html: true
|
||||||
}
|
});
|
||||||
|
$('#tb_general_list').show();
|
||||||
$generalTable.find('.obj_tooltip').tooltip({
|
}
|
||||||
title:function(){
|
|
||||||
return $.trim($(this).find('.tooltiptext').html());
|
$(function($) {
|
||||||
},
|
window.generalList = [];
|
||||||
html:true
|
|
||||||
});
|
$.post('j_get_select_npc_token.php').then(function(value) {
|
||||||
$('#tb_general_list').show();
|
if (!value.result) {
|
||||||
}
|
alert(value.reason);
|
||||||
|
return;
|
||||||
$(function($){
|
}
|
||||||
window.generalList = [];
|
|
||||||
|
console.log(value);
|
||||||
$.post('j_get_select_npc_token.php').then(function(value){
|
printGenerals(value);
|
||||||
if(!value.result){
|
});
|
||||||
alert(value.reason);
|
|
||||||
return;
|
$('#btn_pick_more').click(function() {
|
||||||
}
|
var generals = $.map($('.keep_select:checked'), function(value) {
|
||||||
|
return $(value).val();
|
||||||
console.log(value);
|
});
|
||||||
printGenerals(value);
|
console.log(generals);
|
||||||
});
|
$.post({
|
||||||
|
url: 'j_get_select_npc_token.php',
|
||||||
$('#btn_pick_more').click(function(){
|
dataType: 'json',
|
||||||
var generals = $.map($('.keep_select:checked'), function(value){
|
data: {
|
||||||
return $(value).val();
|
refresh: true,
|
||||||
});
|
keep: generals
|
||||||
console.log(generals);
|
}
|
||||||
$.post({
|
}).then(function(result) {
|
||||||
url:'j_get_select_npc_token.php',
|
if (!result.result) {
|
||||||
dataType:'json',
|
alert(result.reason);
|
||||||
data:{
|
location.refresh();
|
||||||
refresh:true,
|
}
|
||||||
keep:generals
|
console.log(result);
|
||||||
}
|
printGenerals(result);
|
||||||
}).then(function(result){
|
});
|
||||||
if(!result.result){
|
});
|
||||||
alert(result.reason);
|
|
||||||
location.refresh();
|
$('#btn_load_general_list').click(function() {
|
||||||
}
|
$.post({
|
||||||
console.log(result);
|
url: 'j_get_general_list.php',
|
||||||
printGenerals(result);
|
dataType: 'json',
|
||||||
});
|
data: {
|
||||||
});
|
with_token: true
|
||||||
|
}
|
||||||
$('#btn_load_general_list').click(function(){
|
}).then(function(result) {
|
||||||
$.post({
|
if (!result.result) {
|
||||||
url:'j_get_general_list.php',
|
alert(result.reason);
|
||||||
dataType:'json',
|
return false;
|
||||||
data:{
|
}
|
||||||
with_token:true
|
printGeneralList(result);
|
||||||
}
|
});
|
||||||
}).then(function(result){
|
});
|
||||||
if(!result.result){
|
|
||||||
alert(result.reason);
|
$('#btn_print_more').click(function() {
|
||||||
return false;
|
_printGeneralList();
|
||||||
}
|
})
|
||||||
printGeneralList(result);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#btn_print_more').click(function(){
|
|
||||||
_printGeneralList();
|
|
||||||
})
|
|
||||||
|
|
||||||
});
|
});
|
||||||
+74
-57
@@ -1,57 +1,74 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
/** @var \Composer\Autoload\ClassLoader $loader */
|
/** @var \Composer\Autoload\ClassLoader $loader */
|
||||||
$loader = require __DIR__.'/../vendor/autoload.php';
|
$loader = require __DIR__.'/../vendor/autoload.php';
|
||||||
$loader->addPsr4('sammo\\', __DIR__.'/sammo', true);
|
$loader->addPsr4('sammo\\', __DIR__.'/sammo', true);
|
||||||
|
|
||||||
$loader->addClassMap((function () {
|
$loader->addClassMap((function () {
|
||||||
$d_settingMap = [];
|
$d_settingMap = [];
|
||||||
foreach (glob(__DIR__.'/d_setting/*.orig.php') as $filepath) {
|
foreach (glob(__DIR__.'/d_setting/*.orig.php') as $filepath) {
|
||||||
$filepath = str_replace('.orig.php', '.php', $filepath);
|
$filepath = str_replace('.orig.php', '.php', $filepath);
|
||||||
$filename = basename($filepath);
|
$filename = basename($filepath);
|
||||||
$classname = explode('.', $filename)[0];
|
$classname = explode('.', $filename)[0];
|
||||||
$d_settingMap['sammo\\'.$classname] = $filepath;
|
$d_settingMap['sammo\\'.$classname] = $filepath;
|
||||||
};
|
};
|
||||||
return $d_settingMap;
|
return $d_settingMap;
|
||||||
})());
|
})());
|
||||||
|
|
||||||
|
|
||||||
//디버그용 매크로
|
//디버그용 매크로
|
||||||
ini_set("session.cache_expire", 10080); // minutes
|
ini_set("session.cache_expire", 10080); // minutes
|
||||||
|
|
||||||
// 각종 변수
|
// 각종 변수
|
||||||
define('STEP_LOG', true);
|
define('STEP_LOG', true);
|
||||||
define('PROCESS_LOG', true);
|
define('PROCESS_LOG', true);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
// 에러 메세지 출력
|
// 에러 메세지 출력
|
||||||
function Error($message='', $url="")
|
function Error($message='', $url="")
|
||||||
{
|
{
|
||||||
if (!$url) {
|
if (!$url) {
|
||||||
$url = $_SERVER['REQUEST_URI'];
|
$url = $_SERVER['REQUEST_URI'];
|
||||||
}
|
}
|
||||||
$e = new \Exception();
|
$e = new \Exception();
|
||||||
logError("aux_err", $message, '', getExceptionTraceAsString($e));
|
logError("aux_err", $message, '', getExceptionTraceAsString($e));
|
||||||
|
|
||||||
$templates = new \League\Plates\Engine(__DIR__.'/templates');
|
$templates = new \League\Plates\Engine(__DIR__.'/templates');
|
||||||
|
|
||||||
ob_get_flush();
|
ob_get_flush();
|
||||||
WebUtil::setHeaderNoCache();
|
WebUtil::setHeaderNoCache();
|
||||||
|
|
||||||
die($templates->render('error', [
|
die($templates->render('error', [
|
||||||
'message' => $message
|
'message' => $message
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function MessageBox($str)
|
function MessageBox($str)
|
||||||
{
|
{
|
||||||
echo "<script>alert('$str');</script>";
|
echo "<script>alert('$str');</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function LogText($prefix, $variable)
|
function LogText($prefix, $variable)
|
||||||
{
|
{
|
||||||
$text = sprintf('%s : %s'."\r\n", $prefix, TVarDumper::dump($variable));
|
$text = sprintf('%s : %s'."\r\n", $prefix, TVarDumper::dump($variable));
|
||||||
file_put_contents(ROOT.'/d_log/'.UniqueConst::$serverName.'_dbg_logs.txt', $text, FILE_APPEND);
|
file_put_contents(ROOT.'/d_log/'.UniqueConst::$serverName.'_dbg_logs.txt', $text, FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepareDir(string $dirPath, bool $forceCreate=true):bool{
|
||||||
|
if(file_exists($dirPath)){
|
||||||
|
if(is_dir($dirPath)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(!$forceCreate){
|
||||||
|
throw new \RuntimeException('이미 파일이 있습니다');
|
||||||
|
}
|
||||||
|
if(!unlink($dirPath)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mkdir($dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mkdir($dirPath, 0777, true);
|
||||||
|
}
|
||||||
@@ -1,22 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionItem;
|
namespace sammo\ActionItem;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
|
||||||
class che_계략_삼략 extends \sammo\BaseItem{
|
class che_계략_삼략 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 22;
|
protected $id = 22;
|
||||||
protected $rawName = '삼략';
|
protected $rawName = '삼략';
|
||||||
protected $name = '삼략(계략)';
|
protected $name = '삼략(계략)';
|
||||||
protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p';
|
protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p<br>[전투] 계략 시도 확률 +10%p, 계략 성공 확률 +10%p';
|
||||||
protected $cost = 200;
|
protected $cost = 200;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if($turnType == '계략'){
|
if($turnType == '계략'){
|
||||||
if($varType == 'success') return $value + 0.2;
|
if($varType == 'success') return $value + 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if($statName === 'warMagicTrialProb'){
|
||||||
|
return $value + 0.1;
|
||||||
|
}
|
||||||
|
if($statName === 'warMagicSuccessProb'){
|
||||||
|
return $value + 0.1;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionItem;
|
namespace sammo\ActionItem;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
|
||||||
class che_계략_육도 extends \sammo\BaseItem{
|
class che_계략_육도 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 21;
|
protected $id = 21;
|
||||||
protected $rawName = '육도';
|
protected $rawName = '육도';
|
||||||
protected $name = '육도(계략)';
|
protected $name = '육도(계략)';
|
||||||
protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p';
|
protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p<br>[전투] 계략 시도 확률 +10%p, 계략 성공 확률 +10%p';
|
||||||
protected $cost = 200;
|
protected $cost = 200;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if($turnType == '계략'){
|
if($turnType == '계략'){
|
||||||
if($varType == 'success') return $value + 0.2;
|
if($varType == 'success') return $value + 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if($statName === 'warMagicTrialProb'){
|
||||||
|
return $value + 0.1;
|
||||||
|
}
|
||||||
|
if($statName === 'warMagicSuccessProb'){
|
||||||
|
return $value + 0.1;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,31 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionItem;
|
namespace sammo\ActionItem;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
|
||||||
class che_계략_이추 extends \sammo\BaseItem{
|
class che_계략_이추 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 5;
|
protected $id = 5;
|
||||||
protected $rawName = '이추';
|
protected $rawName = '이추';
|
||||||
protected $name = '이추(계략)';
|
protected $name = '이추(계략)';
|
||||||
protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +10%p';
|
protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p';
|
||||||
protected $cost = 1000;
|
protected $cost = 1000;
|
||||||
protected $consumable = true;
|
protected $consumable = true;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $reqSecu = 1000;
|
protected $reqSecu = 1000;
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if($turnType == '계략'){
|
if($turnType == '계략'){
|
||||||
if($varType == 'success') return $value + 0.1;
|
if($varType == 'success') return $value + 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isConsumableNow(string $actionType, string $command):bool{
|
function isConsumableNow(string $actionType, string $command):bool{
|
||||||
if($actionType == 'GeneralCommand' && $command == '계략'){
|
if($actionType == 'GeneralCommand' && $command == '계략'){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,31 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionItem;
|
namespace sammo\ActionItem;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
|
||||||
class che_계략_향낭 extends \sammo\BaseItem{
|
class che_계략_향낭 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 5;
|
protected $id = 5;
|
||||||
protected $rawName = '항냥';
|
protected $rawName = '항냥';
|
||||||
protected $name = '항냥(계략)';
|
protected $name = '항냥(계략)';
|
||||||
protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p';
|
protected $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +50%p';
|
||||||
protected $cost = 3000;
|
protected $cost = 3000;
|
||||||
protected $consumable = true;
|
protected $consumable = true;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $reqSecu = 2000;
|
protected $reqSecu = 2000;
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if($turnType == '계략'){
|
if($turnType == '계략'){
|
||||||
if($varType == 'success') return $value + 0.2;
|
if($varType == 'success') return $value + 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isConsumableNow(string $actionType, string $command):bool{
|
function isConsumableNow(string $actionType, string $command):bool{
|
||||||
if($actionType == 'GeneralCommand' && $command == '계략'){
|
if($actionType == 'GeneralCommand' && $command == '계략'){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\ActionItem;
|
||||||
|
use \sammo\iAction;
|
||||||
|
use \sammo\General;
|
||||||
|
use \sammo\SpecialityHelper;
|
||||||
|
use \sammo\WarUnit;
|
||||||
|
use sammo\WarUnitTriggerCaller;
|
||||||
|
use \sammo\BaseWarUnitTrigger;
|
||||||
|
use \sammo\WarUnitTrigger\WarActivateSkills;
|
||||||
|
use \sammo\WarUnitTrigger\che_반계시도;
|
||||||
|
use \sammo\WarUnitTrigger\che_반계발동;
|
||||||
|
|
||||||
|
class che_반계_백우선 extends \sammo\BaseItem{
|
||||||
|
|
||||||
|
protected $id = 45;
|
||||||
|
protected $rawName = '백우선';
|
||||||
|
protected $name = '백우선(반계)';
|
||||||
|
protected $info = '[전투] 상대의 계략 성공 확률 -10%p, 상대의 계략을 40% 확률로 되돌림';
|
||||||
|
protected $cost = 200;
|
||||||
|
protected $consumable = false;
|
||||||
|
|
||||||
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
|
return new WarUnitTriggerCaller(
|
||||||
|
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '계략약화'),
|
||||||
|
new che_반계시도($unit),
|
||||||
|
new che_반계발동($unit)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\ActionItem;
|
||||||
|
use \sammo\iAction;
|
||||||
|
use \sammo\General;
|
||||||
|
use \sammo\SpecialityHelper;
|
||||||
|
use \sammo\WarUnit;
|
||||||
|
use sammo\WarUnitTriggerCaller;
|
||||||
|
use \sammo\BaseWarUnitTrigger;
|
||||||
|
use \sammo\WarUnitTrigger\WarActivateSkills;
|
||||||
|
use \sammo\WarUnitTrigger\che_반계시도;
|
||||||
|
use \sammo\WarUnitTrigger\che_반계발동;
|
||||||
|
|
||||||
|
class che_반계_파초선 extends \sammo\BaseItem{
|
||||||
|
|
||||||
|
protected $id = 45;
|
||||||
|
protected $rawName = '파초선';
|
||||||
|
protected $name = '파초선(반계)';
|
||||||
|
protected $info = '[전투] 상대의 계략 성공 확률 -10%p, 상대의 계략을 40% 확률로 되돌림';
|
||||||
|
protected $cost = 200;
|
||||||
|
protected $consumable = false;
|
||||||
|
|
||||||
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
|
return new WarUnitTriggerCaller(
|
||||||
|
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '계략약화'),
|
||||||
|
new che_반계시도($unit),
|
||||||
|
new che_반계발동($unit)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\ActionItem;
|
||||||
|
use \sammo\iAction;
|
||||||
|
use \sammo\General;
|
||||||
|
use \sammo\GeneralTrigger;
|
||||||
|
use \sammo\GeneralTriggerCaller;
|
||||||
|
use \sammo\WarUnit;
|
||||||
|
use sammo\WarUnitTriggerCaller;
|
||||||
|
use sammo\BaseWarUnitTrigger;
|
||||||
|
use sammo\WarUnitTrigger\che_부상무효;
|
||||||
|
use sammo\WarUnitTrigger\WarActivateSkills;
|
||||||
|
|
||||||
|
class che_부적_태현청생부 extends \sammo\BaseItem{
|
||||||
|
|
||||||
|
protected $id = 9;
|
||||||
|
protected $rawName = '태현청생부';
|
||||||
|
protected $name = '태현청생부(부적)';
|
||||||
|
protected $info = '[전투] 저격 불가, 부상 없음';
|
||||||
|
protected $cost = 200;
|
||||||
|
protected $consumable = false;
|
||||||
|
|
||||||
|
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
|
return new WarUnitTriggerCaller(
|
||||||
|
new che_부상무효($unit, BaseWarUnitTrigger::TYPE_NONE),
|
||||||
|
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '저격불가')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
|
return new WarUnitTriggerCaller(
|
||||||
|
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '저격불가')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\ActionItem;
|
||||||
|
use \sammo\iAction;
|
||||||
|
use \sammo\General;
|
||||||
|
use \sammo\GeneralTrigger;
|
||||||
|
use \sammo\GeneralTriggerCaller;
|
||||||
|
use \sammo\BaseWarUnitTrigger;
|
||||||
|
use \sammo\WarUnitTriggerCaller;
|
||||||
|
use sammo\WarUnitTrigger\che_전투치료발동;
|
||||||
|
use sammo\WarUnitTrigger\che_전투치료시도;
|
||||||
|
|
||||||
|
class che_의술_상한잡병론 extends \sammo\BaseItem{
|
||||||
|
|
||||||
|
protected $id = 24;
|
||||||
|
protected $rawName = '상한잡병론';
|
||||||
|
protected $name = '상한잡병론(의술)';
|
||||||
|
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 40% 확률로 치료 발동(아군 피해 1/3 감소, 부상 회복)';
|
||||||
|
protected $cost = 200;
|
||||||
|
protected $consumable = false;
|
||||||
|
|
||||||
|
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
|
||||||
|
return new GeneralTriggerCaller(
|
||||||
|
new GeneralTrigger\che_도시치료($general)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller
|
||||||
|
{
|
||||||
|
return new WarUnitTriggerCaller(
|
||||||
|
new che_전투치료시도($unit, BaseWarUnitTrigger::TYPE_ITEM),
|
||||||
|
new che_전투치료발동($unit, BaseWarUnitTrigger::TYPE_ITEM)
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,35 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionItem;
|
namespace sammo\ActionItem;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\GeneralTrigger;
|
use \sammo\GeneralTrigger;
|
||||||
use \sammo\GeneralTriggerCaller;
|
use \sammo\GeneralTriggerCaller;
|
||||||
use sammo\WarUnitTrigger\che_전투치료발동;
|
use sammo\WarUnitTrigger\che_전투치료발동;
|
||||||
use sammo\WarUnitTrigger\che_전투치료시도;
|
use sammo\WarUnitTrigger\che_전투치료시도;
|
||||||
use sammo\BaseWarUnitTrigger;
|
use sammo\BaseWarUnitTrigger;
|
||||||
use sammo\WarUnitTriggerCaller;
|
use sammo\WarUnitTriggerCaller;
|
||||||
|
|
||||||
class che_의술_청낭서 extends \sammo\BaseItem{
|
class che_의술_청낭서 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 23;
|
protected $id = 23;
|
||||||
protected $rawName = '청낭서';
|
protected $rawName = '청낭서';
|
||||||
protected $name = '청낭서(의술)';
|
protected $name = '청낭서(의술)';
|
||||||
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)';
|
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 40% 확률로 치료 발동(아군 피해 1/3 감소, 부상 회복)';
|
||||||
protected $cost = 200;
|
protected $cost = 200;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
|
|
||||||
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
|
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
|
||||||
return new GeneralTriggerCaller(
|
return new GeneralTriggerCaller(
|
||||||
new GeneralTrigger\che_도시치료($general)
|
new GeneralTrigger\che_도시치료($general)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller
|
public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller
|
||||||
{
|
{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new che_전투치료시도($unit, BaseWarUnitTrigger::TYPE_ITEM),
|
new che_전투치료시도($unit, BaseWarUnitTrigger::TYPE_ITEM),
|
||||||
new che_전투치료발동($unit, BaseWarUnitTrigger::TYPE_ITEM)
|
new che_전투치료발동($unit, BaseWarUnitTrigger::TYPE_ITEM)
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,35 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionItem;
|
namespace sammo\ActionItem;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\GeneralTrigger;
|
use \sammo\GeneralTrigger;
|
||||||
use \sammo\GeneralTriggerCaller;
|
use \sammo\GeneralTriggerCaller;
|
||||||
use \sammo\BaseWarUnitTrigger;
|
use \sammo\BaseWarUnitTrigger;
|
||||||
use \sammo\WarUnitTriggerCaller;
|
use \sammo\WarUnitTriggerCaller;
|
||||||
use sammo\WarUnitTrigger\che_전투치료발동;
|
use sammo\WarUnitTrigger\che_전투치료발동;
|
||||||
use sammo\WarUnitTrigger\che_전투치료시도;
|
use sammo\WarUnitTrigger\che_전투치료시도;
|
||||||
|
|
||||||
class che_의술_태평청령 extends \sammo\BaseItem{
|
class che_의술_태평청령 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 24;
|
protected $id = 24;
|
||||||
protected $rawName = '태평청령';
|
protected $rawName = '태평청령';
|
||||||
protected $name = '태평청령(의술)';
|
protected $name = '태평청령(의술)';
|
||||||
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)';
|
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 40% 확률로 치료 발동(아군 피해 1/3 감소, 부상 회복)';
|
||||||
protected $cost = 200;
|
protected $cost = 200;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
|
|
||||||
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
|
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
|
||||||
return new GeneralTriggerCaller(
|
return new GeneralTriggerCaller(
|
||||||
new GeneralTrigger\che_도시치료($general)
|
new GeneralTrigger\che_도시치료($general)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller
|
public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller
|
||||||
{
|
{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new che_전투치료시도($unit, BaseWarUnitTrigger::TYPE_ITEM),
|
new che_전투치료시도($unit, BaseWarUnitTrigger::TYPE_ITEM),
|
||||||
new che_전투치료발동($unit, BaseWarUnitTrigger::TYPE_ITEM)
|
new che_전투치료발동($unit, BaseWarUnitTrigger::TYPE_ITEM)
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\ActionItem;
|
||||||
|
use \sammo\iAction;
|
||||||
|
use \sammo\General;
|
||||||
|
use \sammo\SpecialityHelper;
|
||||||
|
use \sammo\WarUnit;
|
||||||
|
use sammo\WarUnitTriggerCaller;
|
||||||
|
use \sammo\WarUnitTrigger\che_저격시도;
|
||||||
|
use \sammo\WarUnitTrigger\che_저격발동;
|
||||||
|
|
||||||
|
class che_저격_매화수전 extends \sammo\BaseItem{
|
||||||
|
|
||||||
|
protected $id = 70;
|
||||||
|
protected $rawName = '매화수전';
|
||||||
|
protected $name = '매화수전(저격)';
|
||||||
|
protected $info = '[전투] 새로운 상대와 전투 시 50% 확률로 저격 발동, 성공 시 사기+10';
|
||||||
|
protected $cost = 200;
|
||||||
|
protected $consumable = false;
|
||||||
|
|
||||||
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
|
return new WarUnitTriggerCaller(
|
||||||
|
new che_저격시도($unit, che_저격시도::TYPE_ITEM, 0.5, 20, 40),
|
||||||
|
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\ActionItem;
|
||||||
|
use \sammo\iAction;
|
||||||
|
use \sammo\General;
|
||||||
|
use \sammo\SpecialityHelper;
|
||||||
|
use \sammo\WarUnit;
|
||||||
|
use sammo\WarUnitTriggerCaller;
|
||||||
|
use \sammo\WarUnitTrigger\che_저격시도;
|
||||||
|
use \sammo\WarUnitTrigger\che_저격발동;
|
||||||
|
|
||||||
|
class che_저격_비도 extends \sammo\BaseItem{
|
||||||
|
|
||||||
|
protected $id = 70;
|
||||||
|
protected $rawName = '비도';
|
||||||
|
protected $name = '비도(저격)';
|
||||||
|
protected $info = '[전투] 새로운 상대와 전투 시 50% 확률로 저격 발동, 성공 시 사기+10';
|
||||||
|
protected $cost = 200;
|
||||||
|
protected $consumable = false;
|
||||||
|
|
||||||
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
|
return new WarUnitTriggerCaller(
|
||||||
|
new che_저격시도($unit, che_저격시도::TYPE_ITEM, 0.5, 20, 40),
|
||||||
|
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionItem;
|
namespace sammo\ActionItem;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\WarUnitTriggerCaller;
|
use \sammo\WarUnitTriggerCaller;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use \sammo\WarUnitTrigger\che_저격시도;
|
use \sammo\WarUnitTrigger\che_저격시도;
|
||||||
use \sammo\WarUnitTrigger\che_저격발동;
|
use \sammo\WarUnitTrigger\che_저격발동;
|
||||||
use \sammo\BaseWarUnitTrigger;
|
use \sammo\BaseWarUnitTrigger;
|
||||||
|
|
||||||
class che_저격_수극 extends \sammo\BaseItem{
|
class che_저격_수극 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 2;
|
protected $id = 2;
|
||||||
protected $rawName = '수극';
|
protected $rawName = '수극';
|
||||||
protected $name = '수극(저격)';
|
protected $name = '수극(저격)';
|
||||||
protected $info = '[전투] 전투 개시 전 20% 확률로 저격 시도. 1회용';
|
protected $info = '[전투] 전투 개시 전 50% 확률로 저격 시도. 1회용';
|
||||||
protected $cost = 1000;
|
protected $cost = 1000;
|
||||||
protected $consumable = true;
|
protected $consumable = true;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $reqSecu = 1000;
|
protected $reqSecu = 1000;
|
||||||
|
|
||||||
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new che_저격시도($unit, BaseWarUnitTrigger::TYPE_CONSUMABLE_ITEM, 0.2, 20, 40),
|
new che_저격시도($unit, BaseWarUnitTrigger::TYPE_CONSUMABLE_ITEM, 0.5, 20, 40),
|
||||||
new che_저격발동($unit)
|
new che_저격발동($unit)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\ActionItem;
|
||||||
|
use \sammo\iAction;
|
||||||
|
use \sammo\General;
|
||||||
|
|
||||||
|
class che_행동_서촉지형도 extends \sammo\BaseItem{
|
||||||
|
|
||||||
|
protected $id = 22;
|
||||||
|
protected $rawName = '서촉지형도';
|
||||||
|
protected $name = '서촉지형도(행동)';
|
||||||
|
protected $info = '[전투] 공격 시 페이즈 + 2';
|
||||||
|
protected $cost = 200;
|
||||||
|
protected $consumable = false;
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if($statName === 'initWarPhase'){
|
||||||
|
return $value + 2;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ class event_전투특기_격노 extends \sammo\BaseItem{
|
|||||||
protected $id = 74;
|
protected $id = 74;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(격노)';
|
protected $name = '비급(격노)';
|
||||||
protected $info = '[전투] 상대방 필살 및 회피 시도시 일정 확률로 격노(필살) 발동, 공격 시 일정 확률로 진노(1페이즈 추가)';
|
protected $info = '[전투] 상대방 필살 시 격노(필살) 발동, 회피 시도시 25% 확률로 격노 발동, 공격 시 일정 확률로 진노(1페이즈 추가)';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class event_전투특기_공성 extends \sammo\BaseItem{
|
|||||||
protected $id = 53;
|
protected $id = 53;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(공성)';
|
protected $name = '비급(공성)';
|
||||||
protected $info = '[군사] 차병 계통 징·모병비 -10%<br>[전투] 성벽 공격 시 대미지 +100%';
|
protected $info = '[군사] 차병 계통 징·모병비 -10%<br>[전투] 성벽 공격 시 대미지 +100%,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 차병 숙련을 가산';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -32,4 +32,18 @@ class event_전투특기_공성 extends \sammo\BaseItem{
|
|||||||
}
|
}
|
||||||
return [1, 1];
|
return [1, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_SIEGE;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ class event_전투특기_궁병 extends \sammo\BaseItem{
|
|||||||
protected $id = 51;
|
protected $id = 51;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(궁병)';
|
protected $name = '비급(궁병)';
|
||||||
protected $info = '[군사] 궁병 계통 징·모병비 -10%<br>[전투] 회피 확률 +20%p';
|
protected $info = '[군사] 궁병 계통 징·모병비 -10%<br>[전투] 회피 확률 +20%p,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 궁병 숙련을 가산';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -29,6 +29,16 @@ class event_전투특기_궁병 extends \sammo\BaseItem{
|
|||||||
if($statName === 'warAvoidRatio'){
|
if($statName === 'warAvoidRatio'){
|
||||||
return $value + 0.2;
|
return $value + 0.2;
|
||||||
}
|
}
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_ARCHER;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ class event_전투특기_귀병 extends \sammo\BaseItem{
|
|||||||
protected $id = 40;
|
protected $id = 40;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(귀병)';
|
protected $name = '비급(귀병)';
|
||||||
protected $info = '[군사] 귀병 계통 징·모병비 -10%<br>[전투] 계략 성공 확률 +20%p';
|
protected $info = '[군사] 귀병 계통 징·모병비 -10%<br>[전투] 계략 성공 확률 +20%p,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 귀병 숙련을 가산';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -29,6 +29,16 @@ class event_전투특기_귀병 extends \sammo\BaseItem{
|
|||||||
if($statName === 'warMagicSuccessProb'){
|
if($statName === 'warMagicSuccessProb'){
|
||||||
return $value + 0.2;
|
return $value + 0.2;
|
||||||
}
|
}
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_WIZARD;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ class event_전투특기_기병 extends \sammo\BaseItem{
|
|||||||
protected $id = 52;
|
protected $id = 52;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(기병)';
|
protected $name = '비급(기병)';
|
||||||
protected $info = '[군사] 기병 계통 징·모병비 -10%<br>[전투] 수비 시 대미지 +10%, 공격 시 대미지 +20%';
|
protected $info = '[군사] 기병 계통 징·모병비 -10%<br>[전투] 수비 시 대미지 +10%, 공격 시 대미지 +20%,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 기병 숙련을 가산';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -31,4 +31,18 @@ class event_전투특기_기병 extends \sammo\BaseItem{
|
|||||||
}
|
}
|
||||||
return [1.1, 1];
|
return [1.1, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_CAVALRY;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,13 +7,14 @@ use \sammo\WarUnit;
|
|||||||
use \sammo\BaseWarUnitTrigger;
|
use \sammo\BaseWarUnitTrigger;
|
||||||
use \sammo\WarUnitTriggerCaller;
|
use \sammo\WarUnitTriggerCaller;
|
||||||
use sammo\WarUnitTrigger\WarActivateSkills;
|
use sammo\WarUnitTrigger\WarActivateSkills;
|
||||||
|
use \sammo\WarUnitTrigger\che_돌격지속;
|
||||||
|
|
||||||
class event_전투특기_돌격 extends \sammo\BaseItem{
|
class event_전투특기_돌격 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 60;
|
protected $id = 60;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(돌격)';
|
protected $name = '비급(돌격)';
|
||||||
protected $info = '[전투] 상대 회피 불가, 공격 시 전투 페이즈 +1, 공격 시 대미지 +10%';
|
protected $info = '[전투] 공격 시 대등/유리한 병종에게는 퇴각 전까지 전투, 공격 시 페이즈 + 2, 공격 시 대미지 +5%';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -21,21 +22,20 @@ class event_전투특기_돌격 extends \sammo\BaseItem{
|
|||||||
|
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
if($statName === 'initWarPhase'){
|
if($statName === 'initWarPhase'){
|
||||||
return $value + 1;
|
return $value + 2;
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
if($unit->isAttacker()){
|
if($unit->isAttacker()){
|
||||||
return [1.1, 1];
|
return [1.05, 1];
|
||||||
}
|
}
|
||||||
return [1, 1];
|
return [1, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
(new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '회피불가'))->setPriority(BaseWarUnitTrigger::PRIORITY_BEGIN + 200)
|
new che_돌격지속($unit)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,14 @@ use \sammo\iAction;
|
|||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class event_전투특기_무쌍 extends \sammo\BaseItem{
|
class event_전투특기_무쌍 extends \sammo\BaseItem{
|
||||||
|
|
||||||
protected $id = 61;
|
protected $id = 61;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(무쌍)';
|
protected $name = '비급(무쌍)';
|
||||||
protected $info = '[전투] 대미지 +10%, 공격 시 필살 확률 +10%p';
|
protected $info = '[전투] 대미지 +10%, 공격 시 필살 확률 +10%p, <br>승리 수만큼 대미지 0.20%씩 추가 상승(최대40%)<br>승리 수만큼 피해 0.05%씩 감소(최대50%)';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -24,6 +25,11 @@ class event_전투특기_무쌍 extends \sammo\BaseItem{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
return [1.1, 1];
|
$attackMultiplier = 1.1;
|
||||||
|
$defenceMultiplier = 1;
|
||||||
|
$killnum = $unit->getGeneral()->getRankVar('killnum');
|
||||||
|
$attackMultiplier += Util::valueFit($killnum * 0.01 * 0.2, null, 0.4);
|
||||||
|
$defenceMultiplier -= Util::valueFit($killnum * 0.01 * 0.05, null, 0.5);
|
||||||
|
return [$attackMultiplier, $defenceMultiplier];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ class event_전투특기_반계 extends \sammo\BaseItem{
|
|||||||
protected $id = 45;
|
protected $id = 45;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(반계)';
|
protected $name = '비급(반계)';
|
||||||
protected $info = '[전투] 상대의 계략 성공 확률 -10%p, 상대의 계략을 40% 확률로 되돌림, 반목 성공시 대미지 추가(+60% → +100%)';
|
protected $info = '[전투] 상대의 계략 성공 확률 -10%p, 상대의 계략을 40% 확률로 되돌림, 반목 성공시 대미지 추가(+60% → +150%)';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -23,15 +23,15 @@ class event_전투특기_반계 extends \sammo\BaseItem{
|
|||||||
|
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
if($statName === 'warMagicSuccessDamage' && $aux === '반목'){
|
if($statName === 'warMagicSuccessDamage' && $aux === '반목'){
|
||||||
return $value + 0.4;
|
return $value + 0.9;
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM, false, '계략약화'),
|
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '계략약화'),
|
||||||
new che_반계시도($unit, che_반계시도::TYPE_ITEM),
|
new che_반계시도($unit),
|
||||||
new che_반계발동($unit)
|
new che_반계발동($unit)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class event_전투특기_보병 extends \sammo\BaseItem{
|
|||||||
protected $id = 50;
|
protected $id = 50;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(보병)';
|
protected $name = '비급(보병)';
|
||||||
protected $info = '[군사] 보병 계통 징·모병비 -10%<br>[전투] 공격 시 아군 피해 -10%, 수비 시 아군 피해 -20%';
|
protected $info = '[군사] 보병 계통 징·모병비 -10%<br>[전투] 공격 시 아군 피해 -10%, 수비 시 아군 피해 -20%,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 보병 숙련을 가산';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -32,4 +32,18 @@ class event_전투특기_보병 extends \sammo\BaseItem{
|
|||||||
}
|
}
|
||||||
return [1, 0.8];
|
return [1, 0.8];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_FOOTMAN;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ class event_전투특기_위압 extends \sammo\BaseItem{
|
|||||||
protected $id = 63;
|
protected $id = 63;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(위압)';
|
protected $name = '비급(위압)';
|
||||||
protected $info = '[전투] 훈련/사기≥90, 병력≥1,000 일 때 첫 페이즈 위압 발동(적 공격 불가)';
|
protected $info = '[전투] 첫 페이즈 위압 발동(적 공격, 회피 불가, 사기 5 감소)';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class event_전투특기_의술 extends \sammo\BaseItem{
|
|||||||
protected $id = 73;
|
protected $id = 73;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(의술)';
|
protected $name = '비급(의술)';
|
||||||
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)';
|
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 40% 확률로 치료 발동(아군 피해 1/3 감소, 부상 회복)';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class event_전투특기_저격 extends \sammo\BaseItem{
|
|||||||
protected $id = 70;
|
protected $id = 70;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(저격)';
|
protected $name = '비급(저격)';
|
||||||
protected $info = '[전투] 새로운 상대와 전투 시 1/3 확률로 저격 발동, 성공 시 사기+10';
|
protected $info = '[전투] 새로운 상대와 전투 시 50% 확률로 저격 발동, 성공 시 사기+10';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -21,7 +21,7 @@ class event_전투특기_저격 extends \sammo\BaseItem{
|
|||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new che_저격시도($unit, che_저격시도::TYPE_ITEM, 1/3, 20, 60),
|
new che_저격시도($unit, che_저격시도::TYPE_ITEM, 0.5, 20, 40),
|
||||||
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class event_전투특기_필살 extends \sammo\BaseItem{
|
|||||||
protected $id = 71;
|
protected $id = 71;
|
||||||
protected $rawName = '비급';
|
protected $rawName = '비급';
|
||||||
protected $name = '비급(필살)';
|
protected $name = '비급(필살)';
|
||||||
protected $info = '[전투] 필살 확률 +20%p, 필살 발동시 대상 회피 불가';
|
protected $info = '[전투] 필살 확률 +30%p, 필살 발동시 대상 회피 불가';
|
||||||
protected $cost = 100;
|
protected $cost = 100;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
@@ -20,7 +20,7 @@ class event_전투특기_필살 extends \sammo\BaseItem{
|
|||||||
|
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
if($statName === 'warCriticalRatio'){
|
if($statName === 'warCriticalRatio'){
|
||||||
return $value + 0.2;
|
return $value + 0.3;
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,45 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\Util;
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_종횡가 extends \sammo\BaseNation{
|
class che_종횡가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
protected $name = '종횡가';
|
protected $name = '종횡가';
|
||||||
protected $info = '';
|
protected $info = '';
|
||||||
static $pros = '전략↑ 수성↑';
|
static $pros = '전략↑ 수성↑';
|
||||||
static $cons = '금수입↓ 내정↓';
|
static $cons = '금수입↓ 내정↓';
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if($turnType == '수비' || $turnType == '성벽'){
|
if($turnType == '수비' || $turnType == '성벽'){
|
||||||
if($varType == 'score') return $value * 1.1;
|
if($varType == 'score') return $value * 1.1;
|
||||||
if($varType == 'cost') return $value * 0.8;
|
if($varType == 'cost') return $value * 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if($turnType == '농업' || $turnType == '상업'){
|
else if($turnType == '농업' || $turnType == '상업'){
|
||||||
if($varType == 'score') return $value * 0.9;
|
if($varType == 'score') return $value * 0.9;
|
||||||
if($varType == 'cost') return $value * 1.2;
|
if($varType == 'cost') return $value * 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCalcNationalIncome(string $type, $amount){
|
public function onCalcNationalIncome(string $type, $amount){
|
||||||
if($type == 'gold'){
|
if($type == 'gold'){
|
||||||
return $amount * 0.9;
|
return $amount * 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCalcStrategic(string $turnType, string $varType, $value){
|
public function onCalcStrategic(string $turnType, string $varType, $value){
|
||||||
if($varType == 'delay'){
|
if($varType == 'delay'){
|
||||||
return Util::round($value / 2);
|
return Util::round($value / 2);
|
||||||
}
|
}
|
||||||
return $value;
|
if($varType == 'globalDelay'){
|
||||||
}
|
return Util::round($value / 2);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use sammo\WarUnitTriggerCaller;
|
use sammo\WarUnitTriggerCaller;
|
||||||
use sammo\WarUnitTrigger\che_격노시도;
|
use sammo\WarUnitTrigger\che_격노시도;
|
||||||
use sammo\WarUnitTrigger\che_격노발동;
|
use sammo\WarUnitTrigger\che_격노발동;
|
||||||
|
|
||||||
class che_격노 extends \sammo\BaseSpecial{
|
class che_격노 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 74;
|
protected $id = 74;
|
||||||
protected $name = '격노';
|
protected $name = '격노';
|
||||||
protected $info = '[전투] 상대방 필살 및 회피 시도시 일정 확률로 격노(필살) 발동, 공격 시 일정 확률로 진노(1페이즈 추가)';
|
protected $info = '[전투] 상대방 필살 시 격노(필살) 발동, 회피 시도시 25% 확률로 격노 발동, 공격 시 일정 확률로 진노(1페이즈 추가), 격노마다 대미지 20% 추가 중첩';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_STRENGTH,
|
SpecialityHelper::STAT_STRENGTH,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
return new WarUnitTriggerCaller(
|
$activatedCnt = $unit->hasActivatedSkillOnLog('격노');
|
||||||
new che_격노시도($unit),
|
return [1 + 0.2*$activatedCnt, 1];
|
||||||
new che_격노발동($unit)
|
}
|
||||||
);
|
|
||||||
}
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
|
return new WarUnitTriggerCaller(
|
||||||
|
new che_격노시도($unit),
|
||||||
|
new che_격노발동($unit)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use sammo\WarUnitTriggerCaller;
|
use sammo\WarUnitTriggerCaller;
|
||||||
use sammo\BaseWarUnitTrigger;
|
use sammo\BaseWarUnitTrigger;
|
||||||
use sammo\WarUnitTrigger\che_부상무효;
|
use sammo\WarUnitTrigger\che_부상무효;
|
||||||
use sammo\WarUnitTrigger\WarActivateSkills;
|
use sammo\WarUnitTrigger\WarActivateSkills;
|
||||||
|
|
||||||
class che_견고 extends \sammo\BaseSpecial{
|
class che_견고 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 62;
|
protected $id = 62;
|
||||||
protected $name = '견고';
|
protected $name = '견고';
|
||||||
protected $info = '[전투] 상대 필살, 격노, 위압, 저격 불가, 상대 계략 시도시 성공 확률 -10%p, 부상 없음, 아군 피해 -5%';
|
protected $info = '[전투] 상대 필살, 저격 불가, 상대 계략 시도시 성공 확률 -10%p, 부상 없음, 아군 피해 -10%';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_STRENGTH
|
SpecialityHelper::STAT_STRENGTH
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new che_부상무효($unit, BaseWarUnitTrigger::TYPE_NONE),
|
new che_부상무효($unit, BaseWarUnitTrigger::TYPE_NONE),
|
||||||
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '저격불가')
|
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '저격불가')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '필살불가', '위압불가', '격노불가', '계략약화', '저격불가')
|
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '필살불가', '계략약화', '저격불가')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
return [1, 0.95];
|
return [1, 0.9];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,36 +1,50 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\GameUnitConst;
|
use \sammo\GameUnitConst;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use \sammo\WarUnitCity;
|
use \sammo\WarUnitCity;
|
||||||
|
|
||||||
class che_공성 extends \sammo\BaseSpecial{
|
class che_공성 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 53;
|
protected $id = 53;
|
||||||
protected $name = '공성';
|
protected $name = '공성';
|
||||||
protected $info = '[군사] 차병 계통 징·모병비 -10%<br>[전투] 성벽 공격 시 대미지 +100%';
|
protected $info = '[군사] 차병 계통 징·모병비 -10%<br>[전투] 성벽 공격 시 대미지 +100%,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 차병 숙련을 가산';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_SIEGE,
|
SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_SIEGE,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if(in_array($turnType, ['징병', '모병'])){
|
if(in_array($turnType, ['징병', '모병'])){
|
||||||
if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_SIEGE) return $value * 0.9;
|
if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_SIEGE) return $value * 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
if($unit->getOppose() instanceof WarUnitCity){
|
if($unit->getOppose() instanceof WarUnitCity){
|
||||||
return [2, 1];
|
return [2, 1];
|
||||||
}
|
}
|
||||||
return [1, 1];
|
return [1, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_SIEGE;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ class che_궁병 extends \sammo\BaseSpecial{
|
|||||||
|
|
||||||
protected $id = 51;
|
protected $id = 51;
|
||||||
protected $name = '궁병';
|
protected $name = '궁병';
|
||||||
protected $info = '[군사] 궁병 계통 징·모병비 -10%<br>[전투] 회피 확률 +20%p';
|
protected $info = '[군사] 궁병 계통 징·모병비 -10%<br>[전투] 회피 확률 +20%p,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 궁병 숙련을 가산';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
@@ -31,6 +31,16 @@ class che_궁병 extends \sammo\BaseSpecial{
|
|||||||
if($statName === 'warAvoidRatio'){
|
if($statName === 'warAvoidRatio'){
|
||||||
return $value + 0.2;
|
return $value + 0.2;
|
||||||
}
|
}
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_ARCHER;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,35 +1,45 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\GameUnitConst;
|
use \sammo\GameUnitConst;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
|
|
||||||
class che_귀병 extends \sammo\BaseSpecial{
|
class che_귀병 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 40;
|
protected $id = 40;
|
||||||
protected $name = '귀병';
|
protected $name = '귀병';
|
||||||
protected $info = '[군사] 귀병 계통 징·모병비 -10%<br>[전투] 계략 성공 확률 +20%p';
|
protected $info = '[군사] 귀병 계통 징·모병비 -10%<br>[전투] 계략 성공 확률 +20%p,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 귀병 숙련을 가산';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_INTEL | SpecialityHelper::ARMY_WIZARD | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::STAT_NOT_STRENGTH
|
SpecialityHelper::STAT_INTEL | SpecialityHelper::ARMY_WIZARD | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::STAT_NOT_STRENGTH
|
||||||
];
|
];
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if(in_array($turnType, ['징병', '모병'])){
|
if(in_array($turnType, ['징병', '모병'])){
|
||||||
if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_WIZARD) return $value * 0.9;
|
if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_WIZARD) return $value * 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
if($statName === 'warMagicSuccessProb'){
|
if($statName === 'warMagicSuccessProb'){
|
||||||
return $value + 0.2;
|
return $value + 0.2;
|
||||||
}
|
}
|
||||||
return $value;
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
}
|
$myArmType = 'dex'.GameUnitConst::T_WIZARD;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,36 +1,50 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\GameUnitConst;
|
use \sammo\GameUnitConst;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
|
|
||||||
class che_기병 extends \sammo\BaseSpecial{
|
class che_기병 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 52;
|
protected $id = 52;
|
||||||
protected $name = '기병';
|
protected $name = '기병';
|
||||||
protected $info = '[군사] 기병 계통 징·모병비 -10%<br>[전투] 수비 시 대미지 +10%, 공격 시 대미지 +20%';
|
protected $info = '[군사] 기병 계통 징·모병비 -10%<br>[전투] 수비 시 대미지 +10%, 공격 시 대미지 +20%,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 기병 숙련을 가산';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_CAVALRY | SpecialityHelper::STAT_NOT_INTEL,
|
SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_CAVALRY | SpecialityHelper::STAT_NOT_INTEL,
|
||||||
SpecialityHelper::STAT_STRENGTH | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_CAVALRY
|
SpecialityHelper::STAT_STRENGTH | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_CAVALRY
|
||||||
];
|
];
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if(in_array($turnType, ['징병', '모병'])){
|
if(in_array($turnType, ['징병', '모병'])){
|
||||||
if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_CAVALRY) return $value * 0.9;
|
if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_CAVALRY) return $value * 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
if($unit->isAttacker()){
|
if($unit->isAttacker()){
|
||||||
return [1.2, 1];
|
return [1.2, 1];
|
||||||
}
|
}
|
||||||
return [1.1, 1];
|
return [1.1, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_CAVALRY;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,42 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use \sammo\BaseWarUnitTrigger;
|
use \sammo\BaseWarUnitTrigger;
|
||||||
use \sammo\WarUnitTriggerCaller;
|
use \sammo\WarUnitTriggerCaller;
|
||||||
use sammo\WarUnitTrigger\WarActivateSkills;
|
use sammo\WarUnitTrigger\WarActivateSkills;
|
||||||
|
use \sammo\WarUnitTrigger\che_돌격지속;
|
||||||
class che_돌격 extends \sammo\BaseSpecial{
|
|
||||||
|
class che_돌격 extends \sammo\BaseSpecial{
|
||||||
protected $id = 60;
|
|
||||||
protected $name = '돌격';
|
protected $id = 60;
|
||||||
protected $info = '[전투] 상대 회피 불가, 공격 시 전투 페이즈 +1, 공격 시 대미지 +10%';
|
protected $name = '돌격';
|
||||||
|
protected $info = '[전투] 공격 시 대등/유리한 병종에게는 퇴각 전까지 전투, 공격 시 페이즈 + 2, 공격 시 대미지 +5%';
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
|
||||||
static $selectWeight = 1;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $type = [
|
static $selectWeight = 1;
|
||||||
SpecialityHelper::STAT_STRENGTH
|
static $type = [
|
||||||
];
|
SpecialityHelper::STAT_STRENGTH
|
||||||
|
];
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
|
||||||
if($statName === 'initWarPhase'){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
return $value + 1;
|
if($statName === 'initWarPhase'){
|
||||||
}
|
return $value + 2;
|
||||||
return $value;
|
}
|
||||||
}
|
return $value;
|
||||||
|
}
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
if($unit->isAttacker()){
|
if($unit->isAttacker()){
|
||||||
return [1.1, 1];
|
return [1.05, 1];
|
||||||
}
|
}
|
||||||
return [1, 1];
|
return [1, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
(new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '회피불가'))->setPriority(BaseWarUnitTrigger::PRIORITY_BEGIN + 200)
|
new che_돌격지속($unit)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,30 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
|
use \sammo\Util;
|
||||||
class che_무쌍 extends \sammo\BaseSpecial{
|
|
||||||
|
class che_무쌍 extends \sammo\BaseSpecial{
|
||||||
protected $id = 61;
|
|
||||||
protected $name = '무쌍';
|
protected $id = 61;
|
||||||
protected $info = '[전투] 대미지 +10%, 공격 시 필살 확률 +10%p';
|
protected $name = '무쌍';
|
||||||
|
protected $info = '[전투] 대미지 +10%, 공격 시 필살 확률 +10%p, <br>승리 수만큼 대미지 0.20%씩 추가 상승(최대40%)<br>승리 수만큼 피해 0.05%씩 감소(최대50%)';
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
|
||||||
static $selectWeight = 1;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $type = [
|
static $selectWeight = 1;
|
||||||
SpecialityHelper::STAT_STRENGTH
|
static $type = [
|
||||||
];
|
SpecialityHelper::STAT_STRENGTH
|
||||||
|
];
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
|
||||||
if($statName === 'warCriticalRatio' && $aux['isAttacker']??false){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
return $value += 0.1;
|
if($statName === 'warCriticalRatio' && $aux['isAttacker']??false){
|
||||||
}
|
return $value += 0.1;
|
||||||
return $value;
|
}
|
||||||
}
|
return $value;
|
||||||
|
}
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
|
||||||
return [1.1, 1];
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
}
|
$attackMultiplier = 1.1;
|
||||||
|
$defenceMultiplier = 1;
|
||||||
|
$killnum = $unit->getGeneral()->getRankVar('killnum');
|
||||||
|
$attackMultiplier += Util::valueFit($killnum * 0.01 * 0.2, null, 0.4);
|
||||||
|
$defenceMultiplier -= Util::valueFit($killnum * 0.01 * 0.05, null, 0.5);
|
||||||
|
return [$attackMultiplier, $defenceMultiplier];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,39 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use sammo\WarUnitTriggerCaller;
|
use sammo\WarUnitTriggerCaller;
|
||||||
use \sammo\BaseWarUnitTrigger;
|
use \sammo\BaseWarUnitTrigger;
|
||||||
use \sammo\WarUnitTrigger\WarActivateSkills;
|
use \sammo\WarUnitTrigger\WarActivateSkills;
|
||||||
use \sammo\WarUnitTrigger\che_반계시도;
|
use \sammo\WarUnitTrigger\che_반계시도;
|
||||||
use \sammo\WarUnitTrigger\che_반계발동;
|
use \sammo\WarUnitTrigger\che_반계발동;
|
||||||
|
|
||||||
class che_반계 extends \sammo\BaseSpecial{
|
class che_반계 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 45;
|
protected $id = 45;
|
||||||
protected $name = '반계';
|
protected $name = '반계';
|
||||||
protected $info = '[전투] 상대의 계략 성공 확률 -10%p, 상대의 계략을 40% 확률로 되돌림, 반목 성공시 대미지 추가(+60% → +100%)';
|
protected $info = '[전투] 상대의 계략 성공 확률 -10%p, 상대의 계략을 40% 확률로 되돌림, 반목 성공시 대미지 추가(+60% → +150%)';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_INTEL,
|
SpecialityHelper::STAT_INTEL,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
if($statName === 'warMagicSuccessDamage' && $aux === '반목'){
|
if($statName === 'warMagicSuccessDamage' && $aux === '반목'){
|
||||||
return $value + 0.4;
|
return $value + 0.9;
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '계략약화'),
|
new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '계략약화'),
|
||||||
new che_반계시도($unit),
|
new che_반계시도($unit),
|
||||||
new che_반계발동($unit)
|
new che_반계발동($unit)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,36 +1,50 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\GameUnitConst;
|
use \sammo\GameUnitConst;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
|
|
||||||
class che_보병 extends \sammo\BaseSpecial{
|
class che_보병 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 50;
|
protected $id = 50;
|
||||||
protected $name = '보병';
|
protected $name = '보병';
|
||||||
protected $info = '[군사] 보병 계통 징·모병비 -10%<br>[전투] 공격 시 아군 피해 -10%, 수비 시 아군 피해 -20%';
|
protected $info = '[군사] 보병 계통 징·모병비 -10%<br>[전투] 공격 시 아군 피해 -10%, 수비 시 아군 피해 -20%,<br>공격시 상대 병종에/수비시 자신 병종 숙련에 보병 숙련을 가산';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_FOOTMAN | SpecialityHelper::STAT_NOT_INTEL,
|
SpecialityHelper::STAT_LEADERSHIP | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_FOOTMAN | SpecialityHelper::STAT_NOT_INTEL,
|
||||||
SpecialityHelper::STAT_STRENGTH | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_FOOTMAN
|
SpecialityHelper::STAT_STRENGTH | SpecialityHelper::REQ_DEXTERITY | SpecialityHelper::ARMY_FOOTMAN
|
||||||
];
|
];
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if(in_array($turnType, ['징병', '모병'])){
|
if(in_array($turnType, ['징병', '모병'])){
|
||||||
if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_FOOTMAN) return $value * 0.9;
|
if($varType == 'cost' && $aux['armType'] == GameUnitConst::T_FOOTMAN) return $value * 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
if($unit->isAttacker()){
|
if($unit->isAttacker()){
|
||||||
return [1, 0.9];
|
return [1, 0.9];
|
||||||
}
|
}
|
||||||
return [1, 0.8];
|
return [1, 0.8];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
|
if(\sammo\Util::starts_with($statName, 'dex')){
|
||||||
|
$myArmType = 'dex'.GameUnitConst::T_FOOTMAN;
|
||||||
|
$opposeArmType = 'dex'.$aux['opposeType']->armType;;
|
||||||
|
if($aux['isAttacker'] && $opposeArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
if(!$aux['isAttacker'] && $myArmType === $statName){
|
||||||
|
return $value + $general->getVar($myArmType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,32 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use sammo\WarUnitTriggerCaller;
|
use sammo\WarUnitTriggerCaller;
|
||||||
use \sammo\WarUnitTrigger\che_위압시도;
|
use \sammo\WarUnitTrigger\che_위압시도;
|
||||||
use \sammo\WarUnitTrigger\che_위압발동;
|
use \sammo\WarUnitTrigger\che_위압발동;
|
||||||
|
|
||||||
class che_위압 extends \sammo\BaseSpecial{
|
class che_위압 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 63;
|
protected $id = 63;
|
||||||
protected $name = '위압';
|
protected $name = '위압';
|
||||||
protected $info = '[전투] 훈련/사기≥90, 병력≥1,000 일 때 첫 페이즈 위압 발동(적 공격 불가)';
|
protected $info = '[전투] 첫 페이즈 위압 발동(적 공격, 회피 불가, 사기 5 감소)';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_STRENGTH
|
SpecialityHelper::STAT_STRENGTH
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
if($unit->getPhase() != 0){
|
return new WarUnitTriggerCaller(
|
||||||
return null;
|
new che_위압시도($unit),
|
||||||
}
|
new che_위압발동($unit)
|
||||||
return new WarUnitTriggerCaller(
|
);
|
||||||
new che_위압시도($unit),
|
}
|
||||||
new che_위압발동($unit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,41 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use sammo\BaseGeneralTrigger;
|
use sammo\BaseGeneralTrigger;
|
||||||
use sammo\SpecialityHelper;
|
use sammo\SpecialityHelper;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\GeneralTrigger;
|
use \sammo\GeneralTrigger;
|
||||||
use \sammo\GeneralTriggerCaller;
|
use \sammo\GeneralTriggerCaller;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use sammo\WarUnitTrigger\che_전투치료발동;
|
use sammo\WarUnitTrigger\che_전투치료발동;
|
||||||
use sammo\WarUnitTrigger\che_전투치료시도;
|
use sammo\WarUnitTrigger\che_전투치료시도;
|
||||||
use sammo\WarUnitTriggerCaller;
|
use sammo\WarUnitTriggerCaller;
|
||||||
|
|
||||||
class che_의술 extends \sammo\BaseSpecial{
|
class che_의술 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 73;
|
protected $id = 73;
|
||||||
protected $name = '의술';
|
protected $name = '의술';
|
||||||
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)';
|
protected $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 40% 확률로 치료 발동(아군 피해 1/3 감소, 부상 회복)';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_PERCENT;
|
static $selectWeightType = SpecialityHelper::WEIGHT_PERCENT;
|
||||||
static $selectWeight = 2;
|
static $selectWeight = 2;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_LEADERSHIP,
|
SpecialityHelper::STAT_LEADERSHIP,
|
||||||
SpecialityHelper::STAT_STRENGTH,
|
SpecialityHelper::STAT_STRENGTH,
|
||||||
SpecialityHelper::STAT_INTEL
|
SpecialityHelper::STAT_INTEL
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
|
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
|
||||||
return new GeneralTriggerCaller(
|
return new GeneralTriggerCaller(
|
||||||
new GeneralTrigger\che_도시치료($general)
|
new GeneralTrigger\che_도시치료($general)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller
|
public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller
|
||||||
{
|
{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new che_전투치료시도($unit),
|
new che_전투치료시도($unit),
|
||||||
new che_전투치료발동($unit)
|
new che_전투치료발동($unit)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use sammo\WarUnitTriggerCaller;
|
use sammo\WarUnitTriggerCaller;
|
||||||
use \sammo\WarUnitTrigger\che_저격시도;
|
use \sammo\WarUnitTrigger\che_저격시도;
|
||||||
use \sammo\WarUnitTrigger\che_저격발동;
|
use \sammo\WarUnitTrigger\che_저격발동;
|
||||||
|
|
||||||
class che_저격 extends \sammo\BaseSpecial{
|
class che_저격 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 70;
|
protected $id = 70;
|
||||||
protected $name = '저격';
|
protected $name = '저격';
|
||||||
protected $info = '[전투] 새로운 상대와 전투 시 1/3 확률로 저격 발동, 성공 시 사기+10';
|
protected $info = '[전투] 새로운 상대와 전투 시 50% 확률로 저격 발동, 성공 시 사기+10';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_LEADERSHIP,
|
SpecialityHelper::STAT_LEADERSHIP,
|
||||||
SpecialityHelper::STAT_STRENGTH,
|
SpecialityHelper::STAT_STRENGTH,
|
||||||
SpecialityHelper::STAT_INTEL
|
SpecialityHelper::STAT_INTEL
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new che_저격시도($unit, che_저격시도::TYPE_NONE, 1/3, 20, 60),
|
new che_저격시도($unit, che_저격시도::TYPE_NONE, 0.5, 20, 40),
|
||||||
new che_저격발동($unit)
|
new che_저격발동($unit)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,36 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
|
|
||||||
class che_징병 extends \sammo\BaseSpecial{
|
class che_징병 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 72;
|
protected $id = 72;
|
||||||
protected $name = '징병';
|
protected $name = '징병';
|
||||||
protected $info = '[군사] 징·모병비 -50%, 통솔 순수 능력치 보정 +15%';
|
protected $info = '[군사] 징·모병비 -50%, 통솔 순수 능력치 보정 +25%';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_LEADERSHIP,
|
SpecialityHelper::STAT_LEADERSHIP,
|
||||||
SpecialityHelper::STAT_STRENGTH,
|
SpecialityHelper::STAT_STRENGTH,
|
||||||
SpecialityHelper::STAT_INTEL
|
SpecialityHelper::STAT_INTEL
|
||||||
];
|
];
|
||||||
|
|
||||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
|
||||||
if(in_array($turnType, ['징병', '모병'])){
|
if(in_array($turnType, ['징병', '모병'])){
|
||||||
if($varType == 'cost') return $value * 0.5;
|
if($varType == 'cost') return $value * 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
if($statName === 'leadership'){
|
if($statName === 'leadership'){
|
||||||
return $value *= 1.15;
|
return $value + $general->getVar('leadership') * 0.25;
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
|
|
||||||
class che_척사 extends \sammo\BaseSpecial{
|
class che_척사 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 75;
|
protected $id = 75;
|
||||||
protected $name = '척사';
|
protected $name = '척사';
|
||||||
protected $info = '[전투] 지역·도시 병종 상대로 대미지 +10%, 아군 피해 -10%';
|
protected $info = '[전투] 지역·도시 병종 상대로 대미지 +15%, 아군 피해 -15%';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_LEADERSHIP,
|
SpecialityHelper::STAT_LEADERSHIP,
|
||||||
SpecialityHelper::STAT_STRENGTH,
|
SpecialityHelper::STAT_STRENGTH,
|
||||||
SpecialityHelper::STAT_INTEL
|
SpecialityHelper::STAT_INTEL
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||||
$opposeCrewType = $unit->getOppose()->getCrewType();
|
$opposeCrewType = $unit->getOppose()->getCrewType();
|
||||||
if($opposeCrewType->reqCities || $opposeCrewType->reqRegions){
|
if($opposeCrewType->reqCities || $opposeCrewType->reqRegions){
|
||||||
return [1.1, 0.9];
|
return [1.15, 0.85];
|
||||||
}
|
}
|
||||||
return [1, 1];
|
return [1, 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,36 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\ActionSpecialWar;
|
namespace sammo\ActionSpecialWar;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\SpecialityHelper;
|
use \sammo\SpecialityHelper;
|
||||||
use \sammo\WarUnit;
|
use \sammo\WarUnit;
|
||||||
use sammo\WarUnitTriggerCaller;
|
use sammo\WarUnitTriggerCaller;
|
||||||
use sammo\WarUnitTrigger\che_필살강화_회피불가;
|
use sammo\WarUnitTrigger\che_필살강화_회피불가;
|
||||||
|
|
||||||
class che_필살 extends \sammo\BaseSpecial{
|
class che_필살 extends \sammo\BaseSpecial{
|
||||||
|
|
||||||
protected $id = 71;
|
protected $id = 71;
|
||||||
protected $name = '필살';
|
protected $name = '필살';
|
||||||
protected $info = '[전투] 필살 확률 +20%p, 필살 발동시 대상 회피 불가';
|
protected $info = '[전투] 필살 확률 +30%p, 필살 발동시 대상 회피 불가';
|
||||||
|
|
||||||
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
static $selectWeightType = SpecialityHelper::WEIGHT_NORM;
|
||||||
static $selectWeight = 1;
|
static $selectWeight = 1;
|
||||||
static $type = [
|
static $type = [
|
||||||
SpecialityHelper::STAT_LEADERSHIP,
|
SpecialityHelper::STAT_LEADERSHIP,
|
||||||
SpecialityHelper::STAT_STRENGTH,
|
SpecialityHelper::STAT_STRENGTH,
|
||||||
SpecialityHelper::STAT_INTEL
|
SpecialityHelper::STAT_INTEL
|
||||||
];
|
];
|
||||||
|
|
||||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||||
if($statName === 'warCriticalRatio'){
|
if($statName === 'warCriticalRatio'){
|
||||||
return $value + 0.2;
|
return $value + 0.30;
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
return new WarUnitTriggerCaller(
|
return new WarUnitTriggerCaller(
|
||||||
new che_필살강화_회피불가($unit)
|
new che_필살강화_회피불가($unit)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+104
-104
@@ -1,104 +1,104 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
abstract class BaseWarUnitTrigger extends ObjectTrigger{
|
abstract class BaseWarUnitTrigger extends ObjectTrigger{
|
||||||
/** @var WarUnit $object */
|
/** @var WarUnit $object */
|
||||||
|
|
||||||
const TYPE_NONE = 0;
|
const TYPE_NONE = 0;
|
||||||
const TYPE_ITEM = 1;
|
const TYPE_ITEM = 1;
|
||||||
const TYPE_CONSUMABLE_ITEM = 1 | 2;
|
const TYPE_CONSUMABLE_ITEM = 1 | 2;
|
||||||
|
|
||||||
protected $raiseType = self::TYPE_NONE;
|
protected $raiseType = self::TYPE_NONE;
|
||||||
|
|
||||||
public function __construct(WarUnit $unit, int $raiseType = 0){
|
public function __construct(WarUnit $unit, int $raiseType = 0){
|
||||||
$this->object = $unit;
|
$this->object = $unit;
|
||||||
$this->raiseType = $raiseType;
|
$this->raiseType = $raiseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUniqueID():string{
|
public function getUniqueID():string{
|
||||||
$priority = $this->priority;
|
$priority = $this->priority;
|
||||||
$fqn = static::class;
|
$fqn = static::class;
|
||||||
if($this->object === null){
|
if($this->object === null){
|
||||||
$objID = '';
|
$objID = '';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$objID = spl_object_id($this->object);
|
$objID = spl_object_id($this->object);
|
||||||
}
|
}
|
||||||
return "{$priority}_{$fqn}_{$objID}_{$this->raiseType}";
|
return "{$priority}_{$fqn}_{$objID}_{$this->raiseType}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action(?array $env=null, $arg=null):?array{
|
public function action(?array $env=null, $arg=null):?array{
|
||||||
if($env === null){
|
if($env === null){
|
||||||
$env = [];
|
$env = [];
|
||||||
}
|
}
|
||||||
if(!key_exists('e_attacker', $env)){
|
if(!key_exists('e_attacker', $env)){
|
||||||
$env['e_attacker'] = [];
|
$env['e_attacker'] = [];
|
||||||
}
|
}
|
||||||
if(!key_exists('e_defender', $env)){
|
if(!key_exists('e_defender', $env)){
|
||||||
$env['e_defender'] = [];
|
$env['e_defender'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($env['stopNextAction']??false){
|
if($env['stopNextAction']??false){
|
||||||
return $env;
|
return $env;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var WarUnitGeneral $attacker */
|
/** @var WarUnitGeneral $attacker */
|
||||||
/** @var WarUnit $defender */
|
/** @var WarUnit $defender */
|
||||||
[$attacker, $defender] = $arg;
|
[$attacker, $defender] = $arg;
|
||||||
|
|
||||||
/** @var WarUnit $self */
|
/** @var WarUnit $self */
|
||||||
$self = $this->object;
|
$self = $this->object;
|
||||||
$isAttacker = $self->isAttacker();
|
$isAttacker = $self->isAttacker();
|
||||||
$oppose = $isAttacker?$defender:$attacker;
|
$oppose = $isAttacker?$defender:$attacker;
|
||||||
|
|
||||||
$selfEnv = $isAttacker?$env['e_attacker']:$env['e_defender'];
|
$selfEnv = $isAttacker?$env['e_attacker']:$env['e_defender'];
|
||||||
$opposeEnv = $isAttacker?$env['e_defender']:$env['e_attacker'];
|
$opposeEnv = $isAttacker?$env['e_defender']:$env['e_attacker'];
|
||||||
|
|
||||||
$callNextAction = $this->actionWar($self, $oppose, $selfEnv, $opposeEnv);
|
$callNextAction = $this->actionWar($self, $oppose, $selfEnv, $opposeEnv);
|
||||||
|
|
||||||
$env['e_attacker'] = $isAttacker?$selfEnv:$opposeEnv;
|
$env['e_attacker'] = $isAttacker?$selfEnv:$opposeEnv;
|
||||||
$env['e_defender'] = $isAttacker?$opposeEnv:$selfEnv;
|
$env['e_defender'] = $isAttacker?$opposeEnv:$selfEnv;
|
||||||
|
|
||||||
if(!$callNextAction){
|
if(!$callNextAction){
|
||||||
$env['stopNextAction'] = true;
|
$env['stopNextAction'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $env;
|
return $env;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool;
|
abstract protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool;
|
||||||
|
|
||||||
public function processConsumableItem():bool{
|
public function processConsumableItem():bool{
|
||||||
if(!($this->raiseType & static::TYPE_ITEM)){
|
if(!($this->raiseType & static::TYPE_ITEM)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var WarUnit $self */
|
/** @var WarUnit $self */
|
||||||
$self = $this->object;
|
$self = $this->object;
|
||||||
|
|
||||||
if($self->hasActivatedSkill('아이템사용')){
|
if($self->hasActivatedSkill('아이템사용')){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->activateSkill('아이템사용');
|
$self->activateSkill('아이템사용');
|
||||||
$item = $self->getGeneral()->getItem();
|
$item = $self->getGeneral()->getItem();
|
||||||
$itemName = $item->getName();
|
$itemName = $item->getName();
|
||||||
$itemRawName = $item->getRawName();
|
$itemRawName = $item->getRawName();
|
||||||
$self->activateSkill($itemName);
|
$self->activateSkill($itemName);
|
||||||
|
|
||||||
if (!($this->raiseType & static::TYPE_CONSUMABLE_ITEM)) {
|
if ($this->raiseType != static::TYPE_CONSUMABLE_ITEM) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($self->hasActivatedSkill('아이템소모')){
|
if($self->hasActivatedSkill('아이템소모')){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->activateSkill('아이템소모');
|
$self->activateSkill('아이템소모');
|
||||||
$josaUl = JosaUtil::pick($itemRawName, '을');
|
$josaUl = JosaUtil::pick($itemRawName, '을');
|
||||||
$self->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
|
$self->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
|
||||||
$self->getGeneral()->deleteItem();
|
$self->getGeneral()->deleteItem();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use \sammo\Constraint\ConstraintHelper;
|
|||||||
abstract class BaseCommand{
|
abstract class BaseCommand{
|
||||||
static protected $actionName = 'CommandName';
|
static protected $actionName = 'CommandName';
|
||||||
static public $reqArg = false;
|
static public $reqArg = false;
|
||||||
|
static protected $isLazyCalcReqTurn = false;
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
return $this->getName();
|
return $this->getName();
|
||||||
@@ -54,7 +55,6 @@ abstract class BaseCommand{
|
|||||||
|
|
||||||
static protected $isInitStatic = true;
|
static protected $isInitStatic = true;
|
||||||
protected static function initStatic(){
|
protected static function initStatic(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(General $generalObj, array $env, $arg = null){
|
public function __construct(General $generalObj, array $env, $arg = null){
|
||||||
@@ -271,6 +271,29 @@ abstract class BaseCommand{
|
|||||||
return $this->logger;
|
return $this->logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract public function getNextExecuteKey():string;
|
||||||
|
abstract public function getNextAvailableTurn():?int;
|
||||||
|
abstract public function setNextAvailable(?int $yearMonth=null);
|
||||||
|
|
||||||
|
protected function testPostReqTurn():?array{
|
||||||
|
if(!$this->getPostReqTurn()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nextAvailableTurn = $this->getNextAvailableTurn();
|
||||||
|
if($nextAvailableTurn === null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
||||||
|
$remainTurn = $nextAvailableTurn - $yearMonth;
|
||||||
|
if($remainTurn <= 0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['testPostReqTurn', "{$remainTurn}턴 더 기다려야 합니다"];
|
||||||
|
}
|
||||||
|
|
||||||
public function testPermissionToReserve():?string{
|
public function testPermissionToReserve():?string{
|
||||||
if($this->cachedPermissionToReserve){
|
if($this->cachedPermissionToReserve){
|
||||||
return $this->reasonNoPermissionToReserve;
|
return $this->reasonNoPermissionToReserve;
|
||||||
@@ -331,6 +354,11 @@ abstract class BaseCommand{
|
|||||||
];
|
];
|
||||||
|
|
||||||
[$this->reasonConstraint, $this->reasonNotMinConditionMet] = Constraint::testAll($this->minConditionConstraints??[], $constraintInput, $this->env);
|
[$this->reasonConstraint, $this->reasonNotMinConditionMet] = Constraint::testAll($this->minConditionConstraints??[], $constraintInput, $this->env);
|
||||||
|
|
||||||
|
if($this->reasonNotMinConditionMet === null && !self::$isLazyCalcReqTurn){
|
||||||
|
[$this->reasonConstraint, $this->reasonNotMinConditionMet] = $this->testPostReqTurn();
|
||||||
|
}
|
||||||
|
|
||||||
$this->cachedMinConditionMet = true;
|
$this->cachedMinConditionMet = true;
|
||||||
return $this->reasonNotMinConditionMet;
|
return $this->reasonNotMinConditionMet;
|
||||||
|
|
||||||
@@ -364,6 +392,11 @@ abstract class BaseCommand{
|
|||||||
];
|
];
|
||||||
|
|
||||||
[$this->reasonConstraint, $this->reasonNotFullConditionMet] = Constraint::testAll($this->fullConditionConstraints??[], $constraintInput, $this->env);
|
[$this->reasonConstraint, $this->reasonNotFullConditionMet] = Constraint::testAll($this->fullConditionConstraints??[], $constraintInput, $this->env);
|
||||||
|
|
||||||
|
if($this->reasonNotFullConditionMet === null){
|
||||||
|
[$this->reasonConstraint, $this->reasonNotFullConditionMet] = $this->testPostReqTurn();
|
||||||
|
}
|
||||||
|
|
||||||
$this->cachedFullConditionMet = true;
|
$this->cachedFullConditionMet = true;
|
||||||
return $this->reasonNotFullConditionMet;
|
return $this->reasonNotFullConditionMet;
|
||||||
|
|
||||||
|
|||||||
@@ -1,137 +1,137 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
Command, GameConst
|
Command, GameConst
|
||||||
};
|
};
|
||||||
|
|
||||||
use function sammo\{
|
use function sammo\{
|
||||||
TechLimit,
|
TechLimit,
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_기술연구 extends che_상업투자{
|
class che_기술연구 extends che_상업투자{
|
||||||
static protected $statKey = 'intel';
|
static protected $statKey = 'intel';
|
||||||
static protected $actionKey = '기술';
|
static protected $actionKey = '기술';
|
||||||
static protected $actionName = '기술 연구';
|
static protected $actionName = '기술 연구';
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['tech']);
|
$this->setNation(['tech']);
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::NotWanderingNation(),
|
ConstraintHelper::NotWanderingNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice)
|
ConstraintHelper::ReqGeneralRice($reqRice)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reqGold = $reqGold;
|
$this->reqGold = $reqGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$trust = Util::valueFit($this->city['trust'], 50);
|
$trust = Util::valueFit($this->city['trust'], 50);
|
||||||
|
|
||||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||||
|
|
||||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||||
if($trust < 80){
|
if($trust < 80){
|
||||||
$successRatio *= $trust / 80;
|
$successRatio *= $trust / 80;
|
||||||
}
|
}
|
||||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
$failRatio = $general->onCalcDomestic(static::$actionKey, 'fail', $failRatio);
|
||||||
|
|
||||||
$successRatio = Util::valueFit($successRatio, 0, 1);
|
$successRatio = Util::valueFit($successRatio, 0, 1);
|
||||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||||
$normalRatio = 1 - $failRatio - $successRatio;
|
$normalRatio = 1 - $failRatio - $successRatio;
|
||||||
|
|
||||||
$pick = Util::choiceRandomUsingWeight([
|
$pick = Util::choiceRandomUsingWeight([
|
||||||
'fail'=>$failRatio,
|
'fail'=>$failRatio,
|
||||||
'success'=>$successRatio,
|
'success'=>$successRatio,
|
||||||
'normal'=>$normalRatio
|
'normal'=>$normalRatio
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$score *= CriticalScoreEx($pick);
|
$score *= CriticalScoreEx($pick);
|
||||||
$score = Util::round($score);
|
$score = Util::round($score);
|
||||||
|
|
||||||
$exp = $score * 0.7;
|
$exp = $score * 0.7;
|
||||||
$ded = $score * 1.0;
|
$ded = $score * 1.0;
|
||||||
|
|
||||||
$scoreText = number_format($score, 0);
|
$scoreText = number_format($score, 0);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||||
if($pick == 'fail'){
|
if($pick == 'fail'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else if($pick == 'success'){
|
else if($pick == 'success'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TechLimit($this->env['startyear'], $this->env['year'], $this->nation['tech'])){
|
if(TechLimit($this->env['startyear'], $this->env['year'], $this->nation['tech'])){
|
||||||
$score /= 4;
|
$score /= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
$genCount = Util::valueFit(
|
$genCount = Util::valueFit(
|
||||||
$db->queryFirstField('SELECT gennum FROM nation WHERE nation=%i', $general->getVar('nation')),
|
$db->queryFirstField('SELECT gennum FROM nation WHERE nation=%i', $general->getVar('nation')),
|
||||||
GameConst::$initialNationGenLimit
|
GameConst::$initialNationGenLimit
|
||||||
);
|
);
|
||||||
|
|
||||||
$nationUpdated = [
|
$nationUpdated = [
|
||||||
'tech' => $this->nation['tech'] + $score/$genCount
|
'tech' => $this->nation['tech'] + $score/$genCount
|
||||||
];
|
];
|
||||||
$db->update('nation', $nationUpdated, 'nation=%i', $general->getVar('nation'));
|
$db->update('nation', $nationUpdated, 'nation=%i', $general->getVar('nation'));
|
||||||
|
|
||||||
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
||||||
$general->addExperience($exp);
|
$general->addExperience($exp);
|
||||||
$general->addDedication($ded);
|
$general->addDedication($ded);
|
||||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,208 +1,208 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command
|
Command
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_상업투자 extends Command\GeneralCommand{
|
class che_상업투자 extends Command\GeneralCommand{
|
||||||
static protected $cityKey = 'comm';
|
static protected $cityKey = 'comm';
|
||||||
static protected $statKey = 'intel';
|
static protected $statKey = 'intel';
|
||||||
static protected $actionKey = '상업';
|
static protected $actionKey = '상업';
|
||||||
static protected $actionName = '상업 투자';
|
static protected $actionName = '상업 투자';
|
||||||
static protected $debuffFront = 0.5;
|
static protected $debuffFront = 0.5;
|
||||||
|
|
||||||
protected $reqGold;
|
protected $reqGold;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::NotWanderingNation(),
|
ConstraintHelper::NotWanderingNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
ConstraintHelper::RemainCityCapacity(static::$cityKey, static::$actionName)
|
ConstraintHelper::RemainCityCapacity(static::$cityKey, static::$actionName)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reqGold = $reqGold;
|
$this->reqGold = $reqGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$statTypeBase = [
|
$statTypeBase = [
|
||||||
'leadership'=>'통솔경험',
|
'leadership'=>'통솔경험',
|
||||||
'strength'=>'무력경험',
|
'strength'=>'무력경험',
|
||||||
'intel'=>'지력경험',
|
'intel'=>'지력경험',
|
||||||
];
|
];
|
||||||
$statType = $statTypeBase[static::$statKey];
|
$statType = $statTypeBase[static::$statKey];
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$title = "{$name}({$statType}";
|
$title = "{$name}({$statType}";
|
||||||
if($reqGold > 0){
|
if($reqGold > 0){
|
||||||
$title .= ", 자금{$reqGold}";
|
$title .= ", 자금{$reqGold}";
|
||||||
}
|
}
|
||||||
if($reqRice > 0){
|
if($reqRice > 0){
|
||||||
$title .= ", 군량{$reqRice}";
|
$title .= ", 군량{$reqRice}";
|
||||||
}
|
}
|
||||||
$title .= ')';
|
$title .= ')';
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
$develCost = $this->env['develcost'];
|
$develCost = $this->env['develcost'];
|
||||||
$reqGold = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
$reqGold = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
||||||
$reqRice = 0;
|
$reqRice = 0;
|
||||||
|
|
||||||
return [$reqGold, $reqRice];
|
return [$reqGold, $reqRice];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCompensationStyle():?int{
|
public function getCompensationStyle():?int{
|
||||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcBaseScore():float{
|
protected function calcBaseScore():float{
|
||||||
$trust = Util::valueFit($this->city['trust'], 50);
|
$trust = Util::valueFit($this->city['trust'], 50);
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
if(static::$statKey == 'intel'){
|
if(static::$statKey == 'intel'){
|
||||||
$score = $general->getIntel(true, true, true, false);
|
$score = $general->getIntel(true, true, true, false);
|
||||||
}
|
}
|
||||||
else if(static::$statKey == 'strength'){
|
else if(static::$statKey == 'strength'){
|
||||||
$score = $general->getStrength(true, true, true, false);
|
$score = $general->getStrength(true, true, true, false);
|
||||||
}
|
}
|
||||||
else if(static::$statKey == 'leadership'){
|
else if(static::$statKey == 'leadership'){
|
||||||
$score = $general->getLeadership(true, true, true, false);
|
$score = $general->getLeadership(true, true, true, false);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new \sammo\MustNotBeReachedException();
|
throw new \sammo\MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$score *= $trust / 100;
|
$score *= $trust / 100;
|
||||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||||
$score *= Util::randRange(0.8, 1.2);
|
$score *= Util::randRange(0.8, 1.2);
|
||||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||||
|
|
||||||
return $score;
|
return $score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$trust = Util::valueFit($this->city['trust'], 50);
|
$trust = Util::valueFit($this->city['trust'], 50);
|
||||||
|
|
||||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||||
|
|
||||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||||
if($trust < 80){
|
if($trust < 80){
|
||||||
$successRatio *= $trust / 80;
|
$successRatio *= $trust / 80;
|
||||||
}
|
}
|
||||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
$failRatio = $general->onCalcDomestic(static::$actionKey, 'fail', $failRatio);
|
||||||
|
|
||||||
$successRatio = Util::valueFit($successRatio, 0, 1);
|
$successRatio = Util::valueFit($successRatio, 0, 1);
|
||||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||||
$normalRatio = 1 - $failRatio - $successRatio;
|
$normalRatio = 1 - $failRatio - $successRatio;
|
||||||
|
|
||||||
$pick = Util::choiceRandomUsingWeight([
|
$pick = Util::choiceRandomUsingWeight([
|
||||||
'fail'=>$failRatio,
|
'fail'=>$failRatio,
|
||||||
'success'=>$successRatio,
|
'success'=>$successRatio,
|
||||||
'normal'=>$normalRatio
|
'normal'=>$normalRatio
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$score *= CriticalScoreEx($pick);
|
$score *= CriticalScoreEx($pick);
|
||||||
$score = Util::round($score);
|
$score = Util::round($score);
|
||||||
|
|
||||||
$exp = $score * 0.7;
|
$exp = $score * 0.7;
|
||||||
$ded = $score * 1.0;
|
$ded = $score * 1.0;
|
||||||
|
|
||||||
$scoreText = number_format($score, 0);
|
$scoreText = number_format($score, 0);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||||
if($pick == 'fail'){
|
if($pick == 'fail'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else if($pick == 'success'){
|
else if($pick == 'success'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_array($this->city['front'], [1, 3]) && $this->nation['capital'] != $this->city['city']){
|
if(in_array($this->city['front'], [1, 3]) && $this->nation['capital'] != $this->city['city']){
|
||||||
$score *= static::$debuffFront;
|
$score *= static::$debuffFront;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: 내정량 상승시 초과 가능?
|
//NOTE: 내정량 상승시 초과 가능?
|
||||||
$cityUpdated = [
|
$cityUpdated = [
|
||||||
static::$cityKey => Util::valueFit(
|
static::$cityKey => Util::valueFit(
|
||||||
$this->city[static::$cityKey] + $score,
|
$this->city[static::$cityKey] + $score,
|
||||||
0,
|
0,
|
||||||
$this->city[static::$cityKey.'_max']
|
$this->city[static::$cityKey.'_max']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
||||||
|
|
||||||
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
||||||
$general->addExperience($exp);
|
$general->addExperience($exp);
|
||||||
$general->addDedication($ded);
|
$general->addDedication($ded);
|
||||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,242 +1,242 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use\sammo\{
|
use\sammo\{
|
||||||
DB,
|
DB,
|
||||||
Util,
|
Util,
|
||||||
JosaUtil,
|
JosaUtil,
|
||||||
Session,
|
Session,
|
||||||
KVStorage,
|
KVStorage,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
Command,
|
Command,
|
||||||
ServConfig
|
ServConfig
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
use function\sammo\{
|
use function\sammo\{
|
||||||
getDexCall,
|
getDexCall,
|
||||||
getTechCall,
|
getTechCall,
|
||||||
tryUniqueItemLottery,
|
tryUniqueItemLottery,
|
||||||
getTechAbil
|
getTechAbil
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class che_숙련전환 extends Command\GeneralCommand
|
class che_숙련전환 extends Command\GeneralCommand
|
||||||
{
|
{
|
||||||
static protected $actionName = '숙련전환';
|
static protected $actionName = '숙련전환';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $srcArmType;
|
protected $srcArmType;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $srcArmTypeName;
|
protected $srcArmTypeName;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $destArmType;
|
protected $destArmType;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $destArmTypeName;
|
protected $destArmTypeName;
|
||||||
|
|
||||||
protected function argTest(): bool
|
protected function argTest(): bool
|
||||||
{
|
{
|
||||||
if ($this->arg === null) {
|
if ($this->arg === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!key_exists('srcArmType', $this->arg)) {
|
if (!key_exists('srcArmType', $this->arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!key_exists('destArmType', $this->arg)) {
|
if (!key_exists('destArmType', $this->arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$srcArmType = $this->arg['srcArmType'];
|
$srcArmType = $this->arg['srcArmType'];
|
||||||
$destArmType = $this->arg['destArmType'];
|
$destArmType = $this->arg['destArmType'];
|
||||||
|
|
||||||
if (!is_int($srcArmType)) {
|
if (!is_int($srcArmType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!key_exists($srcArmType, GameUnitConst::allType())) {
|
if (!key_exists($srcArmType, GameUnitConst::allType())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_int($destArmType)) {
|
if (!is_int($destArmType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!key_exists($destArmType, GameUnitConst::allType())) {
|
if (!key_exists($destArmType, GameUnitConst::allType())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($srcArmType === $destArmType) {
|
if ($srcArmType === $destArmType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->arg = [
|
$this->arg = [
|
||||||
'srcArmType' => $srcArmType,
|
'srcArmType' => $srcArmType,
|
||||||
'destArmType' => $destArmType
|
'destArmType' => $destArmType
|
||||||
];
|
];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
|
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->minConditionConstraints = [
|
$this->minConditionConstraints = [
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$this->srcArmType = $this->arg['srcArmType'];
|
$this->srcArmType = $this->arg['srcArmType'];
|
||||||
$this->srcArmTypeName = GameUnitConst::allType()[$this->srcArmType];
|
$this->srcArmTypeName = GameUnitConst::allType()[$this->srcArmType];
|
||||||
$this->destArmType = $this->arg['destArmType'];
|
$this->destArmType = $this->arg['destArmType'];
|
||||||
$this->destArmTypeName = GameUnitConst::allType()[$this->destArmType];
|
$this->destArmTypeName = GameUnitConst::allType()[$this->destArmType];
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints = [
|
$this->fullConditionConstraints = [
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrief(): string
|
public function getBrief(): string
|
||||||
{
|
{
|
||||||
return "【{$this->srcArmTypeName}】숙련을 【{$this->destArmTypeName}】숙련으로 전환";
|
return "【{$this->srcArmTypeName}】숙련을 【{$this->destArmTypeName}】숙련으로 전환";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle(): string
|
public function getCommandDetailTitle(): string
|
||||||
{
|
{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$title = "{$name}(통솔경험";
|
$title = "{$name}(통솔경험";
|
||||||
if ($reqGold > 0) {
|
if ($reqGold > 0) {
|
||||||
$title .= ", 자금{$reqGold}";
|
$title .= ", 자금{$reqGold}";
|
||||||
}
|
}
|
||||||
if ($reqRice > 0) {
|
if ($reqRice > 0) {
|
||||||
$title .= ", 군량{$reqRice}";
|
$title .= ", 군량{$reqRice}";
|
||||||
}
|
}
|
||||||
$title .= ')';
|
$title .= ')';
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost(): array
|
public function getCost(): array
|
||||||
{
|
{
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
return [$env['develcost'], $env['develcost']];
|
return [$env['develcost'], $env['develcost']];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn(): int
|
public function getPreReqTurn(): int
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn(): int
|
public function getPostReqTurn(): int
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(): bool
|
public function run(): bool
|
||||||
{
|
{
|
||||||
if (!$this->hasFullConditionMet()) {
|
if (!$this->hasFullConditionMet()) {
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$srcDex = $general->getVar('dex' . $this->srcArmType);
|
$srcDex = $general->getVar('dex' . $this->srcArmType);
|
||||||
$cutDex = Util::toInt($srcDex * 0.25);
|
$cutDex = Util::toInt($srcDex * 0.4);
|
||||||
$cutDexText = number_format($cutDex);
|
$cutDexText = number_format($cutDex);
|
||||||
$addDex = Util::toInt($cutDex * 9 / 10);
|
$addDex = Util::toInt($cutDex * 9 / 10);
|
||||||
$addDexText = number_format($addDex);
|
$addDexText = number_format($addDex);
|
||||||
|
|
||||||
$general->increaseVar('dex' . $this->srcArmType, -$cutDex);
|
$general->increaseVar('dex' . $this->srcArmType, -$cutDex);
|
||||||
$general->increaseVar('dex' . $this->destArmType, $addDex);
|
$general->increaseVar('dex' . $this->destArmType, $addDex);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick($cutDex, '을');
|
$josaUl = JosaUtil::pick($cutDex, '을');
|
||||||
$josaRo = JosaUtil::pick($addDex, '로');
|
$josaRo = JosaUtil::pick($addDex, '로');
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$logger->pushGeneralActionLog("{$this->srcArmTypeName} 숙련 {$cutDexText}{$josaUl} {$this->destArmTypeName} 숙련 {$addDexText}{$josaRo} 전환했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog("{$this->srcArmTypeName} 숙련 {$cutDexText}{$josaUl} {$this->destArmTypeName} 숙련 {$addDexText}{$josaRo} 전환했습니다. <1>$date</>");
|
||||||
|
|
||||||
$general->addExperience(10);
|
$general->addExperience(10);
|
||||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||||
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
||||||
$general->increaseVar('leadership_exp', 2);
|
$general->increaseVar('leadership_exp', 2);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getForm(): string
|
public function getForm(): string
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$dexSrcTexts = [];
|
$dexSrcTexts = [];
|
||||||
$dexDestTexts = [];
|
$dexDestTexts = [];
|
||||||
foreach (GameUnitConst::allType() as $armType => $armName) {
|
foreach (GameUnitConst::allType() as $armType => $armName) {
|
||||||
$dexVal = $general->getVar('dex' . $armType);
|
$dexVal = $general->getVar('dex' . $armType);
|
||||||
$dexValText = number_format($dexVal);
|
$dexValText = number_format($dexVal);
|
||||||
$cutDex = Util::toInt($dexVal * 0.25);
|
$cutDex = Util::toInt($dexVal * 0.4);
|
||||||
$addDex = Util::toInt($cutDex * 9 / 10);
|
$addDex = Util::toInt($cutDex * 9 / 10);
|
||||||
$addDexText = number_format($addDex);
|
$addDexText = number_format($addDex);
|
||||||
$newDex = $dexVal - $cutDex;
|
$newDex = $dexVal - $cutDex;
|
||||||
$beforeDexLevel = getDexCall($dexVal);
|
$beforeDexLevel = getDexCall($dexVal);
|
||||||
$afterDexLevel = getDexCall($newDex);
|
$afterDexLevel = getDexCall($newDex);
|
||||||
|
|
||||||
$dexSrcTexts[$armType] = "{$armName} ({$beforeDexLevel} ⇒ {$afterDexLevel}, {$addDexText} 전환)";
|
$dexSrcTexts[$armType] = "{$armName} ({$beforeDexLevel} ⇒ {$afterDexLevel}, {$addDexText} 전환)";
|
||||||
$dexDestTexts[$armType] = "{$armName} ({$dexValText})";
|
$dexDestTexts[$armType] = "{$armName} ({$dexValText})";
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
본인의 특정 병종 숙련을 25% 줄이고, 줄어든 숙련 중 9/10(90%p)를 다른 병종 숙련으로 전환합니다.<br>
|
본인의 특정 병종 숙련을 40% 줄이고, 줄어든 숙련 중 9/10(90%p)를 다른 병종 숙련으로 전환합니다.<br>
|
||||||
|
|
||||||
<select class='formInput' name="srcArmType" id="srcArmType" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="srcArmType" id="srcArmType" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach ($dexSrcTexts as $armType => $infoText) : ?>
|
<?php foreach ($dexSrcTexts as $armType => $infoText) : ?>
|
||||||
<option value="<?= $armType ?>"><?= $infoText ?></option>
|
<option value="<?= $armType ?>"><?= $infoText ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
숙련을
|
숙련을
|
||||||
|
|
||||||
<select class='formInput' name="destArmType" id="destArmType" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="destArmType" id="destArmType" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach ($dexDestTexts as $armType => $infoText) : ?>
|
<?php foreach ($dexDestTexts as $armType => $infoText) : ?>
|
||||||
<option value="<?= $armType ?>"><?= $infoText ?></option>
|
<option value="<?= $armType ?>"><?= $infoText ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
숙련으로 <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
|
숙련으로 <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,300 +1,292 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use\sammo\{
|
use\sammo\{
|
||||||
DB,
|
DB,
|
||||||
Util,
|
Util,
|
||||||
JosaUtil,
|
JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command
|
Command
|
||||||
};
|
};
|
||||||
|
|
||||||
use function\sammo\{
|
use function\sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery,
|
tryUniqueItemLottery,
|
||||||
getAllNationStaticInfo
|
getAllNationStaticInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_인재탐색 extends Command\GeneralCommand
|
class che_인재탐색 extends Command\GeneralCommand
|
||||||
{
|
{
|
||||||
static protected $actionName = '인재탐색';
|
static protected $actionName = '인재탐색';
|
||||||
|
|
||||||
protected function argTest(): bool
|
protected function argTest(): bool
|
||||||
{
|
{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints = [
|
$this->fullConditionConstraints = [
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle(): string
|
public function getCommandDetailTitle(): string
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$maxGenCnt = $env['maxgeneral'];
|
$maxGenCnt = $env['maxgeneral'];
|
||||||
$totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2');
|
$totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2');
|
||||||
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
||||||
|
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$foundProp = $this->calcFoundProp($maxGenCnt, $totalGenCnt, $totalNpcCnt);
|
$foundProp = $this->calcFoundProp($maxGenCnt, $totalGenCnt, $totalNpcCnt);
|
||||||
$foundPropText = number_format($foundProp * 100, 1);
|
$foundPropText = number_format($foundProp * 100, 1);
|
||||||
|
|
||||||
$title = "{$name}(랜덤경험";
|
$title = "{$name}(랜덤경험";
|
||||||
if ($reqGold > 0) {
|
if ($reqGold > 0) {
|
||||||
$title .= ", 자금{$reqGold}";
|
$title .= ", 자금{$reqGold}";
|
||||||
}
|
}
|
||||||
if ($reqRice > 0) {
|
if ($reqRice > 0) {
|
||||||
$title .= ", 군량{$reqRice}";
|
$title .= ", 군량{$reqRice}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$title .= ", 확률 {$foundPropText}%)";
|
$title .= ", 확률 {$foundPropText}%)";
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost(): array
|
public function getCost(): array
|
||||||
{
|
{
|
||||||
return [$this->env['develcost'], 0];
|
return [$this->env['develcost'], 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn(): int
|
public function getPreReqTurn(): int
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn(): int
|
public function getPostReqTurn(): int
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calcFoundProp(int $maxGenCnt, int $totalGenCnt, int $totalNpcCnt): float
|
public function calcFoundProp(int $maxGenCnt, int $totalGenCnt, int $totalNpcCnt): float
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2);
|
$currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2);
|
||||||
$remainSlot = $maxGenCnt - $currCnt;
|
$remainSlot = $maxGenCnt - $currCnt;
|
||||||
if ($remainSlot < 0) {
|
if ($remainSlot < 0) {
|
||||||
$remainSlot = 0;
|
$remainSlot = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$foundPropMain = pow($remainSlot / $maxGenCnt, 6);
|
$foundPropMain = pow($remainSlot / $maxGenCnt, 6);
|
||||||
$foundPropSmall = 1 / ($totalNpcCnt / 3 + 1);
|
$foundPropSmall = 1 / ($totalNpcCnt / 3 + 1);
|
||||||
$foundPropBig = 1 / $maxGenCnt;
|
$foundPropBig = 1 / $maxGenCnt;
|
||||||
|
|
||||||
if ($totalNpcCnt < 50) {
|
if ($totalNpcCnt < 50) {
|
||||||
$foundProp = max($foundPropMain, $foundPropSmall);
|
$foundProp = max($foundPropMain, $foundPropSmall);
|
||||||
} else {
|
} else {
|
||||||
$foundProp = max($foundPropMain, $foundPropBig);
|
$foundProp = max($foundPropMain, $foundPropBig);
|
||||||
}
|
}
|
||||||
return $foundProp;
|
return $foundProp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(): bool
|
public function run(): bool
|
||||||
{
|
{
|
||||||
if (!$this->hasFullConditionMet()) {
|
if (!$this->hasFullConditionMet()) {
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
$relYear = $env['year'] - $env['startyear'];
|
$relYear = $env['year'] - $env['startyear'];
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$nationID = $general->getNationID();
|
$nationID = $general->getNationID();
|
||||||
|
|
||||||
$nationCnt = count(getAllNationStaticInfo());
|
$totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2');
|
||||||
|
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
||||||
$totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2');
|
|
||||||
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
$foundNpc = Util::randBool($this->calcFoundProp($env['maxgeneral'], $totalGenCnt, $totalNpcCnt));
|
||||||
|
|
||||||
$genCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc < 2', $nationID);
|
$logger = $general->getLogger();
|
||||||
$npcCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND 3 <= npc AND npc <= 4', $nationID);
|
|
||||||
|
if (!$foundNpc) {
|
||||||
$currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2);
|
$logger->pushGeneralActionLog("인재를 찾을 수 없었습니다. <1>$date</>");
|
||||||
$avgCnt = $currCnt / $nationCnt;
|
|
||||||
|
$incStat = Util::choiceRandomUsingWeight([
|
||||||
$foundNpc = Util::randBool($this->calcFoundProp($env['maxgeneral'], $totalGenCnt, $totalNpcCnt));
|
'leadership_exp' => $general->getLeadership(false, false, false, false),
|
||||||
|
'strength_exp' => $general->getStrength(false, false, false, false),
|
||||||
$logger = $general->getLogger();
|
'intel_exp' => $general->getIntel(false, false, false, false)
|
||||||
|
]);
|
||||||
if (!$foundNpc) {
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
$logger->pushGeneralActionLog("인재를 찾을 수 없었습니다. <1>$date</>");
|
|
||||||
|
$exp = 100;
|
||||||
$incStat = Util::choiceRandomUsingWeight([
|
$ded = 70;
|
||||||
'leadership_exp' => $general->getLeadership(false, false, false, false),
|
|
||||||
'strength_exp' => $general->getStrength(false, false, false, false),
|
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||||
'intel_exp' => $general->getIntel(false, false, false, false)
|
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
||||||
]);
|
$general->addExperience($exp);
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
$general->addDedication($ded);
|
||||||
|
$general->increaseVar($incStat, 1);
|
||||||
$exp = 100;
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$ded = 70;
|
$general->checkStatChange();
|
||||||
|
tryUniqueItemLottery($general);
|
||||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
$general->applyDB($db);
|
||||||
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
return true;
|
||||||
$general->addExperience($exp);
|
}
|
||||||
$general->addDedication($ded);
|
//인간적으로 너무 길어서 끊었다!
|
||||||
$general->increaseVar($incStat, 1);
|
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$exp = 200;
|
||||||
$general->checkStatChange();
|
$ded = 300;
|
||||||
tryUniqueItemLottery($general);
|
|
||||||
$general->applyDB($db);
|
$pickTypeList = ['무' => 6, '지' => 6, '무지' => 3];
|
||||||
return true;
|
|
||||||
}
|
$pickType = Util::choiceRandomUsingWeight($pickTypeList);
|
||||||
//인간적으로 너무 길어서 끊었다!
|
|
||||||
|
$totalStat = GameConst::$defaultStatNPCTotal;
|
||||||
$exp = 200;
|
$minStat = GameConst::$defaultStatNPCMin;
|
||||||
$ded = 300;
|
$mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, GameConst::$defaultStatNPCMin);
|
||||||
|
$otherStat = $minStat + Util::randRangeInt(0, Util::toInt(GameConst::$defaultStatNPCMin/2));
|
||||||
$pickTypeList = ['무' => 6, '지' => 6, '무지' => 3];
|
$subStat = $totalStat - $mainStat - $otherStat;
|
||||||
|
if ($subStat < $minStat) {
|
||||||
$pickType = Util::choiceRandomUsingWeight($pickTypeList);
|
$subStat = $otherStat;
|
||||||
|
$otherStat = $minStat;
|
||||||
$totalStat = GameConst::$defaultStatNPCTotal;
|
$mainStat = $totalStat - $subStat - $otherStat;
|
||||||
$minStat = GameConst::$defaultStatNPCMin;
|
if ($mainStat) {
|
||||||
$mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, GameConst::$defaultStatNPCMin);
|
throw new \LogicException('기본 스탯 설정값이 잘못되어 있음');
|
||||||
$otherStat = $minStat + Util::randRangeInt(0, Util::toInt(GameConst::$defaultStatNPCMin/2));
|
}
|
||||||
$subStat = $totalStat - $mainStat - $otherStat;
|
}
|
||||||
if ($subStat < $minStat) {
|
|
||||||
$subStat = $otherStat;
|
$avgGen = $db->queryFirstRow(
|
||||||
$otherStat = $minStat;
|
'SELECT avg(dedication) as ded,avg(experience) as exp,
|
||||||
$mainStat = $totalStat - $subStat - $otherStat;
|
avg(dex1+dex2+dex3+dex4) as dex_t, avg(age) as age, avg(dex5) as dex5
|
||||||
if ($mainStat) {
|
from general where npc < 5',
|
||||||
throw new \LogicException('기본 스탯 설정값이 잘못되어 있음');
|
$nationID
|
||||||
}
|
);
|
||||||
}
|
$dexTotal = $avgGen['dex_t'];
|
||||||
|
|
||||||
$avgGen = $db->queryFirstRow(
|
if ($pickType == '무') {
|
||||||
'SELECT avg(dedication) as ded,avg(experience) as exp,
|
$leadership = $subStat;
|
||||||
avg(dex1+dex2+dex3+dex4) as dex_t, avg(age) as age, avg(dex5) as dex5
|
$strength = $mainStat;
|
||||||
from general where npc < 5',
|
$intel = $otherStat;
|
||||||
$nationID
|
$dexVal = Util::choiceRandom([
|
||||||
);
|
[$dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8, $dexTotal / 8],
|
||||||
$dexTotal = $avgGen['dex_t'];
|
[$dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8],
|
||||||
|
[$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8],
|
||||||
if ($pickType == '무') {
|
]);
|
||||||
$leadership = $subStat;
|
} else if ($pickType == '지') {
|
||||||
$strength = $mainStat;
|
$leadership = $subStat;
|
||||||
$intel = $otherStat;
|
$strength = $otherStat;
|
||||||
$dexVal = Util::choiceRandom([
|
$intel = $mainStat;
|
||||||
[$dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8, $dexTotal / 8],
|
$dexVal = [$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8];
|
||||||
[$dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8],
|
} else {
|
||||||
[$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8],
|
$leadership = $otherStat;
|
||||||
]);
|
$strength = $subStat;
|
||||||
} else if ($pickType == '지') {
|
$intel = $mainStat;
|
||||||
$leadership = $subStat;
|
$dexVal = [$dexTotal / 4, $dexTotal / 4, $dexTotal / 4, $dexTotal / 4];
|
||||||
$strength = $otherStat;
|
}
|
||||||
$intel = $mainStat;
|
|
||||||
$dexVal = [$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8];
|
$leadership = Util::round($leadership);
|
||||||
} else {
|
$strength = Util::round($strength);
|
||||||
$leadership = $otherStat;
|
$intel = Util::round($intel);
|
||||||
$strength = $subStat;
|
|
||||||
$intel = $mainStat;
|
$scoutType = "발견";
|
||||||
$dexVal = [$dexTotal / 4, $dexTotal / 4, $dexTotal / 4, $dexTotal / 4];
|
$scoutLevel = 0;
|
||||||
}
|
$scoutNation = 0;
|
||||||
|
|
||||||
$leadership = Util::round($leadership);
|
$age = Util::randRangeInt(20, 25);
|
||||||
$strength = Util::round($strength);
|
$birthYear = $env['year'] - $age;
|
||||||
$intel = Util::round($intel);
|
$deathYear = $env['year'] + Util::randRangeInt(10, 50);
|
||||||
|
|
||||||
$scoutType = "발견";
|
$cityID = Util::choiceRandom(array_keys(\sammo\CityConst::all()));
|
||||||
$scoutLevel = 0;
|
$newNPC = new \sammo\Scenario\NPC(
|
||||||
$scoutNation = 0;
|
Util::randRangeInt(1, 150),
|
||||||
|
\sammo\getRandGenName(),
|
||||||
$age = Util::randRangeInt(20, 25);
|
null,
|
||||||
$birthYear = $env['year'] - $age;
|
$scoutNation,
|
||||||
$deathYear = $env['year'] + Util::randRangeInt(10, 50);
|
$cityID,
|
||||||
|
$leadership,
|
||||||
$cityID = Util::choiceRandom(array_keys(\sammo\CityConst::all()));
|
$strength,
|
||||||
$newNPC = new \sammo\Scenario\NPC(
|
$intel,
|
||||||
Util::randRangeInt(1, 150),
|
$scoutLevel,
|
||||||
\sammo\getRandGenName(),
|
$birthYear,
|
||||||
null,
|
$deathYear,
|
||||||
$scoutNation,
|
null,
|
||||||
$cityID,
|
null
|
||||||
$leadership,
|
);
|
||||||
$strength,
|
$newNPC->npc = 3;
|
||||||
$intel,
|
$newNPC->setMoney(1000, 1000);
|
||||||
$scoutLevel,
|
$newNPC->setExpDed($avgGen['exp'], $avgGen['ded']);
|
||||||
$birthYear,
|
$newNPC->setSpecYear(
|
||||||
$deathYear,
|
Util::round((GameConst::$retirementYear - $age) / 12) + $age,
|
||||||
null,
|
Util::round((GameConst::$retirementYear - $age) / 6) + $age
|
||||||
null
|
);
|
||||||
);
|
$newNPC->setDex(
|
||||||
$newNPC->npc = 3;
|
$dexVal[0],
|
||||||
$newNPC->setMoney(1000, 1000);
|
$dexVal[1],
|
||||||
$newNPC->setExpDed($avgGen['exp'], $avgGen['ded']);
|
$dexVal[2],
|
||||||
$newNPC->setSpecYear(
|
$dexVal[3],
|
||||||
Util::round((GameConst::$retirementYear - $age) / 12) + $age,
|
$avgGen['dex5']
|
||||||
Util::round((GameConst::$retirementYear - $age) / 6) + $age
|
);
|
||||||
);
|
|
||||||
$newNPC->setDex(
|
$newNPC->build($this->env);
|
||||||
$dexVal[0],
|
$npcName = $newNPC->realName;
|
||||||
$dexVal[1],
|
$josaRa = JosaUtil::pick($npcName, '라');
|
||||||
$dexVal[2],
|
|
||||||
$dexVal[3],
|
$generalName = $general->getName();
|
||||||
$avgGen['dex5']
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
);
|
|
||||||
|
$logger->pushGeneralActionLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다! <1>$date</>");
|
||||||
$newNPC->build($this->env);
|
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다!");
|
||||||
$npcName = $newNPC->realName;
|
$logger->pushGeneralHistoryLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}");
|
||||||
$josaRa = JosaUtil::pick($npcName, '라');
|
|
||||||
|
$incStat = Util::choiceRandomUsingWeight([
|
||||||
$generalName = $general->getName();
|
'leadership_exp' => $general->getLeadership(false, false, false, false),
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
'strength_exp' => $general->getStrength(false, false, false, false),
|
||||||
|
'intel_exp' => $general->getIntel(false, false, false, false)
|
||||||
$logger->pushGeneralActionLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다! <1>$date</>");
|
]);
|
||||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다!");
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
$logger->pushGeneralHistoryLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}");
|
|
||||||
|
$exp = 200;
|
||||||
$incStat = Util::choiceRandomUsingWeight([
|
$ded = 300;
|
||||||
'leadership_exp' => $general->getLeadership(false, false, false, false),
|
|
||||||
'strength_exp' => $general->getStrength(false, false, false, false),
|
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||||
'intel_exp' => $general->getIntel(false, false, false, false)
|
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
||||||
]);
|
$general->addExperience($exp);
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
$general->addDedication($ded);
|
||||||
|
$general->increaseVar($incStat, 3);
|
||||||
$exp = 200;
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$ded = 300;
|
$general->checkStatChange();
|
||||||
|
tryUniqueItemLottery($general);
|
||||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
$general->applyDB($db);
|
||||||
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
return true;
|
||||||
$general->addExperience($exp);
|
}
|
||||||
$general->addDedication($ded);
|
}
|
||||||
$general->increaseVar($incStat, 3);
|
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
|
||||||
$general->checkStatChange();
|
|
||||||
tryUniqueItemLottery($general);
|
|
||||||
$general->applyDB($db);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,130 +1,110 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst, GameUnitConst,
|
GameConst, GameUnitConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
Command
|
Command
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class che_전투특기초기화 extends Command\GeneralCommand{
|
class che_전투특기초기화 extends Command\GeneralCommand{
|
||||||
static protected $actionName = '전투 특기 초기화';
|
static protected $actionName = '전투 특기 초기화';
|
||||||
static protected $specialType = 'special2';
|
static protected $specialType = 'special2';
|
||||||
static protected $speicalAge = 'specage2';
|
static protected $speicalAge = 'specage2';
|
||||||
static protected $specialText = '전투 특기';
|
static protected $specialText = '전투 특기';
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
|
$this->minConditionConstraints=[
|
||||||
$general = $this->generalObj;
|
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'),
|
||||||
$env = $this->env;
|
];
|
||||||
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
|
|
||||||
$auxYearMonth = $general->getAuxVar('used_'.$this->getName())??-999;
|
$this->fullConditionConstraints=[
|
||||||
|
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.')
|
||||||
if($yearMonth < $auxYearMonth + 60){
|
];
|
||||||
$this->minConditionConstraints=[
|
}
|
||||||
ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다')
|
|
||||||
];
|
public function getCommandDetailTitle():string{
|
||||||
|
$name = $this->getName();
|
||||||
$this->fullConditionConstraints=[
|
if($this->getPreReqTurn()){
|
||||||
ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다')
|
$reqTurn = ($this->getPreReqTurn()+1).'턴, ';
|
||||||
];
|
}
|
||||||
return;
|
else{
|
||||||
}
|
$reqTurn = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$this->minConditionConstraints=[
|
$title = "{$name}({$reqTurn}5년마다 1회)";
|
||||||
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'),
|
return $title;
|
||||||
];
|
}
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
public function getCost():array{
|
||||||
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.')
|
return [0, 0];
|
||||||
];
|
}
|
||||||
|
|
||||||
}
|
public function getPreReqTurn():int{
|
||||||
|
return 1;
|
||||||
public function getCommandDetailTitle():string{
|
}
|
||||||
$name = $this->getName();
|
|
||||||
if($this->getPreReqTurn()){
|
public function getPostReqTurn():int{
|
||||||
$reqTurn = ($this->getPreReqTurn()+1).'턴, ';
|
return 60;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$reqTurn = 0;
|
public function getTermString():string{
|
||||||
}
|
$term = $this->getResultTurn()->getTerm();
|
||||||
|
$termMax = $this->getPreReqTurn() + 1;
|
||||||
$title = "{$name}({$reqTurn}5년마다 1회)";
|
return "새로운 적성을 찾는 중... ({$term}/{$termMax})";
|
||||||
return $title;
|
}
|
||||||
}
|
|
||||||
|
public function run():bool{
|
||||||
public function getCost():array{
|
if(!$this->hasFullConditionMet()){
|
||||||
return [0, 0];
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
$db = DB::db();
|
||||||
return 1;
|
|
||||||
}
|
$general = $this->generalObj;
|
||||||
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
public function getPostReqTurn():int{
|
|
||||||
return 0;
|
$oldTypeKey = 'prev_types_'.static::$specialType;
|
||||||
}
|
$specialName = static::$specialText;
|
||||||
|
|
||||||
public function getTermString():string{
|
$env = $this->env;
|
||||||
$term = $this->getResultTurn()->getTerm();
|
|
||||||
$termMax = $this->getPreReqTurn() + 1;
|
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
|
||||||
return "새로운 적성을 찾는 중... ({$term}/{$termMax})";
|
$oldSpecialList = $general->getAuxVar($oldTypeKey)??[];
|
||||||
}
|
$oldSpecialList[] = $general->getVar(static::$specialType);
|
||||||
|
$general->setAuxVar($oldTypeKey, $oldSpecialList);
|
||||||
public function run():bool{
|
|
||||||
if(!$this->hasFullConditionMet()){
|
$general->setVar(static::$specialType, 'None');
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
$general->setVar(static::$speicalAge, $general->getVar('age') + 1);
|
||||||
}
|
|
||||||
|
$logger = $general->getLogger();
|
||||||
$db = DB::db();
|
|
||||||
|
$logger->pushGeneralActionLog("새로운 {$specialName}를 가질 준비가 되었습니다. <1>$date</>");
|
||||||
$general = $this->generalObj;
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
|
tryUniqueItemLottery($general);
|
||||||
$oldTypeKey = 'prev_types_'.static::$specialType;
|
$general->applyDB($db);
|
||||||
$specialName = static::$specialText;
|
|
||||||
|
return true;
|
||||||
$env = $this->env;
|
}
|
||||||
|
|
||||||
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
|
|
||||||
$oldSpecialList = $general->getAuxVar($oldTypeKey)??[];
|
|
||||||
$oldSpecialList[] = $general->getVar(static::$specialType);
|
|
||||||
$general->setAuxVar($oldTypeKey, $oldSpecialList);
|
|
||||||
|
|
||||||
$general->setVar(static::$specialType, 'None');
|
|
||||||
$general->setVar(static::$speicalAge, $general->getVar('age') + 1);
|
|
||||||
$general->setAuxVar('used_'.$this->getName(), $yearMonth);
|
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
|
||||||
|
|
||||||
$logger->pushGeneralActionLog("새로운 {$specialName}를 가질 준비가 되었습니다. <1>$date</>");
|
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
|
||||||
tryUniqueItemLottery($general);
|
|
||||||
$general->applyDB($db);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,191 +1,191 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command
|
Command
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_정착장려 extends Command\GeneralCommand{
|
class che_정착장려 extends Command\GeneralCommand{
|
||||||
static protected $cityKey = 'pop';
|
static protected $cityKey = 'pop';
|
||||||
static protected $statKey = 'leadership';
|
static protected $statKey = 'leadership';
|
||||||
static protected $actionKey = '인구';
|
static protected $actionKey = '인구';
|
||||||
static protected $actionName = '정착 장려';
|
static protected $actionName = '정착 장려';
|
||||||
|
|
||||||
protected $reqRice;
|
protected $reqRice;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::NotWanderingNation(),
|
ConstraintHelper::NotWanderingNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
ConstraintHelper::RemainCityCapacity(static::$cityKey, static::$actionName)
|
ConstraintHelper::RemainCityCapacity(static::$cityKey, static::$actionName)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reqRice = $reqRice;
|
$this->reqRice = $reqRice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$statTypeBase = [
|
$statTypeBase = [
|
||||||
'leadership'=>'통솔경험',
|
'leadership'=>'통솔경험',
|
||||||
'strength'=>'무력경험',
|
'strength'=>'무력경험',
|
||||||
'intel'=>'지력경험',
|
'intel'=>'지력경험',
|
||||||
];
|
];
|
||||||
$statType = $statTypeBase[static::$statKey];
|
$statType = $statTypeBase[static::$statKey];
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$title = "{$name}({$statType}";
|
$title = "{$name}({$statType}";
|
||||||
if($reqGold > 0){
|
if($reqGold > 0){
|
||||||
$title .= ", 자금{$reqGold}";
|
$title .= ", 자금{$reqGold}";
|
||||||
}
|
}
|
||||||
if($reqRice > 0){
|
if($reqRice > 0){
|
||||||
$title .= ", 군량{$reqRice}";
|
$title .= ", 군량{$reqRice}";
|
||||||
}
|
}
|
||||||
$title .= ')';
|
$title .= ')';
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
$develCost = $this->env['develcost'] * 2;
|
$develCost = $this->env['develcost'] * 2;
|
||||||
$reqGold = 0;
|
$reqGold = 0;
|
||||||
$reqRice = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
$reqRice = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
||||||
|
|
||||||
return [$reqGold, $reqRice];
|
return [$reqGold, $reqRice];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompensationStyle():?int{
|
public function getCompensationStyle():?int{
|
||||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcBaseScore():float{
|
protected function calcBaseScore():float{
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
if(static::$statKey == 'leadership'){
|
if(static::$statKey == 'leadership'){
|
||||||
$score = $general->getLeadership(true, true, true, false);
|
$score = $general->getLeadership(true, true, true, false);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new \sammo\MustNotBeReachedException();
|
throw new \sammo\MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||||
$score *= Util::randRange(0.8, 1.2);
|
$score *= Util::randRange(0.8, 1.2);
|
||||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||||
|
|
||||||
return $score;
|
return $score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||||
|
|
||||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
$failRatio = $general->onCalcDomestic(static::$actionKey, 'fail', $failRatio);
|
||||||
|
|
||||||
$successRatio = Util::valueFit($successRatio, 0, 1);
|
$successRatio = Util::valueFit($successRatio, 0, 1);
|
||||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||||
$normalRatio = 1 - $failRatio - $successRatio;
|
$normalRatio = 1 - $failRatio - $successRatio;
|
||||||
|
|
||||||
$pick = Util::choiceRandomUsingWeight([
|
$pick = Util::choiceRandomUsingWeight([
|
||||||
'fail'=>$failRatio,
|
'fail'=>$failRatio,
|
||||||
'success'=>$successRatio,
|
'success'=>$successRatio,
|
||||||
'normal'=>$normalRatio
|
'normal'=>$normalRatio
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$score *= CriticalScoreEx($pick);
|
$score *= CriticalScoreEx($pick);
|
||||||
$score = Util::round($score);
|
$score = Util::round($score);
|
||||||
|
|
||||||
$exp = $score * 0.7;
|
$exp = $score * 0.7;
|
||||||
$ded = $score * 1.0;
|
$ded = $score * 1.0;
|
||||||
|
|
||||||
$score *= 10;
|
$score *= 10;
|
||||||
|
|
||||||
$scoreText = number_format($score, 0);
|
$scoreText = number_format($score, 0);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||||
if($pick == 'fail'){
|
if($pick == 'fail'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else if($pick == 'success'){
|
else if($pick == 'success'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: 내정량 상승시 초과 가능?
|
//NOTE: 내정량 상승시 초과 가능?
|
||||||
$cityUpdated = [
|
$cityUpdated = [
|
||||||
static::$cityKey => Util::valueFit(
|
static::$cityKey => Util::valueFit(
|
||||||
$this->city[static::$cityKey] + $score,
|
$this->city[static::$cityKey] + $score,
|
||||||
0,
|
0,
|
||||||
$this->city[static::$cityKey.'_max']
|
$this->city[static::$cityKey.'_max']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
||||||
|
|
||||||
$general->increaseVarWithLimit('rice', -$this->reqRice, 0);
|
$general->increaseVarWithLimit('rice', -$this->reqRice, 0);
|
||||||
$general->addExperience($exp);
|
$general->addExperience($exp);
|
||||||
$general->addDedication($ded);
|
$general->addDedication($ded);
|
||||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,191 +1,191 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command
|
Command
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_주민선정 extends Command\GeneralCommand{
|
class che_주민선정 extends Command\GeneralCommand{
|
||||||
static protected $cityKey = 'trust';
|
static protected $cityKey = 'trust';
|
||||||
static protected $statKey = 'leadership';
|
static protected $statKey = 'leadership';
|
||||||
static protected $actionKey = '민심';
|
static protected $actionKey = '민심';
|
||||||
static protected $actionName = '주민 선정';
|
static protected $actionName = '주민 선정';
|
||||||
|
|
||||||
protected $reqRice;
|
protected $reqRice;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::NotWanderingNation(),
|
ConstraintHelper::NotWanderingNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
ConstraintHelper::RemainCityTrust(static::$actionName)
|
ConstraintHelper::RemainCityTrust(static::$actionName)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reqRice = $reqRice;
|
$this->reqRice = $reqRice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$statTypeBase = [
|
$statTypeBase = [
|
||||||
'leadership'=>'통솔경험',
|
'leadership'=>'통솔경험',
|
||||||
'strength'=>'무력경험',
|
'strength'=>'무력경험',
|
||||||
'intel'=>'지력경험',
|
'intel'=>'지력경험',
|
||||||
];
|
];
|
||||||
$statType = $statTypeBase[static::$statKey];
|
$statType = $statTypeBase[static::$statKey];
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$title = "{$name}({$statType}";
|
$title = "{$name}({$statType}";
|
||||||
if($reqGold > 0){
|
if($reqGold > 0){
|
||||||
$title .= ", 자금{$reqGold}";
|
$title .= ", 자금{$reqGold}";
|
||||||
}
|
}
|
||||||
if($reqRice > 0){
|
if($reqRice > 0){
|
||||||
$title .= ", 군량{$reqRice}";
|
$title .= ", 군량{$reqRice}";
|
||||||
}
|
}
|
||||||
$title .= ')';
|
$title .= ')';
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
$develCost = $this->env['develcost'] * 2;
|
$develCost = $this->env['develcost'] * 2;
|
||||||
$reqGold = 0;
|
$reqGold = 0;
|
||||||
$reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
|
$reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
|
||||||
|
|
||||||
return [$reqGold, Util::round($reqRice)];
|
return [$reqGold, Util::round($reqRice)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompensationStyle():?int{
|
public function getCompensationStyle():?int{
|
||||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcBaseScore():float{
|
protected function calcBaseScore():float{
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
if(static::$statKey == 'leadership'){
|
if(static::$statKey == 'leadership'){
|
||||||
$score = $general->getLeadership(true, true, true, false);
|
$score = $general->getLeadership(true, true, true, false);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new \sammo\MustNotBeReachedException();
|
throw new \sammo\MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||||
$score *= Util::randRange(0.8, 1.2);
|
$score *= Util::randRange(0.8, 1.2);
|
||||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||||
$score = Util::valueFit($score, 1);
|
$score = Util::valueFit($score, 1);
|
||||||
|
|
||||||
return $score;
|
return $score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||||
|
|
||||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
$failRatio = $general->onCalcDomestic(static::$actionKey, 'fail', $failRatio);
|
||||||
|
|
||||||
$successRatio = Util::valueFit($successRatio, 0, 1);
|
$successRatio = Util::valueFit($successRatio, 0, 1);
|
||||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||||
$normalRatio = 1 - $failRatio - $successRatio;
|
$normalRatio = 1 - $failRatio - $successRatio;
|
||||||
|
|
||||||
$pick = Util::choiceRandomUsingWeight([
|
$pick = Util::choiceRandomUsingWeight([
|
||||||
'fail'=>$failRatio,
|
'fail'=>$failRatio,
|
||||||
'success'=>$successRatio,
|
'success'=>$successRatio,
|
||||||
'normal'=>$normalRatio
|
'normal'=>$normalRatio
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$score *= CriticalScoreEx($pick);
|
$score *= CriticalScoreEx($pick);
|
||||||
|
|
||||||
$exp = $score * 0.7;
|
$exp = $score * 0.7;
|
||||||
$ded = $score * 1.0;
|
$ded = $score * 1.0;
|
||||||
|
|
||||||
$score /= 10;
|
$score /= 10;
|
||||||
|
|
||||||
$scoreText = number_format($score, 1);
|
$scoreText = number_format($score, 1);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||||
if($pick == 'fail'){
|
if($pick == 'fail'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else if($pick == 'success'){
|
else if($pick == 'success'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: 내정량 상승시 초과 가능?
|
//NOTE: 내정량 상승시 초과 가능?
|
||||||
$cityUpdated = [
|
$cityUpdated = [
|
||||||
static::$cityKey => Util::valueFit(
|
static::$cityKey => Util::valueFit(
|
||||||
$this->city[static::$cityKey] + $score,
|
$this->city[static::$cityKey] + $score,
|
||||||
0,
|
0,
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
||||||
|
|
||||||
$general->increaseVarWithLimit('rice', -$this->reqRice, 0);
|
$general->increaseVarWithLimit('rice', -$this->reqRice, 0);
|
||||||
$general->addExperience($exp);
|
$general->addExperience($exp);
|
||||||
$general->addDedication($ded);
|
$general->addDedication($ded);
|
||||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command;
|
namespace sammo\Command;
|
||||||
|
use \sammo\Util;
|
||||||
abstract class GeneralCommand extends BaseCommand{
|
|
||||||
|
abstract class GeneralCommand extends BaseCommand{
|
||||||
|
|
||||||
|
public function getNextExecuteKey():string{
|
||||||
|
$turnKey = static::$actionName;
|
||||||
|
$generalID = $this->getGeneral()->getID();
|
||||||
|
$executeKey = "next_execute_{$generalID}_{$turnKey}";
|
||||||
|
return $executeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextAvailableTurn():?int{
|
||||||
|
if($this->isArgValid && !$this->getPostReqTurn()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$db = \sammo\DB::db();
|
||||||
|
$lastExecuteStor = \sammo\KVStorage::getStorage($db, 'next_execute');
|
||||||
|
return $lastExecuteStor->getValue($this->getNextExecuteKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNextAvailable(?int $yearMonth=null){
|
||||||
|
if(!$this->getPostReqTurn()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($yearMonth === null){
|
||||||
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month'])
|
||||||
|
+ $this->getPostReqTurn() - $this->getPreReqTurn();
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = \sammo\DB::db();
|
||||||
|
$lastExecuteStor = \sammo\KVStorage::getStorage($db, 'next_execute');
|
||||||
|
$lastExecuteStor->setValue($this->getNextExecuteKey(), $yearMonth);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
+251
-251
@@ -1,251 +1,251 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use\sammo\{
|
use\sammo\{
|
||||||
DB,
|
DB,
|
||||||
Util,
|
Util,
|
||||||
JosaUtil,
|
JosaUtil,
|
||||||
General,
|
General,
|
||||||
DummyGeneral,
|
DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
Message,
|
Message,
|
||||||
MessageTarget
|
MessageTarget
|
||||||
};
|
};
|
||||||
|
|
||||||
use function\sammo\{
|
use function\sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
getAllNationStaticInfo,
|
getAllNationStaticInfo,
|
||||||
getNationStaticInfo,
|
getNationStaticInfo,
|
||||||
GetImageURL
|
GetImageURL
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
class che_급습 extends Command\NationCommand
|
class che_급습 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
static protected $actionName = '급습';
|
static protected $actionName = '급습';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest(): bool
|
protected function argTest(): bool
|
||||||
{
|
{
|
||||||
if ($this->arg === null) {
|
if ($this->arg === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
||||||
if (!key_exists('destNationID', $this->arg)) {
|
if (!key_exists('destNationID', $this->arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$destNationID = $this->arg['destNationID'];
|
$destNationID = $this->arg['destNationID'];
|
||||||
|
|
||||||
if (!is_int($destNationID)) {
|
if (!is_int($destNationID)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($destNationID < 1) {
|
if ($destNationID < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->arg = [
|
$this->arg = [
|
||||||
'destNationID' => $destNationID
|
'destNationID' => $destNationID
|
||||||
];
|
];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['strategic_cmd_limit']);
|
$this->setNation(['strategic_cmd_limit']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->minConditionConstraints = [
|
$this->minConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$this->setDestNation($this->arg['destNationID'], null);
|
$this->setDestNation($this->arg['destNationID'], null);
|
||||||
|
|
||||||
$this->fullConditionConstraints = [
|
$this->fullConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::ExistsDestNation(),
|
ConstraintHelper::ExistsDestNation(),
|
||||||
ConstraintHelper::AllowDiplomacyWithTerm(
|
ConstraintHelper::AllowDiplomacyWithTerm(
|
||||||
1,
|
1,
|
||||||
12,
|
12,
|
||||||
'선포 12개월 이상인 상대국에만 가능합니다.'
|
'선포 12개월 이상인 상대국에만 가능합니다.'
|
||||||
),
|
),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle(): string
|
public function getCommandDetailTitle(): string
|
||||||
{
|
{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$reqTurn = $this->getPreReqTurn() + 1;
|
$reqTurn = $this->getPreReqTurn() + 1;
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
$postReqTurn = $this->getPostReqTurn();
|
||||||
|
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost(): array
|
public function getCost(): array
|
||||||
{
|
{
|
||||||
return [0, 0];
|
return [0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn(): int
|
public function getPreReqTurn(): int
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn(): int
|
public function getPostReqTurn(): int
|
||||||
{
|
{
|
||||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||||
$nextTerm = Util::round(sqrt($genCount * 16) * 10);
|
$nextTerm = Util::round(sqrt($genCount * 16) * 10);
|
||||||
|
|
||||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||||
return $nextTerm;
|
return $nextTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrief(): string
|
public function getBrief(): string
|
||||||
{
|
{
|
||||||
$commandName = $this->getName();
|
$commandName = $this->getName();
|
||||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||||
return "【{$destNationName}】에 {$commandName}";
|
return "【{$destNationName}】에 {$commandName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function run(): bool
|
public function run(): bool
|
||||||
{
|
{
|
||||||
if (!$this->hasFullConditionMet()) {
|
if (!$this->hasFullConditionMet()) {
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
$generalID = $general->getID();
|
$generalID = $general->getID();
|
||||||
$generalName = $general->getName();
|
$generalName = $general->getName();
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$year = $this->env['year'];
|
$year = $this->env['year'];
|
||||||
$month = $this->env['month'];
|
$month = $this->env['month'];
|
||||||
|
|
||||||
$nation = $this->nation;
|
$nation = $this->nation;
|
||||||
$nationID = $nation['nation'];
|
$nationID = $nation['nation'];
|
||||||
$nationName = $nation['name'];
|
$nationName = $nation['name'];
|
||||||
|
|
||||||
$destNation = $this->destNation;
|
$destNation = $this->destNation;
|
||||||
$destNationID = $destNation['nation'];
|
$destNationID = $destNation['nation'];
|
||||||
$destNationName = $destNation['name'];
|
$destNationName = $destNation['name'];
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||||
|
|
||||||
$commandName = $this->getName();
|
$commandName = $this->getName();
|
||||||
$josaUl = JosaUtil::pick($commandName, '을');
|
$josaUl = JosaUtil::pick($commandName, '을');
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
$logger->pushGeneralActionLog("{$commandName} 발동! <1>$date</>");
|
$logger->pushGeneralActionLog("{$commandName} 발동! <1>$date</>");
|
||||||
|
|
||||||
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
||||||
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
||||||
|
|
||||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동하였습니다.";
|
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동하였습니다.";
|
||||||
|
|
||||||
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
foreach ($nationGeneralList as $nationGeneralID) {
|
foreach ($nationGeneralList as $nationGeneralID) {
|
||||||
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
|
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
|
||||||
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
$nationGeneralLogger->flush();
|
$nationGeneralLogger->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$josaYiCommand = JosaUtil::pick($commandName, '이');
|
$josaYiCommand = JosaUtil::pick($commandName, '이');
|
||||||
|
|
||||||
$broadcastMessage = "아국에 <M>{$commandName}</>{$josaYiCommand} 발동되었습니다.";
|
$broadcastMessage = "아국에 <M>{$commandName}</>{$josaYiCommand} 발동되었습니다.";
|
||||||
|
|
||||||
$destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
foreach ($destNationGeneralList as $destNationGeneralID) {
|
foreach ($destNationGeneralList as $destNationGeneralID) {
|
||||||
$destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month);
|
$destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month);
|
||||||
$destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
$destNationGeneralLogger->flush();
|
$destNationGeneralLogger->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
||||||
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <M>{$commandName}</>{$josaUl} 발동");
|
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <M>{$commandName}</>{$josaUl} 발동");
|
||||||
$destNationLogger->flush();
|
$destNationLogger->flush();
|
||||||
|
|
||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => $this->generalObj->onCalcStrategic($this->getName(), 'globalDelay', 9)
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
$db->update('diplomacy', [
|
$db->update('diplomacy', [
|
||||||
'term' => $db->sqleval('`term` - %i', 3),
|
'term' => $db->sqleval('`term` - %i', 3),
|
||||||
], '(me = %i AND you = %i) OR (you = %i AND me = %i)', $nationID, $destNationID, $nationID, $destNationID);
|
], '(me = %i AND you = %i) OR (you = %i AND me = %i)', $nationID, $destNationID, $nationID, $destNationID);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJSFiles(): array
|
public function getJSFiles(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'js/defaultSelectNationByMap.js'
|
'js/defaultSelectNationByMap.js'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getForm(): string
|
public function getForm(): string
|
||||||
{
|
{
|
||||||
$generalObj = $this->generalObj;
|
$generalObj = $this->generalObj;
|
||||||
$nationID = $generalObj->getNationID();
|
$nationID = $generalObj->getNationID();
|
||||||
$nationList = [];
|
$nationList = [];
|
||||||
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
|
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
|
||||||
foreach (getAllNationStaticInfo() as $destNation) {
|
foreach (getAllNationStaticInfo() as $destNation) {
|
||||||
if ($destNation['nation'] == $nationID) {
|
if ($destNation['nation'] == $nationID) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$testTurn->setArg(['destNationID' => $destNation['nation']]);
|
$testTurn->setArg(['destNationID' => $destNation['nation']]);
|
||||||
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
|
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
|
||||||
if ($testCommand->hasFullConditionMet()) {
|
if ($testCommand->hasFullConditionMet()) {
|
||||||
$destNation['availableCommand'] = true;
|
$destNation['availableCommand'] = true;
|
||||||
} else {
|
} else {
|
||||||
$destNation['availableCommand'] = false;
|
$destNation['availableCommand'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nationList[] = $destNation;
|
$nationList[] = $destNation;
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<?= \sammo\getMapHtml() ?><br>
|
<?= \sammo\getMapHtml() ?><br>
|
||||||
선택된 국가에 급습을 발동합니다.<br>
|
선택된 국가에 급습을 발동합니다.<br>
|
||||||
선포, 전쟁중인 상대국에만 가능합니다.<br>
|
선포, 전쟁중인 상대국에만 가능합니다.<br>
|
||||||
상대 국가를 목록에서 선택하세요.<br>
|
상대 국가를 목록에서 선택하세요.<br>
|
||||||
배경색은 현재 급습 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
배경색은 현재 급습 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
||||||
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach ($nationList as $nation) : ?>
|
<?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; ?>
|
<?php endforeach; ?>
|
||||||
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,282 +1,291 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General, DummyGeneral,
|
General, DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
StringUtil
|
StringUtil
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
getAllNationStaticInfo,
|
getAllNationStaticInfo,
|
||||||
getNationStaticInfo
|
getNationStaticInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
class che_물자원조 extends Command\NationCommand{
|
class che_물자원조 extends Command\NationCommand{
|
||||||
static protected $actionName = '원조';
|
static protected $actionName = '원조';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
if($this->arg === null){
|
if($this->arg === null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!key_exists('destNationID', $this->arg)){
|
if(!key_exists('destNationID', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$destNationID = $this->arg['destNationID'];
|
$destNationID = $this->arg['destNationID'];
|
||||||
if(!is_int($destNationID)){
|
if(!is_int($destNationID)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($destNationID < 1){
|
if($destNationID < 1){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!key_exists('amountList', $this->arg)){
|
if(!key_exists('amountList', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$amountList = $this->arg['amountList'];
|
$amountList = $this->arg['amountList'];
|
||||||
if(!is_array($amountList)){
|
if(!is_array($amountList)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($amountList) != 2){
|
if(count($amountList) != 2){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[$goldAmount, $riceAmount] = $amountList;
|
[$goldAmount, $riceAmount] = $amountList;
|
||||||
|
|
||||||
if(!is_int($goldAmount) || !is_int($riceAmount)){
|
if(!is_int($goldAmount) || !is_int($riceAmount)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($goldAmount < 0 || $riceAmount < 0){
|
if($goldAmount < 0 || $riceAmount < 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($goldAmount == 0 && $riceAmount == 0){
|
if($goldAmount == 0 && $riceAmount == 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->arg = [
|
$this->arg = [
|
||||||
'destNationID'=>$destNationID,
|
'destNationID'=>$destNationID,
|
||||||
'amountList'=>[$goldAmount, $riceAmount]
|
'amountList'=>[$goldAmount, $riceAmount]
|
||||||
];
|
];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['gold', 'rice', 'surlimit']);
|
$this->setNation(['gold', 'rice', 'surlimit']);
|
||||||
|
|
||||||
$this->minConditionConstraints=[
|
$this->minConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'),
|
ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$destNationID = $this->arg['destNationID'];
|
$destNationID = $this->arg['destNationID'];
|
||||||
$this->setDestNation($destNationID, ['gold', 'rice', 'surlimit']);
|
$this->setDestNation($destNationID, ['gold', 'rice', 'surlimit']);
|
||||||
|
|
||||||
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
||||||
$limit = $this->nation['level'] * GameConst::$coefAidAmount;
|
$limit = $this->nation['level'] * GameConst::$coefAidAmount;
|
||||||
|
|
||||||
if($goldAmount > $limit || $riceAmount > $limit){
|
if($goldAmount > $limit || $riceAmount > $limit){
|
||||||
$this->fullConditionConstraints[
|
$this->fullConditionConstraints[
|
||||||
ConstraintHelper::AlwaysFail('작위 제한량 이상은 보낼 수 없습니다.')
|
ConstraintHelper::AlwaysFail('작위 제한량 이상은 보낼 수 없습니다.')
|
||||||
];
|
];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::ExistsDestNation(),
|
ConstraintHelper::ExistsDestNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqNationGold(GameConst::$basegold+(($goldAmount>0)?1:0)),
|
ConstraintHelper::ReqNationGold(GameConst::$basegold+(($goldAmount>0)?1:0)),
|
||||||
ConstraintHelper::ReqNationRice(GameConst::$baserice+(($riceAmount>0)?1:0)),
|
ConstraintHelper::ReqNationRice(GameConst::$baserice+(($riceAmount>0)?1:0)),
|
||||||
ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'),
|
ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'),
|
||||||
ConstraintHelper::ReqDestNationValue('surlimit', '외교제한', '==', 0, '상대국이 외교제한중입니다.'),
|
ConstraintHelper::ReqDestNationValue('surlimit', '외교제한', '==', 0, '상대국이 외교제한중입니다.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
return [0, 0];
|
return [0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
return 12;
|
//NOTE: 자체 postReqTurn 사용
|
||||||
}
|
return 12;
|
||||||
|
}
|
||||||
public function getBrief():string{
|
|
||||||
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
public function getNextAvailableTurn():?int{
|
||||||
$goldAmountText = number_format($goldAmount);
|
return null;
|
||||||
$riceAmountText = number_format($riceAmount);
|
}
|
||||||
$destNationName = $this->destNation['name'];
|
|
||||||
$commandName = $this->getName();
|
public function setNextAvailable(?int $yearMonth=null){
|
||||||
return "【{$destNationName}】에게 국고 {$goldAmountText} 병량 {$riceAmountText} {$commandName}";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBrief():string{
|
||||||
public function run():bool{
|
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
||||||
if(!$this->hasFullConditionMet()){
|
$goldAmountText = number_format($goldAmount);
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
$riceAmountText = number_format($riceAmount);
|
||||||
}
|
$destNationName = $this->destNation['name'];
|
||||||
|
$commandName = $this->getName();
|
||||||
$db = DB::db();
|
return "【{$destNationName}】에게 국고 {$goldAmountText} 병량 {$riceAmountText} {$commandName}";
|
||||||
|
}
|
||||||
$general = $this->generalObj;
|
|
||||||
$generalID = $general->getID();
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
public function run():bool{
|
||||||
|
if(!$this->hasFullConditionMet()){
|
||||||
$nation = $this->nation;
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
$nationID = $nation['nation'];
|
}
|
||||||
$nationName = $nation['name'];
|
|
||||||
|
$db = DB::db();
|
||||||
$destNationID = $this->destNation['nation'];
|
|
||||||
$destNationName = $this->destNation['name'];
|
$general = $this->generalObj;
|
||||||
|
$generalID = $general->getID();
|
||||||
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
|
||||||
|
$nation = $this->nation;
|
||||||
|
$nationID = $nation['nation'];
|
||||||
$goldAmount = Util::valueFit(
|
$nationName = $nation['name'];
|
||||||
$goldAmount,
|
|
||||||
0,
|
$destNationID = $this->destNation['nation'];
|
||||||
$nation['gold'] - GameConst::$basegold
|
$destNationName = $this->destNation['name'];
|
||||||
);
|
|
||||||
|
|
||||||
$riceAmount = Util::valueFit(
|
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
||||||
$riceAmount,
|
|
||||||
0,
|
|
||||||
$nation['rice'] - GameConst::$baserice
|
$goldAmount = Util::valueFit(
|
||||||
);
|
$goldAmount,
|
||||||
|
0,
|
||||||
$goldAmountText = number_format($goldAmount);
|
$nation['gold'] - GameConst::$basegold
|
||||||
$riceAmountText = number_format($riceAmount);
|
);
|
||||||
|
|
||||||
|
$riceAmount = Util::valueFit(
|
||||||
$logger = $general->getLogger();
|
$riceAmount,
|
||||||
|
0,
|
||||||
$year = $this->env['year'];
|
$nation['rice'] - GameConst::$baserice
|
||||||
$month = $this->env['month'];
|
);
|
||||||
|
|
||||||
|
$goldAmountText = number_format($goldAmount);
|
||||||
|
$riceAmountText = number_format($riceAmount);
|
||||||
$josaRo = JosaUtil::pick($destNationName, '로');
|
|
||||||
|
|
||||||
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$broadcastMessage = "<D><b>{$destNationName}</b></>{$josaRo} 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원했습니다.";
|
$year = $this->env['year'];
|
||||||
|
$month = $this->env['month'];
|
||||||
$chiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND no != %i AND nation = %i', $generalID, $nationID);
|
|
||||||
foreach($chiefList as $chiefID){
|
|
||||||
$chiefLogger = new ActionLogger($chiefID, $nationID, $year, $month);
|
|
||||||
$chiefLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$josaRo = JosaUtil::pick($destNationName, '로');
|
||||||
$chiefLogger->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>{$josaRo} 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원");
|
$broadcastMessage = "<D><b>{$destNationName}</b></>{$josaRo} 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원했습니다.";
|
||||||
$logger->pushNationalHistoryLog("<D><b>{$destNationName}</b></>{$josaRo} 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원");
|
|
||||||
$logger->pushGlobalHistoryLog("<Y><b>【원조】</b></><D><b>{$nationName}</b></>에서 <D><b>{$destNationName}</b></>{$josaRo} 물자를 지원합니다");
|
$chiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND no != %i AND nation = %i', $generalID, $nationID);
|
||||||
|
foreach($chiefList as $chiefID){
|
||||||
$logger->pushGeneralActionLog($broadcastMessage);
|
$chiefLogger = new ActionLogger($chiefID, $nationID, $year, $month);
|
||||||
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>{$josaRo} 물자를 지원합니다. <1>$date</>", ActionLogger::PLAIN);
|
$chiefLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
|
$chiefLogger->flush();
|
||||||
$destBroadcastMessage = $broadcastMessage = "<D><b>{$nationName}</b></>에서 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 원조했습니다.";
|
}
|
||||||
$destChiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND nation = %i', $destNationID);
|
|
||||||
foreach($destChiefList as $destChiefID){
|
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>{$josaRo} 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원");
|
||||||
$destChiefLogger = new ActionLogger($destChiefID, $nationID, $year, $month);
|
$logger->pushNationalHistoryLog("<D><b>{$destNationName}</b></>{$josaRo} 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원");
|
||||||
$destChiefLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
|
$logger->pushGlobalHistoryLog("<Y><b>【원조】</b></><D><b>{$nationName}</b></>에서 <D><b>{$destNationName}</b></>{$josaRo} 물자를 지원합니다");
|
||||||
$destChiefLogger->flush();
|
|
||||||
}
|
$logger->pushGeneralActionLog($broadcastMessage);
|
||||||
|
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>{$josaRo} 물자를 지원합니다. <1>$date</>", ActionLogger::PLAIN);
|
||||||
$josaRoSrc = JosaUtil::pick($nationName, '로');
|
|
||||||
$destNationLogger = new ActionLogger(0, $destChiefID, $year, $month);
|
$destBroadcastMessage = $broadcastMessage = "<D><b>{$nationName}</b></>에서 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 원조했습니다.";
|
||||||
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaRoSrc}부터 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원 받음");
|
$destChiefList = $db->queryFirstColumn('SELECT no FROM general WHERE officer_level >= 5 AND nation = %i', $destNationID);
|
||||||
|
foreach($destChiefList as $destChiefID){
|
||||||
|
$destChiefLogger = new ActionLogger($destChiefID, $nationID, $year, $month);
|
||||||
|
$destChiefLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
|
||||||
$db->update('nation', [
|
$destChiefLogger->flush();
|
||||||
'gold'=>$db->sqleval('gold - %i', $goldAmount),
|
}
|
||||||
'rice'=>$db->sqleval('rice - %i', $riceAmount),
|
|
||||||
'surlimit'=>$db->sqleval('surlimit + %i', $this->getPostReqTurn())
|
$josaRoSrc = JosaUtil::pick($nationName, '로');
|
||||||
], 'nation = %i', $nationID);
|
$destNationLogger = new ActionLogger(0, $destChiefID, $year, $month);
|
||||||
|
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaRoSrc}부터 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원 받음");
|
||||||
$db->update('nation', [
|
|
||||||
'gold'=>$db->sqleval('gold + %i', $goldAmount),
|
|
||||||
'rice'=>$db->sqleval('rice + %i', $riceAmount),
|
|
||||||
], 'nation = %i', $destNationID);
|
$db->update('nation', [
|
||||||
|
'gold'=>$db->sqleval('gold - %i', $goldAmount),
|
||||||
$general->addExperience(5);
|
'rice'=>$db->sqleval('rice - %i', $riceAmount),
|
||||||
$general->addDedication(5);
|
'surlimit'=>$db->sqleval('surlimit + %i', $this->getPostReqTurn())
|
||||||
|
], 'nation = %i', $nationID);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
|
||||||
$general->applyDB($db);
|
$db->update('nation', [
|
||||||
|
'gold'=>$db->sqleval('gold + %i', $goldAmount),
|
||||||
return true;
|
'rice'=>$db->sqleval('rice + %i', $riceAmount),
|
||||||
}
|
], 'nation = %i', $destNationID);
|
||||||
|
|
||||||
public function getJSFiles(): array
|
$general->addExperience(5);
|
||||||
{
|
$general->addDedication(5);
|
||||||
return [
|
|
||||||
'js/defaultSelectNationByMap.js'
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
];
|
$general->applyDB($db);
|
||||||
}
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
public function getForm(): string
|
|
||||||
{
|
public function getJSFiles(): array
|
||||||
$currentNationLevel = getNationStaticInfo($this->generalObj->getNationID())['level'];
|
{
|
||||||
ob_start();
|
return [
|
||||||
?>
|
'js/defaultSelectNationByMap.js'
|
||||||
<?=\sammo\getMapHtml()?><br>
|
];
|
||||||
타국에게 원조합니다.<br>
|
}
|
||||||
작위별로 금액 제한이 있습니다.<br>
|
|
||||||
<?php foreach(\sammo\getNationLevelList() as $level => [$levelText,,]): ?>
|
|
||||||
<?=StringUtil::padStringAlignRight($levelText, 10)?>: <?=number_format($level*GameConst::$coefAidAmount)?><br>
|
public function getForm(): string
|
||||||
<?php endforeach; ?>
|
{
|
||||||
원조할 국가를 목록에서 선택하세요.<br>
|
$currentNationLevel = getNationStaticInfo($this->generalObj->getNationID())['level'];
|
||||||
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
ob_start();
|
||||||
<?php foreach(getAllNationStaticInfo() as $nation): ?>
|
?>
|
||||||
<option
|
<?=\sammo\getMapHtml()?><br>
|
||||||
value='<?=$nation['nation']?>'
|
타국에게 원조합니다.<br>
|
||||||
style='color:<?=$nation['color']?>;'
|
작위별로 금액 제한이 있습니다.<br>
|
||||||
>【<?=$nation['name']?> 】</option>
|
<?php foreach(\sammo\getNationLevelList() as $level => [$levelText,,]): ?>
|
||||||
<?php endforeach; ?>
|
<?=StringUtil::padStringAlignRight($levelText, 10)?>: <?=number_format($level*GameConst::$coefAidAmount)?><br>
|
||||||
</select>
|
<?php endforeach; ?>
|
||||||
국고 <select class='formInput' name="amountList[]" class="amountList" size='1' style='color:white;background-color:black;'>
|
원조할 국가를 목록에서 선택하세요.<br>
|
||||||
<?php foreach(Util::range($currentNationLevel+1) as $nationLevel): ?>
|
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
||||||
<option value='<?=$nationLevel*GameConst::$coefAidAmount?>'><?=$nationLevel*GameConst::$coefAidAmount?></option>
|
<?php foreach(getAllNationStaticInfo() as $nation): ?>
|
||||||
<?php endforeach; ?>
|
<option
|
||||||
</select>
|
value='<?=$nation['nation']?>'
|
||||||
병량 <select class='formInput' name="amountList[]" class="amountList" size='1' style='color:white;background-color:black;'>
|
style='color:<?=$nation['color']?>;'
|
||||||
<?php foreach(Util::range($currentNationLevel+1) as $nationLevel): ?>
|
>【<?=$nation['name']?> 】</option>
|
||||||
<option value='<?=$nationLevel*GameConst::$coefAidAmount?>'><?=$nationLevel*GameConst::$coefAidAmount?></option>
|
<?php endforeach; ?>
|
||||||
<?php endforeach; ?>
|
</select>
|
||||||
</select>
|
국고 <select class='formInput amountList' name="amountList[]" size='1' style='color:white;background-color:black;'>
|
||||||
<input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
<?php foreach(Util::range($currentNationLevel+1) as $nationLevel): ?>
|
||||||
<br>
|
<option value='<?=$nationLevel*GameConst::$coefAidAmount?>'><?=$nationLevel*GameConst::$coefAidAmount?></option>
|
||||||
<?php
|
<?php endforeach; ?>
|
||||||
return ob_get_clean();
|
</select>
|
||||||
}
|
병량 <select class='formInput amountList' name="amountList[]" size='1' style='color:white;background-color:black;'>
|
||||||
|
<?php foreach(Util::range($currentNationLevel+1) as $nationLevel): ?>
|
||||||
|
<option value='<?=$nationLevel*GameConst::$coefAidAmount?>'><?=$nationLevel*GameConst::$coefAidAmount?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
||||||
|
<br>
|
||||||
|
<?php
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,196 +1,193 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General, DummyGeneral,
|
General, DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
MessageTarget,
|
MessageTarget,
|
||||||
Message,
|
Message,
|
||||||
CityConst
|
CityConst
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
GetImageURL,
|
GetImageURL,
|
||||||
getNationStaticInfo
|
getNationStaticInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
use sammo\Event\Action;
|
use sammo\Event\Action;
|
||||||
|
|
||||||
class che_백성동원 extends Command\NationCommand{
|
class che_백성동원 extends Command\NationCommand{
|
||||||
static protected $actionName = '백성동원';
|
static protected $actionName = '백성동원';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
if($this->arg === null){
|
if($this->arg === null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!key_exists('destCityID', $this->arg)){
|
if(!key_exists('destCityID', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(CityConst::byID($this->arg['destCityID']) === null){
|
if(CityConst::byID($this->arg['destCityID']) === null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$destCityID = $this->arg['destCityID'];
|
$destCityID = $this->arg['destCityID'];
|
||||||
|
|
||||||
$this->arg = [
|
$this->arg = [
|
||||||
'destCityID'=>$destCityID,
|
'destCityID'=>$destCityID,
|
||||||
];
|
];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['strategic_cmd_limit']);
|
$this->setNation(['strategic_cmd_limit']);
|
||||||
|
|
||||||
$this->minConditionConstraints=[
|
$this->minConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand()
|
ConstraintHelper::AvailableStrategicCommand()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$this->setDestCity($this->arg['destCityID']);
|
$this->setDestCity($this->arg['destCityID']);
|
||||||
$this->setDestNation($this->destCity['nation']);
|
$this->setDestNation($this->destCity['nation']);
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
ConstraintHelper::OccupiedDestCity(),
|
||||||
0, 1
|
ConstraintHelper::AvailableStrategicCommand()
|
||||||
], '전쟁중이 아닙니다.'),
|
];
|
||||||
ConstraintHelper::OccupiedDestCity(),
|
}
|
||||||
ConstraintHelper::AvailableStrategicCommand()
|
|
||||||
];
|
public function getCommandDetailTitle():string{
|
||||||
}
|
$name = $this->getName();
|
||||||
|
$reqTurn = $this->getPreReqTurn()+1;
|
||||||
public function getCommandDetailTitle():string{
|
$postReqTurn = $this->getPostReqTurn();
|
||||||
$name = $this->getName();
|
|
||||||
$reqTurn = $this->getPreReqTurn()+1;
|
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
}
|
||||||
|
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
public function getCost():array{
|
||||||
}
|
return [0, 0];
|
||||||
|
}
|
||||||
public function getCost():array{
|
|
||||||
return [0, 0];
|
public function getPreReqTurn():int{
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
public function getPreReqTurn():int{
|
|
||||||
return 0;
|
public function getPostReqTurn():int{
|
||||||
}
|
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||||
|
$nextTerm = Util::round(sqrt($genCount*4)*10);
|
||||||
public function getPostReqTurn():int{
|
|
||||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||||
$nextTerm = Util::round(sqrt($genCount*4)*10);
|
return $nextTerm;
|
||||||
|
}
|
||||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
|
||||||
return $nextTerm;
|
public function getBrief():string{
|
||||||
}
|
$commandName = $this->getName();
|
||||||
|
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||||
public function getBrief():string{
|
return "【{$destCityName}】에 {$commandName}";
|
||||||
$commandName = $this->getName();
|
}
|
||||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
|
||||||
return "【{$destCityName}】에 {$commandName}";
|
public function run():bool{
|
||||||
}
|
if(!$this->hasFullConditionMet()){
|
||||||
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
public function run():bool{
|
}
|
||||||
if(!$this->hasFullConditionMet()){
|
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
$db = DB::db();
|
||||||
}
|
|
||||||
|
$general = $this->generalObj;
|
||||||
$db = DB::db();
|
$generalID = $general->getID();
|
||||||
|
$generalName = $general->getName();
|
||||||
$general = $this->generalObj;
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
$generalID = $general->getID();
|
|
||||||
$generalName = $general->getName();
|
$year = $this->env['year'];
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$month = $this->env['month'];
|
||||||
|
|
||||||
$year = $this->env['year'];
|
$destCity = $this->destCity;
|
||||||
$month = $this->env['month'];
|
$destCityID = $destCity['city'];
|
||||||
|
$destCityName = $destCity['name'];
|
||||||
$destCity = $this->destCity;
|
|
||||||
$destCityID = $destCity['city'];
|
$nationID = $general->getNationID();
|
||||||
$destCityName = $destCity['name'];
|
$nationName = $this->nation['name'];
|
||||||
|
|
||||||
$nationID = $general->getNationID();
|
$logger = $general->getLogger();
|
||||||
$nationName = $this->nation['name'];
|
$logger->pushGeneralActionLog("백성동원 발동! <1>$date</>");
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
||||||
$logger->pushGeneralActionLog("백성동원 발동! <1>$date</>");
|
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
||||||
|
|
||||||
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
|
||||||
|
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>백성동원</>을 하였습니다.";
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
|
||||||
|
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>백성동원</>을 하였습니다.";
|
foreach($targetGeneralList as $targetGeneralID){
|
||||||
|
$targetLogger = new ActionLogger($targetGeneralID, $nationID, $year, $month);
|
||||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$targetLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
foreach($targetGeneralList as $targetGeneralID){
|
$targetLogger->flush();
|
||||||
$targetLogger = new ActionLogger($targetGeneralID, $nationID, $year, $month);
|
}
|
||||||
$targetLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
|
||||||
$targetLogger->flush();
|
$db->update('city', [
|
||||||
}
|
'def' => $db->sqleval('GREATEST(def_max * 0.8, def)'),
|
||||||
|
'wall' => $db->sqleval('GREATEST(wall_max * 0.8, wall)'),
|
||||||
$db->update('city', [
|
], 'city=%i', $destCityID);
|
||||||
'def' => $db->sqleval('GREATEST(def_max * 0.8, def)'),
|
|
||||||
'wall' => $db->sqleval('GREATEST(wall_max * 0.8, wall)'),
|
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||||
], 'city=%i', $destCityID);
|
|
||||||
|
|
||||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
$logger->pushGeneralHistoryLog('<M>백성동원</>을 발동');
|
||||||
|
$logger->pushNationalHistoryLog("<L><b>【전략】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>에 <M>백성동원</>을 하였습니다.");
|
||||||
|
|
||||||
$logger->pushGeneralHistoryLog('<M>백성동원</>을 발동');
|
$db->update('nation', [
|
||||||
$logger->pushNationalHistoryLog("<L><b>【전략】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>에 <M>백성동원</>을 하였습니다.");
|
'strategic_cmd_limit' => $this->generalObj->onCalcStrategic($this->getName(), 'globalDelay', 9)
|
||||||
|
], 'nation=%i', $nationID);
|
||||||
$db->update('nation', [
|
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||||
], 'nation=%i', $nationID);
|
$general->applyDB($db);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
return true;
|
||||||
$general->applyDB($db);
|
}
|
||||||
|
|
||||||
return true;
|
public function getJSFiles(): array
|
||||||
}
|
{
|
||||||
|
return [
|
||||||
public function getJSFiles(): array
|
'js/defaultSelectCityByMap.js'
|
||||||
{
|
];
|
||||||
return [
|
}
|
||||||
'js/defaultSelectCityByMap.js'
|
|
||||||
];
|
|
||||||
}
|
public function getForm(): string
|
||||||
|
{
|
||||||
|
ob_start();
|
||||||
public function getForm(): string
|
?>
|
||||||
{
|
<?=\sammo\getMapHtml()?><br>
|
||||||
ob_start();
|
선택된 도시에 백성을 동원해 성벽을 쌓습니다.<br>
|
||||||
?>
|
아국 도시만 가능합니다.<br>
|
||||||
<?=\sammo\getMapHtml()?><br>
|
목록을 선택하거나 도시를 클릭하세요.<br>
|
||||||
선택된 도시에 백성을 동원해 성벽을 쌓습니다.<br>
|
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
|
||||||
아국 도시만 가능합니다.<br>
|
<?=\sammo\optionsForCities()?><br>
|
||||||
목록을 선택하거나 도시를 클릭하세요.<br>
|
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
||||||
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
|
<br>
|
||||||
<?=\sammo\optionsForCities()?><br>
|
<?php
|
||||||
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
return ob_get_clean();
|
||||||
<br>
|
}
|
||||||
<?php
|
|
||||||
return ob_get_clean();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ class che_수몰 extends Command\NationCommand{
|
|||||||
$reqTurn = $this->getPreReqTurn()+1;
|
$reqTurn = $this->getPreReqTurn()+1;
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
$postReqTurn = $this->getPostReqTurn();
|
||||||
|
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
@@ -179,7 +179,7 @@ class che_수몰 extends Command\NationCommand{
|
|||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>수몰</>을 발동");
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>수몰</>을 발동");
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => $this->generalObj->onCalcStrategic($this->getName(), 'globalDelay', 9)
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||||
|
|||||||
@@ -1,243 +1,243 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use\sammo\{
|
use\sammo\{
|
||||||
DB,
|
DB,
|
||||||
Util,
|
Util,
|
||||||
JosaUtil,
|
JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
KVStorage
|
KVStorage
|
||||||
};
|
};
|
||||||
|
|
||||||
use function\sammo\{
|
use function\sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_의병모집 extends Command\NationCommand
|
class che_의병모집 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
static protected $actionName = '의병모집';
|
static protected $actionName = '의병모집';
|
||||||
|
|
||||||
protected function argTest(): bool
|
protected function argTest(): bool
|
||||||
{
|
{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setNation(['strategic_cmd_limit']);
|
$this->setNation(['strategic_cmd_limit']);
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
$relYear = $env['year'] - $env['startyear'];
|
$relYear = $env['year'] - $env['startyear'];
|
||||||
|
|
||||||
$this->fullConditionConstraints = [
|
$this->fullConditionConstraints = [
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand(),
|
||||||
ConstraintHelper::NotOpeningPart($relYear),
|
ConstraintHelper::NotOpeningPart($relYear),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle(): string
|
public function getCommandDetailTitle(): string
|
||||||
{
|
{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$reqTurn = $this->getPreReqTurn() + 1;
|
$reqTurn = $this->getPreReqTurn() + 1;
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
$postReqTurn = $this->getPostReqTurn();
|
||||||
|
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost(): array
|
public function getCost(): array
|
||||||
{
|
{
|
||||||
return [0, 0];
|
return [0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn(): int
|
public function getPreReqTurn(): int
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn(): int
|
public function getPostReqTurn(): int
|
||||||
{
|
{
|
||||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||||
$nextTerm = Util::round(sqrt($genCount * 10) * 10);
|
$nextTerm = Util::round(sqrt($genCount * 10) * 10);
|
||||||
|
|
||||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||||
return $nextTerm;
|
return $nextTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(): bool
|
public function run(): bool
|
||||||
{
|
{
|
||||||
if (!$this->hasFullConditionMet()) {
|
if (!$this->hasFullConditionMet()) {
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
$generalID = $general->getID();
|
$generalID = $general->getID();
|
||||||
$generalName = $general->getName();
|
$generalName = $general->getName();
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$year = $this->env['year'];
|
$year = $this->env['year'];
|
||||||
$month = $this->env['month'];
|
$month = $this->env['month'];
|
||||||
|
|
||||||
$nation = $this->nation;
|
$nation = $this->nation;
|
||||||
$nationID = $nation['nation'];
|
$nationID = $nation['nation'];
|
||||||
$nationName = $nation['name'];
|
$nationName = $nation['name'];
|
||||||
|
|
||||||
$commandName = $this->getName();
|
$commandName = $this->getName();
|
||||||
$josaUl = JosaUtil::pick($commandName, '을');
|
$josaUl = JosaUtil::pick($commandName, '을');
|
||||||
|
|
||||||
$genCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc < 2', $nationID);
|
$genCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc < 2', $nationID);
|
||||||
$npcCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc = 3', $nationID);
|
$npcCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc = 3', $nationID);
|
||||||
$npcOtherCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation!=%i AND npc = 3', $nationID);
|
$npcOtherCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation!=%i AND npc = 3', $nationID);
|
||||||
|
|
||||||
|
|
||||||
$genCount = Util::valueFit($genCount, 1);
|
$genCount = Util::valueFit($genCount, 1);
|
||||||
$npcCount = Util::valueFit($npcCount, 1);
|
$npcCount = Util::valueFit($npcCount, 1);
|
||||||
$npcOtherCountScore = Util::round(sqrt($npcOtherCount + 1)) - 1;
|
$npcOtherCountScore = Util::round(sqrt($npcOtherCount + 1)) - 1;
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
$logger->pushGeneralActionLog("{$commandName} 발동! <1>$date</>");
|
$logger->pushGeneralActionLog("{$commandName} 발동! <1>$date</>");
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||||
|
|
||||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>{$commandName}</>{$josaUl} 발동하였습니다.";
|
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>{$commandName}</>{$josaUl} 발동하였습니다.";
|
||||||
|
|
||||||
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
foreach ($nationGeneralList as $nationGeneralID) {
|
foreach ($nationGeneralList as $nationGeneralID) {
|
||||||
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
|
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
|
||||||
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
$nationGeneralLogger->flush();
|
$nationGeneralLogger->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$logger->pushGeneralHistoryLog("<M>{$commandName}</>{$josaUl} 발동");
|
$logger->pushGeneralHistoryLog("<M>{$commandName}</>{$josaUl} 발동");
|
||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <M>{$commandName}</>{$josaUl} 발동");
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <M>{$commandName}</>{$josaUl} 발동");
|
||||||
|
|
||||||
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
||||||
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
||||||
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env'); //TODO: 차라리 env가 이거여야..?
|
$gameStor = KVStorage::getStorage($db, 'game_env'); //TODO: 차라리 env가 이거여야..?
|
||||||
|
|
||||||
$avgGenCnt = $db->queryFirstField('SELECT avg(gennum) FROM nation WHERE level > 0');
|
$avgGenCnt = $db->queryFirstField('SELECT avg(gennum) FROM nation WHERE level > 0');
|
||||||
$createGenCnt = 5 + Util::round($avgGenCnt / 10);
|
$createGenCnt = 5 + Util::round($avgGenCnt / 10);
|
||||||
$createGenIdx = $gameStor->npccount + 1;
|
$createGenIdx = $gameStor->npccount + 1;
|
||||||
$lastCreatGenIdx = $createGenIdx + $createGenCnt;
|
$lastCreatGenIdx = $createGenIdx + $createGenCnt;
|
||||||
|
|
||||||
$pickTypeList = ['무' => 5, '지' => 5];
|
$pickTypeList = ['무' => 5, '지' => 5];
|
||||||
|
|
||||||
$avgGen = $db->queryFirstRow(
|
$avgGen = $db->queryFirstRow(
|
||||||
'SELECT avg(dedication) as ded,avg(experience) as exp,
|
'SELECT avg(dedication) as ded,avg(experience) as exp,
|
||||||
avg(dex1+dex2+dex3+dex4) as dex_t, avg(age) as age, avg(dex5) as dex5
|
avg(dex1+dex2+dex3+dex4) as dex_t, avg(age) as age, avg(dex5) as dex5
|
||||||
from general where nation=%i',
|
from general where nation=%i',
|
||||||
$nationID
|
$nationID
|
||||||
);
|
);
|
||||||
$dexTotal = $avgGen['dex_t'];
|
$dexTotal = $avgGen['dex_t'];
|
||||||
|
|
||||||
for (; $createGenIdx <= $lastCreatGenIdx; $createGenIdx++) {
|
for (; $createGenIdx <= $lastCreatGenIdx; $createGenIdx++) {
|
||||||
$pickType = Util::choiceRandomUsingWeight($pickTypeList);
|
$pickType = Util::choiceRandomUsingWeight($pickTypeList);
|
||||||
|
|
||||||
$totalStat = GameConst::$defaultStatNPCMax * 2 + 10;
|
$totalStat = GameConst::$defaultStatNPCMax * 2 + 10;
|
||||||
$minStat = 10;
|
$minStat = 10;
|
||||||
$mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, 10);
|
$mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, 10);
|
||||||
//TODO: defaultStatNPCTotal, defaultStatNPCMin 추가
|
//TODO: defaultStatNPCTotal, defaultStatNPCMin 추가
|
||||||
$otherStat = $minStat + Util::randRangeInt(0, 5);
|
$otherStat = $minStat + Util::randRangeInt(0, 5);
|
||||||
$subStat = $totalStat - $mainStat - $otherStat;
|
$subStat = $totalStat - $mainStat - $otherStat;
|
||||||
if ($subStat < $minStat) {
|
if ($subStat < $minStat) {
|
||||||
$subStat = $otherStat;
|
$subStat = $otherStat;
|
||||||
$otherStat = $minStat;
|
$otherStat = $minStat;
|
||||||
$mainStat = $totalStat - $subStat - $otherStat;
|
$mainStat = $totalStat - $subStat - $otherStat;
|
||||||
if ($mainStat) {
|
if ($mainStat) {
|
||||||
throw new \LogicException('기본 스탯 설정값이 잘못되어 있음');
|
throw new \LogicException('기본 스탯 설정값이 잘못되어 있음');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pickType == '무') {
|
if ($pickType == '무') {
|
||||||
$leadership = $subStat;
|
$leadership = $subStat;
|
||||||
$strength = $mainStat;
|
$strength = $mainStat;
|
||||||
$intel = $otherStat;
|
$intel = $otherStat;
|
||||||
$dexVal = Util::choiceRandom([
|
$dexVal = Util::choiceRandom([
|
||||||
[$dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8, $dexTotal / 8],
|
[$dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8, $dexTotal / 8],
|
||||||
[$dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8],
|
[$dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8],
|
||||||
[$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8],
|
[$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8],
|
||||||
]);
|
]);
|
||||||
} else if ($pickType == '지') {
|
} else if ($pickType == '지') {
|
||||||
$leadership = $subStat;
|
$leadership = $subStat;
|
||||||
$strength = $otherStat;
|
$strength = $otherStat;
|
||||||
$intel = $mainStat;
|
$intel = $mainStat;
|
||||||
$dexVal = [$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8];
|
$dexVal = [$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8];
|
||||||
} else {
|
} else {
|
||||||
$leadership = $otherStat;
|
$leadership = $otherStat;
|
||||||
$strength = $subStat;
|
$strength = $subStat;
|
||||||
$intel = $mainStat;
|
$intel = $mainStat;
|
||||||
$dexVal = [$dexTotal / 4, $dexTotal / 4, $dexTotal / 4, $dexTotal / 4];
|
$dexVal = [$dexTotal / 4, $dexTotal / 4, $dexTotal / 4, $dexTotal / 4];
|
||||||
}
|
}
|
||||||
|
|
||||||
$leadership = Util::round($leadership);
|
$leadership = Util::round($leadership);
|
||||||
$strength = Util::round($strength);
|
$strength = Util::round($strength);
|
||||||
$intel = Util::round($intel);
|
$intel = Util::round($intel);
|
||||||
|
|
||||||
$age = $avgGen['age'];
|
$age = $avgGen['age'];
|
||||||
|
|
||||||
$newNPC = new \sammo\Scenario\NPC(
|
$newNPC = new \sammo\Scenario\NPC(
|
||||||
Util::randRangeInt(1, 150),
|
Util::randRangeInt(1, 150),
|
||||||
"의병장{$createGenIdx}",
|
"의병장{$createGenIdx}",
|
||||||
null,
|
null,
|
||||||
$nationID,
|
$nationID,
|
||||||
$general->getCityID(),
|
$general->getCityID(),
|
||||||
$leadership,
|
$leadership,
|
||||||
$strength,
|
$strength,
|
||||||
$intel,
|
$intel,
|
||||||
1,
|
1,
|
||||||
$env['year'] - 20,
|
$env['year'] - 20,
|
||||||
$env['year'] + 6,
|
$env['year'] + 6,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
$newNPC->killturn = Util::randRangeInt(64, 70);
|
$newNPC->killturn = Util::randRangeInt(64, 70);
|
||||||
$newNPC->npc = 4;
|
$newNPC->npc = 4;
|
||||||
$newNPC->setMoney(1000, 1000);
|
$newNPC->setMoney(1000, 1000);
|
||||||
$newNPC->setExpDed($avgGen['exp'], $avgGen['ded']);
|
$newNPC->setExpDed($avgGen['exp'], $avgGen['ded']);
|
||||||
$newNPC->setDex(
|
$newNPC->setDex(
|
||||||
$dexVal[0],
|
$dexVal[0],
|
||||||
$dexVal[1],
|
$dexVal[1],
|
||||||
$dexVal[2],
|
$dexVal[2],
|
||||||
$dexVal[3],
|
$dexVal[3],
|
||||||
$avgGen['dex5']
|
$avgGen['dex5']
|
||||||
);
|
);
|
||||||
|
|
||||||
$newNPC->build($this->env);
|
$newNPC->build($this->env);
|
||||||
}
|
}
|
||||||
|
|
||||||
$gameStor->npccount = $lastCreatGenIdx;
|
$gameStor->npccount = $lastCreatGenIdx;
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'gennum' => $db->sqleval('gennum + %i', $createGenCnt),
|
'gennum' => $db->sqleval('gennum + %i', $createGenCnt),
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => $this->generalObj->onCalcStrategic($this->getName(), 'globalDelay', 9)
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,250 +1,250 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use\sammo\{
|
use\sammo\{
|
||||||
DB,
|
DB,
|
||||||
Util,
|
Util,
|
||||||
JosaUtil,
|
JosaUtil,
|
||||||
General,
|
General,
|
||||||
DummyGeneral,
|
DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
Message,
|
Message,
|
||||||
MessageTarget
|
MessageTarget
|
||||||
};
|
};
|
||||||
|
|
||||||
use function\sammo\{
|
use function\sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
getAllNationStaticInfo,
|
getAllNationStaticInfo,
|
||||||
getNationStaticInfo,
|
getNationStaticInfo,
|
||||||
GetImageURL
|
GetImageURL
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
class che_이호경식 extends Command\NationCommand
|
class che_이호경식 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
static protected $actionName = '이호경식';
|
static protected $actionName = '이호경식';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest(): bool
|
protected function argTest(): bool
|
||||||
{
|
{
|
||||||
if ($this->arg === null) {
|
if ($this->arg === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
||||||
if (!key_exists('destNationID', $this->arg)) {
|
if (!key_exists('destNationID', $this->arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$destNationID = $this->arg['destNationID'];
|
$destNationID = $this->arg['destNationID'];
|
||||||
|
|
||||||
if (!is_int($destNationID)) {
|
if (!is_int($destNationID)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($destNationID < 1) {
|
if ($destNationID < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->arg = [
|
$this->arg = [
|
||||||
'destNationID' => $destNationID
|
'destNationID' => $destNationID
|
||||||
];
|
];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['strategic_cmd_limit']);
|
$this->setNation(['strategic_cmd_limit']);
|
||||||
|
|
||||||
$this->minConditionConstraints = [
|
$this->minConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$this->setDestNation($this->arg['destNationID'], null);
|
$this->setDestNation($this->arg['destNationID'], null);
|
||||||
|
|
||||||
$this->fullConditionConstraints = [
|
$this->fullConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::ExistsDestNation(),
|
ConstraintHelper::ExistsDestNation(),
|
||||||
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
||||||
[0, 1],
|
[0, 1],
|
||||||
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
||||||
),
|
),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle(): string
|
public function getCommandDetailTitle(): string
|
||||||
{
|
{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$reqTurn = $this->getPreReqTurn() + 1;
|
$reqTurn = $this->getPreReqTurn() + 1;
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
$postReqTurn = $this->getPostReqTurn();
|
||||||
|
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost(): array
|
public function getCost(): array
|
||||||
{
|
{
|
||||||
return [0, 0];
|
return [0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn(): int
|
public function getPreReqTurn(): int
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn(): int
|
public function getPostReqTurn(): int
|
||||||
{
|
{
|
||||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||||
$nextTerm = Util::round(sqrt($genCount * 16) * 10);
|
$nextTerm = Util::round(sqrt($genCount * 16) * 10);
|
||||||
|
|
||||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||||
return $nextTerm;
|
return $nextTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrief(): string
|
public function getBrief(): string
|
||||||
{
|
{
|
||||||
$commandName = $this->getName();
|
$commandName = $this->getName();
|
||||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||||
return "【{$destNationName}】에 {$commandName}";
|
return "【{$destNationName}】에 {$commandName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function run(): bool
|
public function run(): bool
|
||||||
{
|
{
|
||||||
if (!$this->hasFullConditionMet()) {
|
if (!$this->hasFullConditionMet()) {
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
$generalID = $general->getID();
|
$generalID = $general->getID();
|
||||||
$generalName = $general->getName();
|
$generalName = $general->getName();
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$year = $this->env['year'];
|
$year = $this->env['year'];
|
||||||
$month = $this->env['month'];
|
$month = $this->env['month'];
|
||||||
|
|
||||||
$nation = $this->nation;
|
$nation = $this->nation;
|
||||||
$nationID = $nation['nation'];
|
$nationID = $nation['nation'];
|
||||||
$nationName = $nation['name'];
|
$nationName = $nation['name'];
|
||||||
|
|
||||||
$destNation = $this->destNation;
|
$destNation = $this->destNation;
|
||||||
$destNationID = $destNation['nation'];
|
$destNationID = $destNation['nation'];
|
||||||
$destNationName = $destNation['name'];
|
$destNationName = $destNation['name'];
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||||
|
|
||||||
$commandName = $this->getName();
|
$commandName = $this->getName();
|
||||||
$josaUl = JosaUtil::pick($commandName, '을');
|
$josaUl = JosaUtil::pick($commandName, '을');
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
$logger->pushGeneralActionLog("{$commandName} 발동! <1>$date</>");
|
$logger->pushGeneralActionLog("{$commandName} 발동! <1>$date</>");
|
||||||
|
|
||||||
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
||||||
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
||||||
|
|
||||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동하였습니다.";
|
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동하였습니다.";
|
||||||
|
|
||||||
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
foreach ($nationGeneralList as $nationGeneralID) {
|
foreach ($nationGeneralList as $nationGeneralID) {
|
||||||
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
|
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
|
||||||
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
$nationGeneralLogger->flush();
|
$nationGeneralLogger->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$josaYiCommand = JosaUtil::pick($commandName, '이');
|
$josaYiCommand = JosaUtil::pick($commandName, '이');
|
||||||
|
|
||||||
$broadcastMessage = "아국에 <M>{$commandName}</>{$josaYiCommand} 발동되었습니다.";
|
$broadcastMessage = "아국에 <M>{$commandName}</>{$josaYiCommand} 발동되었습니다.";
|
||||||
|
|
||||||
$destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
foreach ($destNationGeneralList as $destNationGeneralID) {
|
foreach ($destNationGeneralList as $destNationGeneralID) {
|
||||||
$destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month);
|
$destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month);
|
||||||
$destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
$destNationGeneralLogger->flush();
|
$destNationGeneralLogger->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
||||||
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <M>{$commandName}</>{$josaUl} 발동");
|
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <M>{$commandName}</>{$josaUl} 발동");
|
||||||
$destNationLogger->flush();
|
$destNationLogger->flush();
|
||||||
|
|
||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => $this->generalObj->onCalcStrategic($this->getName(), 'globalDelay', 9)
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
$db->update('diplomacy', [
|
$db->update('diplomacy', [
|
||||||
'term' => $db->sqleval('IF(`state`=0, %i, `term`+ %i)', 3, 3),
|
'term' => $db->sqleval('IF(`state`=0, %i, `term`+ %i)', 3, 3),
|
||||||
'state' => 1,
|
'state' => 1,
|
||||||
], '(me = %i AND you = %i) OR (you = %i AND me = %i)', $nationID, $destNationID, $nationID, $destNationID);
|
], '(me = %i AND you = %i) OR (you = %i AND me = %i)', $nationID, $destNationID, $nationID, $destNationID);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJSFiles(): array
|
public function getJSFiles(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'js/defaultSelectNationByMap.js'
|
'js/defaultSelectNationByMap.js'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getForm(): string
|
public function getForm(): string
|
||||||
{
|
{
|
||||||
$generalObj = $this->generalObj;
|
$generalObj = $this->generalObj;
|
||||||
$nationID = $generalObj->getNationID();
|
$nationID = $generalObj->getNationID();
|
||||||
$nationList = [];
|
$nationList = [];
|
||||||
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
|
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
|
||||||
foreach (getAllNationStaticInfo() as $destNation) {
|
foreach (getAllNationStaticInfo() as $destNation) {
|
||||||
if ($destNation['nation'] == $nationID) {
|
if ($destNation['nation'] == $nationID) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$testTurn->setArg(['destNationID' => $destNation['nation']]);
|
$testTurn->setArg(['destNationID' => $destNation['nation']]);
|
||||||
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
|
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID' => $destNation['nation']]);
|
||||||
if ($testCommand->hasFullConditionMet()) {
|
if ($testCommand->hasFullConditionMet()) {
|
||||||
$destNation['availableCommand'] = true;
|
$destNation['availableCommand'] = true;
|
||||||
} else {
|
} else {
|
||||||
$destNation['availableCommand'] = false;
|
$destNation['availableCommand'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nationList[] = $destNation;
|
$nationList[] = $destNation;
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<?= \sammo\getMapHtml() ?><br>
|
<?= \sammo\getMapHtml() ?><br>
|
||||||
선택된 국가에 이호경식을 발동합니다.<br>
|
선택된 국가에 이호경식을 발동합니다.<br>
|
||||||
선포, 전쟁중인 상대국에만 가능합니다.<br>
|
선포, 전쟁중인 상대국에만 가능합니다.<br>
|
||||||
상대 국가를 목록에서 선택하세요.<br>
|
상대 국가를 목록에서 선택하세요.<br>
|
||||||
배경색은 현재 이호경식 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
배경색은 현재 이호경식 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
||||||
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach ($nationList as $nation) : ?>
|
<?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; ?>
|
<?php endforeach; ?>
|
||||||
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,232 +1,240 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General, DummyGeneral,
|
General, DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
MessageTarget,
|
MessageTarget,
|
||||||
Message,
|
Message,
|
||||||
CityConst,
|
CityConst,
|
||||||
CityInitialDetail
|
CityInitialDetail
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
GetImageURL,
|
GetImageURL,
|
||||||
getNationStaticInfo
|
getNationStaticInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
use sammo\Event\Action;
|
use sammo\Event\Action;
|
||||||
|
|
||||||
class che_초토화 extends Command\NationCommand{
|
class che_초토화 extends Command\NationCommand{
|
||||||
static protected $actionName = '초토화';
|
static protected $actionName = '초토화';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
private $cachedDist = null;
|
private $cachedDist = null;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
if($this->arg === null){
|
if($this->arg === null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!key_exists('destCityID', $this->arg)){
|
if(!key_exists('destCityID', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(CityConst::byID($this->arg['destCityID']) === null){
|
if(CityConst::byID($this->arg['destCityID']) === null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$destCityID = $this->arg['destCityID'];
|
$destCityID = $this->arg['destCityID'];
|
||||||
|
|
||||||
$this->arg = [
|
$this->arg = [
|
||||||
'destCityID'=>$destCityID,
|
'destCityID'=>$destCityID,
|
||||||
];
|
];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['surlimit', 'gold', 'rice', 'capital']);
|
$this->setNation(['surlimit', 'gold', 'rice', 'capital']);
|
||||||
|
|
||||||
$this->minConditionConstraints=[
|
$this->minConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqNationValue('surlimit', '제한 턴', '==', 0, '외교제한 턴이 남아있습니다.'),
|
ConstraintHelper::ReqNationValue('surlimit', '제한 턴', '==', 0, '외교제한 턴이 남아있습니다.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$this->setDestCity($this->arg['destCityID']);
|
$this->setDestCity($this->arg['destCityID']);
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::OccupiedDestCity(),
|
ConstraintHelper::OccupiedDestCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::SuppliedDestCity(),
|
ConstraintHelper::SuppliedDestCity(),
|
||||||
ConstraintHelper::ReqNationValue('capital', '수도', '!=', $this->destCity['city'], '수도입니다.'),
|
ConstraintHelper::ReqNationValue('capital', '수도', '!=', $this->destCity['city'], '수도입니다.'),
|
||||||
ConstraintHelper::ReqNationValue('surlimit', '제한 턴', '==', 0, '외교제한 턴이 남아있습니다.'),
|
ConstraintHelper::ReqNationValue('surlimit', '제한 턴', '==', 0, '외교제한 턴이 남아있습니다.'),
|
||||||
ConstraintHelper::DisallowDiplomacyStatus($this->generalObj->getNationID(), [
|
ConstraintHelper::DisallowDiplomacyStatus($this->generalObj->getNationID(), [
|
||||||
0 => '평시에만 가능합니다.',
|
0 => '평시에만 가능합니다.',
|
||||||
1 => '평시에만 가능합니다.'
|
], ),
|
||||||
], ),
|
];
|
||||||
];
|
}
|
||||||
}
|
|
||||||
|
public function getCost():array{
|
||||||
public function getCost():array{
|
return [0, 0];
|
||||||
return [0, 0];
|
}
|
||||||
}
|
|
||||||
|
public function getPreReqTurn():int{
|
||||||
public function getPreReqTurn():int{
|
return 2;
|
||||||
return 2;
|
}
|
||||||
}
|
|
||||||
|
public function getPostReqTurn():int{
|
||||||
public function getPostReqTurn():int{
|
//NOTE: 자체 postReqTurn 사용
|
||||||
return 24;
|
return 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getNextAvailableTurn():?int{
|
||||||
$name = $this->getName();
|
return null;
|
||||||
|
}
|
||||||
$reqTurn = $this->getPreReqTurn()+1;
|
|
||||||
|
public function setNextAvailable(?int $yearMonth=null){
|
||||||
return "{$name}/{$reqTurn}턴(공백지화, 금쌀 회수, 수뇌진 명성하락)";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrief():string{
|
public function getCommandDetailTitle():string{
|
||||||
$commandName = $this->getName();
|
$name = $this->getName();
|
||||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
|
||||||
$josaUl = JosaUtil::pick($destCityName, '을');
|
$reqTurn = $this->getPreReqTurn()+1;
|
||||||
return "【{$destCityName}】{$josaUl} {$commandName}";
|
|
||||||
}
|
return "{$name}/{$reqTurn}턴(공백지화, 금쌀 회수, 수뇌진 명성하락)";
|
||||||
|
}
|
||||||
public function calcReturnAmount(array $destCity):int{
|
|
||||||
$amount = $destCity['pop'] / 5;
|
public function getBrief():string{
|
||||||
foreach(['agri', 'comm', 'secu'] as $cityRes){
|
$commandName = $this->getName();
|
||||||
$cityResMax = "{$cityRes}_max";
|
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||||
$amount *= (($destCity[$cityRes] - $destCity[$cityResMax] * 0.5) / $destCity[$cityResMax]) + 0.8;
|
$josaUl = JosaUtil::pick($destCityName, '을');
|
||||||
}
|
return "【{$destCityName}】{$josaUl} {$commandName}";
|
||||||
return Util::toInt($amount);
|
}
|
||||||
}
|
|
||||||
|
public function calcReturnAmount(array $destCity):int{
|
||||||
public function run():bool{
|
$amount = $destCity['pop'] / 5;
|
||||||
if(!$this->hasFullConditionMet()){
|
foreach(['agri', 'comm', 'secu'] as $cityRes){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
$cityResMax = "{$cityRes}_max";
|
||||||
}
|
$amount *= (($destCity[$cityRes] - $destCity[$cityResMax] * 0.5) / $destCity[$cityResMax]) + 0.8;
|
||||||
|
}
|
||||||
$db = DB::db();
|
return Util::toInt($amount);
|
||||||
|
}
|
||||||
$general = $this->generalObj;
|
|
||||||
$generalID = $general->getID();
|
public function run():bool{
|
||||||
$generalName = $general->getName();
|
if(!$this->hasFullConditionMet()){
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
|
}
|
||||||
$destCity = $this->destCity;
|
|
||||||
$destCityID = $destCity['city'];
|
$db = DB::db();
|
||||||
$destCityName = $destCity['name'];
|
|
||||||
|
$general = $this->generalObj;
|
||||||
$nationID = $general->getNationID();
|
$generalID = $general->getID();
|
||||||
$nationName = $this->nation['name'];
|
$generalName = $general->getName();
|
||||||
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
$josaUl = JosaUtil::pick($destCityName, '을');
|
|
||||||
|
$destCity = $this->destCity;
|
||||||
$logger = $general->getLogger();
|
$destCityID = $destCity['city'];
|
||||||
|
$destCityName = $destCity['name'];
|
||||||
|
|
||||||
$general->addExperience(-$general->getVar('experience') * 0.1, false);
|
$nationID = $general->getNationID();
|
||||||
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
$nationName = $this->nation['name'];
|
||||||
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
|
||||||
|
$josaUl = JosaUtil::pick($destCityName, '을');
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
|
||||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$amount = $this->calcReturnAmount($destCity);
|
|
||||||
|
$general->addExperience(-$general->getVar('experience') * 0.1, false);
|
||||||
$db->update('general', [
|
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
||||||
'experience'=>$db->sqleval('experience * 0.9')
|
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
||||||
], 'nation = %i AND officer_level >= 5 AND no!=%i', $nationID, $generalID);
|
|
||||||
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
$db->update('general', [
|
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||||
'betray'=>$db->sqleval('betray + 1')
|
|
||||||
], 'nation = %i AND no!=%i', $nationID, $generalID);
|
$amount = $this->calcReturnAmount($destCity);
|
||||||
$general->increaseVar('betray', 1);
|
|
||||||
|
$db->update('general', [
|
||||||
$db->update('city', [
|
'experience'=>$db->sqleval('experience * 0.9')
|
||||||
'trust'=>$db->sqleval('greatest(50, trust)'),
|
], 'nation = %i AND officer_level >= 5 AND no!=%i', $nationID, $generalID);
|
||||||
'pop'=>$db->sqleval('greatest(pop_max*0.1, pop*0.2)'),
|
|
||||||
'agri'=>$db->sqleval('greatest(agri_max*0.1, agri*0.2)'),
|
$db->update('general', [
|
||||||
'comm'=>$db->sqleval('greatest(comm_max*0.1, comm*0.2)'),
|
'betray'=>$db->sqleval('betray + 1')
|
||||||
'nation'=>0,
|
], 'nation = %i AND no!=%i', $nationID, $generalID);
|
||||||
'front'=>0,
|
$general->increaseVar('betray', 1);
|
||||||
'conflict'=>'{}'
|
|
||||||
], 'city=%i', $destCityID);
|
$db->update('city', [
|
||||||
|
'trust'=>$db->sqleval('greatest(50, trust)'),
|
||||||
$db->update('nation', [
|
'pop'=>$db->sqleval('greatest(pop_max*0.1, pop*0.2)'),
|
||||||
'gold' => $db->sqleval('gold + %i', $amount),
|
'agri'=>$db->sqleval('greatest(agri_max*0.1, agri*0.2)'),
|
||||||
'rice' => $db->sqleval('rice + %i', $amount),
|
'comm'=>$db->sqleval('greatest(comm_max*0.1, comm*0.2)'),
|
||||||
'surlimit' => $db->sqleval('surlimit + %i', $this->getPostReqTurn()),
|
'nation'=>0,
|
||||||
], 'nation=%i', $nationID);
|
'front'=>0,
|
||||||
|
'conflict'=>'{}'
|
||||||
\sammo\refreshNationStaticInfo();
|
], 'city=%i', $destCityID);
|
||||||
\sammo\SetNationFront($nationID);
|
|
||||||
|
$db->update('nation', [
|
||||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaUl} 초토화했습니다. <1>$date</>");
|
'gold' => $db->sqleval('gold + %i', $amount),
|
||||||
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>{$josaUl} <M>초토화</> 명령");
|
'rice' => $db->sqleval('rice + %i', $amount),
|
||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>{$josaUl} <M>초토화</> 명령");
|
'surlimit' => $db->sqleval('surlimit + %i', $this->getPostReqTurn()),
|
||||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>{$josaUl} <M>초토화</>하였습니다.");
|
], 'nation=%i', $nationID);
|
||||||
$logger->pushGlobalHistoryLog("<S><b>【초토화】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>{$josaUl} <M>초토화</>하였습니다.");
|
|
||||||
|
\sammo\refreshNationStaticInfo();
|
||||||
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
\sammo\SetNationFront($nationID);
|
||||||
$general->applyDB($db);
|
|
||||||
return true;
|
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaUl} 초토화했습니다. <1>$date</>");
|
||||||
}
|
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>{$josaUl} <M>초토화</> 명령");
|
||||||
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>{$josaUl} <M>초토화</> 명령");
|
||||||
public function getJSFiles(): array
|
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>{$josaUl} <M>초토화</>하였습니다.");
|
||||||
{
|
$logger->pushGlobalHistoryLog("<S><b>【초토화】</b></><D><b>{$nationName}</b></>{$josaYiNation} <G><b>{$destCityName}</b></>{$josaUl} <M>초토화</>하였습니다.");
|
||||||
return [
|
|
||||||
'js/defaultSelectCityByMap.js'
|
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||||
];
|
$general->applyDB($db);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function getForm(): string
|
public function getJSFiles(): array
|
||||||
{
|
{
|
||||||
|
return [
|
||||||
$cities = Util::convertArrayToDict(DB::db()->query('SELECT * FROM city WHERE nation =%i', $this->generalObj->getNationID()), 'city');
|
'js/defaultSelectCityByMap.js'
|
||||||
$calc = function(CityInitialDetail $constCity)use($cities){
|
];
|
||||||
if(!key_exists($constCity->id, $cities)){
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$amount = $this->calcReturnAmount($cities[$constCity->id]);
|
public function getForm(): string
|
||||||
$amountText = number_format($amount);
|
{
|
||||||
return "금쌀 각 {$amountText} 회수";
|
|
||||||
};
|
$cities = Util::convertArrayToDict(DB::db()->query('SELECT * FROM city WHERE nation =%i', $this->generalObj->getNationID()), 'city');
|
||||||
ob_start();
|
$calc = function(CityInitialDetail $constCity)use($cities){
|
||||||
?>
|
if(!key_exists($constCity->id, $cities)){
|
||||||
<?=\sammo\getMapHtml()?><br>
|
return null;
|
||||||
선택된 도시를 초토화 시킵니다.<br>
|
}
|
||||||
도시가 공백지가 되며, 도시의 인구, 내정 상태에 따라 상당량의 국고가 확보됩니다.<br>
|
$amount = $this->calcReturnAmount($cities[$constCity->id]);
|
||||||
국가의 수뇌들은 명성을 잃고, 모든 장수들은 배신 수치가 1 증가합니다.<br>
|
$amountText = number_format($amount);
|
||||||
목록을 선택하거나 도시를 클릭하세요.<br>
|
return "금쌀 각 {$amountText} 회수";
|
||||||
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
|
};
|
||||||
<?=\sammo\optionsForCities($calc)?><br>
|
ob_start();
|
||||||
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
?>
|
||||||
<br>
|
<?=\sammo\getMapHtml()?><br>
|
||||||
<?php
|
선택된 도시를 초토화 시킵니다.<br>
|
||||||
return ob_get_clean();
|
도시가 공백지가 되며, 도시의 인구, 내정 상태에 따라 상당량의 국고가 확보됩니다.<br>
|
||||||
}
|
국가의 수뇌들은 명성을 잃고, 모든 장수들은 배신 수치가 1 증가합니다.<br>
|
||||||
|
목록을 선택하거나 도시를 클릭하세요.<br>
|
||||||
|
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
|
||||||
|
<?=\sammo\optionsForCities($calc)?><br>
|
||||||
|
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
||||||
|
<br>
|
||||||
|
<?php
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,239 +1,302 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General, DummyGeneral,
|
General, DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
Message, MessageTarget
|
KVStorage,
|
||||||
};
|
Message, MessageTarget
|
||||||
|
};
|
||||||
use function \sammo\{
|
|
||||||
getDomesticExpLevelBonus,
|
use function \sammo\{
|
||||||
CriticalRatioDomestic,
|
buildNationCommandClass,
|
||||||
CriticalScoreEx,
|
getDomesticExpLevelBonus,
|
||||||
getAllNationStaticInfo,
|
CriticalRatioDomestic,
|
||||||
getNationStaticInfo,
|
CriticalScoreEx,
|
||||||
GetImageURL
|
getAllNationStaticInfo,
|
||||||
};
|
getNationStaticInfo,
|
||||||
|
GetImageURL
|
||||||
use \sammo\Constraint\Constraint;
|
};
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
|
||||||
|
use \sammo\Constraint\Constraint;
|
||||||
class che_피장파장 extends Command\NationCommand{
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
static protected $actionName = '피장파장';
|
|
||||||
static public $reqArg = true;
|
class che_피장파장 extends Command\NationCommand{
|
||||||
static public $delayCnt = 60;
|
static protected $actionName = '피장파장';
|
||||||
|
static public $reqArg = true;
|
||||||
protected function argTest():bool{
|
static public $delayCnt = 60;
|
||||||
if($this->arg === null){
|
|
||||||
return false;
|
protected function argTest():bool{
|
||||||
}
|
if($this->arg === null){
|
||||||
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
return false;
|
||||||
if(!key_exists('destNationID', $this->arg)){
|
}
|
||||||
return false;
|
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
||||||
}
|
if(!key_exists('destNationID', $this->arg)){
|
||||||
$destNationID = $this->arg['destNationID'];
|
return false;
|
||||||
|
}
|
||||||
if(!is_int($destNationID)){
|
$destNationID = $this->arg['destNationID'];
|
||||||
return false;
|
$commandType = $this->arg['commandType'];
|
||||||
}
|
|
||||||
if($destNationID < 1){
|
if(!is_int($destNationID)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if($destNationID < 1){
|
||||||
$this->arg = [
|
return false;
|
||||||
'destNationID'=>$destNationID
|
}
|
||||||
];
|
|
||||||
return true;
|
if(!is_string($commandType)){
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
protected function init(){
|
if(!in_array($commandType, GameConst::$availableChiefCommand['전략'])){
|
||||||
$general = $this->generalObj;
|
return false;
|
||||||
|
}
|
||||||
$env = $this->env;
|
|
||||||
|
|
||||||
$this->setCity();
|
$this->arg = [
|
||||||
$this->setNation(['strategic_cmd_limit']);
|
'destNationID'=>$destNationID,
|
||||||
|
'commandType'=>$commandType
|
||||||
$this->minConditionConstraints=[
|
];
|
||||||
ConstraintHelper::OccupiedCity(),
|
return true;
|
||||||
ConstraintHelper::BeChief(),
|
}
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
|
||||||
];
|
protected function init(){
|
||||||
}
|
$general = $this->generalObj;
|
||||||
|
|
||||||
protected function initWithArg()
|
$env = $this->env;
|
||||||
{
|
|
||||||
$this->setDestNation($this->arg['destNationID'], null);
|
$this->setCity();
|
||||||
|
$this->setNation();
|
||||||
$this->fullConditionConstraints=[
|
|
||||||
ConstraintHelper::OccupiedCity(),
|
$this->minConditionConstraints=[
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::ExistsDestNation(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
];
|
||||||
[0, 1],
|
}
|
||||||
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
|
||||||
),
|
protected function initWithArg()
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
{
|
||||||
];
|
$this->setDestNation($this->arg['destNationID'], null);
|
||||||
}
|
|
||||||
|
if($this->getNationID() == 0){
|
||||||
public function getCommandDetailTitle():string{
|
$this->fullConditionConstraints=[
|
||||||
$name = $this->getName();
|
ConstraintHelper::OccupiedCity()
|
||||||
$reqTurn = $this->getPreReqTurn()+1;
|
];
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
return;
|
||||||
|
}
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
|
||||||
}
|
$cmd = buildNationCommandClass($this->arg['commandType'], $this->generalObj, $this->env, new LastTurn());
|
||||||
|
|
||||||
public function getCost():array{
|
$currYearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
||||||
return [0, 0];
|
$nextAvailableTurn = $cmd->getNextAvailableTurn();
|
||||||
}
|
if($currYearMonth < $nextAvailableTurn){
|
||||||
|
$this->fullConditionConstraints=[
|
||||||
public function getPreReqTurn():int{
|
ConstraintHelper::AlwaysFail('해당 전략을 아직 사용할 수 없습니다')
|
||||||
return 2;
|
];
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
public function getPostReqTurn():int{
|
|
||||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
$this->fullConditionConstraints=[
|
||||||
$nextTerm = Util::round(sqrt($genCount*2)*10);
|
ConstraintHelper::OccupiedCity(),
|
||||||
|
ConstraintHelper::BeChief(),
|
||||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
ConstraintHelper::ExistsDestNation(),
|
||||||
return $nextTerm;
|
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
||||||
}
|
[0, 1],
|
||||||
|
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
||||||
public function getBrief():string{
|
),
|
||||||
$commandName = $this->getName();
|
];
|
||||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
}
|
||||||
return "【{$destNationName}】에 {$commandName}";
|
|
||||||
}
|
public function getCommandDetailTitle():string{
|
||||||
|
$name = $this->getName();
|
||||||
|
$reqTurn = $this->getPreReqTurn()+1;
|
||||||
public function run():bool{
|
|
||||||
if(!$this->hasFullConditionMet()){
|
return "{$name}/{$reqTurn}턴(대상 재사용 대기 {$this->getTargetPostReqTurn()})";
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
}
|
||||||
}
|
|
||||||
|
public function getCost():array{
|
||||||
$db = DB::db();
|
return [0, 0];
|
||||||
$env = $this->env;
|
}
|
||||||
|
|
||||||
$general = $this->generalObj;
|
public function getPreReqTurn():int{
|
||||||
$generalID = $general->getID();
|
return 1;
|
||||||
$generalName = $general->getName();
|
}
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
|
||||||
|
public function getPostReqTurn():int{
|
||||||
$year = $this->env['year'];
|
return 0;
|
||||||
$month = $this->env['month'];
|
}
|
||||||
|
|
||||||
$nation = $this->nation;
|
public function getTargetPostReqTurn():int{
|
||||||
$nationID = $nation['nation'];
|
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||||
$nationName = $nation['name'];
|
$nextTerm = Util::round(sqrt($genCount*2)*10);
|
||||||
|
|
||||||
$destNation = $this->destNation;
|
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||||
$destNationID = $destNation['nation'];
|
return $nextTerm;
|
||||||
$destNationName = $destNation['name'];
|
}
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
public function getBrief():string{
|
||||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
$commandName = $this->getName();
|
||||||
|
$cmd = buildNationCommandClass($this->arg['commandType'], $this->generalObj, $this->env, new LastTurn());
|
||||||
$commandName = $this->getName();
|
$targetCommandName = $cmd->getName();
|
||||||
$josaUl = JosaUtil::pick($commandName, '을');
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||||
|
return "【{$destNationName}】에 【{$targetCommandName}】 {$commandName}";
|
||||||
$logger = $general->getLogger();
|
}
|
||||||
$logger->pushGeneralActionLog("{$commandName} 발동! <1>$date</>");
|
|
||||||
|
|
||||||
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
public function run():bool{
|
||||||
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
if(!$this->hasFullConditionMet()){
|
||||||
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동하였습니다.";
|
}
|
||||||
|
|
||||||
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$db = DB::db();
|
||||||
foreach($nationGeneralList as $nationGeneralID){
|
$env = $this->env;
|
||||||
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
|
|
||||||
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$general = $this->generalObj;
|
||||||
$nationGeneralLogger->flush();
|
$generalID = $general->getID();
|
||||||
}
|
$generalName = $general->getName();
|
||||||
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
$josaYiCommand = JosaUtil::pick($commandName, '이');
|
|
||||||
|
$year = $this->env['year'];
|
||||||
$broadcastMessage = "아국에 <M>{$commandName}</>{$josaYiCommand} 발동되었습니다.";
|
$month = $this->env['month'];
|
||||||
|
|
||||||
$destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$nation = $this->nation;
|
||||||
foreach($destNationGeneralList as $destNationGeneralID){
|
$nationID = $nation['nation'];
|
||||||
$destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month);
|
$nationName = $nation['name'];
|
||||||
$destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
|
||||||
$destNationGeneralLogger->flush();
|
$destNation = $this->destNation;
|
||||||
}
|
$destNationID = $destNation['nation'];
|
||||||
|
$destNationName = $destNation['name'];
|
||||||
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
|
||||||
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <M>{$commandName}</>{$josaUl} 발동");
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
$destNationLogger->flush();
|
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||||
|
|
||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
$commandName = $this->getName();
|
||||||
|
$josaUl = JosaUtil::pick($commandName, '을');
|
||||||
$db->update('nation', [
|
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
$cmd = buildNationCommandClass($this->arg['commandType'], $this->generalObj, $this->env, new LastTurn());
|
||||||
], 'nation=%i', $nationID);
|
|
||||||
$db->update('nation', [
|
|
||||||
'strategic_cmd_limit' => $db->sqleval('strategic_cmd_limit + %i', static::$delayCnt)
|
$logger = $general->getLogger();
|
||||||
], 'nation = %i', $destNationID);
|
$logger->pushGeneralActionLog("<G><b>{$cmd->getName()}</b></> 전략의 {$commandName} 발동! <1>$date</>");
|
||||||
|
|
||||||
$general->applyDB($db);
|
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
||||||
|
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
||||||
return true;
|
|
||||||
}
|
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destNationName}</b></>에 <G><b>{$cmd->getName()}</b></> 전략의 <M>{$commandName}</>{$josaUl} 발동하였습니다.";
|
||||||
|
|
||||||
public function getJSFiles(): array
|
$nationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
{
|
foreach($nationGeneralList as $nationGeneralID){
|
||||||
return [
|
$nationGeneralLogger = new ActionLogger($nationGeneralID, $nationID, $year, $month);
|
||||||
'js/defaultSelectNationByMap.js'
|
$nationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
];
|
$nationGeneralLogger->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getForm(): string
|
$josaYiCommand = JosaUtil::pick($commandName, '이');
|
||||||
{
|
|
||||||
$generalObj = $this->generalObj;
|
$broadcastMessage = "아국에 <G><b>{$cmd->getName()}</b></> 전략의 <M>{$commandName}</>{$josaYiCommand} 발동되었습니다.";
|
||||||
$nationID = $generalObj->getNationID();
|
|
||||||
$nationList = [];
|
$destNationGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
|
foreach($destNationGeneralList as $destNationGeneralID){
|
||||||
foreach(getAllNationStaticInfo() as $destNation){
|
$destNationGeneralLogger = new ActionLogger($destNationGeneralID, $destNationID, $year, $month);
|
||||||
if($destNation['nation'] == $nationID){
|
$destNationGeneralLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
continue;
|
$destNationGeneralLogger->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$testTurn->setArg(['destNationID'=>$destNation['nation']]);
|
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
||||||
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID'=>$destNation['nation']]);
|
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <G><b>{$cmd->getName()}</b></> <M>{$commandName}</>{$josaUl} 발동");
|
||||||
if($testCommand->hasFullConditionMet()){
|
$destNationLogger->flush();
|
||||||
$destNation['availableCommand'] = true;
|
|
||||||
}
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <G><b>{$cmd->getName()}</b></> <M>{$commandName}</>{$josaUl} 발동");
|
||||||
else{
|
|
||||||
$destNation['availableCommand'] = false;
|
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||||
}
|
$destNationStor = KVStorage::getStorage($db, $destNationID, 'nation_env');
|
||||||
|
|
||||||
$nationList[] = $destNation;
|
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
|
||||||
}
|
$nationStor->setValue($cmd->getNextExecuteKey(), $yearMonth + $this->getTargetPostReqTurn());
|
||||||
|
$destNationStor->setValue($cmd->getNextExecuteKey(), $yearMonth + static::$delayCnt);
|
||||||
ob_start();
|
|
||||||
?>
|
$general->applyDB($db);
|
||||||
<?=\sammo\getMapHtml()?><br>
|
|
||||||
선택된 국가에 피장파장을 발동합니다.<br>
|
return true;
|
||||||
선포, 전쟁중인 상대국에만 가능합니다.<br>
|
}
|
||||||
상대 국가를 목록에서 선택하세요.<br>
|
|
||||||
배경색은 현재 피장파장 불가능 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
public function getJSFiles(): array
|
||||||
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
{
|
||||||
<?php foreach($nationList as $nation): ?>
|
return [
|
||||||
<option
|
'js/defaultSelectNationByMap.js'
|
||||||
value='<?=$nation['nation']?>'
|
];
|
||||||
style='color:<?=$nation['color']?>;<?=$nation['availableCommand']?'':'background-color:red;'?>'
|
}
|
||||||
>【<?=$nation['name']?> 】</option>
|
|
||||||
<?php endforeach; ?>
|
public function getForm(): string
|
||||||
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
|
{
|
||||||
<?php
|
$generalObj = $this->generalObj;
|
||||||
return ob_get_clean();
|
$nationID = $generalObj->getNationID();
|
||||||
}
|
$nationList = [];
|
||||||
|
$testTurn = new LastTurn($this->getName(), null, $this->getPreReqTurn());
|
||||||
|
foreach(getAllNationStaticInfo() as $destNation){
|
||||||
|
if($destNation['nation'] == $nationID){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$testTurn->setArg(['destNationID'=>$destNation['nation']]);
|
||||||
|
$testCommand = new static($generalObj, $this->env, $testTurn, ['destNationID'=>$destNation['nation']]);
|
||||||
|
if($testCommand->hasFullConditionMet()){
|
||||||
|
$destNation['availableCommand'] = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$destNation['availableCommand'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nationList[] = $destNation;
|
||||||
|
}
|
||||||
|
|
||||||
|
$availableCommandTypeList = [];
|
||||||
|
$currYearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
||||||
|
foreach(GameConst::$availableChiefCommand['전략'] as $commandType){
|
||||||
|
$cmd = buildNationCommandClass($commandType, $generalObj, $this->env, new LastTurn());
|
||||||
|
$cmdName = $cmd->getName();
|
||||||
|
$remainTurn = 0;
|
||||||
|
$nextAvailableTurn = $cmd->getNextAvailableTurn();
|
||||||
|
|
||||||
|
if($nextAvailableTurn !== null && $currYearMonth < $nextAvailableTurn){
|
||||||
|
$remainTurn = $nextAvailableTurn - $currYearMonth;
|
||||||
|
}
|
||||||
|
$availableCommandTypeList[$commandType] = [$cmdName, $remainTurn];
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
<?=\sammo\getMapHtml()?><br>
|
||||||
|
선택된 국가에 피장파장을 발동합니다.<br>
|
||||||
|
지정한 전략을 상대국이 <?=static::$delayCnt?>턴 동안 사용할 수 없게됩니다.<br>
|
||||||
|
대신 아국은 지정한 전략을<?=$this->getTargetPostReqTurn()?>턴 동안 사용할 수 없습니다.<br>
|
||||||
|
선포, 전쟁중인 상대국에만 가능합니다.<br>
|
||||||
|
상대 국가를 목록에서 선택하세요.<br>
|
||||||
|
배경색은 현재 피장파장 불가능 국가는 <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>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>에
|
||||||
|
<select class='formInput' name="commandType" id="commandType" size='1' style='color:white;background-color:black;'>
|
||||||
|
<?php foreach($availableCommandTypeList as $commandType=>[$cmdName, $cmdRemainTurn]):
|
||||||
|
/** @var \sammo\Command\NationCommand $cmdObj */
|
||||||
|
?>
|
||||||
|
<option
|
||||||
|
value='<?=$commandType?>'
|
||||||
|
style='color:white;<?=$cmdRemainTurn?'background-color:red;':''?>'
|
||||||
|
><?=$cmdName?><?=$cmdRemainTurn?"({$cmdRemainTurn}턴 뒤)":''?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select> 전략을
|
||||||
|
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
|
||||||
|
<?php
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,134 +1,134 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General, DummyGeneral,
|
General, DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
MessageTarget,
|
MessageTarget,
|
||||||
Message
|
Message
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
GetImageURL
|
GetImageURL
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
use sammo\Event\Action;
|
use sammo\Event\Action;
|
||||||
|
|
||||||
class che_필사즉생 extends Command\NationCommand{
|
class che_필사즉생 extends Command\NationCommand{
|
||||||
static protected $actionName = '필사즉생';
|
static protected $actionName = '필사즉생';
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = [];
|
$this->arg = [];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['strategic_cmd_limit']);
|
$this->setNation(['strategic_cmd_limit']);
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
ConstraintHelper::AllowDiplomacyStatus($this->generalObj->getNationID(), [
|
||||||
0
|
0
|
||||||
], '전쟁중이 아닙니다.'),
|
], '전쟁중이 아닙니다.'),
|
||||||
ConstraintHelper::AvailableStrategicCommand()
|
ConstraintHelper::AvailableStrategicCommand()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$reqTurn = $this->getPreReqTurn()+1;
|
$reqTurn = $this->getPreReqTurn()+1;
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
$postReqTurn = $this->getPostReqTurn();
|
||||||
|
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
return [0, 0];
|
return [0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||||
$nextTerm = Util::round(sqrt($genCount*8)*10);
|
$nextTerm = Util::round(sqrt($genCount*8)*10);
|
||||||
|
|
||||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||||
return $nextTerm;
|
return $nextTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
$generalID = $general->getID();
|
$generalID = $general->getID();
|
||||||
$generalName = $general->getName();
|
$generalName = $general->getName();
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$nationID = $general->getNationID();
|
$nationID = $general->getNationID();
|
||||||
$nationName = $this->nation['name'];
|
$nationName = $this->nation['name'];
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
$logger->pushGeneralActionLog("필사즉생 발동! <1>$date</>");
|
$logger->pushGeneralActionLog("필사즉생 발동! <1>$date</>");
|
||||||
|
|
||||||
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
||||||
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
|
|
||||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동하였습니다.";
|
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동하였습니다.";
|
||||||
|
|
||||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
foreach(General::createGeneralObjListFromDB($targetGeneralList, ['train', 'atmos'], 1) as $targetGeneral){
|
foreach(General::createGeneralObjListFromDB($targetGeneralList, ['train', 'atmos'], 1) as $targetGeneral){
|
||||||
$targetGeneral->getLogger()->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$targetGeneral->getLogger()->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
if($targetGeneral->getVar('train') < 100){
|
if($targetGeneral->getVar('train') < 100){
|
||||||
$targetGeneral->setVar('train', 100);
|
$targetGeneral->setVar('train', 100);
|
||||||
}
|
}
|
||||||
if($targetGeneral->getVar('atmos') < 100){
|
if($targetGeneral->getVar('atmos') < 100){
|
||||||
$targetGeneral->setVar('atmos', 100);
|
$targetGeneral->setVar('atmos', 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
$targetGeneral->applyDB($db);
|
$targetGeneral->applyDB($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($general->getVar('train') < 100){
|
if($general->getVar('train') < 100){
|
||||||
$general->setVar('train', 100);
|
$general->setVar('train', 100);
|
||||||
}
|
}
|
||||||
if($general->getVar('atmos') < 100){
|
if($general->getVar('atmos') < 100){
|
||||||
$general->setVar('atmos', 100);
|
$general->setVar('atmos', 100);
|
||||||
}
|
}
|
||||||
$logger->pushGeneralHistoryLog('<M>필사즉생</>을 발동');
|
$logger->pushGeneralHistoryLog('<M>필사즉생</>을 발동');
|
||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동");
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동");
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => $this->generalObj->onCalcStrategic($this->getName(), 'globalDelay', 9)
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+239
-239
@@ -1,239 +1,239 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Command\Nation;
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
use\sammo\{
|
use\sammo\{
|
||||||
DB,
|
DB,
|
||||||
Util,
|
Util,
|
||||||
JosaUtil,
|
JosaUtil,
|
||||||
General,
|
General,
|
||||||
DummyGeneral,
|
DummyGeneral,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
MessageTarget,
|
MessageTarget,
|
||||||
Message,
|
Message,
|
||||||
CityConst
|
CityConst
|
||||||
};
|
};
|
||||||
|
|
||||||
use function\sammo\{
|
use function\sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
GetImageURL,
|
GetImageURL,
|
||||||
getNationStaticInfo
|
getNationStaticInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
use sammo\Event\Action;
|
use sammo\Event\Action;
|
||||||
|
|
||||||
class che_허보 extends Command\NationCommand
|
class che_허보 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
static protected $actionName = '허보';
|
static protected $actionName = '허보';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest(): bool
|
protected function argTest(): bool
|
||||||
{
|
{
|
||||||
if ($this->arg === null) {
|
if ($this->arg === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!key_exists('destCityID', $this->arg)) {
|
if (!key_exists('destCityID', $this->arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (CityConst::byID($this->arg['destCityID']) === null) {
|
if (CityConst::byID($this->arg['destCityID']) === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$destCityID = $this->arg['destCityID'];
|
$destCityID = $this->arg['destCityID'];
|
||||||
|
|
||||||
$this->arg = [
|
$this->arg = [
|
||||||
'destCityID' => $destCityID,
|
'destCityID' => $destCityID,
|
||||||
];
|
];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['strategic_cmd_limit']);
|
$this->setNation(['strategic_cmd_limit']);
|
||||||
|
|
||||||
$this->minConditionConstraints = [
|
$this->minConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$this->setDestCity($this->arg['destCityID']);
|
$this->setDestCity($this->arg['destCityID']);
|
||||||
$this->setDestNation($this->destCity['nation']);
|
$this->setDestNation($this->destCity['nation']);
|
||||||
|
|
||||||
$this->fullConditionConstraints = [
|
$this->fullConditionConstraints = [
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::NotNeutralDestCity(),
|
ConstraintHelper::NotNeutralDestCity(),
|
||||||
ConstraintHelper::NotOccupiedDestCity(),
|
ConstraintHelper::NotOccupiedDestCity(),
|
||||||
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
||||||
[0, 1],
|
[0, 1],
|
||||||
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
||||||
),
|
),
|
||||||
ConstraintHelper::AvailableStrategicCommand(),
|
ConstraintHelper::AvailableStrategicCommand(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle(): string
|
public function getCommandDetailTitle(): string
|
||||||
{
|
{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$reqTurn = $this->getPreReqTurn() + 1;
|
$reqTurn = $this->getPreReqTurn() + 1;
|
||||||
$postReqTurn = $this->getPostReqTurn();
|
$postReqTurn = $this->getPostReqTurn();
|
||||||
|
|
||||||
return "{$name}/{$reqTurn}턴(전략$postReqTurn)";
|
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost(): array
|
public function getCost(): array
|
||||||
{
|
{
|
||||||
return [0, 0];
|
return [0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn(): int
|
public function getPreReqTurn(): int
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn(): int
|
public function getPostReqTurn(): int
|
||||||
{
|
{
|
||||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||||
$nextTerm = Util::round(sqrt($genCount * 4) * 10);
|
$nextTerm = Util::round(sqrt($genCount * 4) * 10);
|
||||||
|
|
||||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||||
return $nextTerm;
|
return $nextTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrief(): string
|
public function getBrief(): string
|
||||||
{
|
{
|
||||||
$commandName = $this->getName();
|
$commandName = $this->getName();
|
||||||
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
|
||||||
return "【{$destCityName}】에 {$commandName}";
|
return "【{$destCityName}】에 {$commandName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(): bool
|
public function run(): bool
|
||||||
{
|
{
|
||||||
if (!$this->hasFullConditionMet()) {
|
if (!$this->hasFullConditionMet()) {
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
$generalID = $general->getID();
|
$generalID = $general->getID();
|
||||||
$generalName = $general->getName();
|
$generalName = $general->getName();
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$year = $this->env['year'];
|
$year = $this->env['year'];
|
||||||
$month = $this->env['month'];
|
$month = $this->env['month'];
|
||||||
|
|
||||||
$destCity = $this->destCity;
|
$destCity = $this->destCity;
|
||||||
$destCityID = $destCity['city'];
|
$destCityID = $destCity['city'];
|
||||||
$destCityName = $destCity['name'];
|
$destCityName = $destCity['name'];
|
||||||
|
|
||||||
$destNationID = $destCity['nation'];
|
$destNationID = $destCity['nation'];
|
||||||
$destNationName = getNationStaticInfo($destNationID)['name'];
|
$destNationName = getNationStaticInfo($destNationID)['name'];
|
||||||
|
|
||||||
$nationID = $general->getNationID();
|
$nationID = $general->getNationID();
|
||||||
$nationName = $this->nation['name'];
|
$nationName = $this->nation['name'];
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
$logger->pushGeneralActionLog("허보 발동! <1>$date</>");
|
$logger->pushGeneralActionLog("허보 발동! <1>$date</>");
|
||||||
|
|
||||||
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
$general->addExperience(5 * ($this->getPreReqTurn() + 1));
|
||||||
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
$general->addDedication(5 * ($this->getPreReqTurn() + 1));
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($generalName, '이');
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
|
|
||||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>허보</>를 발동하였습니다.";
|
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>허보</>를 발동하였습니다.";
|
||||||
|
|
||||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||||
foreach ($targetGeneralList as $targetGeneralID) {
|
foreach ($targetGeneralList as $targetGeneralID) {
|
||||||
$targetLogger = new ActionLogger($targetGeneralID, $nationID, $year, $month);
|
$targetLogger = new ActionLogger($targetGeneralID, $nationID, $year, $month);
|
||||||
$targetLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
$targetLogger->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||||
$targetLogger->flush();
|
$targetLogger->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$destBroadcastMessage = "상대의 <M>허보</>에 당했다! <1>$date</>";
|
$destBroadcastMessage = "상대의 <M>허보</>에 당했다! <1>$date</>";
|
||||||
$destNationCityList = $db->queryFirstColumn('SELECT city FROM city WHERE nation = %i AND supply = 1', $destNationID);
|
$destNationCityList = $db->queryFirstColumn('SELECT city FROM city WHERE nation = %i AND supply = 1', $destNationID);
|
||||||
|
|
||||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i', $destNationID, $destCityID);
|
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i', $destNationID, $destCityID);
|
||||||
foreach (General::createGeneralObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral) {
|
foreach (General::createGeneralObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral) {
|
||||||
$targetLogger = $targetGeneral->getLogger();
|
$targetLogger = $targetGeneral->getLogger();
|
||||||
$targetLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
|
$targetLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
|
||||||
|
|
||||||
$moveCityID = Util::choiceRandom($destNationCityList);
|
$moveCityID = Util::choiceRandom($destNationCityList);
|
||||||
if ($moveCityID == $destCityID) {
|
if ($moveCityID == $destCityID) {
|
||||||
//현재도시면 다시 랜덤 추첨
|
//현재도시면 다시 랜덤 추첨
|
||||||
$moveCityID = Util::choiceRandom($destNationCityList);
|
$moveCityID = Util::choiceRandom($destNationCityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
$targetGeneral->setVar('city', $moveCityID);
|
$targetGeneral->setVar('city', $moveCityID);
|
||||||
$targetGeneral->applyDB($db);
|
$targetGeneral->applyDB($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
|
||||||
$destNationLogger->pushNationalHistoryLog(
|
$destNationLogger->pushNationalHistoryLog(
|
||||||
"<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국의 <G><b>{$destCityName}</b></>에 <M>허보</>를 발동",
|
"<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국의 <G><b>{$destCityName}</b></>에 <M>허보</>를 발동",
|
||||||
ActionLogger::PLAIN
|
ActionLogger::PLAIN
|
||||||
);
|
);
|
||||||
$destNationLogger->flush();
|
$destNationLogger->flush();
|
||||||
|
|
||||||
|
|
||||||
$db->update('city', [
|
$db->update('city', [
|
||||||
'def' => $db->sqleval('def * 0.2'),
|
'def' => $db->sqleval('def * 0.2'),
|
||||||
'wall' => $db->sqleval('wall * 0.2'),
|
'wall' => $db->sqleval('wall * 0.2'),
|
||||||
], 'city=%i', $destCityID);
|
], 'city=%i', $destCityID);
|
||||||
|
|
||||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||||
|
|
||||||
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>에 <M>허보</>를 발동");
|
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>에 <M>허보</>를 발동");
|
||||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>허보</>를 발동");
|
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>허보</>를 발동");
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'strategic_cmd_limit' => $this->getPostReqTurn()
|
'strategic_cmd_limit' => $this->generalObj->onCalcStrategic($this->getName(), 'globalDelay', 9)
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
$this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0));
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJSFiles(): array
|
public function getJSFiles(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'js/defaultSelectCityByMap.js'
|
'js/defaultSelectCityByMap.js'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getForm(): string
|
public function getForm(): string
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<?= \sammo\getMapHtml() ?><br>
|
<?= \sammo\getMapHtml() ?><br>
|
||||||
선택된 도시에 허보를 발동합니다.<br>
|
선택된 도시에 허보를 발동합니다.<br>
|
||||||
전쟁중인 상대국 도시만 가능합니다.<br>
|
전쟁중인 상대국 도시만 가능합니다.<br>
|
||||||
목록을 선택하거나 도시를 클릭하세요.<br>
|
목록을 선택하거나 도시를 클릭하세요.<br>
|
||||||
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
|
||||||
<?= \sammo\optionsForCities() ?><br>
|
<?= \sammo\optionsForCities() ?><br>
|
||||||
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
|
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
|
||||||
<br>
|
<br>
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,59 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command;
|
namespace sammo\Command;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
use \sammo\LastTurn;
|
use sammo\KVStorage;
|
||||||
|
use \sammo\LastTurn;
|
||||||
abstract class NationCommand extends BaseCommand{
|
use \sammo\Util;
|
||||||
protected $lastTurn;
|
|
||||||
protected $resultTurn;
|
abstract class NationCommand extends BaseCommand{
|
||||||
|
protected $lastTurn;
|
||||||
public function __construct(General $generalObj, array $env, LastTurn $lastTurn, $arg = null){
|
protected $resultTurn;
|
||||||
$this->lastTurn = $lastTurn;
|
|
||||||
$this->resultTurn = $lastTurn->duplicate();
|
public function __construct(General $generalObj, array $env, LastTurn $lastTurn, $arg = null){
|
||||||
parent::__construct($generalObj, $env, $arg);
|
$this->lastTurn = $lastTurn;
|
||||||
}
|
$this->resultTurn = $lastTurn->duplicate();
|
||||||
|
parent::__construct($generalObj, $env, $arg);
|
||||||
public function getLastTurn():LastTurn{
|
}
|
||||||
return $this->lastTurn;
|
|
||||||
}
|
public function getLastTurn():LastTurn{
|
||||||
|
return $this->lastTurn;
|
||||||
public function setResultTurn(LastTurn $lastTurn){
|
}
|
||||||
$this->resultTurn = $lastTurn;
|
|
||||||
}
|
public function setResultTurn(LastTurn $lastTurn){
|
||||||
|
$this->resultTurn = $lastTurn;
|
||||||
public function getResultTurn():LastTurn{
|
}
|
||||||
return $this->resultTurn;
|
|
||||||
}
|
public function getResultTurn():LastTurn{
|
||||||
|
return $this->resultTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextExecuteKey():string{
|
||||||
|
$turnKey = static::$actionName;
|
||||||
|
$executeKey = "next_execute_{$turnKey}";
|
||||||
|
return $executeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextAvailableTurn():?int{
|
||||||
|
if($this->isArgValid && !$this->getPostReqTurn()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$db = \sammo\DB::db();
|
||||||
|
$nationStor = \sammo\KVStorage::getStorage($db, $this->getNationID(), 'nation_env');
|
||||||
|
return $nationStor->getValue($this->getNextExecuteKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNextAvailable(?int $yearMonth=null){
|
||||||
|
if(!$this->getPostReqTurn()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($yearMonth === null){
|
||||||
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month'])
|
||||||
|
+ $this->getPostReqTurn() - $this->getPreReqTurn();
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = \sammo\DB::db();
|
||||||
|
$nationStor = \sammo\KVStorage::getStorage($db, $this->getNationID(), 'nation_env');
|
||||||
|
$nationStor->setValue($this->getNextExecuteKey(), $yearMonth);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -1,32 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Constraint;
|
namespace sammo\Constraint;
|
||||||
|
|
||||||
class AvailableStrategicCommand extends Constraint{
|
class AvailableStrategicCommand extends Constraint{
|
||||||
const REQ_VALUES = Constraint::REQ_NATION;
|
const REQ_VALUES = Constraint::REQ_NATION | Constraint::REQ_INT_ARG;
|
||||||
|
|
||||||
public function checkInputValues(bool $throwExeception=true):bool{
|
public function checkInputValues(bool $throwExeception=true):bool{
|
||||||
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
|
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!key_exists('strategic_cmd_limit', $this->nation)){
|
if(!key_exists('strategic_cmd_limit', $this->nation)){
|
||||||
if(!$throwExeception){return false; }
|
if(!$throwExeception){return false; }
|
||||||
throw new \InvalidArgumentException("require strategic_cmd_limit in nation");
|
throw new \InvalidArgumentException("require strategic_cmd_limit in nation");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test():bool{
|
public function test():bool{
|
||||||
$this->checkInputValues();
|
$this->checkInputValues();
|
||||||
$this->tested = true;
|
$this->tested = true;
|
||||||
|
|
||||||
if($this->nation['strategic_cmd_limit'] == 0){
|
if($this->nation['strategic_cmd_limit'] <= $this->arg){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->reason = "전략기한이 남았습니다.";
|
$this->reason = "전략기한이 남았습니다.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,274 +1,274 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace sammo\Constraint;
|
namespace sammo\Constraint;
|
||||||
|
|
||||||
class ConstraintHelper{
|
class ConstraintHelper{
|
||||||
|
|
||||||
static function AdhocCallback(callable $callback):array{
|
static function AdhocCallback(callable $callback):array{
|
||||||
return [__FUNCTION__, $callback];
|
return [__FUNCTION__, $callback];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AllowDiplomacyStatus(int $nationID, array $allowList, string $errMsg):array{
|
static function AllowDiplomacyStatus(int $nationID, array $allowList, string $errMsg):array{
|
||||||
return [__FUNCTION__, [$nationID, $allowList, $errMsg]];
|
return [__FUNCTION__, [$nationID, $allowList, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AllowDiplomacyBetweenStatus(array $allowDipCodeList, string $errMsg):array{
|
static function AllowDiplomacyBetweenStatus(array $allowDipCodeList, string $errMsg):array{
|
||||||
return [__FUNCTION__, [$allowDipCodeList, $errMsg]];
|
return [__FUNCTION__, [$allowDipCodeList, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AllowDiplomacyWithTerm(int $allowDipCode, int $allowMinTerm, string $errMsg):array{
|
static function AllowDiplomacyWithTerm(int $allowDipCode, int $allowMinTerm, string $errMsg):array{
|
||||||
return [__FUNCTION__, [$allowDipCode, $allowMinTerm, $errMsg]];
|
return [__FUNCTION__, [$allowDipCode, $allowMinTerm, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AllowJoinAction():array{
|
static function AllowJoinAction():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AllowJoinDestNation(int $relYear):array{
|
static function AllowJoinDestNation(int $relYear):array{
|
||||||
return [__FUNCTION__, $relYear];
|
return [__FUNCTION__, $relYear];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AllowRebellion():array{
|
static function AllowRebellion():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AllowWar():array{
|
static function AllowWar():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AlwaysFail(string $failMessage):array{
|
static function AlwaysFail(string $failMessage):array{
|
||||||
return [__FUNCTION__, $failMessage];
|
return [__FUNCTION__, $failMessage];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AvailableRecruitCrewType(int $crewTypeID):array{
|
static function AvailableRecruitCrewType(int $crewTypeID):array{
|
||||||
return [__FUNCTION__, $crewTypeID];
|
return [__FUNCTION__, $crewTypeID];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function AvailableStrategicCommand():array{
|
static function AvailableStrategicCommand(int $allowTurnCnt=0):array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__, $allowTurnCnt];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function BattleGroundCity():array{
|
static function BattleGroundCity():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function BeChief():array{
|
static function BeChief():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function BeLord():array{
|
static function BeLord():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function BeNeutral():array{
|
static function BeNeutral():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function BeOpeningPart(int $relYear):array{
|
static function BeOpeningPart(int $relYear):array{
|
||||||
return [__FUNCTION__, $relYear];
|
return [__FUNCTION__, $relYear];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function CheckNationNameDuplicate(string $nationName):array{
|
static function CheckNationNameDuplicate(string $nationName):array{
|
||||||
return [__FUNCTION__, $nationName];
|
return [__FUNCTION__, $nationName];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ConstructableCity():array{
|
static function ConstructableCity():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function DifferentNationDestGeneral():array{
|
static function DifferentNationDestGeneral():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function DifferentDestNation():array{
|
static function DifferentDestNation():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function DisallowDiplomacyBetweenStatus(array $disallowList):array{
|
static function DisallowDiplomacyBetweenStatus(array $disallowList):array{
|
||||||
return [__FUNCTION__, $disallowList];
|
return [__FUNCTION__, $disallowList];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function DisallowDiplomacyStatus(int $nationID, array $disallowList):array{
|
static function DisallowDiplomacyStatus(int $nationID, array $disallowList):array{
|
||||||
return [__FUNCTION__, [$nationID, $disallowList]];
|
return [__FUNCTION__, [$nationID, $disallowList]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ExistsAllowJoinNation(int $relYear, array $excludeNationList):array{
|
static function ExistsAllowJoinNation(int $relYear, array $excludeNationList):array{
|
||||||
return [__FUNCTION__, [$relYear, $excludeNationList]];
|
return [__FUNCTION__, [$relYear, $excludeNationList]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ExistsDestGeneral():array{
|
static function ExistsDestGeneral():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ExistsDestNation():array{
|
static function ExistsDestNation():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function FriendlyDestGeneral():array{
|
static function FriendlyDestGeneral():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function HasRoute():array{
|
static function HasRoute():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function HasRouteWithEnemy():array{
|
static function HasRouteWithEnemy():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function MustBeNPC():array{
|
static function MustBeNPC():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function MustBeTroopLeader():array{
|
static function MustBeTroopLeader():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NearCity(int $distance):array{
|
static function NearCity(int $distance):array{
|
||||||
return [__FUNCTION__, $distance];
|
return [__FUNCTION__, $distance];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NearNation():array{
|
static function NearNation():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotBeNeutral():array{
|
static function NotBeNeutral():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotCapital(bool $ignoreOfficer=false):array{
|
static function NotCapital(bool $ignoreOfficer=false):array{
|
||||||
return [__FUNCTION__, $ignoreOfficer];
|
return [__FUNCTION__, $ignoreOfficer];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotChief():array{
|
static function NotChief():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotLord():array{
|
static function NotLord():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotNeutralDestCity():array{
|
static function NotNeutralDestCity():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotOccupiedDestCity():array{
|
static function NotOccupiedDestCity():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotOpeningPart(int $relYear):array{
|
static function NotOpeningPart(int $relYear):array{
|
||||||
return [__FUNCTION__, $relYear];
|
return [__FUNCTION__, $relYear];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotSameDestCity():array{
|
static function NotSameDestCity():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function NotWanderingNation():array{
|
static function NotWanderingNation():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function OccupiedCity(bool $allowNeutral=false):array{
|
static function OccupiedCity(bool $allowNeutral=false):array{
|
||||||
return [__FUNCTION__, $allowNeutral];
|
return [__FUNCTION__, $allowNeutral];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function OccupiedDestCity():array{
|
static function OccupiedDestCity():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function RemainCityCapacity($key, string $actionName):array{
|
static function RemainCityCapacity($key, string $actionName):array{
|
||||||
return [__FUNCTION__, [$key, $actionName]];
|
return [__FUNCTION__, [$key, $actionName]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function RemainCityTrust(string $actionName):array{
|
static function RemainCityTrust(string $actionName):array{
|
||||||
return [__FUNCTION__, $actionName];
|
return [__FUNCTION__, $actionName];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqCityCapacity($key, string $keyNick, $reqVal):array{
|
static function ReqCityCapacity($key, string $keyNick, $reqVal):array{
|
||||||
return [__FUNCTION__, [$key, $keyNick, $reqVal]];
|
return [__FUNCTION__, [$key, $keyNick, $reqVal]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqCityTrust(float $minTrust):array{
|
static function ReqCityTrust(float $minTrust):array{
|
||||||
return [__FUNCTION__, $minTrust];
|
return [__FUNCTION__, $minTrust];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqCityValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
static function ReqCityValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
||||||
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqDestCityValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
static function ReqDestCityValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
||||||
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqCityTrader(int $npcType):array{
|
static function ReqCityTrader(int $npcType):array{
|
||||||
return [__FUNCTION__, $npcType];
|
return [__FUNCTION__, $npcType];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqDestNationValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
static function ReqDestNationValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
||||||
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqEnvValue($key, string $comp, $reqVal, string $failMessage):array{
|
static function ReqEnvValue($key, string $comp, $reqVal, string $failMessage):array{
|
||||||
return [__FUNCTION__, [$key, $comp, $reqVal, $failMessage]];
|
return [__FUNCTION__, [$key, $comp, $reqVal, $failMessage]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqGeneralAtmosMargin(int $maxAtmos):array{
|
static function ReqGeneralAtmosMargin(int $maxAtmos):array{
|
||||||
return [__FUNCTION__, $maxAtmos];
|
return [__FUNCTION__, $maxAtmos];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqGeneralCrew():array{
|
static function ReqGeneralCrew():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqGeneralCrewMargin(int $crewTypeID):array{
|
static function ReqGeneralCrewMargin(int $crewTypeID):array{
|
||||||
return [__FUNCTION__, $crewTypeID];
|
return [__FUNCTION__, $crewTypeID];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqGeneralGold(int $reqGold):array{
|
static function ReqGeneralGold(int $reqGold):array{
|
||||||
return [__FUNCTION__, $reqGold];
|
return [__FUNCTION__, $reqGold];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqGeneralRice(int $reqRice):array{
|
static function ReqGeneralRice(int $reqRice):array{
|
||||||
return [__FUNCTION__, $reqRice];
|
return [__FUNCTION__, $reqRice];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqGeneralTrainMargin(int $maxTrain):array{
|
static function ReqGeneralTrainMargin(int $maxTrain):array{
|
||||||
return [__FUNCTION__, $maxTrain];
|
return [__FUNCTION__, $maxTrain];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqGeneralValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
static function ReqGeneralValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
||||||
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqNationGold(int $reqGold):array{
|
static function ReqNationGold(int $reqGold):array{
|
||||||
return [__FUNCTION__, $reqGold];
|
return [__FUNCTION__, $reqGold];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqNationRice(int $reqRice):array{
|
static function ReqNationRice(int $reqRice):array{
|
||||||
return [__FUNCTION__, $reqRice];
|
return [__FUNCTION__, $reqRice];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqNationValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
static function ReqNationValue($key, string $keyNick, string $comp, $reqVal, ?string $errMsg=null):array{
|
||||||
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqNationAuxValue($key, $defaultValue, string $comp, $reqVal, string $errMsg):array{
|
static function ReqNationAuxValue($key, $defaultValue, string $comp, $reqVal, string $errMsg):array{
|
||||||
return [__FUNCTION__, [$key, $defaultValue, $comp, $reqVal, $errMsg]];
|
return [__FUNCTION__, [$key, $defaultValue, $comp, $reqVal, $errMsg]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function ReqTroopMembers():array{
|
static function ReqTroopMembers():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function SuppliedCity():array{
|
static function SuppliedCity():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function SuppliedDestCity():array{
|
static function SuppliedDestCity():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function WanderingNation():array{
|
static function WanderingNation():array{
|
||||||
return [__FUNCTION__];
|
return [__FUNCTION__];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user