Compare commits
300
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5432590591 | ||
|
|
a38a8867ee | ||
|
|
9da44d0001 | ||
|
|
fc6f84ce23 | ||
|
|
5d9512ced7 | ||
|
|
136acadd04 | ||
|
|
bee18f20d0 | ||
|
|
f16a6b6880 | ||
|
|
3b2fd1082f | ||
|
|
faab4561f6 | ||
|
|
f4a1e2258d | ||
|
|
4ffd7b5bc0 | ||
|
|
dcddea15b4 | ||
|
|
90d078c100 | ||
|
|
765dee831c | ||
|
|
e7c773709d | ||
|
|
1e30659bdd | ||
|
|
162f198f08 | ||
|
|
10c4814f34 | ||
|
|
fe221a7bd9 | ||
|
|
4aa09a294e | ||
|
|
191abf83c0 | ||
|
|
edfeae5f0f | ||
|
|
424184a51a | ||
|
|
03a321f95d | ||
|
|
e3615fa6bb | ||
|
|
32991f736d | ||
|
|
8b2748d3d4 | ||
|
|
883080e275 | ||
|
|
ce807e2564 | ||
|
|
9a2ac82373 | ||
|
|
3c35539c16 | ||
|
|
5ab08403c6 | ||
|
|
c1ce478d22 | ||
|
|
d8bf8ba922 | ||
|
|
8cdc9c9b84 | ||
|
|
df189f4408 | ||
|
|
47fa7885c5 | ||
|
|
004dbb39b4 | ||
|
|
cd94c15137 | ||
|
|
eeb965353e | ||
|
|
6dd09bd4b4 | ||
|
|
a73189a604 | ||
|
|
4341341a07 | ||
|
|
4b82f0b35c | ||
|
|
b417e117ad | ||
|
|
85e435e99d | ||
|
|
e48c13a92f | ||
|
|
4495f0c06e | ||
|
|
312711b7ed | ||
|
|
3e8c18b8d3 | ||
|
|
fb0f768f2c | ||
|
|
5fc230d89b | ||
|
|
5fd1a6c752 | ||
|
|
76a5ea273a | ||
|
|
3d0a5a4be8 | ||
|
|
23309113ec | ||
|
|
1a1bc541f5 | ||
|
|
20060a89fd | ||
|
|
24f788d1a0 | ||
|
|
813957479d | ||
|
|
cdf58c54e0 | ||
|
|
6399134380 | ||
|
|
eb49e6f8ff | ||
|
|
ef855eb2cc | ||
|
|
c970e6586d | ||
|
|
6eaa529048 | ||
|
|
fe39241a90 | ||
|
|
d936d93be8 | ||
|
|
89127c0258 | ||
|
|
57aa07453e | ||
|
|
0722f6ab5e | ||
|
|
b9c51da782 | ||
|
|
c290404e42 | ||
|
|
cc0f965cb4 | ||
|
|
64736d194e | ||
|
|
963b04e8b0 | ||
|
|
e58ffab2a2 | ||
|
|
de29e2e157 | ||
|
|
7aa1b1889c | ||
|
|
618cfe5720 | ||
|
|
a8cecf8ec2 | ||
|
|
d858c64a3c | ||
|
|
f49b1d26a5 | ||
|
|
92e5f2472d | ||
|
|
11144f1f88 | ||
|
|
34c9a9b53e | ||
|
|
84d9cf9eb4 | ||
|
|
8a4cc5df21 | ||
|
|
df0b8ccebe | ||
|
|
ac47bc58bd | ||
|
|
570ef6f005 | ||
|
|
7eecde62fa | ||
|
|
4e0e5c9cd7 | ||
|
|
18abcde0d5 | ||
|
|
6176b64c28 | ||
|
|
3bae1157b6 | ||
|
|
5a51ad5699 | ||
|
|
312d20269c | ||
|
|
178d6f042b | ||
|
|
3352b64d0f | ||
|
|
e7d86a16d5 | ||
|
|
820c25d8dc | ||
|
|
f2dcb4d4d1 | ||
|
|
de357cfe95 | ||
|
|
0f333f8c96 | ||
|
|
93e8adadac | ||
|
|
8f98626075 | ||
|
|
a321eb1362 | ||
|
|
1a17fad0a5 | ||
|
|
c74efbb372 | ||
|
|
66f79ca5d2 | ||
|
|
f42f844f17 | ||
|
|
aee98e15d7 | ||
|
|
0936dabc9e | ||
|
|
39b209caf0 | ||
|
|
07867b3aaf | ||
|
|
de1f74cb44 | ||
|
|
65c97107c6 | ||
|
|
d796eda13c | ||
|
|
2a9029470f | ||
|
|
254364bab8 | ||
|
|
0319410ade | ||
|
|
6b64f6f8ed | ||
|
|
62fcb2e987 | ||
|
|
ff3ef4e4f3 | ||
|
|
008b0e416c | ||
|
|
bf96849027 | ||
|
|
1b035e4a42 | ||
|
|
47dec60c2b | ||
|
|
c03a28be93 | ||
|
|
d1ab2b0450 | ||
|
|
95f66e4c39 | ||
|
|
fe9ae97821 | ||
|
|
98e0a676cb | ||
|
|
2bb1387bc4 | ||
|
|
af382c541e | ||
|
|
8616a094e5 | ||
|
|
4de7ebec17 | ||
|
|
d43dff35fb | ||
|
|
5b13f8bd30 | ||
|
|
e51bc6f711 | ||
|
|
1b08aa0c58 | ||
|
|
f2547fe207 | ||
|
|
cec7726731 | ||
|
|
d679a6fed8 | ||
|
|
6fe156eb7c | ||
|
|
663ddbe76a | ||
|
|
30297454f7 | ||
|
|
bc602722bf | ||
|
|
be8f147216 | ||
|
|
b9495fb64a | ||
|
|
07b217b290 | ||
|
|
42fac46062 | ||
|
|
24bc8985d0 | ||
|
|
76a2d5ff63 | ||
|
|
148f32f78b | ||
|
|
62f5b6597e | ||
|
|
7e810b0279 | ||
|
|
2336b29b65 | ||
|
|
185c0e16a0 | ||
|
|
656baeb9ee | ||
|
|
3e06304dc7 | ||
|
|
4bb940c8c5 | ||
|
|
2b376b6aab | ||
|
|
04df26ff83 | ||
|
|
aca4240b92 | ||
|
|
faf26fa8a2 | ||
|
|
030ab1e7ea | ||
|
|
7f2c1d4782 | ||
|
|
9132138a99 | ||
|
|
84875d60bd | ||
|
|
3cbaf76626 | ||
|
|
f4846d0d66 | ||
|
|
f183dcc72b | ||
|
|
63cc5d8e88 | ||
|
|
f858c32fdf | ||
|
|
60eb127d71 | ||
|
|
ede33f3a37 | ||
|
|
ffd53a2390 | ||
|
|
2591fbde67 | ||
|
|
922d3f1938 | ||
|
|
64522ba8a6 | ||
|
|
7b1eedb574 | ||
|
|
7ec6ca605f | ||
|
|
5a5c613814 | ||
|
|
1a3ef20a35 | ||
|
|
fba966177d | ||
|
|
62c72dfdbe | ||
|
|
1ae1ff9b72 | ||
|
|
c1e12c2737 | ||
|
|
de09a66d6f | ||
|
|
3c2012da46 | ||
|
|
d55be54320 | ||
|
|
dcbefa1a96 | ||
|
|
be8f1fff96 | ||
|
|
6117dbdcc0 | ||
|
|
0a39ba1023 | ||
|
|
dae5f65baa | ||
|
|
080bb30103 | ||
|
|
9e647c7ce5 | ||
|
|
73606b0fb4 | ||
|
|
e62eb36cc2 | ||
|
|
6b81f744d4 | ||
|
|
1a9b3b78cb | ||
|
|
c3cbf956d0 | ||
|
|
91188c555d | ||
|
|
913028dd6c | ||
|
|
dfb3f6478d | ||
|
|
6afc6221d3 | ||
|
|
7b5a02487e | ||
|
|
533b79762e | ||
|
|
53b7dbfdd0 | ||
|
|
fd14c5403b | ||
|
|
dc476e73a1 | ||
|
|
e60150705e | ||
|
|
2869ba5c42 | ||
|
|
91e56644b4 | ||
|
|
e0b7a3d763 | ||
|
|
6a25f03687 | ||
|
|
104f306deb | ||
|
|
09c21cd466 | ||
|
|
5b89797f57 | ||
|
|
ab1cc5146d | ||
|
|
2483a7723f | ||
|
|
367db15d93 | ||
|
|
30e02aac08 | ||
|
|
ce5ddf05fe | ||
|
|
475837bca0 | ||
|
|
bd0ae25afd | ||
|
|
688de08feb | ||
|
|
83b550adbe | ||
|
|
fa89bae7d9 | ||
|
|
456246362f | ||
|
|
b472440ec1 | ||
|
|
7b5613d032 | ||
|
|
f5b3b985ce | ||
|
|
515298700a | ||
|
|
41d7566acb | ||
|
|
f4196263fa | ||
|
|
6bc69ac467 | ||
|
|
15b2c8b8e6 | ||
|
|
8e1d33e880 | ||
|
|
797902552d | ||
|
|
f3d2dcdad2 | ||
|
|
928478a8ad | ||
|
|
5023ee800b | ||
|
|
4a70625487 | ||
|
|
26327b5c8c | ||
|
|
372f47760b | ||
|
|
3111a5eb71 | ||
|
|
74f914488b | ||
|
|
a8d219afec | ||
|
|
4b4a7ffdf0 | ||
|
|
98e2e2f125 | ||
|
|
05000ae954 | ||
|
|
85bf53f317 | ||
|
|
d65407079e | ||
|
|
a8c9946aa9 | ||
|
|
1e5b2de913 | ||
|
|
747ab3d563 | ||
|
|
82ffbba661 | ||
|
|
3f08876079 | ||
|
|
5622839ffa | ||
|
|
4b3ab5e31c | ||
|
|
f774a28e2a | ||
|
|
61bdb8da01 | ||
|
|
c117ada117 | ||
|
|
1f0d0f992d | ||
|
|
6445b77b90 | ||
|
|
6d935733e6 | ||
|
|
cfd0a2d26f | ||
|
|
749e8f673b | ||
|
|
4812f324e0 | ||
|
|
085f34b307 | ||
|
|
622ce7b780 | ||
|
|
34b1fc9c5e | ||
|
|
9cc27c40aa | ||
|
|
eece1cbae5 | ||
|
|
7e6770b5e7 | ||
|
|
a0c032c2c6 | ||
|
|
3d12de3838 | ||
|
|
477b77b59f | ||
|
|
04a7a34fcc | ||
|
|
86f1805160 | ||
|
|
d573e9f98a | ||
|
|
3ad16d96be | ||
|
|
d8870caf29 | ||
|
|
7c9d5d34f6 | ||
|
|
5268ce9b71 | ||
|
|
e395c98a6c | ||
|
|
d5897e2a49 | ||
|
|
c82003f982 | ||
|
|
5447274aa8 | ||
|
|
688162ffbf | ||
|
|
220d1d821d | ||
|
|
2b16c3c1a9 | ||
|
|
d731acdaef | ||
|
|
3511b159a8 | ||
|
|
87294d5477 |
@@ -29,6 +29,7 @@ d_pic/*.jpg
|
|||||||
d_pic/*.gif
|
d_pic/*.gif
|
||||||
d_pic/*.png
|
d_pic/*.png
|
||||||
d_pic/*.webp
|
d_pic/*.webp
|
||||||
|
d_pic/*.avif
|
||||||
d_pic/uploaded_image
|
d_pic/uploaded_image
|
||||||
|
|
||||||
/dist_js
|
/dist_js
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"brandonwamboldt/utilphp": "^1.1",
|
|
||||||
"sergeytsalkov/meekrodb": "^2.5",
|
"sergeytsalkov/meekrodb": "^2.5",
|
||||||
"league/plates": "^3.5",
|
"league/plates": "^3.5",
|
||||||
"vlucas/valitron": "^1.4",
|
"vlucas/valitron": "^1.4",
|
||||||
|
|||||||
Generated
+2
-52
@@ -4,58 +4,8 @@
|
|||||||
"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": "deed9afdc95bc42f84784df67d295223",
|
"content-hash": "7edae9b6be35e66ffd0d180f5fac6679",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
|
||||||
"name": "brandonwamboldt/utilphp",
|
|
||||||
"version": "1.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/brandonwamboldt/utilphp.git",
|
|
||||||
"reference": "36c32efc4f0679c05163464a550f45c8d83fe683"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/brandonwamboldt/utilphp/zipball/36c32efc4f0679c05163464a550f45c8d83fe683",
|
|
||||||
"reference": "36c32efc4f0679c05163464a550f45c8d83fe683",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"satooshi/php-coveralls": "dev-master"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"utilphp\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Brandon Wamboldt",
|
|
||||||
"email": "brandon.wamboldt@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "util.php is a collection of useful functions and snippets that you need or could use every day, designed to avoid conflicts with existing projects",
|
|
||||||
"homepage": "https://github.com/brandonwamboldt/utilphp",
|
|
||||||
"keywords": [
|
|
||||||
"collection",
|
|
||||||
"helpers",
|
|
||||||
"php",
|
|
||||||
"utility"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/brandonwamboldt/utilphp/issues",
|
|
||||||
"source": "https://github.com/brandonwamboldt/utilphp/tree/master"
|
|
||||||
},
|
|
||||||
"time": "2015-02-02T17:56:14+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
"version": "0.12.1",
|
"version": "0.12.1",
|
||||||
@@ -5721,5 +5671,5 @@
|
|||||||
"platform-overrides": {
|
"platform-overrides": {
|
||||||
"php": "8.3"
|
"php": "8.3"
|
||||||
},
|
},
|
||||||
"plugin-api-version": "2.3.0"
|
"plugin-api-version": "2.6.0"
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -99,7 +99,10 @@ function logError(string $err, string $errstr, string $errpath, array $trace)
|
|||||||
$err = str_replace(ROOT, '{ROOT}', $err);
|
$err = str_replace(ROOT, '{ROOT}', $err);
|
||||||
$errstr = str_replace(ROOT, '{ROOT}', $errstr);
|
$errstr = str_replace(ROOT, '{ROOT}', $errstr);
|
||||||
$errpath = str_replace(ROOT, '{ROOT}', $errpath);
|
$errpath = str_replace(ROOT, '{ROOT}', $errpath);
|
||||||
$trace = array_map(function (string $text) {
|
$trace = array_map(function (string|array $text) {
|
||||||
|
if (is_array($text)) {
|
||||||
|
$text = Json::encode($text);
|
||||||
|
}
|
||||||
return str_replace(ROOT, '{ROOT}', $text);
|
return str_replace(ROOT, '{ROOT}', $text);
|
||||||
}, $trace);
|
}, $trace);
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ $rootDB->insert('member', [
|
|||||||
'token_valid_until' => '2999-01-01 00:00:00',
|
'token_valid_until' => '2999-01-01 00:00:00',
|
||||||
'pw' => $finalPassword,
|
'pw' => $finalPassword,
|
||||||
'salt' => $userSalt,
|
'salt' => $userSalt,
|
||||||
'grade' => 6,
|
'grade' => 7,
|
||||||
'name' => $nickname,
|
'name' => $nickname,
|
||||||
'reg_date' => $nowDate
|
'reg_date' => $nowDate
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -92,4 +92,14 @@ CREATE TABLE `login_token` (
|
|||||||
INDEX `by_date` (`user_id`, `expire_date`)
|
INDEX `by_date` (`user_id`, `expire_date`)
|
||||||
)
|
)
|
||||||
COLLATE='utf8mb4_general_ci'
|
COLLATE='utf8mb4_general_ci'
|
||||||
ENGINE=Aria;
|
ENGINE=Aria;
|
||||||
|
|
||||||
|
CREATE TABLE `banned_member` (
|
||||||
|
`no` INT NOT NULL AUTO_INCREMENT,
|
||||||
|
`hashed_email` VARCHAR(128) NOT NULL COLLATE 'utf8mb4_general_ci' COMMENT 'SHA512(salt | email | salt )',
|
||||||
|
`info` TEXT NULL COLLATE 'utf8mb4_general_ci' COMMENT '부가정보',
|
||||||
|
PRIMARY KEY (`no`),
|
||||||
|
UNIQUE INDEX `email` (`hashed_email`(128))
|
||||||
|
)
|
||||||
|
COLLATE='utf8mb4_general_ci'
|
||||||
|
ENGINE = Aria;
|
||||||
+5
-2
@@ -13,6 +13,9 @@ $db = DB::db();
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
[$turntime, $tnmt_time] = $gameStor->getValuesAsArray(['turntime','tnmt_time']);
|
[$turntime, $tnmt_time] = $gameStor->getValuesAsArray(['turntime','tnmt_time']);
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
$turntimeDisplay = $clock->formatTick(Util::toInt($turntime), true);
|
||||||
|
$tnmtTimeDisplay = $tnmt_time === null ? '-' : $clock->formatTick(Util::toInt($tnmt_time), true);
|
||||||
|
|
||||||
$plock = $db->queryFirstField('SELECT plock FROM plock WHERE `type` ="GAME"');
|
$plock = $db->queryFirstField('SELECT plock FROM plock WHERE `type` ="GAME"');
|
||||||
?>
|
?>
|
||||||
@@ -30,8 +33,8 @@ $plock = $db->queryFirstField('SELECT plock FROM plock WHERE `type` ="GAME"');
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<form action=_119_b.php method=post>
|
<form action=_119_b.php method=post>
|
||||||
시간조정 : <input type=text size=3 name=minute><input type=submit name=btn value='분당김'><input type=submit name=btn value='분지연'> 최종갱신 : <?=$turntime?><br>
|
시간조정 : <input type=text size=3 name=minute><input type=submit name=btn value='분당김'><input type=submit name=btn value='분지연'> 최종갱신 : <?=$turntimeDisplay?> (tick <?=$turntime?>)<br>
|
||||||
시간조정 : <input type=text size=3 name=minute2><input type=submit name=btn value='토너분당김'><input type=submit name=btn value='토너분지연'> 토너먼트 : <?=$tnmt_time?><br>
|
시간조정 : <input type=text size=3 name=minute2><input type=submit name=btn value='토너분당김'><input type=submit name=btn value='토너분지연'> 토너먼트 : <?=$tnmtTimeDisplay?> (tick <?=$tnmt_time?>)<br>
|
||||||
봉급지급 : <input type=submit name=btn value='금지급'><input type=submit name=btn value='쌀지급'><br>
|
봉급지급 : <input type=submit name=btn value='금지급'><input type=submit name=btn value='쌀지급'><br>
|
||||||
락 풀 기 : <input type=submit name=btn value='락걸기'><input type=submit name=btn value='락풀기'> 현재 : <?=$plock>0?"동결중":"가동중"?><br>
|
락 풀 기 : <input type=submit name=btn value='락걸기'><input type=submit name=btn value='락풀기'> 현재 : <?=$plock>0?"동결중":"가동중"?><br>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
+9
-36
@@ -38,21 +38,9 @@ switch ($btn) {
|
|||||||
usleep(500000);
|
usleep(500000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']);
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
$turntime = (new \DateTimeImmutable($gameStor->turntime))->sub(new \DateInterval("PT{$minute}M"));
|
// 스케줄 전체를 벽시계에서 빼지 않고 논리 현재 tick만 앞으로 이동합니다.
|
||||||
$starttime = (new \DateTimeImmutable($gameStor->starttime))->sub(new \DateInterval("PT{$minute}M"));
|
$clock->advance($gameStor, $clock->ticksFromMinutes($minute));
|
||||||
$tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->sub(new \DateInterval("PT{$minute}M"));
|
|
||||||
|
|
||||||
$gameStor->turntime = $turntime->format('Y-m-d H:i:s.u');
|
|
||||||
$gameStor->starttime = $starttime->format('Y-m-d H:i:s');
|
|
||||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
$db->update('general', [
|
|
||||||
'turntime' => $db->sqleval('DATE_SUB(turntime, INTERVAL %i MINUTE)', $minute)
|
|
||||||
], true);
|
|
||||||
$db->update('ng_auction', [
|
|
||||||
'close_date' => $db->sqleval('DATE_SUB(close_date, INTERVAL %i MINUTE)', $minute)
|
|
||||||
], 'finished = 0');
|
|
||||||
if ($locked) {
|
if ($locked) {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
@@ -66,34 +54,19 @@ switch ($btn) {
|
|||||||
}
|
}
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
}
|
}
|
||||||
$gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']);
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
$turntime = (new \DateTimeImmutable($gameStor->turntime))->add(new \DateInterval("PT{$minute}M"));
|
$clock->advance($gameStor, -$clock->ticksFromMinutes($minute));
|
||||||
$starttime = (new \DateTimeImmutable($gameStor->starttime))->add(new \DateInterval("PT{$minute}M"));
|
|
||||||
$tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->add(new \DateInterval("PT{$minute}M"));
|
|
||||||
|
|
||||||
$gameStor->turntime = $turntime->format('Y-m-d H:i:s.u');
|
|
||||||
$gameStor->starttime = $starttime->format('Y-m-d H:i:s');
|
|
||||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
$db->update('general', [
|
|
||||||
'turntime' => $db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
|
|
||||||
], true);
|
|
||||||
$db->update('ng_auction', [
|
|
||||||
'close_date' => $db->sqleval('DATE_ADD(close_date, INTERVAL %i MINUTE)', $minute)
|
|
||||||
], 'finished = 0');
|
|
||||||
if ($locked) {
|
if ($locked) {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "토너분당김":
|
case "토너분당김":
|
||||||
$tnmt_time = new \DateTime($gameStor->tnmt_time);
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
$tnmt_time->sub(new \DateInterval("PT{$minute2}M"));
|
$gameStor->tnmt_time = Util::toInt($gameStor->tnmt_time) - $clock->ticksFromMinutes($minute2);
|
||||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
|
||||||
break;
|
break;
|
||||||
case "토너분지연":
|
case "토너분지연":
|
||||||
$tnmt_time = new \DateTimeImmutable($gameStor->tnmt_time);
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
$tnmt_time->add(new \DateInterval("PT{$minute2}M"));
|
$gameStor->tnmt_time = Util::toInt($gameStor->tnmt_time) + $clock->ticksFromMinutes($minute2);
|
||||||
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
|
|
||||||
break;
|
break;
|
||||||
case "금지급":
|
case "금지급":
|
||||||
processGoldIncome();
|
processGoldIncome();
|
||||||
|
|||||||
+3
-3
@@ -6,7 +6,7 @@ include "func.php";
|
|||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
|
||||||
if($session->userGrade < 5) {
|
if($session->userGrade < 6) {
|
||||||
die(requireAdminPermissionHTML());
|
die(requireAdminPermissionHTML());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ $admin = getAdmin();
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width=110 align=right>시작시간변경</td>
|
<td width=110 align=right>시작시간변경</td>
|
||||||
<td width=285><input type=text size=20 maxlength=20 style=color:white;background-color:black;text-align:right; name=starttime value='<?=substr($admin['starttime'], 0, 19)?>'><input type=submit name=btn value=변경1></td>
|
<td width=285><input type=text size=20 maxlength=20 style=color:white;background-color:black;text-align:right; name=starttime value='<?=substr($admin['starttime_display'], 0, 19)?>'><input type=submit name=btn value=변경1></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width=110 align=right>최대 장수</td>
|
<td width=110 align=right>최대 장수</td>
|
||||||
@@ -52,7 +52,7 @@ $admin = getAdmin();
|
|||||||
<td width=110 align=right>시작 년도</td>
|
<td width=110 align=right>시작 년도</td>
|
||||||
<td width=285><input type=text size=3 maxlength=3 style=color:white;background-color:black;text-align:right; name=startyear value='<?=$admin['startyear']?>'><input type=submit name=btn value=변경4></td>
|
<td width=285><input type=text size=3 maxlength=3 style=color:white;background-color:black;text-align:right; name=startyear value='<?=$admin['startyear']?>'><input type=submit name=btn value=변경4></td>
|
||||||
<td width=110 align=right>최근 갱신 시간</td>
|
<td width=110 align=right>최근 갱신 시간</td>
|
||||||
<td width=285> <?=$admin['turntime']?></td>
|
<td width=285> <?=$admin['turntime_display']?> (tick <?=$admin['turntime']?>)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width=110 align=right>턴시간</td>
|
<td width=110 align=right>턴시간</td>
|
||||||
|
|||||||
+10
-4
@@ -6,7 +6,7 @@ include "func.php";
|
|||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
header('location:_admin1.php');
|
header('location:_admin1.php');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
@@ -25,13 +25,15 @@ if (!$v->validate()) {
|
|||||||
$msg = Util::getPost('msg');
|
$msg = Util::getPost('msg');
|
||||||
$btn = Util::getPost('btn');
|
$btn = Util::getPost('btn');
|
||||||
$log = Util::getPost('log');
|
$log = Util::getPost('log');
|
||||||
$starttime = Util::getPost('starttime', 'string', (new \DateTime())->format('Y-m-d H:i:s'));
|
$starttime = Util::getPost('starttime', 'string', null);
|
||||||
$maxgeneral = Util::getPost('maxgeneral', 'int', GameConst::$defaultMaxGeneral);
|
$maxgeneral = Util::getPost('maxgeneral', 'int', GameConst::$defaultMaxGeneral);
|
||||||
$maxnation = Util::getPost('maxnation', 'int', GameConst::$defaultMaxNation);
|
$maxnation = Util::getPost('maxnation', 'int', GameConst::$defaultMaxNation);
|
||||||
$startyear = Util::getPost('startyear', 'int', GameConst::$defaultStartYear);
|
$startyear = Util::getPost('startyear', 'int', GameConst::$defaultStartYear);
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
$starttime ??= $clock->formatTick($clock->nowTick());
|
||||||
|
|
||||||
$admin = getAdmin();
|
$admin = getAdmin();
|
||||||
|
|
||||||
@@ -43,7 +45,11 @@ switch ($btn) {
|
|||||||
pushGlobalHistoryLog(["<R>★</><S>{$log}</>"]);
|
pushGlobalHistoryLog(["<R>★</><S>{$log}</>"]);
|
||||||
break;
|
break;
|
||||||
case "변경1":
|
case "변경1":
|
||||||
$gameStor->starttime = (new \DateTime($starttime))->format('Y-m-d H:i:s');
|
$gameStor->clock_base_time = TimeUtil::format(GameClock::baseTimeForProjection(
|
||||||
|
new \DateTimeImmutable($starttime),
|
||||||
|
Util::toInt($gameStor->starttime),
|
||||||
|
$clock->getTurnTermMinutes(),
|
||||||
|
), true);
|
||||||
break;
|
break;
|
||||||
case "변경2":
|
case "변경2":
|
||||||
$gameStor->maxgeneral = $maxgeneral;
|
$gameStor->maxgeneral = $maxgeneral;
|
||||||
@@ -78,4 +84,4 @@ switch ($btn) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
header('location:_admin1.php');
|
header('location:_admin1.php');
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ include "func.php";
|
|||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
die(requireAdminPermissionHTML());
|
die(requireAdminPermissionHTML());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -15,7 +15,7 @@ $msg = Util::getPost('msg', 'string');
|
|||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireLogin()->loginGame()->setReadOnly();
|
$session = Session::requireLogin()->loginGame()->setReadOnly();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
header('location:_admin2.php');
|
header('location:_admin2.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ switch ($btn) {
|
|||||||
], '`no` IN %li', $genlist);
|
], '`no` IN %li', $genlist);
|
||||||
break;
|
break;
|
||||||
case "강제 사망":
|
case "강제 사망":
|
||||||
$date = TimeUtil::now(true);
|
$date = GameClock::fromStorage($gameStor)->nowTick();
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
'killturn' => 0,
|
'killturn' => 0,
|
||||||
'turntime' => $date,
|
'turntime' => $date,
|
||||||
@@ -113,7 +113,7 @@ switch ($btn) {
|
|||||||
case "경험치1000":
|
case "경험치1000":
|
||||||
$text = $btn . " 지급!";
|
$text = $btn . " 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, Message::gameNow(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -124,7 +124,7 @@ switch ($btn) {
|
|||||||
case "공헌치1000":
|
case "공헌치1000":
|
||||||
$text = $btn . " 지급!";
|
$text = $btn . " 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, Message::gameNow(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -135,7 +135,7 @@ switch ($btn) {
|
|||||||
case "보숙10000":
|
case "보숙10000":
|
||||||
$text = "보병숙련도+10000 지급!";
|
$text = "보병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, Message::gameNow(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -145,7 +145,7 @@ switch ($btn) {
|
|||||||
case "궁숙10000":
|
case "궁숙10000":
|
||||||
$text = "궁병숙련도+10000 지급!";
|
$text = "궁병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, Message::gameNow(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -156,7 +156,7 @@ switch ($btn) {
|
|||||||
$src = MessageTarget::buildQuick($session->generalID);
|
$src = MessageTarget::buildQuick($session->generalID);
|
||||||
$text = "기병숙련도+10000 지급!";
|
$text = "기병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, Message::gameNow(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -167,7 +167,7 @@ switch ($btn) {
|
|||||||
$src = MessageTarget::buildQuick($session->generalID);
|
$src = MessageTarget::buildQuick($session->generalID);
|
||||||
$text = "귀병숙련도+10000 지급!";
|
$text = "귀병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, Message::gameNow(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -178,7 +178,7 @@ switch ($btn) {
|
|||||||
$src = MessageTarget::buildQuick($session->generalID);
|
$src = MessageTarget::buildQuick($session->generalID);
|
||||||
$text = "차병숙련도+10000 지급!";
|
$text = "차병숙련도+10000 지급!";
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, Message::gameNow(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
@@ -198,7 +198,7 @@ switch ($btn) {
|
|||||||
case "메세지 전달":
|
case "메세지 전달":
|
||||||
$text = $msg ?? '';
|
$text = $msg ?? '';
|
||||||
foreach ($genlist as $generalID) {
|
foreach ($genlist as $generalID) {
|
||||||
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, new \DateTime(), new \DateTime('9999-12-31'), []);
|
$msg = new Message(MessageType::private, $src, MessageTarget::buildQuick($generalID), $text, Message::gameNow(), new \DateTime('9999-12-31'), []);
|
||||||
$msg->send(true);
|
$msg->send(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ if ($type2 < 0 || $type2 > 6) {
|
|||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
die(requireAdminPermissionHTML());
|
die(requireAdminPermissionHTML());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ $nation = Util::getPost('nation', 'int');
|
|||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
header('location:_admin5.php');
|
header('location:_admin5.php');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-4
@@ -31,17 +31,18 @@ $queryMap = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($reqQueryType === null || !key_exists($reqQueryType, $queryMap)) {
|
if ($reqQueryType === null || !key_exists($reqQueryType, $queryMap)) {
|
||||||
$reqQueryType = Util::array_first_key($queryMap);
|
$reqQueryType = array_key_first($queryMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
die(requireAdminPermissionHTML());
|
die(requireAdminPermissionHTML());
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
$clock = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'));
|
||||||
|
|
||||||
if ($btn == '정렬하기') {
|
if ($btn == '정렬하기') {
|
||||||
$gen = 0;
|
$gen = 0;
|
||||||
@@ -111,7 +112,7 @@ $generalObj = General::createObjFromDB($gen, null, GeneralQueryMode::FullWithAcc
|
|||||||
대상장수 :
|
대상장수 :
|
||||||
<select name=gen size=1>
|
<select name=gen size=1>
|
||||||
<?php foreach ($generalBasicList as $general) : ?>
|
<?php foreach ($generalBasicList as $general) : ?>
|
||||||
<option <?= $gen == $general['no'] ? 'selected' : '' ?> value='<?= $general['no'] ?>'><?= $general['name'] ?> (<?= substr($general['turntime'], 14, 5) ?>)</option>
|
<option <?= $gen == $general['no'] ? 'selected' : '' ?> value='<?= $general['no'] ?>'><?= $general['name'] ?> (<?= substr($clock->formatTick(Util::toInt($general['turntime'])), 14, 5) ?>)</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<input type=submit name=btn value='조회하기'>
|
<input type=submit name=btn value='조회하기'>
|
||||||
@@ -179,4 +180,4 @@ $generalObj = General::createObjFromDB($gen, null, GeneralQueryMode::FullWithAcc
|
|||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-4
@@ -12,7 +12,7 @@ $type = 0;
|
|||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
die(requireAdminPermissionHTML());
|
die(requireAdminPermissionHTML());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +100,6 @@ $sel[$type] = "selected";
|
|||||||
throw new \Exception("알 수 없는 외교 상태: {$dip['state']}");
|
throw new \Exception("알 수 없는 외교 상태: {$dip['state']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = TimeUtil::now();
|
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
<tr>
|
<tr>
|
||||||
<td align=center style=color:" . newColor($nationColor[$me]) . ";background-color:{$nationColor[$me]};>$nationName[$me]</td>
|
<td align=center style=color:" . newColor($nationColor[$me]) . ";background-color:{$nationColor[$me]};>$nationName[$me]</td>
|
||||||
@@ -122,4 +120,4 @@ $sel[$type] = "selected";
|
|||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ include "func.php";
|
|||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
die('권한 부족');
|
die('권한 부족');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,11 +243,14 @@ $templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
|||||||
"SELECT nation,no,name,owner_name as ownerName, owner, picture, imgsvr,
|
"SELECT nation,no,name,owner_name as ownerName, owner, picture, imgsvr,
|
||||||
experience, dedication,
|
experience, dedication,
|
||||||
dex1, dex2, dex3, dex4, dex5,
|
dex1, dex2, dex3, dex4, dex5,
|
||||||
horse, weapon, book, item
|
horse, weapon, book, item, aux
|
||||||
FROM general WHERE %l",
|
FROM general WHERE %l",
|
||||||
$btn == "NPC 보기" ? "npc>=2" : "npc<2"
|
$btn == "NPC 보기" ? "npc>=2" : "npc<2"
|
||||||
) as $general) {
|
) as $general) {
|
||||||
$generalID = $general['no'];
|
$generalID = $general['no'];
|
||||||
|
foreach (['dex1', 'dex2', 'dex3', 'dex4', 'dex5'] as $dexKey) {
|
||||||
|
$general[$dexKey] = CentennialAllStarGrowthService::recordableRawValue($general, $dexKey);
|
||||||
|
}
|
||||||
$general['bgColor'] = $nationColor[$general['nation']] ?? GameConst::$basecolor4;
|
$general['bgColor'] = $nationColor[$general['nation']] ?? GameConst::$basecolor4;
|
||||||
$general['fgColor'] = newColor($general['bgColor']);
|
$general['fgColor'] = newColor($general['bgColor']);
|
||||||
$general['nationName'] = $nationName[$general['nation']];
|
$general['nationName'] = $nationName[$general['nation']];
|
||||||
@@ -427,4 +430,4 @@ $templates = new \League\Plates\Engine(__DIR__ . '/templates');
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-1
@@ -9,6 +9,7 @@ include "func.php";
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
|
||||||
increaseRefresh("갱신정보", 1);
|
increaseRefresh("갱신정보", 1);
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ $recentTraffic[] = [
|
|||||||
'month' => $admin['month'],
|
'month' => $admin['month'],
|
||||||
'refresh' => $admin['refresh'],
|
'refresh' => $admin['refresh'],
|
||||||
'online' => $curonline,
|
'online' => $curonline,
|
||||||
'date' => TimeUtil::now()
|
'date' => $clock->formatNow()
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($admin['maxrefresh'] == 0) {
|
if ($admin['maxrefresh'] == 0) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ $db = DB::db();
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
increaseRefresh("현재도시", 1);
|
increaseRefresh("현재도시", 1);
|
||||||
|
|
||||||
$lastExecute = substr($gameStor->turntime, 5, 14);
|
$lastExecute = substr(GameClock::fromStorage($gameStor)->formatTick(Util::toInt($gameStor->turntime)), 5, 14);
|
||||||
|
|
||||||
$me = $db->queryFirstRow('SELECT no,nation,officer_level,city from general where owner=%i', $userID);
|
$me = $db->queryFirstRow('SELECT no,nation,officer_level,city from general where owner=%i', $userID);
|
||||||
$myNation = $db->queryFirstRow('SELECT nation,level,spy FROM nation WHERE nation=%i', $me['nation']) ?? [
|
$myNation = $db->queryFirstRow('SELECT nation,level,spy FROM nation WHERE nation=%i', $me['nation']) ?? [
|
||||||
@@ -177,7 +177,7 @@ $templates = new \League\Plates\Engine('templates');
|
|||||||
$valid = 1;
|
$valid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($userGrade >= 5) {
|
if ($userGrade >= 6) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
$showDetailedInfo = true;
|
$showDetailedInfo = true;
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ $templates = new \League\Plates\Engine('templates');
|
|||||||
$ourGeneral = false;
|
$ourGeneral = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($userGrade == 6) {
|
if ($userGrade == 7) {
|
||||||
$ourGeneral = true;
|
$ourGeneral = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,4 +537,4 @@ $templates = new \League\Plates\Engine('templates');
|
|||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+3
-1
@@ -129,6 +129,7 @@ $templates = new \League\Plates\Engine('templates');
|
|||||||
);
|
);
|
||||||
|
|
||||||
$generalTurnList = [];
|
$generalTurnList = [];
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
|
||||||
foreach ($db->queryAllLists(
|
foreach ($db->queryAllLists(
|
||||||
'SELECT general_id, turn_idx, brief FROM general_turn WHERE general_id IN %li AND turn_idx < 5 ORDER BY general_id ASC, turn_idx ASC',
|
'SELECT general_id, turn_idx, brief FROM general_turn WHERE general_id IN %li AND turn_idx < 5 ORDER BY general_id ASC, turn_idx ASC',
|
||||||
@@ -142,6 +143,7 @@ $templates = new \League\Plates\Engine('templates');
|
|||||||
|
|
||||||
$genCntEff = 0;
|
$genCntEff = 0;
|
||||||
foreach ($generals as &$general) {
|
foreach ($generals as &$general) {
|
||||||
|
$general['turntime'] = $clock->formatTick(Util::toInt($general['turntime']), true);
|
||||||
$general['cityText'] = CityConst::byID($general['city'])->name;
|
$general['cityText'] = CityConst::byID($general['city'])->name;
|
||||||
$general['troopText'] = $troopName[$general['troop']] ?? '-';
|
$general['troopText'] = $troopName[$general['troop']] ?? '-';
|
||||||
|
|
||||||
@@ -284,4 +286,4 @@ $templates = new \League\Plates\Engine('templates');
|
|||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+30
-12
@@ -19,10 +19,10 @@ $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', 'npcmode']);
|
$gameStor->cacheValues(['turntime', 'opentime', 'autorun_user', 'npcmode']);
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
increaseRefresh("내정보", 1);
|
$nowTick = $clock->nowTick();
|
||||||
|
|
||||||
$me = General::createObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
$me = General::createObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||||
|
|
||||||
@@ -41,12 +41,30 @@ $lastRefresh = $db->queryFirstField(
|
|||||||
$generalID
|
$generalID
|
||||||
);
|
);
|
||||||
|
|
||||||
$targetTime = addTurn($lastRefresh, $gameStor->turnterm, GameConst::$minTurnDieOnPrestart);
|
$nextChange = $me->getAuxVar('next_change');
|
||||||
if ($gameStor->turntime <= $gameStor->opentime) {
|
if (!is_int($nextChange)) {
|
||||||
//서버 가오픈시 할 수 있는 행동
|
$nextChange = null;
|
||||||
if ($me->getNPCType() == 0 && $me->getNationID() == 0) {
|
}
|
||||||
|
$nextChangeDisplay = $nextChange === null ? null : $clock->formatTick($nextChange);
|
||||||
|
|
||||||
|
increaseRefresh("내정보", 1);
|
||||||
|
if ($gameStor->turntime <= $gameStor->opentime) {
|
||||||
|
$targetTime = $me->getAuxVar('prestart_delete_after');
|
||||||
|
if (!is_int($targetTime)) {
|
||||||
|
$targetTime = addTurn(
|
||||||
|
$lastRefresh === null ? $nowTick : Util::toInt($lastRefresh),
|
||||||
|
$gameStor->turnterm,
|
||||||
|
GameConst::$minTurnDieOnPrestart
|
||||||
|
);
|
||||||
|
$me->setAuxVar('prestart_delete_after', $targetTime);
|
||||||
|
$me->applyDB($db);
|
||||||
|
}
|
||||||
|
$targetTimeDisplay = $clock->formatTick($targetTime);
|
||||||
|
|
||||||
|
//서버 가오픈시 할 수 있는 행동
|
||||||
|
if ($me->getNPCType() == 0 && $me->getNationID() == 0) {
|
||||||
$showDieOnPrestartBtn = true;
|
$showDieOnPrestartBtn = true;
|
||||||
if ($targetTime <= TimeUtil::now()) {
|
if ($targetTime <= $nowTick) {
|
||||||
$availableDieOnPrestart = true;
|
$availableDieOnPrestart = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,7 +177,7 @@ $changeDefence999Atmos = $me->onCalcDomestic('changeDefenceTrain', "atmos999", $
|
|||||||
<a href="b_myPage.php?detachNPC=1"><button type="button" style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>빙의 해체 요청</button></a>-->
|
<a href="b_myPage.php?detachNPC=1"><button type="button" style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>빙의 해체 요청</button></a>-->
|
||||||
|
|
||||||
<?php if ($showDieOnPrestartBtn) : ?>
|
<?php if ($showDieOnPrestartBtn) : ?>
|
||||||
가오픈 기간 내 장수 삭제 (<?= substr($targetTime, 0, 19) ?> 부터)<br>
|
가오픈 기간 내 장수 삭제 (<?= $targetTimeDisplay ?> 부터)<br>
|
||||||
<button type="button" id='dieOnPrestart' style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>장수 삭제</button><br><br>
|
<button type="button" id='dieOnPrestart' style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>장수 삭제</button><br><br>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
@@ -174,7 +192,7 @@ $changeDefence999Atmos = $me->onCalcDomestic('changeDefenceTrain', "atmos999", $
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($gameStor->npcmode == 2 && $me->getNPCType() == 0) : ?>
|
<?php if ($gameStor->npcmode == 2 && $me->getNPCType() == 0) : ?>
|
||||||
다른 장수 선택 (<?= substr($me->getAuxVar('next_change') ?? TimeUtil::now(), 0, 19) ?> 부터)<br>
|
다른 장수 선택 (<?= $nextChangeDisplay ?? '지금' ?>부터)<br>
|
||||||
<a href="select_general_from_pool.php" id='select_general_from_pool'><button type="button" style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>다른 장수 선택</button></a><br><br>
|
<a href="select_general_from_pool.php" id='select_general_from_pool'><button type="button" style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>다른 장수 선택</button></a><br><br>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
@@ -272,4 +290,4 @@ $changeDefence999Atmos = $me->onCalcDomestic('changeDefenceTrain', "atmos999", $
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-57
@@ -125,63 +125,7 @@ $globalBetTotal = array_sum($globalBet);
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<table align=center class='tb_layout bg0'>
|
<table align=center class='tb_layout bg0'>
|
||||||
<?php if ($session->userGrade >= 5) : ?>
|
<?php if ($me['no'] > 0 && $me['tournament'] == 0 && $admin['tournament'] == 1) : ?>
|
||||||
<form method=post action=c_tournament.php>
|
|
||||||
<tr>
|
|
||||||
<td colspan=8><input type=textarea size=150 style=color:white;background-color:black; name=msg><input type=submit name=btn value='메시지'></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan=8>
|
|
||||||
<button type="button" class="btn btn-secondary" onclick='location.reload()'>갱신</button>
|
|
||||||
<?php if ($admin['tournament'] == 0) : ?>
|
|
||||||
<select name=trig size=1 style=color:white;background-color:black;>
|
|
||||||
<option style=color:white; value=0 <?= !$admin['tnmt_trig'] ? 'selected' : '' ?>>수동진행</option>
|
|
||||||
<option style=color:white; value=1 <?= $admin['tnmt_trig'] ? 'selected' : '' ?>>자동진행</option>
|
|
||||||
</select>
|
|
||||||
<input type=submit name=btn value='자동개최설정'>
|
|
||||||
<?php else : ?>
|
|
||||||
<input type=submit name=btn value='중단' onclick='return confirm("진짜 중단하시겠습니까?")'>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?php switch ($admin['tournament']) {
|
|
||||||
case 1:
|
|
||||||
echo "<input type=submit name=btn value='랜덤투입'>";
|
|
||||||
echo "<input type=submit name=btn value='랜덤전부투입'>";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
echo "<input type=submit name=btn value='예선'><input type=submit name=btn value='예선전부'>";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
echo "<input type=submit name=btn value='추첨'><input type=submit name=btn value='추첨전부'>";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
echo "<input type=submit name=btn value='본선'><input type=submit name=btn value='본선전부'>";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
echo "<input type=submit name=btn value='배정'>";
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
echo "<input type=submit name=btn value='베팅마감'>";
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
echo "<input type=submit name=btn value='16강'>";
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
echo "<input type=submit name=btn value='8강'>";
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
echo "<input type=submit name=btn value='4강'>";
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
echo "<input type=submit name=btn value='결승'>";
|
|
||||||
break;
|
|
||||||
} ?>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</form>
|
|
||||||
<?php elseif ($me['no'] > 0 && $me['tournament'] == 0 && $admin['tournament'] == 1) : ?>
|
|
||||||
<form method=post action=c_tournament.php>
|
<form method=post action=c_tournament.php>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan=8><button type="button" class="btn btn-secondary" onclick='location.reload()'>갱신</button><button type="submit" class="btn btn-sammo-base2" onclick='return confirm("참가비 금<?= $admin['develcost'] ?>이 필요합니다. 참가하시겠습니까?")'>참가</button><input type='hidden' name='btn' value='참가'/></td>
|
<td colspan=8><button type="button" class="btn btn-secondary" onclick='location.reload()'>갱신</button><button type="submit" class="btn btn-sammo-base2" onclick='return confirm("참가비 금<?= $admin['develcost'] ?>이 필요합니다. 참가하시겠습니까?")'>참가</button><input type='hidden' name='btn' value='참가'/></td>
|
||||||
|
|||||||
@@ -228,10 +228,10 @@ if($btn == "자동개최설정") {
|
|||||||
$phase = 0;
|
$phase = 0;
|
||||||
startBetting($admin['tnmt_type'], 720);
|
startBetting($admin['tnmt_type'], 720);
|
||||||
} elseif($btn == "베팅마감") {
|
} elseif($btn == "베팅마감") {
|
||||||
$dt = date("Y-m-d H:i:s", time() + 60);
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
$gameStor->tournament=7;
|
$gameStor->tournament=7;
|
||||||
$gameStor->phase=0;
|
$gameStor->phase=0;
|
||||||
$gameStor->tnmt_time = $dt;
|
$gameStor->tnmt_time = $clock->nowTick() + $clock->ticksFromSeconds(60);
|
||||||
} elseif($btn == "16강") {
|
} elseif($btn == "16강") {
|
||||||
finalFight($admin['tnmt_type'], $admin['tournament'], $admin['phase'], 16);
|
finalFight($admin['tnmt_type'], $admin['tournament'], $admin['phase'], 16);
|
||||||
} elseif($btn == "8강") {
|
} elseif($btn == "8강") {
|
||||||
@@ -248,4 +248,4 @@ if($btn == "자동개최설정") {
|
|||||||
$gameStor->tnmt_msg = $msg;
|
$gameStor->tnmt_msg = $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
header('location:b_tournament.php');
|
header('location:b_tournament.php');
|
||||||
|
|||||||
@@ -0,0 +1,242 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
use Ds\Map;
|
||||||
|
use sammo\Enums\RankColumn;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
|
||||||
|
final class ComparisonTracingRNG implements RNG
|
||||||
|
{
|
||||||
|
private int $sequence = 0;
|
||||||
|
|
||||||
|
/** @var array<int, array<string, mixed>> */
|
||||||
|
public array $calls = [];
|
||||||
|
|
||||||
|
public function __construct(private readonly RNG $inner)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMaxInt(): int
|
||||||
|
{
|
||||||
|
return LiteHashDRBG::getMaxInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextBytes(int $bytes): string
|
||||||
|
{
|
||||||
|
$value = $this->inner->nextBytes($bytes);
|
||||||
|
$this->record('nextBytes', ['bytes' => $bytes], bin2hex($value));
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextBits(int $bits): string
|
||||||
|
{
|
||||||
|
$value = $this->inner->nextBits($bits);
|
||||||
|
$this->record('nextBits', ['bits' => $bits], bin2hex($value));
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextInt(?int $max = null): int
|
||||||
|
{
|
||||||
|
$value = $this->inner->nextInt($max);
|
||||||
|
$this->record('nextInt', ['maxInclusive' => $max], $value);
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextFloat1(): float
|
||||||
|
{
|
||||||
|
$value = $this->inner->nextFloat1();
|
||||||
|
$this->record('nextFloat1', [], $value);
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function record(string $operation, array $arguments, mixed $result): void
|
||||||
|
{
|
||||||
|
$this->calls[] = [
|
||||||
|
'seq' => $this->sequence++,
|
||||||
|
'operation' => $operation,
|
||||||
|
'arguments' => $arguments,
|
||||||
|
'result' => $result,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonExtractRankVar(array $raw): Map
|
||||||
|
{
|
||||||
|
$rankVars = new Map();
|
||||||
|
foreach ($raw as $rawKey => $rawValue) {
|
||||||
|
$key = RankColumn::tryFrom($rawKey);
|
||||||
|
if ($key !== null) {
|
||||||
|
$rankVars[$key] = $rawValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $rankVars;
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonBuildGeneral(
|
||||||
|
array $raw,
|
||||||
|
array $city,
|
||||||
|
array $nation,
|
||||||
|
int $year,
|
||||||
|
int $month,
|
||||||
|
bool $defender = false,
|
||||||
|
): General {
|
||||||
|
$aux = [];
|
||||||
|
if (array_key_exists('inheritBuff', $raw)) {
|
||||||
|
$aux['inheritBuff'] = $raw['inheritBuff'];
|
||||||
|
}
|
||||||
|
$raw['aux'] = Json::encode($aux);
|
||||||
|
$raw['owner'] = 0;
|
||||||
|
return new General(
|
||||||
|
$raw,
|
||||||
|
comparisonExtractRankVar($raw),
|
||||||
|
null,
|
||||||
|
$city,
|
||||||
|
$nation,
|
||||||
|
$year,
|
||||||
|
$month,
|
||||||
|
$defender,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonRunBattle(array $fixture): array
|
||||||
|
{
|
||||||
|
$seed = (string)($fixture['seed'] ?? 'battle-differential');
|
||||||
|
$year = (int)$fixture['year'];
|
||||||
|
$month = (int)$fixture['month'];
|
||||||
|
$startYear = (int)($fixture['startYear'] ?? 180);
|
||||||
|
$rawAttacker = $fixture['attackerGeneral'];
|
||||||
|
$rawAttackerCity = $fixture['attackerCity'];
|
||||||
|
$rawAttackerNation = $fixture['attackerNation'];
|
||||||
|
$rawDefenderCity = $fixture['defenderCity'];
|
||||||
|
$rawDefenderNation = $fixture['defenderNation'];
|
||||||
|
// 비교 fixture에 명시된 경우에만 ref runtime의 scenario action chain을
|
||||||
|
// 활성화합니다. 일반 비교 fixture의 기존 동작은 그대로 유지합니다.
|
||||||
|
$scenarioEffect = $fixture['scenarioEffect'] ?? null;
|
||||||
|
if ($scenarioEffect === '' || $scenarioEffect === 'None') {
|
||||||
|
$scenarioEffect = null;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
$scenarioEffect !== null
|
||||||
|
&& (!is_string($scenarioEffect) || getScenarioEffectClass($scenarioEffect) === null)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('scenarioEffect is invalid');
|
||||||
|
}
|
||||||
|
GameConst::$scenarioEffect = $scenarioEffect;
|
||||||
|
|
||||||
|
$tracingRng = new ComparisonTracingRNG(new LiteHashDRBG($seed));
|
||||||
|
$warRng = new RandUtil($tracingRng);
|
||||||
|
$attacker = new WarUnitGeneral(
|
||||||
|
$warRng,
|
||||||
|
comparisonBuildGeneral($rawAttacker, $rawAttackerCity, $rawAttackerNation, $year, $month),
|
||||||
|
$rawAttackerNation,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
$city = new WarUnitCity($warRng, $rawDefenderCity, $rawDefenderNation, $year, $month, $startYear);
|
||||||
|
|
||||||
|
$defenderList = [];
|
||||||
|
foreach ($fixture['defenderGenerals'] as $rawDefender) {
|
||||||
|
$defenderList[] = new WarUnitGeneral(
|
||||||
|
$warRng,
|
||||||
|
comparisonBuildGeneral($rawDefender, $rawDefenderCity, $rawDefenderNation, $year, $month, true),
|
||||||
|
$rawDefenderNation,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (count($defenderList) && extractBattleOrder($city, $attacker) > 0) {
|
||||||
|
$defenderList[] = $city;
|
||||||
|
}
|
||||||
|
usort(
|
||||||
|
$defenderList,
|
||||||
|
fn(WarUnit $lhs, WarUnit $rhs): int =>
|
||||||
|
-(extractBattleOrder($lhs, $attacker) <=> extractBattleOrder($rhs, $attacker)),
|
||||||
|
);
|
||||||
|
|
||||||
|
$iterDefender = new \ArrayIterator($defenderList);
|
||||||
|
$iterDefender->rewind();
|
||||||
|
$finishedDefenders = [];
|
||||||
|
$getNextDefender = function (?WarUnit $previous, bool $requestNext) use (
|
||||||
|
$iterDefender,
|
||||||
|
$attacker,
|
||||||
|
&$finishedDefenders,
|
||||||
|
): ?WarUnit {
|
||||||
|
if ($previous !== null) {
|
||||||
|
$finishedDefenders[] = buildWarTraceUnitSnapshot($previous);
|
||||||
|
}
|
||||||
|
if (!$requestNext || !$iterDefender->valid()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$next = $iterDefender->current();
|
||||||
|
if (extractBattleOrder($next, $attacker) <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$iterDefender->next();
|
||||||
|
return $next;
|
||||||
|
};
|
||||||
|
|
||||||
|
$events = [];
|
||||||
|
$conquered = processWar_NG(
|
||||||
|
$seed,
|
||||||
|
$attacker,
|
||||||
|
$getNextDefender,
|
||||||
|
$city,
|
||||||
|
static function (array $event) use (&$events): void {
|
||||||
|
$events[] = $event;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
$attackerLogs = $attacker->getLogger()->rollback();
|
||||||
|
$defenderLogs = [];
|
||||||
|
foreach ($defenderList as $defenderUnit) {
|
||||||
|
if (!($defenderUnit instanceof WarUnitGeneral)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$snapshot = buildWarTraceUnitSnapshot($defenderUnit);
|
||||||
|
$defenderLogs[(string)$snapshot['id']] = $defenderUnit->getLogger()->rollback();
|
||||||
|
}
|
||||||
|
$cityLogs = $city->getLogger()->rollback();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'engine' => 'ref',
|
||||||
|
'seed' => $seed,
|
||||||
|
'conquered' => $conquered,
|
||||||
|
'attacker' => buildWarTraceUnitSnapshot($attacker),
|
||||||
|
'city' => buildWarTraceUnitSnapshot($city),
|
||||||
|
'finishedDefenders' => $finishedDefenders,
|
||||||
|
'events' => $events,
|
||||||
|
'rng' => $tracingRng->calls,
|
||||||
|
'logs' => [
|
||||||
|
'attacker' => $attackerLogs,
|
||||||
|
'defenders' => $defenderLogs,
|
||||||
|
'city' => $cityLogs,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$fixturePath = $argv[1] ?? null;
|
||||||
|
if ($fixturePath === null || ($fixturePath !== '-' && !is_file($fixturePath))) {
|
||||||
|
fwrite(STDERR, "usage: php compare/battle_trace.php <fixture.json|->\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$fixtureJson = $fixturePath === '-' ? stream_get_contents(STDIN) : file_get_contents($fixturePath);
|
||||||
|
$fixture = json_decode((string)$fixtureJson, true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
echo json_encode(
|
||||||
|
comparisonRunBattle($fixture),
|
||||||
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION,
|
||||||
|
), PHP_EOL;
|
||||||
|
} catch (\Throwable $throwable) {
|
||||||
|
fwrite(STDERR, $throwable::class . ': ' . $throwable->getMessage() . PHP_EOL);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"action": "AddGlobalBetray",
|
||||||
|
"args": [2, 1],
|
||||||
|
"setup": {
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2, 3],
|
||||||
|
"general": [
|
||||||
|
{ "id": 1, "values": { "name": "배신0", "betray": 0 } },
|
||||||
|
{ "id": 2, "values": { "name": "배신1", "betray": 1 } },
|
||||||
|
{ "id": 3, "values": { "name": "배신2", "betray": 2 } }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 194,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2, 3]
|
||||||
|
},
|
||||||
|
"compactOutput": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"action": "AssignGeneralSpeciality",
|
||||||
|
"setup": {
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2, 3],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "내정대상",
|
||||||
|
"nation": 1,
|
||||||
|
"age": 30,
|
||||||
|
"leadership": 40,
|
||||||
|
"strength": 45,
|
||||||
|
"intel": 80,
|
||||||
|
"special": "None",
|
||||||
|
"specage": 30,
|
||||||
|
"special2": "che_신산",
|
||||||
|
"specage2": 99,
|
||||||
|
"aux": {
|
||||||
|
"prev_types_special": ["che_경작"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "전투대상",
|
||||||
|
"nation": 1,
|
||||||
|
"age": 30,
|
||||||
|
"leadership": 80,
|
||||||
|
"strength": 75,
|
||||||
|
"intel": 40,
|
||||||
|
"special": "che_인덕",
|
||||||
|
"specage": 99,
|
||||||
|
"special2": "None",
|
||||||
|
"specage2": 30,
|
||||||
|
"dex1": 200,
|
||||||
|
"dex2": 10,
|
||||||
|
"dex3": 10,
|
||||||
|
"dex4": 10,
|
||||||
|
"dex5": 10,
|
||||||
|
"aux": {
|
||||||
|
"prev_types_special2": ["che_돌격"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"name": "계승대상",
|
||||||
|
"nation": 2,
|
||||||
|
"age": 30,
|
||||||
|
"leadership": 50,
|
||||||
|
"strength": 50,
|
||||||
|
"intel": 50,
|
||||||
|
"special": "che_경작",
|
||||||
|
"specage": 99,
|
||||||
|
"special2": "None",
|
||||||
|
"specage2": 30,
|
||||||
|
"aux": {
|
||||||
|
"inheritSpecificSpecialWar": "che_의술",
|
||||||
|
"marker": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2, 3]
|
||||||
|
},
|
||||||
|
"compactOutput": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"action": "AutoDeleteInvader",
|
||||||
|
"compactOutput": true,
|
||||||
|
"args": [1],
|
||||||
|
"setup": {
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1],
|
||||||
|
"resetDiplomacy": true,
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "ⓞ남만족",
|
||||||
|
"capital": 69,
|
||||||
|
"gennum": 1,
|
||||||
|
"tech": 100,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_병가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "ⓞ남만대왕",
|
||||||
|
"nation": 1,
|
||||||
|
"city": 69,
|
||||||
|
"officer_level": 12,
|
||||||
|
"npc": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"id": 990001,
|
||||||
|
"action": [["AutoDeleteInvader", 1]]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"currentEventID": 990001
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"action": "BlockScoutAction",
|
||||||
|
"args": [true],
|
||||||
|
"setup": {
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 2],
|
||||||
|
"nation": [
|
||||||
|
{ "id": 1, "values": { "name": "위", "level": 2, "scout": 0 } },
|
||||||
|
{ "id": 2, "values": { "name": "촉", "level": 2, "scout": 0 } }
|
||||||
|
],
|
||||||
|
"gameEnvironment": {
|
||||||
|
"block_change_scout": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"nationIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,226 @@
|
|||||||
|
{
|
||||||
|
"action": "MonthlyBoundary",
|
||||||
|
"compactOutput": true,
|
||||||
|
"environment": {
|
||||||
|
"year": 190,
|
||||||
|
"month": 12,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"starttime": "2026-07-25 00:00:00",
|
||||||
|
"turntime": "2026-07-25 02:00:00"
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"syncEnvironment": true,
|
||||||
|
"world": {
|
||||||
|
"hiddenSeed": "monthly-boundary-core-catalog"
|
||||||
|
},
|
||||||
|
"gameEnvironment": {
|
||||||
|
"isunited": 1,
|
||||||
|
"refreshLimit": 3,
|
||||||
|
"block_change_scout": false
|
||||||
|
},
|
||||||
|
"resetCities": true,
|
||||||
|
"deleteOtherCities": true,
|
||||||
|
"keepCityIds": [1, 2],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "경계도시",
|
||||||
|
"level": 1,
|
||||||
|
"nation": 1,
|
||||||
|
"pop": 10000,
|
||||||
|
"pop_max": 20000,
|
||||||
|
"agri": 1000,
|
||||||
|
"agri_max": 2000,
|
||||||
|
"comm": 1000,
|
||||||
|
"comm_max": 2000,
|
||||||
|
"secu": 1000,
|
||||||
|
"secu_max": 2000,
|
||||||
|
"trust": 50,
|
||||||
|
"trade": 100,
|
||||||
|
"def": 1000,
|
||||||
|
"def_max": 2000,
|
||||||
|
"wall": 1000,
|
||||||
|
"wall_max": 2000,
|
||||||
|
"officer_set": 1,
|
||||||
|
"state": 31,
|
||||||
|
"term": 1,
|
||||||
|
"supply": 1,
|
||||||
|
"front": 2,
|
||||||
|
"conflict": {},
|
||||||
|
"dead": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "중립도시",
|
||||||
|
"level": 8,
|
||||||
|
"nation": 0,
|
||||||
|
"pop": 12000,
|
||||||
|
"pop_max": 22000,
|
||||||
|
"agri": 1200,
|
||||||
|
"agri_max": 2200,
|
||||||
|
"comm": 1200,
|
||||||
|
"comm_max": 2200,
|
||||||
|
"secu": 1200,
|
||||||
|
"secu_max": 2200,
|
||||||
|
"trust": 55,
|
||||||
|
"trade": 100,
|
||||||
|
"def": 1200,
|
||||||
|
"def_max": 2200,
|
||||||
|
"wall": 1200,
|
||||||
|
"wall_max": 2200,
|
||||||
|
"officer_set": 1,
|
||||||
|
"state": 0,
|
||||||
|
"term": 0,
|
||||||
|
"supply": 0,
|
||||||
|
"front": 0,
|
||||||
|
"conflict": {},
|
||||||
|
"dead": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "경계군주",
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 12,
|
||||||
|
"npc": 0,
|
||||||
|
"age": 30,
|
||||||
|
"belong": 3,
|
||||||
|
"makelimit": 2,
|
||||||
|
"gold": 1000,
|
||||||
|
"rice": 1000,
|
||||||
|
"crew": 100,
|
||||||
|
"train": 80,
|
||||||
|
"atmos": 70,
|
||||||
|
"leadership": 50,
|
||||||
|
"strength": 50,
|
||||||
|
"intel": 50,
|
||||||
|
"experience": 0,
|
||||||
|
"dedication": 0,
|
||||||
|
"dex1": 0,
|
||||||
|
"dex2": 0,
|
||||||
|
"dex3": 0,
|
||||||
|
"dex4": 0,
|
||||||
|
"dex5": 0,
|
||||||
|
"personal": "None",
|
||||||
|
"special": "None",
|
||||||
|
"specage": 0,
|
||||||
|
"special2": "None",
|
||||||
|
"specage2": 0,
|
||||||
|
"betray": 0,
|
||||||
|
"bornyear": 160,
|
||||||
|
"deadyear": 250
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "경계재야",
|
||||||
|
"nation": 0,
|
||||||
|
"city": 2,
|
||||||
|
"officer_level": 0,
|
||||||
|
"npc": 0,
|
||||||
|
"age": 25,
|
||||||
|
"belong": 4,
|
||||||
|
"makelimit": 0,
|
||||||
|
"gold": 500,
|
||||||
|
"rice": 500,
|
||||||
|
"crew": 50,
|
||||||
|
"train": 60,
|
||||||
|
"atmos": 50,
|
||||||
|
"leadership": 40,
|
||||||
|
"strength": 40,
|
||||||
|
"intel": 40,
|
||||||
|
"experience": 0,
|
||||||
|
"dedication": 0,
|
||||||
|
"dex1": 0,
|
||||||
|
"dex2": 0,
|
||||||
|
"dex3": 0,
|
||||||
|
"dex4": 0,
|
||||||
|
"dex5": 0,
|
||||||
|
"personal": "None",
|
||||||
|
"special": "None",
|
||||||
|
"specage": 0,
|
||||||
|
"special2": "None",
|
||||||
|
"specage2": 0,
|
||||||
|
"betray": 0,
|
||||||
|
"bornyear": 165,
|
||||||
|
"deadyear": 250
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "경계국",
|
||||||
|
"color": "#123456",
|
||||||
|
"capital": 1,
|
||||||
|
"gennum": 1,
|
||||||
|
"gold": 10000,
|
||||||
|
"rice": 20000,
|
||||||
|
"tech": 100,
|
||||||
|
"power": 10,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_유가",
|
||||||
|
"bill": 100,
|
||||||
|
"rate": 20,
|
||||||
|
"rate_tmp": 10,
|
||||||
|
"scout": 1,
|
||||||
|
"chief_set": 1,
|
||||||
|
"strategic_cmd_limit": 2,
|
||||||
|
"surlimit": 1,
|
||||||
|
"spy": "{}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetDiplomacy": true,
|
||||||
|
"resetEvents": true,
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"id": 991001,
|
||||||
|
"target": "PRE_MONTH",
|
||||||
|
"priority": 1000,
|
||||||
|
"condition": true,
|
||||||
|
"action": [
|
||||||
|
["NoticeToHistoryLog", "aggregate-pre", 6]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 991002,
|
||||||
|
"target": "MONTH",
|
||||||
|
"priority": 1000,
|
||||||
|
"condition": true,
|
||||||
|
"action": [
|
||||||
|
["ProcessIncome", "gold"],
|
||||||
|
["NewYear"],
|
||||||
|
["ResetOfficerLock"],
|
||||||
|
["RandomizeCityTradeRate"],
|
||||||
|
["ChangeCity", "all", {"pop": "+10", "trust": 60}],
|
||||||
|
["NoticeToHistoryLog", "aggregate-month", 6],
|
||||||
|
["DeleteEvent"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2],
|
||||||
|
"nationIds": [1],
|
||||||
|
"cityIds": [1, 2],
|
||||||
|
"eventIds": [991001, 991002],
|
||||||
|
"accessGeneralIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"action": "NewYear",
|
||||||
|
"environment": {
|
||||||
|
"year": 191,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"age": 30,
|
||||||
|
"belong": 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"nation": 0,
|
||||||
|
"age": 30,
|
||||||
|
"belong": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"action": "NoticeToHistoryLog",
|
||||||
|
"args": ["<S>새해 알림</>", 6],
|
||||||
|
"environment": {
|
||||||
|
"year": 191,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {},
|
||||||
|
"observe": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"action": "ProcessIncome",
|
||||||
|
"args": ["gold"],
|
||||||
|
"environment": {
|
||||||
|
"year": 190,
|
||||||
|
"month": 7,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 5,
|
||||||
|
"npc": 0,
|
||||||
|
"gold": 1000,
|
||||||
|
"rice": 1000,
|
||||||
|
"dedication": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑국",
|
||||||
|
"capital": 1,
|
||||||
|
"gold": 10000,
|
||||||
|
"rice": 20000,
|
||||||
|
"level": 1,
|
||||||
|
"rate_tmp": 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑성",
|
||||||
|
"nation": 1,
|
||||||
|
"level": 4,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 10000,
|
||||||
|
"pop_max": 20000,
|
||||||
|
"agri": 1000,
|
||||||
|
"agri_max": 2000,
|
||||||
|
"comm": 1000,
|
||||||
|
"comm_max": 2000,
|
||||||
|
"secu": 1000,
|
||||||
|
"secu_max": 2000,
|
||||||
|
"trust": 80,
|
||||||
|
"def": 500,
|
||||||
|
"def_max": 1000,
|
||||||
|
"wall": 500,
|
||||||
|
"wall_max": 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1],
|
||||||
|
"nationIds": [1],
|
||||||
|
"cityIds": [1],
|
||||||
|
"nationEnvironmentKeys": ["prev_income_gold", "prev_income_rice"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"action": "ResetOfficerLock",
|
||||||
|
"environment": {
|
||||||
|
"year": 191,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetNations": true,
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"officer_set": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"chief_set": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"cityIds": [1],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"action": "CreateAdminNPC",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 12,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"observe": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"action": "CreateManyNPC",
|
||||||
|
"args": [2, 0],
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 5,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0193-05-01 00:00:00"
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetGenerals": true
|
||||||
|
},
|
||||||
|
"observe": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
"action": "FinishNationBetting",
|
||||||
|
"args": [1],
|
||||||
|
"setup": {
|
||||||
|
"clearBetting": true,
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 2],
|
||||||
|
"nation": [
|
||||||
|
{ "id": 1, "values": { "name": "위", "gennum": 1, "power": 100, "level": 2 } },
|
||||||
|
{ "id": 2, "values": { "name": "촉", "gennum": 1, "power": 300, "level": 0 } }
|
||||||
|
],
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"general": [
|
||||||
|
{ "id": 1, "values": { "name": "장수1", "nation": 1, "owner": 1, "npc": 0 } },
|
||||||
|
{ "id": 2, "values": { "name": "장수2", "nation": 2, "owner": 2, "npc": 0 } }
|
||||||
|
],
|
||||||
|
"bettingInfo": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"type": "bettingNation",
|
||||||
|
"name": "천통국 예상",
|
||||||
|
"finished": false,
|
||||||
|
"selectCnt": 1,
|
||||||
|
"isExclusive": null,
|
||||||
|
"reqInheritancePoint": true,
|
||||||
|
"openYearMonth": 2400,
|
||||||
|
"closeYearMonth": 2424,
|
||||||
|
"candidates": [
|
||||||
|
{
|
||||||
|
"title": "위",
|
||||||
|
"info": "국력: 100<br>장수 수: 1<br>도시 수: 1",
|
||||||
|
"isHtml": true,
|
||||||
|
"aux": { "nation": 1 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "촉",
|
||||||
|
"info": "국력: 300<br>장수 수: 1<br>도시 수: 1",
|
||||||
|
"isHtml": true,
|
||||||
|
"aux": { "nation": 2 }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"winner": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bet": [
|
||||||
|
{ "betting_id": 1, "general_id": 0, "user_id": null, "betting_type": "[-1]", "amount": 100 },
|
||||||
|
{ "betting_id": 1, "general_id": 1, "user_id": 1, "betting_type": "[0]", "amount": 100 },
|
||||||
|
{ "betting_id": 1, "general_id": 2, "user_id": 2, "betting_type": "[1]", "amount": 100 }
|
||||||
|
],
|
||||||
|
"inheritancePrevious": {
|
||||||
|
"1": 900,
|
||||||
|
"2": 900
|
||||||
|
},
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 202,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2],
|
||||||
|
"nationIds": [1, 2],
|
||||||
|
"ownerIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"action": "InvaderEnding",
|
||||||
|
"compactOutput": true,
|
||||||
|
"setup": {
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1],
|
||||||
|
"setAllCitiesNation": 1,
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "기준국",
|
||||||
|
"capital": 1,
|
||||||
|
"gennum": 1,
|
||||||
|
"tech": 100,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_유가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"gameEnvironment": {
|
||||||
|
"isunited": 1,
|
||||||
|
"refreshLimit": 3
|
||||||
|
},
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"id": 990002,
|
||||||
|
"action": [["InvaderEnding"]]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"currentEventID": 990002
|
||||||
|
},
|
||||||
|
"observe": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
{
|
||||||
|
"action": "InvaderLifecycle",
|
||||||
|
"args": [10, 150, 100, 20],
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1],
|
||||||
|
"resetDiplomacy": true,
|
||||||
|
"resetEvents": true,
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "기준도시",
|
||||||
|
"level": 3,
|
||||||
|
"nation": 1,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 10000,
|
||||||
|
"agri": 2000,
|
||||||
|
"agri_max": 20000,
|
||||||
|
"comm": 3000,
|
||||||
|
"comm_max": 30000,
|
||||||
|
"secu": 4000,
|
||||||
|
"secu_max": 40000,
|
||||||
|
"def": 5000,
|
||||||
|
"def_max": 50000,
|
||||||
|
"wall": 6000,
|
||||||
|
"wall_max": 60000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 48,
|
||||||
|
"values": {
|
||||||
|
"name": "남만",
|
||||||
|
"level": 4,
|
||||||
|
"nation": 0,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 10000,
|
||||||
|
"agri": 2000,
|
||||||
|
"agri_max": 20000,
|
||||||
|
"comm": 3000,
|
||||||
|
"comm_max": 30000,
|
||||||
|
"secu": 4000,
|
||||||
|
"secu_max": 40000,
|
||||||
|
"def": 5000,
|
||||||
|
"def_max": 50000,
|
||||||
|
"wall": 6000,
|
||||||
|
"wall_max": 60000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "기준국",
|
||||||
|
"capital": 1,
|
||||||
|
"gennum": 1,
|
||||||
|
"tech": 100,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_유가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "군주",
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 12,
|
||||||
|
"npc": 0,
|
||||||
|
"leadership": 50,
|
||||||
|
"strength": 50,
|
||||||
|
"intel": 50,
|
||||||
|
"experience": 1000,
|
||||||
|
"dedication": 1000,
|
||||||
|
"dex1": 10,
|
||||||
|
"dex2": 20,
|
||||||
|
"dex3": 30,
|
||||||
|
"dex4": 40,
|
||||||
|
"dex5": 50,
|
||||||
|
"turntime": "0200-01-01 00:05:00"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"gameEnvironment": {
|
||||||
|
"isunited": 0,
|
||||||
|
"refreshLimit": 3
|
||||||
|
},
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0200-01-01 00:00:00",
|
||||||
|
"show_img_level": 3,
|
||||||
|
"fiction": [0]
|
||||||
|
},
|
||||||
|
"observe": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"action": "LostUniqueItem",
|
||||||
|
"args": [0.2],
|
||||||
|
"environment": {
|
||||||
|
"year": 210,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 180
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"syncEnvironment": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑",
|
||||||
|
"npc": 0,
|
||||||
|
"horse": "che_명마_12_옥란백용구",
|
||||||
|
"weapon": "che_무기_15_의천검",
|
||||||
|
"book": "che_서적_01_효경전",
|
||||||
|
"item": "che_저지_삼황내문"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "을",
|
||||||
|
"npc": 1,
|
||||||
|
"horse": "che_명마_12_사륜거",
|
||||||
|
"weapon": "che_무기_01_단도",
|
||||||
|
"book": "None",
|
||||||
|
"item": "che_부적_태현청생부"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"action": "MergeInheritPointRank",
|
||||||
|
"environment": {
|
||||||
|
"year": 210,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 180
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1],
|
||||||
|
"clearInheritanceOwnerIds": [100],
|
||||||
|
"gameEnvironment": {
|
||||||
|
"isunited": 0
|
||||||
|
},
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑",
|
||||||
|
"nation": 1,
|
||||||
|
"owner": 100,
|
||||||
|
"npc": 0,
|
||||||
|
"belong": 3,
|
||||||
|
"dex1": 1000,
|
||||||
|
"dex2": 0,
|
||||||
|
"dex3": 0,
|
||||||
|
"dex4": 0,
|
||||||
|
"dex5": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inheritancePoints": [
|
||||||
|
{"ownerId": 100, "key": "previous", "value": 999},
|
||||||
|
{"ownerId": 100, "key": "lived_month", "value": 2},
|
||||||
|
{"ownerId": 100, "key": "max_domestic_critical", "value": 4},
|
||||||
|
{"ownerId": 100, "key": "active_action", "value": 15},
|
||||||
|
{"ownerId": 100, "key": "unifier", "value": 6},
|
||||||
|
{"ownerId": 100, "key": "tournament", "value": 7}
|
||||||
|
],
|
||||||
|
"rankData": [
|
||||||
|
{"generalId": 1, "type": "warnum", "value": 2},
|
||||||
|
{"generalId": 1, "type": "firenum", "value": 1},
|
||||||
|
{"generalId": 1, "type": "betwin", "value": 2},
|
||||||
|
{"generalId": 1, "type": "betgold", "value": 4000},
|
||||||
|
{"generalId": 1, "type": "betwingold", "value": 2000},
|
||||||
|
{"generalId": 1, "type": "inherit_earned_dyn", "value": 999},
|
||||||
|
{"generalId": 1, "type": "inherit_earned_act", "value": 11},
|
||||||
|
{"generalId": 1, "type": "inherit_earned", "value": 999},
|
||||||
|
{"generalId": 1, "type": "inherit_spent_dyn", "value": 9},
|
||||||
|
{"generalId": 1, "type": "inherit_spent", "value": 999}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1],
|
||||||
|
"ownerIds": [100],
|
||||||
|
"inheritanceKeys": [
|
||||||
|
"previous",
|
||||||
|
"lived_month",
|
||||||
|
"max_domestic_critical",
|
||||||
|
"active_action",
|
||||||
|
"unifier",
|
||||||
|
"tournament"
|
||||||
|
],
|
||||||
|
"rankGeneralIds": [1],
|
||||||
|
"rankTypes": [
|
||||||
|
"inherit_earned",
|
||||||
|
"inherit_earned_act",
|
||||||
|
"inherit_earned_dyn",
|
||||||
|
"inherit_spent",
|
||||||
|
"inherit_spent_dyn"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"action": "NationBettingLifecycle",
|
||||||
|
"args": [1, 100],
|
||||||
|
"bettorGeneralIds": [1, 2],
|
||||||
|
"bettorOwnerIds": [1, 2],
|
||||||
|
"setup": {
|
||||||
|
"clearBetting": true,
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 2],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "위",
|
||||||
|
"color": "#111111",
|
||||||
|
"capital": 1,
|
||||||
|
"gennum": 1,
|
||||||
|
"gold": 1000,
|
||||||
|
"rice": 2000,
|
||||||
|
"tech": 100,
|
||||||
|
"power": 100,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_유가"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "촉",
|
||||||
|
"color": "#222222",
|
||||||
|
"capital": 2,
|
||||||
|
"gennum": 1,
|
||||||
|
"gold": 3000,
|
||||||
|
"rice": 4000,
|
||||||
|
"tech": 200,
|
||||||
|
"power": 300,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_병가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetCities": true,
|
||||||
|
"deleteOtherCities": true,
|
||||||
|
"keepCityIds": [1, 2],
|
||||||
|
"city": [
|
||||||
|
{ "id": 1, "values": { "name": "허창", "nation": 1, "level": 3 } },
|
||||||
|
{ "id": 2, "values": { "name": "성도", "nation": 2, "level": 3 } }
|
||||||
|
],
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"general": [
|
||||||
|
{ "id": 1, "values": { "name": "장수1", "nation": 1, "city": 1, "owner": 1, "npc": 0 } },
|
||||||
|
{ "id": 2, "values": { "name": "장수2", "nation": 2, "city": 2, "owner": 2, "npc": 0 } }
|
||||||
|
],
|
||||||
|
"inheritancePrevious": {
|
||||||
|
"1": 1000,
|
||||||
|
"2": 1000
|
||||||
|
},
|
||||||
|
"rankData": [
|
||||||
|
{ "generalId": 1, "type": "inherit_spent_dyn", "value": 0 },
|
||||||
|
{ "generalId": 1, "type": "inherit_earned_act", "value": 0 },
|
||||||
|
{ "generalId": 2, "type": "inherit_spent_dyn", "value": 0 },
|
||||||
|
{ "generalId": 2, "type": "inherit_earned_act", "value": 0 }
|
||||||
|
],
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"observe": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"action": "NpcNationLifecycle",
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"resetNations": true,
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "점유도시",
|
||||||
|
"level": 5,
|
||||||
|
"nation": 1,
|
||||||
|
"pop": 10001,
|
||||||
|
"pop_max": 50001,
|
||||||
|
"agri": 1001,
|
||||||
|
"agri_max": 5001,
|
||||||
|
"comm": 2001,
|
||||||
|
"comm_max": 6001,
|
||||||
|
"secu": 3001,
|
||||||
|
"secu_max": 7001,
|
||||||
|
"def": 4001,
|
||||||
|
"def_max": 8001,
|
||||||
|
"wall": 5001,
|
||||||
|
"wall_max": 9001
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 48,
|
||||||
|
"values": {
|
||||||
|
"name": "건국도시",
|
||||||
|
"level": 5,
|
||||||
|
"nation": 0,
|
||||||
|
"pop": 10048,
|
||||||
|
"pop_max": 50048,
|
||||||
|
"agri": 1048,
|
||||||
|
"agri_max": 5048,
|
||||||
|
"comm": 2048,
|
||||||
|
"comm_max": 6048,
|
||||||
|
"secu": 3048,
|
||||||
|
"secu_max": 7048,
|
||||||
|
"def": 4048,
|
||||||
|
"def_max": 8048,
|
||||||
|
"wall": 5048,
|
||||||
|
"wall_max": 9048
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "기준국",
|
||||||
|
"capital": 1,
|
||||||
|
"gennum": 0,
|
||||||
|
"tech": 120,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_유가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"gameEnvironment": {
|
||||||
|
"lastNPCTroopLeaderID": 40
|
||||||
|
},
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0200-01-01 00:00:00",
|
||||||
|
"show_img_level": 3,
|
||||||
|
"fiction": [0]
|
||||||
|
},
|
||||||
|
"observe": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"action": "OpenNationBetting",
|
||||||
|
"args": [1, 500],
|
||||||
|
"setup": {
|
||||||
|
"clearBetting": true,
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 2],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "위",
|
||||||
|
"color": "#111111",
|
||||||
|
"capital": 1,
|
||||||
|
"gennum": 1,
|
||||||
|
"gold": 1000,
|
||||||
|
"rice": 2000,
|
||||||
|
"tech": 100,
|
||||||
|
"power": 100,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_유가"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "촉",
|
||||||
|
"color": "#222222",
|
||||||
|
"capital": 2,
|
||||||
|
"gennum": 1,
|
||||||
|
"gold": 3000,
|
||||||
|
"rice": 4000,
|
||||||
|
"tech": 200,
|
||||||
|
"power": 300,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_병가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetCities": true,
|
||||||
|
"city": [
|
||||||
|
{ "id": 1, "values": { "nation": 1, "level": 3 } },
|
||||||
|
{ "id": 2, "values": { "nation": 2, "level": 3 } }
|
||||||
|
],
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"general": [
|
||||||
|
{ "id": 1, "values": { "name": "장수1", "nation": 1, "city": 1, "owner": 1, "npc": 0 } },
|
||||||
|
{ "id": 2, "values": { "name": "장수2", "nation": 2, "city": 2, "owner": 2, "npc": 0 } }
|
||||||
|
],
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2],
|
||||||
|
"cityIds": [1, 2],
|
||||||
|
"nationIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
{
|
||||||
|
"action": "PostUpdateMonthly",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 2,
|
||||||
|
"startyear": 193,
|
||||||
|
"seedYear": 193,
|
||||||
|
"seedMonth": 1
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"world": {
|
||||||
|
"hiddenSeed": "monthly-post-diplomacy-fixture"
|
||||||
|
},
|
||||||
|
"syncEnvironment": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2, 3, 4],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 2, 3, 4],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑장",
|
||||||
|
"nation": 1,
|
||||||
|
"npc": 2,
|
||||||
|
"crew": 0,
|
||||||
|
"gold": 0,
|
||||||
|
"rice": 0,
|
||||||
|
"leadership": 10,
|
||||||
|
"strength": 10,
|
||||||
|
"intel": 10,
|
||||||
|
"experience": 0,
|
||||||
|
"dedication": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "을장",
|
||||||
|
"nation": 2,
|
||||||
|
"npc": 2,
|
||||||
|
"crew": 0,
|
||||||
|
"gold": 0,
|
||||||
|
"rice": 0,
|
||||||
|
"leadership": 10,
|
||||||
|
"strength": 10,
|
||||||
|
"intel": 10,
|
||||||
|
"experience": 0,
|
||||||
|
"dedication": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"name": "병장",
|
||||||
|
"nation": 3,
|
||||||
|
"npc": 2,
|
||||||
|
"crew": 0,
|
||||||
|
"gold": 0,
|
||||||
|
"rice": 0,
|
||||||
|
"leadership": 10,
|
||||||
|
"strength": 10,
|
||||||
|
"intel": 10,
|
||||||
|
"experience": 0,
|
||||||
|
"dedication": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"values": {
|
||||||
|
"name": "정장",
|
||||||
|
"nation": 4,
|
||||||
|
"npc": 2,
|
||||||
|
"crew": 0,
|
||||||
|
"gold": 0,
|
||||||
|
"rice": 0,
|
||||||
|
"leadership": 10,
|
||||||
|
"strength": 10,
|
||||||
|
"intel": 10,
|
||||||
|
"experience": 0,
|
||||||
|
"dedication": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑국",
|
||||||
|
"gennum": 2,
|
||||||
|
"level": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "을국",
|
||||||
|
"gennum": 1,
|
||||||
|
"level": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"name": "병국",
|
||||||
|
"gennum": 1,
|
||||||
|
"level": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"values": {
|
||||||
|
"name": "정국",
|
||||||
|
"gennum": 1,
|
||||||
|
"level": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetDiplomacy": true,
|
||||||
|
"diplomacy": [
|
||||||
|
{
|
||||||
|
"fromNationId": 1,
|
||||||
|
"toNationId": 2,
|
||||||
|
"state": 1,
|
||||||
|
"term": 1,
|
||||||
|
"dead": 777
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fromNationId": 2,
|
||||||
|
"toNationId": 1,
|
||||||
|
"state": 1,
|
||||||
|
"term": 1,
|
||||||
|
"dead": 888
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fromNationId": 1,
|
||||||
|
"toNationId": 3,
|
||||||
|
"state": 0,
|
||||||
|
"term": 5,
|
||||||
|
"dead": 250
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fromNationId": 3,
|
||||||
|
"toNationId": 1,
|
||||||
|
"state": 0,
|
||||||
|
"term": 5,
|
||||||
|
"dead": 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fromNationId": 3,
|
||||||
|
"toNationId": 4,
|
||||||
|
"state": 0,
|
||||||
|
"term": 1,
|
||||||
|
"dead": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fromNationId": 4,
|
||||||
|
"toNationId": 3,
|
||||||
|
"state": 0,
|
||||||
|
"term": 1,
|
||||||
|
"dead": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fromNationId": 2,
|
||||||
|
"toNationId": 4,
|
||||||
|
"state": 7,
|
||||||
|
"term": 1,
|
||||||
|
"dead": 999
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2, 3, 4],
|
||||||
|
"nationIds": [1, 2, 3, 4]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
{
|
||||||
|
"action": "PostUpdateMonthly",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 2,
|
||||||
|
"startyear": 193,
|
||||||
|
"seedYear": 193,
|
||||||
|
"seedMonth": 1
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"world": {
|
||||||
|
"hiddenSeed": "monthly-post-nation-stats-fixture"
|
||||||
|
},
|
||||||
|
"syncEnvironment": true,
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 2],
|
||||||
|
"resetDiplomacy": true,
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"npc": 0,
|
||||||
|
"gold": 1000,
|
||||||
|
"rice": 2000,
|
||||||
|
"crew": 100,
|
||||||
|
"leadership": 50,
|
||||||
|
"strength": 40,
|
||||||
|
"intel": 30,
|
||||||
|
"experience": 100,
|
||||||
|
"dedication": 200,
|
||||||
|
"dex1": 1000,
|
||||||
|
"dex2": 0,
|
||||||
|
"dex3": 0,
|
||||||
|
"dex4": 0,
|
||||||
|
"dex5": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"nation": 2,
|
||||||
|
"npc": 2,
|
||||||
|
"gold": 3000,
|
||||||
|
"rice": 4000,
|
||||||
|
"crew": 200,
|
||||||
|
"leadership": 60,
|
||||||
|
"strength": 50,
|
||||||
|
"intel": 40,
|
||||||
|
"experience": 300,
|
||||||
|
"dedication": 400,
|
||||||
|
"dex1": 2000,
|
||||||
|
"dex2": 1000,
|
||||||
|
"dex3": 0,
|
||||||
|
"dex4": 0,
|
||||||
|
"dex5": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rankData": [
|
||||||
|
{"generalId": 1, "type": "killcrew_person", "value": 100},
|
||||||
|
{"generalId": 1, "type": "deathcrew_person", "value": 0},
|
||||||
|
{"generalId": 2, "type": "killcrew_person", "value": 0},
|
||||||
|
{"generalId": 2, "type": "deathcrew_person", "value": 100}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑국",
|
||||||
|
"gold": 10000,
|
||||||
|
"rice": 20000,
|
||||||
|
"tech": 100,
|
||||||
|
"level": 2,
|
||||||
|
"gennum": 9,
|
||||||
|
"power": 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "을국",
|
||||||
|
"gold": 2000,
|
||||||
|
"rice": 3000,
|
||||||
|
"tech": 50,
|
||||||
|
"level": 1,
|
||||||
|
"gennum": 8,
|
||||||
|
"power": 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑성",
|
||||||
|
"nation": 1,
|
||||||
|
"level": 4,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 2000,
|
||||||
|
"agri": 100,
|
||||||
|
"agri_max": 200,
|
||||||
|
"comm": 100,
|
||||||
|
"comm_max": 200,
|
||||||
|
"secu": 100,
|
||||||
|
"secu_max": 200,
|
||||||
|
"def": 100,
|
||||||
|
"def_max": 200,
|
||||||
|
"wall": 100,
|
||||||
|
"wall_max": 200
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "을성",
|
||||||
|
"nation": 2,
|
||||||
|
"level": 4,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 2000,
|
||||||
|
"pop_max": 4000,
|
||||||
|
"agri": 200,
|
||||||
|
"agri_max": 400,
|
||||||
|
"comm": 200,
|
||||||
|
"comm_max": 400,
|
||||||
|
"secu": 200,
|
||||||
|
"secu_max": 400,
|
||||||
|
"def": 200,
|
||||||
|
"def_max": 400,
|
||||||
|
"wall": 200,
|
||||||
|
"wall_max": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nationEnvironment": [
|
||||||
|
{
|
||||||
|
"nationId": 1,
|
||||||
|
"key": "max_power",
|
||||||
|
"value": {
|
||||||
|
"maxPower": 999,
|
||||||
|
"maxCrew": 50,
|
||||||
|
"maxCities": ["옛도시", "옛도시2"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{"nationId": 1, "key": "available_war_setting_cnt", "value": 1}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2],
|
||||||
|
"nationIds": [1, 2],
|
||||||
|
"cityIds": [1, 2],
|
||||||
|
"rankGeneralIds": [1, 2],
|
||||||
|
"rankTypes": ["killcrew_person", "deathcrew_person"],
|
||||||
|
"nationEnvironmentKeys": ["max_power", "available_war_setting_cnt"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
{
|
||||||
|
"action": "PostUpdateMonthly",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 2,
|
||||||
|
"startyear": 193,
|
||||||
|
"seedYear": 193,
|
||||||
|
"seedMonth": 1
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"world": {
|
||||||
|
"hiddenSeed": "monthly-post-tail-2"
|
||||||
|
},
|
||||||
|
"syncEnvironment": true,
|
||||||
|
"clearNeutralAuctions": true,
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 2],
|
||||||
|
"resetDiplomacy": true,
|
||||||
|
"gameEnvironment": {
|
||||||
|
"tournament": 0,
|
||||||
|
"tnmt_trig": true,
|
||||||
|
"tnmt_pattern": [0, 1, 2, 3],
|
||||||
|
"prev_winner": null
|
||||||
|
},
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑장",
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 12,
|
||||||
|
"npc": 0,
|
||||||
|
"gold": 5000,
|
||||||
|
"rice": 7000,
|
||||||
|
"crew": 100,
|
||||||
|
"leadership": 50,
|
||||||
|
"strength": 40,
|
||||||
|
"intel": 30,
|
||||||
|
"experience": 100,
|
||||||
|
"dedication": 200
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "을장",
|
||||||
|
"nation": 2,
|
||||||
|
"city": 2,
|
||||||
|
"officer_level": 12,
|
||||||
|
"npc": 0,
|
||||||
|
"gold": 6000,
|
||||||
|
"rice": 8000,
|
||||||
|
"crew": 200,
|
||||||
|
"leadership": 60,
|
||||||
|
"strength": 50,
|
||||||
|
"intel": 40,
|
||||||
|
"experience": 300,
|
||||||
|
"dedication": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑국",
|
||||||
|
"capital": 1,
|
||||||
|
"gold": 10000,
|
||||||
|
"rice": 20000,
|
||||||
|
"tech": 100,
|
||||||
|
"level": 2,
|
||||||
|
"gennum": 1,
|
||||||
|
"power": 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "을국",
|
||||||
|
"capital": 2,
|
||||||
|
"gold": 2000,
|
||||||
|
"rice": 3000,
|
||||||
|
"tech": 50,
|
||||||
|
"level": 1,
|
||||||
|
"gennum": 1,
|
||||||
|
"power": 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑성",
|
||||||
|
"nation": 1,
|
||||||
|
"level": 4,
|
||||||
|
"supply": 1,
|
||||||
|
"front": 3,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 2000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "을성",
|
||||||
|
"nation": 2,
|
||||||
|
"level": 4,
|
||||||
|
"supply": 1,
|
||||||
|
"front": 3,
|
||||||
|
"pop": 2000,
|
||||||
|
"pop_max": 4000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2],
|
||||||
|
"nationIds": [1, 2],
|
||||||
|
"cityIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
{
|
||||||
|
"action": "PostUpdateMonthly",
|
||||||
|
"environment": {
|
||||||
|
"year": 195,
|
||||||
|
"month": 2,
|
||||||
|
"startyear": 193,
|
||||||
|
"seedYear": 195,
|
||||||
|
"seedMonth": 1
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"world": {
|
||||||
|
"hiddenSeed": "monthly-post-wander-fixture"
|
||||||
|
},
|
||||||
|
"syncEnvironment": true,
|
||||||
|
"resetCities": true,
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "방랑성",
|
||||||
|
"nation": 4,
|
||||||
|
"level": 4,
|
||||||
|
"front": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "존속성",
|
||||||
|
"nation": 1,
|
||||||
|
"level": 4,
|
||||||
|
"front": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2, 3],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "방랑주",
|
||||||
|
"nation": 4,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 12,
|
||||||
|
"npc": 2,
|
||||||
|
"gold": 2000,
|
||||||
|
"rice": 3000,
|
||||||
|
"crew": 100,
|
||||||
|
"makelimit": 0,
|
||||||
|
"belong": 7,
|
||||||
|
"leadership": 50,
|
||||||
|
"strength": 40,
|
||||||
|
"intel": 30,
|
||||||
|
"experience": 100,
|
||||||
|
"dedication": 200
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "방랑객",
|
||||||
|
"nation": 4,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 1,
|
||||||
|
"npc": 0,
|
||||||
|
"gold": 1500,
|
||||||
|
"rice": 4000,
|
||||||
|
"crew": 200,
|
||||||
|
"makelimit": 0,
|
||||||
|
"belong": 5,
|
||||||
|
"leadership": 60,
|
||||||
|
"strength": 50,
|
||||||
|
"intel": 40,
|
||||||
|
"experience": 300,
|
||||||
|
"dedication": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"name": "존속장",
|
||||||
|
"nation": 1,
|
||||||
|
"city": 2,
|
||||||
|
"officer_level": 12,
|
||||||
|
"npc": 2,
|
||||||
|
"gold": 500,
|
||||||
|
"rice": 500,
|
||||||
|
"crew": 50,
|
||||||
|
"leadership": 50,
|
||||||
|
"strength": 50,
|
||||||
|
"intel": 50,
|
||||||
|
"experience": 0,
|
||||||
|
"dedication": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 4],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "존속국",
|
||||||
|
"gennum": 1,
|
||||||
|
"level": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"values": {
|
||||||
|
"name": "방랑국",
|
||||||
|
"gennum": 2,
|
||||||
|
"level": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resetDiplomacy": true,
|
||||||
|
"diplomacy": [
|
||||||
|
{
|
||||||
|
"fromNationId": 1,
|
||||||
|
"toNationId": 4,
|
||||||
|
"state": 2,
|
||||||
|
"term": 0,
|
||||||
|
"dead": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fromNationId": 4,
|
||||||
|
"toNationId": 1,
|
||||||
|
"state": 2,
|
||||||
|
"term": 0,
|
||||||
|
"dead": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2, 3],
|
||||||
|
"nationIds": [1, 4],
|
||||||
|
"cityIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"action": "PreUpdateMonthly",
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 12,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"syncEnvironment": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1, 2],
|
||||||
|
"general": [
|
||||||
|
{"id": 1, "values": {"makelimit": 2}},
|
||||||
|
{"id": 2, "values": {"makelimit": 0}}
|
||||||
|
],
|
||||||
|
"generalAccessLog": [
|
||||||
|
{"generalId": 1, "refreshScoreTotal": 101},
|
||||||
|
{"generalId": 2, "refreshScoreTotal": 1}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"rate": 35,
|
||||||
|
"rate_tmp": 10,
|
||||||
|
"strategic_cmd_limit": 2,
|
||||||
|
"surlimit": 1,
|
||||||
|
"spy": "{\"1\":1,\"2\":2}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{"id": 1, "values": {"state": 31, "term": 1, "conflict": {"1": 10}}},
|
||||||
|
{"id": 2, "values": {"state": 32, "term": 2, "conflict": {"1": 20}}},
|
||||||
|
{"id": 3, "values": {"state": 33, "term": 0, "conflict": {"1": 30}}},
|
||||||
|
{"id": 4, "values": {"state": 34, "term": 3, "conflict": {"1": 40}}},
|
||||||
|
{"id": 5, "values": {"state": 41, "term": 1, "conflict": {"1": 50}}},
|
||||||
|
{"id": 6, "values": {"state": 42, "term": 2, "conflict": {"1": 60}}},
|
||||||
|
{"id": 7, "values": {"state": 43, "term": 3, "conflict": {"1": 70}}}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2],
|
||||||
|
"nationIds": [1],
|
||||||
|
"cityIds": [1, 2, 3, 4, 5, 6, 7],
|
||||||
|
"accessGeneralIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
{
|
||||||
|
"action": "ProcessIncome",
|
||||||
|
"args": ["gold"],
|
||||||
|
"environment": {
|
||||||
|
"year": 190,
|
||||||
|
"month": 7,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 5,
|
||||||
|
"npc": 0,
|
||||||
|
"gold": 1000,
|
||||||
|
"rice": 1000,
|
||||||
|
"dedication": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑국",
|
||||||
|
"capital": 1,
|
||||||
|
"gold": 10000,
|
||||||
|
"rice": 20000,
|
||||||
|
"level": 1,
|
||||||
|
"rate": 35,
|
||||||
|
"rate_tmp": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "갑성",
|
||||||
|
"nation": 1,
|
||||||
|
"level": 4,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 10000,
|
||||||
|
"pop_max": 20000,
|
||||||
|
"agri": 1000,
|
||||||
|
"agri_max": 2000,
|
||||||
|
"comm": 1000,
|
||||||
|
"comm_max": 2000,
|
||||||
|
"secu": 1000,
|
||||||
|
"secu_max": 2000,
|
||||||
|
"trust": 80,
|
||||||
|
"def": 500,
|
||||||
|
"def_max": 1000,
|
||||||
|
"wall": 500,
|
||||||
|
"wall_max": 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1],
|
||||||
|
"nationIds": [1],
|
||||||
|
"cityIds": [1],
|
||||||
|
"nationEnvironmentKeys": ["prev_income_gold", "prev_income_rice"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
{
|
||||||
|
"action": "ProcessSemiAnnual",
|
||||||
|
"resource": "gold",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "반기검증국",
|
||||||
|
"gold": 100001,
|
||||||
|
"rice": 7777,
|
||||||
|
"rate_tmp": 20,
|
||||||
|
"type": "che_도가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 10000,
|
||||||
|
"pop_max": 50000,
|
||||||
|
"agri": 1001,
|
||||||
|
"agri_max": 5000,
|
||||||
|
"comm": 1001,
|
||||||
|
"comm_max": 5000,
|
||||||
|
"secu": 1001,
|
||||||
|
"secu_max": 2000,
|
||||||
|
"trust": 55,
|
||||||
|
"def": 1001,
|
||||||
|
"def_max": 5000,
|
||||||
|
"wall": 1001,
|
||||||
|
"wall_max": 5000,
|
||||||
|
"dead": 123
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"supply": 0,
|
||||||
|
"pop": 10000,
|
||||||
|
"pop_max": 50000,
|
||||||
|
"agri": 1001,
|
||||||
|
"agri_max": 5000,
|
||||||
|
"comm": 1001,
|
||||||
|
"comm_max": 5000,
|
||||||
|
"secu": 1001,
|
||||||
|
"secu_max": 2000,
|
||||||
|
"trust": 55,
|
||||||
|
"def": 1001,
|
||||||
|
"def_max": 5000,
|
||||||
|
"wall": 1001,
|
||||||
|
"wall_max": 5000,
|
||||||
|
"dead": 123
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"nation": 0,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 10000,
|
||||||
|
"pop_max": 50000,
|
||||||
|
"agri": 1001,
|
||||||
|
"agri_max": 5000,
|
||||||
|
"comm": 1001,
|
||||||
|
"comm_max": 5000,
|
||||||
|
"secu": 1001,
|
||||||
|
"secu_max": 2000,
|
||||||
|
"trust": 55,
|
||||||
|
"def": 1001,
|
||||||
|
"def_max": 5000,
|
||||||
|
"wall": 1001,
|
||||||
|
"wall_max": 5000,
|
||||||
|
"dead": 123
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"gold": 10001,
|
||||||
|
"rice": 8888
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1],
|
||||||
|
"cityIds": [1, 2, 3],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"action": "ProcessSemiAnnual",
|
||||||
|
"resource": "gold",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "반기검증국",
|
||||||
|
"gold": 100001,
|
||||||
|
"rice": 7777,
|
||||||
|
"rate": 50,
|
||||||
|
"rate_tmp": 20,
|
||||||
|
"type": "che_중립"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 10000,
|
||||||
|
"pop_max": 50000,
|
||||||
|
"agri": 1001,
|
||||||
|
"agri_max": 5000,
|
||||||
|
"comm": 1001,
|
||||||
|
"comm_max": 5000,
|
||||||
|
"secu": 1001,
|
||||||
|
"secu_max": 2000,
|
||||||
|
"trust": 55,
|
||||||
|
"def": 1001,
|
||||||
|
"def_max": 5000,
|
||||||
|
"wall": 1001,
|
||||||
|
"wall_max": 5000,
|
||||||
|
"dead": 123
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"gold": 10001,
|
||||||
|
"rice": 8888
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1],
|
||||||
|
"cityIds": [1],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"action": "ProcessWarIncome",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "전쟁수입국",
|
||||||
|
"gold": 1000,
|
||||||
|
"level": 1,
|
||||||
|
"type": "che_중립"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"name": "비활성국",
|
||||||
|
"gold": 2000,
|
||||||
|
"level": 0,
|
||||||
|
"type": "che_중립"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"name": "법가국",
|
||||||
|
"gold": 3000,
|
||||||
|
"level": 1,
|
||||||
|
"type": "che_법가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 2000,
|
||||||
|
"dead": 101
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"supply": 0,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 2000,
|
||||||
|
"dead": 999
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"nation": 2,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 2000,
|
||||||
|
"dead": 1000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"values": {
|
||||||
|
"nation": 3,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 2000,
|
||||||
|
"dead": 105
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"values": {
|
||||||
|
"nation": 0,
|
||||||
|
"supply": 1,
|
||||||
|
"pop": 999,
|
||||||
|
"pop_max": 1000,
|
||||||
|
"dead": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"cityIds": [1, 2, 3, 4, 5],
|
||||||
|
"nationIds": [1, 2, 3]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
{
|
||||||
|
"action": "RaiseInvader",
|
||||||
|
"compactOutput": true,
|
||||||
|
"args": [10, 150, 100, 20],
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"deleteOtherGenerals": true,
|
||||||
|
"keepGeneralIds": [1],
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"level": 3,
|
||||||
|
"nation": 1,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 10000,
|
||||||
|
"agri": 2000,
|
||||||
|
"agri_max": 20000,
|
||||||
|
"comm": 3000,
|
||||||
|
"comm_max": 30000,
|
||||||
|
"secu": 4000,
|
||||||
|
"secu_max": 40000,
|
||||||
|
"def": 5000,
|
||||||
|
"def_max": 50000,
|
||||||
|
"wall": 6000,
|
||||||
|
"wall_max": 60000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 48,
|
||||||
|
"values": {
|
||||||
|
"level": 4,
|
||||||
|
"nation": 0,
|
||||||
|
"pop": 1000,
|
||||||
|
"pop_max": 10000,
|
||||||
|
"agri": 2000,
|
||||||
|
"agri_max": 20000,
|
||||||
|
"comm": 3000,
|
||||||
|
"comm_max": 30000,
|
||||||
|
"secu": 4000,
|
||||||
|
"secu_max": 40000,
|
||||||
|
"def": 5000,
|
||||||
|
"def_max": 50000,
|
||||||
|
"wall": 6000,
|
||||||
|
"wall_max": 60000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "기준국",
|
||||||
|
"capital": 1,
|
||||||
|
"gennum": 1,
|
||||||
|
"tech": 100,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_유가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "군주",
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 12,
|
||||||
|
"npc": 0,
|
||||||
|
"leadership": 50,
|
||||||
|
"strength": 50,
|
||||||
|
"intel": 50,
|
||||||
|
"experience": 1000,
|
||||||
|
"dedication": 1000,
|
||||||
|
"dex1": 10,
|
||||||
|
"dex2": 20,
|
||||||
|
"dex3": 30,
|
||||||
|
"dex4": 40,
|
||||||
|
"dex5": 50,
|
||||||
|
"turntime": "0200-01-01 00:05:00"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0200-01-01 00:00:00",
|
||||||
|
"show_img_level": 3,
|
||||||
|
"fiction": [0]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1],
|
||||||
|
"cityIds": [1, 48],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"action": "RaiseNPCNation",
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"resetNations": true,
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "점유도시",
|
||||||
|
"level": 5,
|
||||||
|
"nation": 1,
|
||||||
|
"pop": 10001,
|
||||||
|
"pop_max": 50001,
|
||||||
|
"agri": 1001,
|
||||||
|
"agri_max": 5001,
|
||||||
|
"comm": 2001,
|
||||||
|
"comm_max": 6001,
|
||||||
|
"secu": 3001,
|
||||||
|
"secu_max": 7001,
|
||||||
|
"def": 4001,
|
||||||
|
"def_max": 8001,
|
||||||
|
"wall": 5001,
|
||||||
|
"wall_max": 9001
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 48,
|
||||||
|
"values": {
|
||||||
|
"name": "건국도시",
|
||||||
|
"level": 5,
|
||||||
|
"nation": 0,
|
||||||
|
"pop": 10048,
|
||||||
|
"pop_max": 50048,
|
||||||
|
"agri": 1048,
|
||||||
|
"agri_max": 5048,
|
||||||
|
"comm": 2048,
|
||||||
|
"comm_max": 6048,
|
||||||
|
"secu": 3048,
|
||||||
|
"secu_max": 7048,
|
||||||
|
"def": 4048,
|
||||||
|
"def_max": 8048,
|
||||||
|
"wall": 5048,
|
||||||
|
"wall_max": 9048
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "기준국",
|
||||||
|
"capital": 1,
|
||||||
|
"gennum": 1,
|
||||||
|
"tech": 120,
|
||||||
|
"level": 2,
|
||||||
|
"type": "che_유가"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0200-01-01 00:00:00",
|
||||||
|
"show_img_level": 3,
|
||||||
|
"fiction": [0]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"cityIds": [1, 48],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"action": "RegNeutralNPC",
|
||||||
|
"args": [
|
||||||
|
0,
|
||||||
|
"등록재야",
|
||||||
|
null,
|
||||||
|
0,
|
||||||
|
33,
|
||||||
|
45,
|
||||||
|
55,
|
||||||
|
65,
|
||||||
|
180,
|
||||||
|
245,
|
||||||
|
null,
|
||||||
|
"무쌍",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"setup": {
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0200-01-01 00:00:00",
|
||||||
|
"show_img_level": 3,
|
||||||
|
"fiction": [0]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [],
|
||||||
|
"cityIds": [33],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"action": "RegNPC",
|
||||||
|
"args": [
|
||||||
|
0,
|
||||||
|
"등록장수",
|
||||||
|
null,
|
||||||
|
0,
|
||||||
|
33,
|
||||||
|
60,
|
||||||
|
50,
|
||||||
|
40,
|
||||||
|
7,
|
||||||
|
186,
|
||||||
|
240,
|
||||||
|
null,
|
||||||
|
"인덕",
|
||||||
|
"등록 대사"
|
||||||
|
],
|
||||||
|
"setup": {
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0200-01-01 00:00:00",
|
||||||
|
"show_img_level": 3,
|
||||||
|
"fiction": [0]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [],
|
||||||
|
"cityIds": [33],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"action": "UnblockScoutAction",
|
||||||
|
"args": [false],
|
||||||
|
"setup": {
|
||||||
|
"resetNations": true,
|
||||||
|
"deleteOtherNations": true,
|
||||||
|
"keepNationIds": [1, 2],
|
||||||
|
"nation": [
|
||||||
|
{ "id": 1, "values": { "name": "위", "level": 2, "scout": 1 } },
|
||||||
|
{ "id": 2, "values": { "name": "촉", "level": 2, "scout": 1 } }
|
||||||
|
],
|
||||||
|
"gameEnvironment": {
|
||||||
|
"block_change_scout": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"nationIds": [1, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
{
|
||||||
|
"action": "UpdateCitySupply",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 99,
|
||||||
|
"values": {
|
||||||
|
"name": "보급검증국",
|
||||||
|
"color": "#777777",
|
||||||
|
"capital": 1,
|
||||||
|
"level": 1,
|
||||||
|
"type": "che_중립"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 98,
|
||||||
|
"values": {
|
||||||
|
"name": "불일치수도국",
|
||||||
|
"color": "#888888",
|
||||||
|
"capital": 2,
|
||||||
|
"level": 1,
|
||||||
|
"type": "che_중립"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 99,
|
||||||
|
"supply": 0,
|
||||||
|
"front": 2,
|
||||||
|
"pop": 1001,
|
||||||
|
"agri": 501,
|
||||||
|
"comm": 499,
|
||||||
|
"secu": 99,
|
||||||
|
"trust": 50,
|
||||||
|
"def": 101,
|
||||||
|
"wall": 50,
|
||||||
|
"officer_set": 7,
|
||||||
|
"term": 2,
|
||||||
|
"conflict": {"98": 3}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"values": {
|
||||||
|
"nation": 99,
|
||||||
|
"supply": 0,
|
||||||
|
"front": 2,
|
||||||
|
"pop": 1001,
|
||||||
|
"agri": 501,
|
||||||
|
"comm": 499,
|
||||||
|
"secu": 99,
|
||||||
|
"trust": 50,
|
||||||
|
"def": 101,
|
||||||
|
"wall": 50,
|
||||||
|
"officer_set": 7,
|
||||||
|
"term": 2,
|
||||||
|
"conflict": {"98": 3}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"nation": 99,
|
||||||
|
"supply": 1,
|
||||||
|
"front": 2,
|
||||||
|
"pop": 1001,
|
||||||
|
"agri": 501,
|
||||||
|
"comm": 499,
|
||||||
|
"secu": 99,
|
||||||
|
"trust": 33,
|
||||||
|
"def": 101,
|
||||||
|
"wall": 50,
|
||||||
|
"officer_set": 7,
|
||||||
|
"term": 2,
|
||||||
|
"conflict": {"98": 3}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"nation": 0,
|
||||||
|
"supply": 0,
|
||||||
|
"front": 0,
|
||||||
|
"trust": 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 99,
|
||||||
|
"city": 2,
|
||||||
|
"officer_level": 4,
|
||||||
|
"officer_city": 2,
|
||||||
|
"crew": 101,
|
||||||
|
"train": 51,
|
||||||
|
"atmos": 99
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"nation": 99,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 4,
|
||||||
|
"officer_city": 2,
|
||||||
|
"crew": 101,
|
||||||
|
"train": 51,
|
||||||
|
"atmos": 99
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"values": {
|
||||||
|
"nation": 98,
|
||||||
|
"city": 2,
|
||||||
|
"officer_level": 3,
|
||||||
|
"officer_city": 1,
|
||||||
|
"crew": 101,
|
||||||
|
"train": 51,
|
||||||
|
"atmos": 99
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1, 2, 3],
|
||||||
|
"cityIds": [1, 2, 3, 9],
|
||||||
|
"nationIds": [98, 99]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"action": "UpdateNationLevel",
|
||||||
|
"environment": {
|
||||||
|
"year": 193,
|
||||||
|
"month": 2,
|
||||||
|
"startyear": 190,
|
||||||
|
"killturn": 1000,
|
||||||
|
"turnterm": 10
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"resetCities": true,
|
||||||
|
"resetGenerals": true,
|
||||||
|
"resetUniqueOccupancy": true,
|
||||||
|
"syncEnvironment": true,
|
||||||
|
"clearNationTurnIds": [1],
|
||||||
|
"clearInheritanceOwnerIds": [990061],
|
||||||
|
"nation": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "작위검증국",
|
||||||
|
"color": "#777777",
|
||||||
|
"capital": 1,
|
||||||
|
"gold": 10000,
|
||||||
|
"rice": 20000,
|
||||||
|
"level": 0,
|
||||||
|
"type": "che_중립",
|
||||||
|
"aux": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"city": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"level": 4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"nation": 1,
|
||||||
|
"level": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"general": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"values": {
|
||||||
|
"name": "조조",
|
||||||
|
"nation": 1,
|
||||||
|
"city": 1,
|
||||||
|
"officer_level": 12,
|
||||||
|
"owner": 990061,
|
||||||
|
"npc": 0,
|
||||||
|
"killturn": 1000,
|
||||||
|
"belong": 10,
|
||||||
|
"horse": "None",
|
||||||
|
"weapon": "None",
|
||||||
|
"book": "None",
|
||||||
|
"item": "None",
|
||||||
|
"aux": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"values": {
|
||||||
|
"nation": 0,
|
||||||
|
"city": 2,
|
||||||
|
"officer_level": 1,
|
||||||
|
"npc": 0,
|
||||||
|
"killturn": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [1],
|
||||||
|
"cityIds": [1, 2],
|
||||||
|
"nationIds": [1],
|
||||||
|
"ownerIds": [990061]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli' || getenv('REF_DETERMINISTIC_INSTALL_ENABLED') !== '1') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
|
||||||
|
$request = json_decode(stream_get_contents(STDIN), true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
$generalIds = $request['generalIds'] ?? null;
|
||||||
|
if (!is_array($generalIds) || $generalIds === []) {
|
||||||
|
throw new \InvalidArgumentException('generalIds must be a non-empty array');
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$gameStorage = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$env = $gameStorage->getAll(true);
|
||||||
|
$result = [];
|
||||||
|
$includeNation = ($request['includeNation'] ?? false) === true;
|
||||||
|
foreach ($generalIds as $generalId) {
|
||||||
|
if (!is_int($generalId) || $generalId < 1) {
|
||||||
|
throw new \InvalidArgumentException('generalIds must contain positive integers');
|
||||||
|
}
|
||||||
|
$general = General::createObjFromDB($generalId);
|
||||||
|
if ($general->getNPCType() < 2) {
|
||||||
|
throw new \InvalidArgumentException("general {$generalId} is not an NPC");
|
||||||
|
}
|
||||||
|
$ai = new GeneralAI($general);
|
||||||
|
$nationDecision = null;
|
||||||
|
if ($includeNation && $general->getNationID() !== 0 && $general->getVar('officer_level') >= 5) {
|
||||||
|
$nationStorage = KVStorage::getStorage($db, $general->getNationID(), 'nation_env');
|
||||||
|
$lastNationTurn = LastTurn::fromRaw($nationStorage->getValue("turn_last_{$general->getVar('officer_level')}"));
|
||||||
|
$reservedNation = buildNationCommandClass(null, $general, $env, $lastNationTurn);
|
||||||
|
$selectedNation = $ai->chooseNationTurn($reservedNation);
|
||||||
|
$nationDecision = [
|
||||||
|
'action' => $selectedNation->getRawClassName(),
|
||||||
|
'args' => $selectedNation->getArg(),
|
||||||
|
'reason' => $selectedNation->reason,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$reserved = $general->getReservedTurn(0, $env);
|
||||||
|
$selected = $ai->chooseGeneralTurn($reserved);
|
||||||
|
$result[] = [
|
||||||
|
'generalId' => $generalId,
|
||||||
|
'name' => $general->getName(),
|
||||||
|
'action' => $selected->getRawClassName(),
|
||||||
|
'brief' => $selected->getBrief(),
|
||||||
|
'args' => $selected->getArg(),
|
||||||
|
'reason' => $selected->reason,
|
||||||
|
'nationDecision' => $nationDecision,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
'year' => (int) $env['year'],
|
||||||
|
'month' => (int) $env['month'],
|
||||||
|
'decisions' => $result,
|
||||||
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
|
||||||
|
$input = stream_get_contents(STDIN);
|
||||||
|
$keys = Json::decode($input);
|
||||||
|
if (!is_array($keys)) {
|
||||||
|
fwrite(STDERR, "Expected a JSON array of item keys.\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
if (!is_string($key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$item = buildItemClass($key);
|
||||||
|
$result[$key] = [
|
||||||
|
'rawName' => $item->getRawName(),
|
||||||
|
'name' => $item->getName(),
|
||||||
|
'info' => $item->getInfo(),
|
||||||
|
'cost' => $item->getCost(),
|
||||||
|
'buyable' => $item->isBuyable(),
|
||||||
|
'consumable' => $item->isConsumable(),
|
||||||
|
'reqSecu' => $item->getReqSecu(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo Json::encode($result);
|
||||||
@@ -0,0 +1,1596 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli' || getenv('TURN_DIFFERENTIAL_ENABLED') !== '1') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
$_SERVER['REMOTE_ADDR'] ??= '127.0.0.1';
|
||||||
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
require_once __DIR__ . '/turn_state_snapshot.php';
|
||||||
|
|
||||||
|
function comparisonGameTick(mixed $value, string $label): int
|
||||||
|
{
|
||||||
|
if (is_int($value)) {
|
||||||
|
return GameClock::requireSafeTick($value);
|
||||||
|
}
|
||||||
|
if (!is_string($value) || $value === '') {
|
||||||
|
throw new \InvalidArgumentException("{$label} must be a game tick or projected date string");
|
||||||
|
}
|
||||||
|
$gameStorage = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
|
return GameClock::fromStorage($gameStorage)->dateTimeToTick(new \DateTimeImmutable($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string, mixed> $values */
|
||||||
|
function comparisonMonthlyPatch(string $table, int $id, array $values): void
|
||||||
|
{
|
||||||
|
$definitions = [
|
||||||
|
'city' => [
|
||||||
|
'idColumn' => 'city',
|
||||||
|
'allowed' => [
|
||||||
|
'name', 'level', 'nation', 'supply', 'front', 'pop', 'pop_max',
|
||||||
|
'agri', 'agri_max', 'comm', 'comm_max', 'secu', 'secu_max',
|
||||||
|
'trust', 'trade', 'def', 'def_max', 'wall', 'wall_max',
|
||||||
|
'officer_set', 'state', 'region', 'term', 'conflict', 'dead',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'nation' => [
|
||||||
|
'idColumn' => 'nation',
|
||||||
|
'allowed' => [
|
||||||
|
'name', 'color', 'capital', 'gennum', 'gold', 'rice', 'tech',
|
||||||
|
'power', 'level', 'type', 'bill', 'rate_tmp', 'scout', 'chief_set', 'aux',
|
||||||
|
'rate', 'strategic_cmd_limit', 'surlimit', 'spy',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'general' => [
|
||||||
|
'idColumn' => 'no',
|
||||||
|
'allowed' => [
|
||||||
|
'name', 'nation', 'city', 'officer_level', 'officer_city',
|
||||||
|
'crew', 'train', 'atmos', 'owner', 'npc', 'killturn', 'belong',
|
||||||
|
'gold', 'rice', 'horse', 'weapon', 'book', 'item', 'aux',
|
||||||
|
'leadership', 'strength', 'intel', 'experience', 'dedication',
|
||||||
|
'injury',
|
||||||
|
'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'personal', 'special',
|
||||||
|
'specage', 'special2', 'specage2', 'betray', 'age',
|
||||||
|
'bornyear', 'deadyear', 'turntime', 'makelimit',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$definition = $definitions[$table] ?? null;
|
||||||
|
if ($definition === null) {
|
||||||
|
throw new \InvalidArgumentException("unsupported setup table: {$table}");
|
||||||
|
}
|
||||||
|
$patch = [];
|
||||||
|
foreach ($values as $key => $value) {
|
||||||
|
if (!is_string($key) || !in_array($key, $definition['allowed'], true)) {
|
||||||
|
throw new \InvalidArgumentException("unsupported {$table} setup field");
|
||||||
|
}
|
||||||
|
if (in_array($key, ['conflict', 'aux'], true) && is_array($value)) {
|
||||||
|
$value = json_encode($value, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);
|
||||||
|
}
|
||||||
|
$patch[$key] = $value;
|
||||||
|
}
|
||||||
|
if ($table === 'nation') {
|
||||||
|
$patch += [
|
||||||
|
'nation' => $id,
|
||||||
|
'name' => "fixture-nation-{$id}",
|
||||||
|
'color' => '#777777',
|
||||||
|
'capital' => 0,
|
||||||
|
'gold' => 0,
|
||||||
|
'rice' => 0,
|
||||||
|
'level' => 1,
|
||||||
|
'type' => 'che_중립',
|
||||||
|
'aux' => '{}',
|
||||||
|
];
|
||||||
|
DB::db()->insertUpdate('nation', $patch, $patch);
|
||||||
|
} elseif ($patch !== []) {
|
||||||
|
DB::db()->update($table, $patch, "`{$definition['idColumn']}` = %i", $id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string, mixed> $observe */
|
||||||
|
function comparisonMonthlyDetails(array $observe, int $worldHistoryAfterId): array
|
||||||
|
{
|
||||||
|
$db = DB::db();
|
||||||
|
$generals = array_map(
|
||||||
|
static fn(array $row): array => comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'no',
|
||||||
|
'nationId' => 'nation',
|
||||||
|
'cityId' => 'city',
|
||||||
|
'officerLevel' => 'officer_level',
|
||||||
|
'officerCityId' => 'officer_city',
|
||||||
|
'crew' => 'crew',
|
||||||
|
'train' => 'train',
|
||||||
|
'atmos' => 'atmos',
|
||||||
|
'gold' => 'gold',
|
||||||
|
'rice' => 'rice',
|
||||||
|
'injury' => 'injury',
|
||||||
|
'leadership' => 'leadership',
|
||||||
|
'strength' => 'strength',
|
||||||
|
'intelligence' => 'intel',
|
||||||
|
'age' => 'age',
|
||||||
|
'specialDomestic' => 'special',
|
||||||
|
'specAge' => 'specage',
|
||||||
|
'specialWar' => 'special2',
|
||||||
|
'specAge2' => 'specage2',
|
||||||
|
'betray' => 'betray',
|
||||||
|
'makeLimit' => 'makelimit',
|
||||||
|
'horse' => 'horse',
|
||||||
|
'weapon' => 'weapon',
|
||||||
|
'book' => 'book',
|
||||||
|
'item' => 'item',
|
||||||
|
'dex1' => 'dex1',
|
||||||
|
'dex2' => 'dex2',
|
||||||
|
'dex3' => 'dex3',
|
||||||
|
'dex4' => 'dex4',
|
||||||
|
'dex5' => 'dex5',
|
||||||
|
'aux' => 'aux',
|
||||||
|
],
|
||||||
|
['aux'],
|
||||||
|
),
|
||||||
|
comparisonRowsById('general', 'no', comparisonIntegerList($observe['generalIds'] ?? [], 'generalIds')),
|
||||||
|
);
|
||||||
|
$cities = array_map(
|
||||||
|
static fn(array $row): array => comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'city',
|
||||||
|
'nationId' => 'nation',
|
||||||
|
'state' => 'state',
|
||||||
|
'supplyState' => 'supply',
|
||||||
|
'frontState' => 'front',
|
||||||
|
'officerSet' => 'officer_set',
|
||||||
|
'term' => 'term',
|
||||||
|
'dead' => 'dead',
|
||||||
|
'population' => 'pop',
|
||||||
|
'populationMax' => 'pop_max',
|
||||||
|
'agriculture' => 'agri',
|
||||||
|
'agricultureMax' => 'agri_max',
|
||||||
|
'commerce' => 'comm',
|
||||||
|
'commerceMax' => 'comm_max',
|
||||||
|
'security' => 'secu',
|
||||||
|
'securityMax' => 'secu_max',
|
||||||
|
'trust' => 'trust',
|
||||||
|
'trade' => 'trade',
|
||||||
|
'defence' => 'def',
|
||||||
|
'defenceMax' => 'def_max',
|
||||||
|
'wall' => 'wall',
|
||||||
|
'wallMax' => 'wall_max',
|
||||||
|
'conflict' => 'conflict',
|
||||||
|
],
|
||||||
|
['conflict'],
|
||||||
|
),
|
||||||
|
comparisonRowsById('city', 'city', comparisonIntegerList($observe['cityIds'] ?? [], 'cityIds')),
|
||||||
|
);
|
||||||
|
$nations = array_map(
|
||||||
|
static fn(array $row): array => comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'nation',
|
||||||
|
'gold' => 'gold',
|
||||||
|
'rice' => 'rice',
|
||||||
|
'rate' => 'rate_tmp',
|
||||||
|
'baseRate' => 'rate',
|
||||||
|
'power' => 'power',
|
||||||
|
'generalCount' => 'gennum',
|
||||||
|
'tech' => 'tech',
|
||||||
|
'typeCode' => 'type',
|
||||||
|
'scout' => 'scout',
|
||||||
|
'strategicCommandLimit' => 'strategic_cmd_limit',
|
||||||
|
'surrenderLimit' => 'surlimit',
|
||||||
|
'spy' => 'spy',
|
||||||
|
'chiefSet' => 'chief_set',
|
||||||
|
],
|
||||||
|
['spy'],
|
||||||
|
),
|
||||||
|
comparisonRowsById('nation', 'nation', comparisonIntegerList($observe['nationIds'] ?? [], 'nationIds')),
|
||||||
|
);
|
||||||
|
$worldHistory = array_map(
|
||||||
|
static fn(array $row): array => comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'id',
|
||||||
|
'nationId' => 'nation_id',
|
||||||
|
'year' => 'year',
|
||||||
|
'month' => 'month',
|
||||||
|
'text' => 'text',
|
||||||
|
],
|
||||||
|
),
|
||||||
|
$db->query(
|
||||||
|
'SELECT id, nation_id, year, month, text FROM world_history WHERE id > %i ORDER BY id',
|
||||||
|
$worldHistoryAfterId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$inheritanceKeys = $observe['inheritanceKeys'] ?? ['unifier'];
|
||||||
|
if (!is_array($inheritanceKeys) || array_filter($inheritanceKeys, static fn($key): bool => !is_string($key))) {
|
||||||
|
throw new \InvalidArgumentException('inheritanceKeys must be an array of strings');
|
||||||
|
}
|
||||||
|
$inheritancePoints = [];
|
||||||
|
foreach (comparisonIntegerList($observe['ownerIds'] ?? [], 'ownerIds') as $ownerId) {
|
||||||
|
$entry = ['ownerId' => $ownerId];
|
||||||
|
foreach ($inheritanceKeys as $key) {
|
||||||
|
$value = $db->queryFirstField(
|
||||||
|
'SELECT value FROM storage WHERE namespace = %s AND `key` = %s',
|
||||||
|
"inheritance_{$ownerId}",
|
||||||
|
$key,
|
||||||
|
);
|
||||||
|
$entry[$key] = $value === null ? 0 : (comparisonJsonValue($value)[0] ?? 0);
|
||||||
|
}
|
||||||
|
$inheritancePoints[] = $entry;
|
||||||
|
}
|
||||||
|
$rankGeneralIds = comparisonIntegerList($observe['rankGeneralIds'] ?? [], 'rankGeneralIds');
|
||||||
|
$rankTypes = $observe['rankTypes'] ?? [];
|
||||||
|
if (!is_array($rankTypes) || array_filter($rankTypes, static fn($type): bool => !is_string($type))) {
|
||||||
|
throw new \InvalidArgumentException('rankTypes must be an array of strings');
|
||||||
|
}
|
||||||
|
$rankData = (!$rankGeneralIds || !$rankTypes)
|
||||||
|
? []
|
||||||
|
: iterator_to_array($db->query(
|
||||||
|
'SELECT general_id AS generalId, nation_id AS nationId, `type`, `value` FROM rank_data WHERE general_id IN %li AND `type` IN %ls ORDER BY general_id, `type`',
|
||||||
|
$rankGeneralIds,
|
||||||
|
$rankTypes,
|
||||||
|
));
|
||||||
|
$generalAccessLogs = [];
|
||||||
|
$accessGeneralIds = comparisonIntegerList($observe['accessGeneralIds'] ?? [], 'accessGeneralIds');
|
||||||
|
if ($accessGeneralIds) {
|
||||||
|
$generalAccessLogs = iterator_to_array($db->query(
|
||||||
|
'SELECT general_id AS generalId, refresh_score_total AS refreshScoreTotal FROM general_access_log WHERE general_id IN %li ORDER BY general_id',
|
||||||
|
$accessGeneralIds,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$nationEnvironment = [];
|
||||||
|
$nationEnvironmentKeys = $observe['nationEnvironmentKeys'] ?? [];
|
||||||
|
if (
|
||||||
|
!is_array($nationEnvironmentKeys)
|
||||||
|
|| array_filter($nationEnvironmentKeys, static fn($key): bool => !is_string($key))
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('nationEnvironmentKeys must be an array of strings');
|
||||||
|
}
|
||||||
|
foreach (comparisonIntegerList($observe['nationIds'] ?? [], 'nationIds') as $nationId) {
|
||||||
|
$entry = ['nationId' => $nationId];
|
||||||
|
$storage = KVStorage::getStorage($db, $nationId, 'nation_env');
|
||||||
|
foreach ($nationEnvironmentKeys as $key) {
|
||||||
|
$entry[$key] = $storage->getValue($key);
|
||||||
|
}
|
||||||
|
$nationEnvironment[] = $entry;
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'generals' => $generals,
|
||||||
|
'cities' => $cities,
|
||||||
|
'nations' => $nations,
|
||||||
|
'worldHistory' => $worldHistory,
|
||||||
|
'inheritancePoints' => $inheritancePoints,
|
||||||
|
'rankData' => $rankData,
|
||||||
|
'generalAccessLogs' => $generalAccessLogs,
|
||||||
|
'nationEnvironment' => $nationEnvironment,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exercise the dynamically-created invader events against one evolving database.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $request
|
||||||
|
* @param array<string, mixed> $environment
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
function comparisonInvaderLifecycleTrace(
|
||||||
|
array $request,
|
||||||
|
array $environment,
|
||||||
|
int $generalIdBeforeAction,
|
||||||
|
int $nationIdBeforeAction,
|
||||||
|
int $eventIdBeforeAction,
|
||||||
|
int $worldHistoryIdBeforeAction,
|
||||||
|
): array {
|
||||||
|
$db = DB::db();
|
||||||
|
$args = $request['args'] ?? [];
|
||||||
|
if (!is_array($args) || count($args) > 4) {
|
||||||
|
throw new \InvalidArgumentException('InvaderLifecycle args must have at most four entries');
|
||||||
|
}
|
||||||
|
$year = $environment['year'];
|
||||||
|
$month = $environment['month'];
|
||||||
|
$startYear = $environment['startyear'];
|
||||||
|
$raiseEnvironment = [
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month,
|
||||||
|
'startyear' => $startYear,
|
||||||
|
'turnterm' => $environment['turnterm'],
|
||||||
|
'turntime' => $environment['turntime'],
|
||||||
|
'show_img_level' => $environment['show_img_level'] ?? 3,
|
||||||
|
'stored_icons' => $environment['stored_icons'] ?? [],
|
||||||
|
'icon_path' => $environment['icon_path'] ?? '.',
|
||||||
|
'fiction' => $environment['fiction'] ?? [0],
|
||||||
|
];
|
||||||
|
|
||||||
|
(new \sammo\Event\Action\RaiseInvader(...$args))->run($raiseEnvironment);
|
||||||
|
|
||||||
|
$invaderNationIds = array_map(
|
||||||
|
'intval',
|
||||||
|
$db->queryFirstColumn('SELECT nation FROM nation WHERE nation > %i ORDER BY nation', $nationIdBeforeAction),
|
||||||
|
);
|
||||||
|
$existingNationId = (int)$db->queryFirstField(
|
||||||
|
'SELECT nation FROM nation WHERE nation <= %i ORDER BY nation LIMIT 1',
|
||||||
|
$nationIdBeforeAction,
|
||||||
|
);
|
||||||
|
$rulerIds = array_map(
|
||||||
|
'intval',
|
||||||
|
$db->queryFirstColumn(
|
||||||
|
'SELECT no FROM general WHERE nation IN %li AND officer_level = 12 ORDER BY nation',
|
||||||
|
$invaderNationIds,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if ($invaderNationIds === [] || $existingNationId <= 0 || count($rulerIds) !== count($invaderNationIds)) {
|
||||||
|
throw new \RuntimeException('InvaderLifecycle failed to create the expected entities');
|
||||||
|
}
|
||||||
|
|
||||||
|
$autoDeleteEvents = [];
|
||||||
|
$endingEventId = 0;
|
||||||
|
foreach ($db->query('SELECT id, action FROM event WHERE id > %i ORDER BY id', $eventIdBeforeAction) as $row) {
|
||||||
|
$action = comparisonJsonValue($row['action']);
|
||||||
|
$actionName = $action[0][0] ?? null;
|
||||||
|
if ($actionName === 'AutoDeleteInvader') {
|
||||||
|
$autoDeleteEvents[] = [
|
||||||
|
'eventId' => (int)$row['id'],
|
||||||
|
'nationId' => (int)($action[0][1] ?? 0),
|
||||||
|
];
|
||||||
|
} elseif ($actionName === 'InvaderEnding') {
|
||||||
|
$endingEventId = (int)$row['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($autoDeleteEvents) !== count($invaderNationIds) || $endingEventId <= 0) {
|
||||||
|
throw new \RuntimeException('InvaderLifecycle failed to create follow-up events');
|
||||||
|
}
|
||||||
|
|
||||||
|
$diplomacyRows = iterator_to_array($db->query(
|
||||||
|
'SELECT me, you, state, term FROM diplomacy WHERE (me IN %li AND you = %i) OR (me = %i AND you IN %li) ORDER BY me, you',
|
||||||
|
$invaderNationIds,
|
||||||
|
$existingNationId,
|
||||||
|
$existingNationId,
|
||||||
|
$invaderNationIds,
|
||||||
|
));
|
||||||
|
$diplomacyStates = array_values(array_unique(array_map(
|
||||||
|
static fn(array $row): string => "{$row['state']}:{$row['term']}",
|
||||||
|
$diplomacyRows,
|
||||||
|
)));
|
||||||
|
sort($diplomacyStates);
|
||||||
|
$generalCounts = array_map(
|
||||||
|
static fn(int $nationId): int => (int)DB::db()->queryFirstField(
|
||||||
|
'SELECT count(*) FROM general WHERE nation = %i',
|
||||||
|
$nationId,
|
||||||
|
),
|
||||||
|
$invaderNationIds,
|
||||||
|
);
|
||||||
|
$diplomacyCounts = array_map(
|
||||||
|
static fn(int $nationId): int => (int)DB::db()->queryFirstField(
|
||||||
|
'SELECT count(*) FROM diplomacy WHERE (me = %i AND you = %i) OR (me = %i AND you = %i)',
|
||||||
|
$nationId,
|
||||||
|
$existingNationId,
|
||||||
|
$existingNationId,
|
||||||
|
$nationId,
|
||||||
|
),
|
||||||
|
$invaderNationIds,
|
||||||
|
);
|
||||||
|
$gameStorage = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$afterRaise = [
|
||||||
|
'createdNationCount' => count($invaderNationIds),
|
||||||
|
'createdGeneralCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM general WHERE no > %i',
|
||||||
|
$generalIdBeforeAction,
|
||||||
|
),
|
||||||
|
'followUpEventCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM event WHERE id > %i',
|
||||||
|
$eventIdBeforeAction,
|
||||||
|
),
|
||||||
|
'generalCountsPerNation' => array_values(array_unique($generalCounts)),
|
||||||
|
'diplomacyCountsPerNation' => array_values(array_unique($diplomacyCounts)),
|
||||||
|
'diplomacyStates' => $diplomacyStates,
|
||||||
|
'isunited' => (int)$gameStorage->isunited,
|
||||||
|
'blockChangeScout' => (bool)$gameStorage->block_change_scout,
|
||||||
|
];
|
||||||
|
|
||||||
|
$warResults = [];
|
||||||
|
foreach ($autoDeleteEvents as $autoDeleteEvent) {
|
||||||
|
$warResult = (new \sammo\Event\Action\AutoDeleteInvader($autoDeleteEvent['nationId']))->run([
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month + 1,
|
||||||
|
'startyear' => $startYear,
|
||||||
|
'currentEventID' => $autoDeleteEvent['eventId'],
|
||||||
|
]);
|
||||||
|
$warResults[] = $warResult[1] ?? null;
|
||||||
|
}
|
||||||
|
$atWar = [
|
||||||
|
'results' => array_values(array_unique($warResults)),
|
||||||
|
'autoDeleteEventCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM event WHERE id IN %li',
|
||||||
|
array_column($autoDeleteEvents, 'eventId'),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
$db->update(
|
||||||
|
'diplomacy',
|
||||||
|
['state' => 2, 'term' => 0],
|
||||||
|
'me IN %li OR you IN %li',
|
||||||
|
$invaderNationIds,
|
||||||
|
$invaderNationIds,
|
||||||
|
);
|
||||||
|
$peaceResults = [];
|
||||||
|
foreach ($autoDeleteEvents as $autoDeleteEvent) {
|
||||||
|
$peaceResult = (new \sammo\Event\Action\AutoDeleteInvader($autoDeleteEvent['nationId']))->run([
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month + 2,
|
||||||
|
'startyear' => $startYear,
|
||||||
|
'currentEventID' => $autoDeleteEvent['eventId'],
|
||||||
|
]);
|
||||||
|
$peaceResults[] = $peaceResult[1] ?? null;
|
||||||
|
}
|
||||||
|
$atPeace = [
|
||||||
|
'results' => array_values(array_unique($peaceResults)),
|
||||||
|
'autoDeleteEventCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM event WHERE id IN %li',
|
||||||
|
array_column($autoDeleteEvents, 'eventId'),
|
||||||
|
),
|
||||||
|
'rulerWanderTurnCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM general_turn WHERE general_id IN %li AND action = %s',
|
||||||
|
$rulerIds,
|
||||||
|
'che_방랑',
|
||||||
|
),
|
||||||
|
'endingEventPresent' => (bool)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM event WHERE id = %i',
|
||||||
|
$endingEventId,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
$invaderGeneralIds = array_map('intval', $db->queryFirstColumn(
|
||||||
|
'SELECT no FROM general WHERE nation IN %li',
|
||||||
|
$invaderNationIds,
|
||||||
|
));
|
||||||
|
if ($invaderGeneralIds !== []) {
|
||||||
|
$db->delete('general_turn', 'general_id IN %li', $invaderGeneralIds);
|
||||||
|
$db->delete('rank_data', 'general_id IN %li', $invaderGeneralIds);
|
||||||
|
$db->delete('troop', 'nation IN %li', $invaderNationIds);
|
||||||
|
$db->delete('general', 'no IN %li', $invaderGeneralIds);
|
||||||
|
}
|
||||||
|
$db->delete('nation_turn', 'nation_id IN %li', $invaderNationIds);
|
||||||
|
$db->delete('diplomacy', 'me IN %li OR you IN %li', $invaderNationIds, $invaderNationIds);
|
||||||
|
$db->delete('nation', 'nation IN %li', $invaderNationIds);
|
||||||
|
$db->update('city', ['nation' => $existingNationId], true);
|
||||||
|
|
||||||
|
$endingResult = (new \sammo\Event\Action\InvaderEnding())->run([
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month + 3,
|
||||||
|
'startyear' => $startYear,
|
||||||
|
'currentEventID' => $endingEventId,
|
||||||
|
]);
|
||||||
|
$gameStorage->resetCache();
|
||||||
|
$afterUserWin = [
|
||||||
|
'result' => $endingResult[1] ?? null,
|
||||||
|
'endingEventPresent' => (bool)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM event WHERE id = %i',
|
||||||
|
$endingEventId,
|
||||||
|
),
|
||||||
|
'isunited' => (int)$gameStorage->isunited,
|
||||||
|
'refreshLimit' => (int)$gameStorage->refreshLimit,
|
||||||
|
'logs' => array_values($db->queryFirstColumn(
|
||||||
|
'SELECT text FROM world_history WHERE id > %i AND nation_id = 0 AND year = %i AND month = %i ORDER BY id',
|
||||||
|
$worldHistoryIdBeforeAction,
|
||||||
|
$year,
|
||||||
|
$month + 3,
|
||||||
|
)),
|
||||||
|
];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'action' => 'InvaderLifecycle',
|
||||||
|
'phases' => [
|
||||||
|
'afterRaise' => $afterRaise,
|
||||||
|
'atWar' => $atWar,
|
||||||
|
'atPeace' => $atPeace,
|
||||||
|
'afterUserWin' => $afterUserWin,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exercise NPC nation creation and the same-month troop leader follow-up.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $environment
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
function comparisonNpcNationLifecycleTrace(
|
||||||
|
array $environment,
|
||||||
|
int $generalIdBeforeAction,
|
||||||
|
int $nationIdBeforeAction,
|
||||||
|
int $worldHistoryIdBeforeAction,
|
||||||
|
): array {
|
||||||
|
$db = DB::db();
|
||||||
|
$actionEnvironment = [
|
||||||
|
'year' => $environment['year'],
|
||||||
|
'month' => $environment['month'],
|
||||||
|
'startyear' => $environment['startyear'],
|
||||||
|
'turnterm' => $environment['turnterm'],
|
||||||
|
'turntime' => $environment['turntime'],
|
||||||
|
'show_img_level' => $environment['show_img_level'] ?? 3,
|
||||||
|
'stored_icons' => $environment['stored_icons'] ?? [],
|
||||||
|
'icon_path' => $environment['icon_path'] ?? '.',
|
||||||
|
'fiction' => $environment['fiction'] ?? [0],
|
||||||
|
];
|
||||||
|
$gameStorage = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$leaderCounterBefore = (int)($gameStorage->lastNPCTroopLeaderID ?? 0);
|
||||||
|
|
||||||
|
(new \sammo\Event\Action\RaiseNPCNation())->run($actionEnvironment);
|
||||||
|
$createdNationIds = array_map(
|
||||||
|
'intval',
|
||||||
|
$db->queryFirstColumn('SELECT nation FROM nation WHERE nation > %i ORDER BY nation', $nationIdBeforeAction),
|
||||||
|
);
|
||||||
|
if ($createdNationIds === []) {
|
||||||
|
throw new \RuntimeException('NpcNationLifecycle failed to create a nation');
|
||||||
|
}
|
||||||
|
$createdNationGeneralCounts = array_map(
|
||||||
|
static fn(int $nationId): int => (int)DB::db()->queryFirstField(
|
||||||
|
'SELECT count(*) FROM general WHERE nation = %i',
|
||||||
|
$nationId,
|
||||||
|
),
|
||||||
|
$createdNationIds,
|
||||||
|
);
|
||||||
|
$afterRaise = [
|
||||||
|
'createdNationCount' => count($createdNationIds),
|
||||||
|
'createdGeneralCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM general WHERE no > %i',
|
||||||
|
$generalIdBeforeAction,
|
||||||
|
),
|
||||||
|
'generalCountsPerCreatedNation' => array_values(array_unique($createdNationGeneralCounts)),
|
||||||
|
'historyLogs' => array_values($db->queryFirstColumn(
|
||||||
|
'SELECT text FROM world_history WHERE id > %i AND nation_id = 0 ORDER BY id',
|
||||||
|
$worldHistoryIdBeforeAction,
|
||||||
|
)),
|
||||||
|
];
|
||||||
|
|
||||||
|
(new \sammo\Event\Action\ProvideNPCTroopLeader())->run($actionEnvironment);
|
||||||
|
$leaderIds = array_map(
|
||||||
|
'intval',
|
||||||
|
$db->queryFirstColumn('SELECT no FROM general WHERE no > %i AND npc = 5 ORDER BY no', $generalIdBeforeAction),
|
||||||
|
);
|
||||||
|
if ($leaderIds === []) {
|
||||||
|
throw new \RuntimeException('NpcNationLifecycle failed to create troop leaders');
|
||||||
|
}
|
||||||
|
$leaderNationCounts = array_map(
|
||||||
|
static fn(int $nationId): int => (int)DB::db()->queryFirstField(
|
||||||
|
'SELECT count(*) FROM general WHERE nation = %i AND npc = 5',
|
||||||
|
$nationId,
|
||||||
|
),
|
||||||
|
array_map(
|
||||||
|
'intval',
|
||||||
|
$db->queryFirstColumn('SELECT nation FROM nation WHERE level > 0 ORDER BY nation'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$gatherTurnCounts = array_map(
|
||||||
|
static fn(int $generalId): int => (int)DB::db()->queryFirstField(
|
||||||
|
'SELECT count(*) FROM general_turn WHERE general_id = %i AND action = %s',
|
||||||
|
$generalId,
|
||||||
|
'che_집합',
|
||||||
|
),
|
||||||
|
$leaderIds,
|
||||||
|
);
|
||||||
|
$gameStorage->resetCache();
|
||||||
|
$afterProvide = [
|
||||||
|
'createdLeaderCount' => count($leaderIds),
|
||||||
|
'leaderCountsPerActiveNation' => array_values(array_unique($leaderNationCounts)),
|
||||||
|
'troopCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM troop WHERE troop_leader IN %li',
|
||||||
|
$leaderIds,
|
||||||
|
),
|
||||||
|
'gatherTurnCounts' => array_values(array_unique($gatherTurnCounts)),
|
||||||
|
'leaderCounterDelta' => (int)$gameStorage->lastNPCTroopLeaderID - $leaderCounterBefore,
|
||||||
|
];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'action' => 'NpcNationLifecycle',
|
||||||
|
'phases' => [
|
||||||
|
'afterRaise' => $afterRaise,
|
||||||
|
'afterProvide' => $afterProvide,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exercise nation betting from monthly open through real user bets and settlement.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $request
|
||||||
|
* @param array<string, mixed> $environment
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
function comparisonNationBettingLifecycleTrace(
|
||||||
|
array $request,
|
||||||
|
array $environment,
|
||||||
|
int $eventIdBeforeAction,
|
||||||
|
int $worldHistoryIdBeforeAction,
|
||||||
|
): array {
|
||||||
|
$db = DB::db();
|
||||||
|
$args = $request['args'] ?? [];
|
||||||
|
if (!is_array($args) || count($args) > 2) {
|
||||||
|
throw new \InvalidArgumentException('NationBettingLifecycle args must have at most two entries');
|
||||||
|
}
|
||||||
|
$bettorGeneralIds = comparisonIntegerList(
|
||||||
|
$request['bettorGeneralIds'] ?? [],
|
||||||
|
'bettorGeneralIds',
|
||||||
|
);
|
||||||
|
$bettorOwnerIds = comparisonIntegerList(
|
||||||
|
$request['bettorOwnerIds'] ?? [],
|
||||||
|
'bettorOwnerIds',
|
||||||
|
);
|
||||||
|
if (count($bettorGeneralIds) !== 2 || count($bettorOwnerIds) !== 2) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'NationBettingLifecycle requires exactly two bettorGeneralIds and bettorOwnerIds',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$year = $environment['year'];
|
||||||
|
$month = $environment['month'];
|
||||||
|
$startYear = $environment['startyear'];
|
||||||
|
(new \sammo\Event\Action\OpenNationBetting(...$args))->run([
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month,
|
||||||
|
'startyear' => $startYear,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$gameStorage = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$gameStorage->resetCache();
|
||||||
|
$bettingId = (int)$gameStorage->last_betting_id;
|
||||||
|
$betting = new Betting($bettingId);
|
||||||
|
$bettingInfo = $betting->getInfo();
|
||||||
|
$candidateNationIds = array_map(
|
||||||
|
static fn(\sammo\DTO\SelectItem $candidate): int => (int)($candidate->aux['nation'] ?? 0),
|
||||||
|
$bettingInfo->candidates,
|
||||||
|
);
|
||||||
|
if (count($candidateNationIds) !== 2) {
|
||||||
|
throw new \RuntimeException('NationBettingLifecycle requires exactly two candidates');
|
||||||
|
}
|
||||||
|
|
||||||
|
$finishEventCount = (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM event WHERE id > %i AND action LIKE %s',
|
||||||
|
$eventIdBeforeAction,
|
||||||
|
"%FinishNationBetting%{$bettingId}%",
|
||||||
|
);
|
||||||
|
$afterOpen = [
|
||||||
|
'bettingId' => $bettingId,
|
||||||
|
'candidateNationIds' => $candidateNationIds,
|
||||||
|
'systemBonus' => (int)($db->queryFirstField(
|
||||||
|
'SELECT amount FROM ng_betting WHERE betting_id = %i AND general_id = 0',
|
||||||
|
$bettingId,
|
||||||
|
) ?? 0),
|
||||||
|
'finishEventCount' => $finishEventCount,
|
||||||
|
'historyLogs' => array_values($db->queryFirstColumn(
|
||||||
|
'SELECT text FROM world_history WHERE id > %i AND nation_id = 0 ORDER BY id',
|
||||||
|
$worldHistoryIdBeforeAction,
|
||||||
|
)),
|
||||||
|
];
|
||||||
|
|
||||||
|
$betting->bet($bettorGeneralIds[0], $bettorOwnerIds[0], [1], 100);
|
||||||
|
$betting->bet($bettorGeneralIds[1], $bettorOwnerIds[1], [0], 100);
|
||||||
|
$afterBets = [
|
||||||
|
'bets' => array_map(
|
||||||
|
static fn(array $row): array => [
|
||||||
|
'generalId' => (int)$row['general_id'],
|
||||||
|
'ownerId' => $row['user_id'] === null ? null : (int)$row['user_id'],
|
||||||
|
'selectionKey' => $row['betting_type'],
|
||||||
|
'amount' => (int)$row['amount'],
|
||||||
|
],
|
||||||
|
iterator_to_array($db->query(
|
||||||
|
'SELECT general_id, user_id, betting_type, amount FROM ng_betting WHERE betting_id = %i ORDER BY general_id',
|
||||||
|
$bettingId,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
'inheritancePrevious' => array_map(
|
||||||
|
static function (int $ownerId): int {
|
||||||
|
$value = KVStorage::getStorage(DB::db(), "inheritance_{$ownerId}")->getValue('previous');
|
||||||
|
return is_array($value) ? (int)($value[0] ?? 0) : 0;
|
||||||
|
},
|
||||||
|
$bettorOwnerIds,
|
||||||
|
),
|
||||||
|
'spentRank' => array_map(
|
||||||
|
static fn(int $generalId): int => (int)(DB::db()->queryFirstField(
|
||||||
|
'SELECT value FROM rank_data WHERE general_id = %i AND type = %s',
|
||||||
|
$generalId,
|
||||||
|
\sammo\Enums\RankColumn::inherit_point_spent_dynamic->value,
|
||||||
|
) ?? 0),
|
||||||
|
$bettorGeneralIds,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
$db->update('nation', ['level' => 0], 'nation = %i', $candidateNationIds[1]);
|
||||||
|
$finishResult = (new \sammo\Event\Action\FinishNationBetting($bettingId))->run([
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month + 1,
|
||||||
|
'startyear' => $startYear,
|
||||||
|
]);
|
||||||
|
$settledInfo = (new Betting($bettingId))->getInfo();
|
||||||
|
$afterFinish = [
|
||||||
|
'result' => $finishResult[1] ?? null,
|
||||||
|
'finished' => $settledInfo->finished,
|
||||||
|
'winner' => $settledInfo->winner,
|
||||||
|
'inheritancePrevious' => array_map(
|
||||||
|
static function (int $ownerId): int {
|
||||||
|
$value = KVStorage::getStorage(DB::db(), "inheritance_{$ownerId}")->getValue('previous');
|
||||||
|
return is_array($value) ? (int)($value[0] ?? 0) : 0;
|
||||||
|
},
|
||||||
|
$bettorOwnerIds,
|
||||||
|
),
|
||||||
|
'earnedRank' => array_map(
|
||||||
|
static fn(int $generalId): int => (int)(DB::db()->queryFirstField(
|
||||||
|
'SELECT value FROM rank_data WHERE general_id = %i AND type = %s',
|
||||||
|
$generalId,
|
||||||
|
\sammo\Enums\RankColumn::inherit_point_earned_by_action->value,
|
||||||
|
) ?? 0),
|
||||||
|
$bettorGeneralIds,
|
||||||
|
),
|
||||||
|
'historyLogs' => array_values($db->queryFirstColumn(
|
||||||
|
'SELECT text FROM world_history WHERE id > %i AND nation_id = 0 ORDER BY id',
|
||||||
|
$worldHistoryIdBeforeAction,
|
||||||
|
)),
|
||||||
|
];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'action' => 'NationBettingLifecycle',
|
||||||
|
'phases' => [
|
||||||
|
'afterOpen' => $afterOpen,
|
||||||
|
'afterBets' => $afterBets,
|
||||||
|
'afterFinish' => $afterFinish,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonMonthlyEventTraceMain(): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$input = stream_get_contents(STDIN);
|
||||||
|
$request = json_decode($input === '' ? '{}' : $input, true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
if (!is_array($request)) {
|
||||||
|
throw new \InvalidArgumentException('request must be an object');
|
||||||
|
}
|
||||||
|
$actionName = $request['action'] ?? null;
|
||||||
|
$supportedActions = [
|
||||||
|
'UpdateCitySupply',
|
||||||
|
'UpdateNationLevel',
|
||||||
|
'RaiseDisaster',
|
||||||
|
'ProcessSemiAnnual',
|
||||||
|
'ProcessWarIncome',
|
||||||
|
'CreateAdminNPC',
|
||||||
|
'CreateManyNPC',
|
||||||
|
'RegNPC',
|
||||||
|
'RegNeutralNPC',
|
||||||
|
'RaiseNPCNation',
|
||||||
|
'NpcNationLifecycle',
|
||||||
|
'RaiseInvader',
|
||||||
|
'InvaderLifecycle',
|
||||||
|
'AutoDeleteInvader',
|
||||||
|
'InvaderEnding',
|
||||||
|
'ChangeCity',
|
||||||
|
'ProvideNPCTroopLeader',
|
||||||
|
'NationBettingLifecycle',
|
||||||
|
'OpenNationBetting',
|
||||||
|
'FinishNationBetting',
|
||||||
|
'BlockScoutAction',
|
||||||
|
'UnblockScoutAction',
|
||||||
|
'AssignGeneralSpeciality',
|
||||||
|
'AddGlobalBetray',
|
||||||
|
'LostUniqueItem',
|
||||||
|
'MergeInheritPointRank',
|
||||||
|
'ProcessIncome',
|
||||||
|
'NoticeToHistoryLog',
|
||||||
|
'NewYear',
|
||||||
|
'ResetOfficerLock',
|
||||||
|
'PreUpdateMonthly',
|
||||||
|
'PostUpdateMonthly',
|
||||||
|
'MonthlyBoundary',
|
||||||
|
];
|
||||||
|
if (!in_array($actionName, $supportedActions, true)) {
|
||||||
|
throw new \InvalidArgumentException('unsupported monthly action');
|
||||||
|
}
|
||||||
|
$setup = $request['setup'] ?? [];
|
||||||
|
if (!is_array($setup)) {
|
||||||
|
throw new \InvalidArgumentException('setup must be an object');
|
||||||
|
}
|
||||||
|
foreach (['city', 'nation', 'general'] as $table) {
|
||||||
|
$rows = $setup[$table] ?? [];
|
||||||
|
if (!is_array($rows)) {
|
||||||
|
throw new \InvalidArgumentException("setup.{$table} must be an array");
|
||||||
|
}
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if (!is_array($row) || !is_int($row['id'] ?? null) || !is_array($row['values'] ?? null)) {
|
||||||
|
throw new \InvalidArgumentException("invalid setup.{$table} row");
|
||||||
|
}
|
||||||
|
comparisonMonthlyPatch($table, $row['id'], $row['values']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (($setup['resetCities'] ?? false) === true) {
|
||||||
|
DB::db()->query('UPDATE city SET nation = 0, level = 1');
|
||||||
|
foreach ($setup['city'] ?? [] as $row) {
|
||||||
|
comparisonMonthlyPatch('city', $row['id'], $row['values']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (($setup['deleteOtherCities'] ?? false) === true) {
|
||||||
|
$keepCityIds = comparisonIntegerList($setup['keepCityIds'] ?? [], 'keepCityIds');
|
||||||
|
if ($keepCityIds === []) {
|
||||||
|
throw new \InvalidArgumentException('deleteOtherCities requires keepCityIds');
|
||||||
|
}
|
||||||
|
DB::db()->query('DELETE FROM city WHERE city NOT IN %li', $keepCityIds);
|
||||||
|
}
|
||||||
|
if (($setup['resetGenerals'] ?? false) === true) {
|
||||||
|
DB::db()->query(
|
||||||
|
'UPDATE general SET nation = 0, officer_level = 1, npc = 2, killturn = 0, horse = %s, weapon = %s, book = %s, item = %s',
|
||||||
|
'None',
|
||||||
|
'None',
|
||||||
|
'None',
|
||||||
|
'None',
|
||||||
|
);
|
||||||
|
foreach ($setup['general'] ?? [] as $row) {
|
||||||
|
comparisonMonthlyPatch('general', $row['id'], $row['values']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (($setup['deleteOtherGenerals'] ?? false) === true) {
|
||||||
|
$keepGeneralIds = comparisonIntegerList($setup['keepGeneralIds'] ?? [], 'keepGeneralIds');
|
||||||
|
if (!$keepGeneralIds) {
|
||||||
|
throw new \InvalidArgumentException('deleteOtherGenerals requires keepGeneralIds');
|
||||||
|
}
|
||||||
|
DB::db()->query('DELETE FROM general_turn WHERE general_id NOT IN %li', $keepGeneralIds);
|
||||||
|
DB::db()->query('DELETE FROM rank_data WHERE general_id NOT IN %li', $keepGeneralIds);
|
||||||
|
DB::db()->query('DELETE FROM general WHERE no NOT IN %li', $keepGeneralIds);
|
||||||
|
}
|
||||||
|
if (($setup['resetNations'] ?? false) === true) {
|
||||||
|
DB::db()->query('UPDATE nation SET level = 0, gennum = 0, tech = 0');
|
||||||
|
foreach ($setup['nation'] ?? [] as $row) {
|
||||||
|
comparisonMonthlyPatch('nation', $row['id'], $row['values']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (($setup['deleteOtherNations'] ?? false) === true) {
|
||||||
|
$keepNationIds = comparisonIntegerList($setup['keepNationIds'] ?? [], 'keepNationIds');
|
||||||
|
if (!$keepNationIds) {
|
||||||
|
throw new \InvalidArgumentException('deleteOtherNations requires keepNationIds');
|
||||||
|
}
|
||||||
|
DB::db()->query(
|
||||||
|
'DELETE FROM diplomacy WHERE me NOT IN %li OR you NOT IN %li',
|
||||||
|
$keepNationIds,
|
||||||
|
$keepNationIds,
|
||||||
|
);
|
||||||
|
DB::db()->query('DELETE FROM nation_turn WHERE nation_id NOT IN %li', $keepNationIds);
|
||||||
|
DB::db()->query('DELETE FROM nation WHERE nation NOT IN %li', $keepNationIds);
|
||||||
|
}
|
||||||
|
if (($setup['resetUniqueOccupancy'] ?? false) === true) {
|
||||||
|
DB::db()->delete('ng_auction', '`type` = %s AND finished = 0', 'uniqueItem');
|
||||||
|
DB::db()->query('DELETE FROM storage WHERE namespace LIKE %s', 'ut\\_%');
|
||||||
|
}
|
||||||
|
if (($setup['clearNeutralAuctions'] ?? false) === true) {
|
||||||
|
DB::db()->delete(
|
||||||
|
'ng_auction',
|
||||||
|
'`type` IN %ls AND host_general_id = 0',
|
||||||
|
['buyRice', 'sellRice'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
foreach (comparisonIntegerList($setup['clearNationTurnIds'] ?? [], 'clearNationTurnIds') as $nationId) {
|
||||||
|
DB::db()->delete('nation_turn', 'nation_id = %i', $nationId);
|
||||||
|
}
|
||||||
|
foreach (comparisonIntegerList($setup['clearInheritanceOwnerIds'] ?? [], 'clearInheritanceOwnerIds') as $ownerId) {
|
||||||
|
DB::db()->delete('storage', 'namespace = %s', "inheritance_{$ownerId}");
|
||||||
|
}
|
||||||
|
if (($setup['clearBetting'] ?? false) === true) {
|
||||||
|
DB::db()->query('DELETE FROM ng_betting');
|
||||||
|
DB::db()->query('DELETE FROM storage WHERE namespace = %s', 'betting');
|
||||||
|
$gameStorage = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
|
$gameStorage->setValue('last_betting_id', 0);
|
||||||
|
}
|
||||||
|
foreach ($setup['bettingInfo'] ?? [] as $rawBettingInfo) {
|
||||||
|
if (!is_array($rawBettingInfo) || !is_int($rawBettingInfo['id'] ?? null)) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.bettingInfo row');
|
||||||
|
}
|
||||||
|
KVStorage::getStorage(DB::db(), 'betting')->setValue(
|
||||||
|
"id_{$rawBettingInfo['id']}",
|
||||||
|
$rawBettingInfo,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
foreach ($setup['bet'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row)
|
||||||
|
|| !is_int($row['betting_id'] ?? null)
|
||||||
|
|| !is_int($row['general_id'] ?? null)
|
||||||
|
|| !is_string($row['betting_type'] ?? null)
|
||||||
|
|| !is_int($row['amount'] ?? null)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.bet row');
|
||||||
|
}
|
||||||
|
DB::db()->insert('ng_betting', [
|
||||||
|
'betting_id' => $row['betting_id'],
|
||||||
|
'general_id' => $row['general_id'],
|
||||||
|
'user_id' => $row['user_id'] ?? null,
|
||||||
|
'betting_type' => $row['betting_type'],
|
||||||
|
'amount' => $row['amount'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
foreach ($setup['inheritancePrevious'] ?? [] as $ownerId => $value) {
|
||||||
|
if (!is_numeric($ownerId) || !is_int($value)) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.inheritancePrevious entry');
|
||||||
|
}
|
||||||
|
KVStorage::getStorage(DB::db(), "inheritance_{$ownerId}")->setValue('previous', [$value, null]);
|
||||||
|
}
|
||||||
|
foreach ($setup['inheritancePoints'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row)
|
||||||
|
|| !is_int($row['ownerId'] ?? null)
|
||||||
|
|| !is_string($row['key'] ?? null)
|
||||||
|
|| !is_numeric($row['value'] ?? null)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.inheritancePoints row');
|
||||||
|
}
|
||||||
|
KVStorage::getStorage(DB::db(), "inheritance_{$row['ownerId']}")->setValue(
|
||||||
|
$row['key'],
|
||||||
|
[$row['value'], null],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
foreach ($setup['rankData'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row)
|
||||||
|
|| !is_int($row['generalId'] ?? null)
|
||||||
|
|| !is_string($row['type'] ?? null)
|
||||||
|
|| !is_int($row['value'] ?? null)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.rankData row');
|
||||||
|
}
|
||||||
|
$nationId = (int)(DB::db()->queryFirstField(
|
||||||
|
'SELECT nation FROM general WHERE no = %i',
|
||||||
|
$row['generalId'],
|
||||||
|
) ?? 0);
|
||||||
|
DB::db()->insertUpdate('rank_data', [
|
||||||
|
'general_id' => $row['generalId'],
|
||||||
|
'nation_id' => $nationId,
|
||||||
|
'type' => $row['type'],
|
||||||
|
'value' => $row['value'],
|
||||||
|
], [
|
||||||
|
'nation_id' => $nationId,
|
||||||
|
'value' => $row['value'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
foreach ($setup['generalAccessLog'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row)
|
||||||
|
|| !is_int($row['generalId'] ?? null)
|
||||||
|
|| !is_int($row['refreshScoreTotal'] ?? null)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.generalAccessLog row');
|
||||||
|
}
|
||||||
|
DB::db()->insertUpdate('general_access_log', [
|
||||||
|
'general_id' => $row['generalId'],
|
||||||
|
'refresh_score_total' => $row['refreshScoreTotal'],
|
||||||
|
], [
|
||||||
|
'refresh_score_total' => $row['refreshScoreTotal'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
foreach ($setup['nationEnvironment'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row)
|
||||||
|
|| !is_int($row['nationId'] ?? null)
|
||||||
|
|| !is_string($row['key'] ?? null)
|
||||||
|
|| !array_key_exists('value', $row)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.nationEnvironment row');
|
||||||
|
}
|
||||||
|
KVStorage::getStorage(DB::db(), $row['nationId'], 'nation_env')->setValue(
|
||||||
|
$row['key'],
|
||||||
|
$row['value'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (($setup['resetDiplomacy'] ?? false) === true) {
|
||||||
|
DB::db()->query('DELETE FROM diplomacy');
|
||||||
|
}
|
||||||
|
foreach ($setup['diplomacy'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row)
|
||||||
|
|| !is_int($row['fromNationId'] ?? null)
|
||||||
|
|| !is_int($row['toNationId'] ?? null)
|
||||||
|
|| !is_int($row['state'] ?? null)
|
||||||
|
|| !is_int($row['term'] ?? null)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.diplomacy row');
|
||||||
|
}
|
||||||
|
$diplomacyPatch = [
|
||||||
|
'me' => $row['fromNationId'],
|
||||||
|
'you' => $row['toNationId'],
|
||||||
|
'state' => $row['state'],
|
||||||
|
'term' => $row['term'],
|
||||||
|
'dead' => $row['dead'] ?? 0,
|
||||||
|
];
|
||||||
|
DB::db()->insertUpdate('diplomacy', $diplomacyPatch, $diplomacyPatch);
|
||||||
|
}
|
||||||
|
if (($setup['resetEvents'] ?? false) === true) {
|
||||||
|
DB::db()->query('DELETE FROM event');
|
||||||
|
}
|
||||||
|
foreach ($setup['event'] ?? [] as $row) {
|
||||||
|
if (!is_array($row) || !is_int($row['id'] ?? null) || !is_array($row['action'] ?? null)) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.event row');
|
||||||
|
}
|
||||||
|
$eventPatch = [
|
||||||
|
'id' => $row['id'],
|
||||||
|
'target' => $row['target'] ?? 'month',
|
||||||
|
'priority' => $row['priority'] ?? 1000,
|
||||||
|
'condition' => Json::encode($row['condition'] ?? true),
|
||||||
|
'action' => Json::encode($row['action']),
|
||||||
|
];
|
||||||
|
DB::db()->insertUpdate('event', $eventPatch, $eventPatch);
|
||||||
|
}
|
||||||
|
$gameEnvironmentPatch = $setup['gameEnvironment'] ?? [];
|
||||||
|
if (!is_array($gameEnvironmentPatch)) {
|
||||||
|
throw new \InvalidArgumentException('setup.gameEnvironment must be an object');
|
||||||
|
}
|
||||||
|
$gameStorage = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
|
$worldPatch = $setup['world'] ?? [];
|
||||||
|
if (!is_array($worldPatch)) {
|
||||||
|
throw new \InvalidArgumentException('setup.world must be an object');
|
||||||
|
}
|
||||||
|
if (array_key_exists('hiddenSeed', $worldPatch)) {
|
||||||
|
if (!is_string($worldPatch['hiddenSeed']) || $worldPatch['hiddenSeed'] === '') {
|
||||||
|
throw new \InvalidArgumentException('setup.world.hiddenSeed must be a non-empty string');
|
||||||
|
}
|
||||||
|
UniqueConst::$hiddenSeed = $worldPatch['hiddenSeed'];
|
||||||
|
}
|
||||||
|
foreach ([
|
||||||
|
'isunited',
|
||||||
|
'refreshLimit',
|
||||||
|
'block_change_scout',
|
||||||
|
'lastNPCTroopLeaderID',
|
||||||
|
'tournament',
|
||||||
|
'tnmt_trig',
|
||||||
|
'tnmt_pattern',
|
||||||
|
'prev_winner',
|
||||||
|
] as $key) {
|
||||||
|
if (array_key_exists($key, $gameEnvironmentPatch)) {
|
||||||
|
$gameStorage->setValue($key, $gameEnvironmentPatch[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (($setup['setAllCitiesNation'] ?? null) !== null) {
|
||||||
|
if (!is_int($setup['setAllCitiesNation'])) {
|
||||||
|
throw new \InvalidArgumentException('setup.setAllCitiesNation must be an integer');
|
||||||
|
}
|
||||||
|
DB::db()->update('city', ['nation' => $setup['setAllCitiesNation']], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$generalIdBeforeAction =
|
||||||
|
(int)($db->queryFirstField('SELECT COALESCE(MAX(no), 0) FROM general') ?? 0);
|
||||||
|
$nationIdBeforeAction =
|
||||||
|
(int)($db->queryFirstField('SELECT COALESCE(MAX(nation), 0) FROM nation') ?? 0);
|
||||||
|
$eventIdBeforeAction =
|
||||||
|
(int)($db->queryFirstField('SELECT COALESCE(MAX(id), 0) FROM event') ?? 0);
|
||||||
|
$auctionIdBeforeAction =
|
||||||
|
(int)($db->queryFirstField('SELECT COALESCE(MAX(id), 0) FROM ng_auction') ?? 0);
|
||||||
|
$snapshotRequest = ['observe' => $request['observe'] ?? []];
|
||||||
|
$snapshotRequest['observe']['logAfterId'] =
|
||||||
|
(int)($db->queryFirstField('SELECT COALESCE(MAX(id), 0) FROM general_record') ?? 0);
|
||||||
|
$worldHistoryAfterId =
|
||||||
|
(int)($db->queryFirstField('SELECT COALESCE(MAX(id), 0) FROM world_history') ?? 0);
|
||||||
|
$before = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
|
$beforeDetails = comparisonMonthlyDetails($snapshotRequest['observe'], $worldHistoryAfterId);
|
||||||
|
|
||||||
|
$environment = $request['environment'] ?? [];
|
||||||
|
if (!is_array($environment)) {
|
||||||
|
throw new \InvalidArgumentException('environment must be an object');
|
||||||
|
}
|
||||||
|
foreach (['starttime', 'turntime'] as $timeKey) {
|
||||||
|
if (array_key_exists($timeKey, $environment)) {
|
||||||
|
$environment[$timeKey] = comparisonGameTick(
|
||||||
|
$environment[$timeKey],
|
||||||
|
"environment.{$timeKey}",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$year = $environment['year'] ?? null;
|
||||||
|
$month = $environment['month'] ?? null;
|
||||||
|
$startYear = $environment['startyear'] ?? null;
|
||||||
|
if (!is_int($year) || !is_int($month) || !is_int($startYear)) {
|
||||||
|
throw new \InvalidArgumentException('environment year, month, and startyear must be integers');
|
||||||
|
}
|
||||||
|
if (($setup['syncEnvironment'] ?? false) === true) {
|
||||||
|
$gameStorage = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
|
$environmentValues = [
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month,
|
||||||
|
'startyear' => $startYear,
|
||||||
|
'killturn' => $environment['killturn'] ?? $gameStorage->killturn,
|
||||||
|
'turnterm' => $environment['turnterm'] ?? $gameStorage->turnterm,
|
||||||
|
];
|
||||||
|
if (isset($environment['starttime'])) {
|
||||||
|
$environmentValues['starttime'] = $environment['starttime'];
|
||||||
|
}
|
||||||
|
foreach ($environmentValues as $key => $value) {
|
||||||
|
$gameStorage->setValue($key, $value);
|
||||||
|
}
|
||||||
|
if ($actionName === 'MonthlyBoundary') {
|
||||||
|
$before = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
|
$beforeDetails = comparisonMonthlyDetails($snapshotRequest['observe'], $worldHistoryAfterId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($actionName === 'InvaderLifecycle') {
|
||||||
|
foreach (['turnterm', 'turntime'] as $requiredEnvironmentKey) {
|
||||||
|
if (!array_key_exists($requiredEnvironmentKey, $environment)) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"InvaderLifecycle requires environment.{$requiredEnvironmentKey}",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo json_encode(
|
||||||
|
comparisonInvaderLifecycleTrace(
|
||||||
|
$request,
|
||||||
|
$environment,
|
||||||
|
$generalIdBeforeAction,
|
||||||
|
$nationIdBeforeAction,
|
||||||
|
$eventIdBeforeAction,
|
||||||
|
$worldHistoryAfterId,
|
||||||
|
),
|
||||||
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION,
|
||||||
|
), PHP_EOL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($actionName === 'NpcNationLifecycle') {
|
||||||
|
foreach (['turnterm', 'turntime'] as $requiredEnvironmentKey) {
|
||||||
|
if (!array_key_exists($requiredEnvironmentKey, $environment)) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"NpcNationLifecycle requires environment.{$requiredEnvironmentKey}",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo json_encode(
|
||||||
|
comparisonNpcNationLifecycleTrace(
|
||||||
|
$environment,
|
||||||
|
$generalIdBeforeAction,
|
||||||
|
$nationIdBeforeAction,
|
||||||
|
$worldHistoryAfterId,
|
||||||
|
),
|
||||||
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION,
|
||||||
|
), PHP_EOL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($actionName === 'NationBettingLifecycle') {
|
||||||
|
echo json_encode(
|
||||||
|
comparisonNationBettingLifecycleTrace(
|
||||||
|
$request,
|
||||||
|
$environment,
|
||||||
|
$eventIdBeforeAction,
|
||||||
|
$worldHistoryAfterId,
|
||||||
|
),
|
||||||
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION,
|
||||||
|
), PHP_EOL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$actionClass = "\\sammo\\Event\\Action\\{$actionName}";
|
||||||
|
if (in_array($actionName, ['PreUpdateMonthly', 'PostUpdateMonthly', 'MonthlyBoundary'], true)) {
|
||||||
|
$action = null;
|
||||||
|
} elseif ($actionName === 'ProcessSemiAnnual') {
|
||||||
|
$resource = $request['resource'] ?? null;
|
||||||
|
if (!is_string($resource)) {
|
||||||
|
throw new \InvalidArgumentException('ProcessSemiAnnual requires resource');
|
||||||
|
}
|
||||||
|
$action = new $actionClass($resource);
|
||||||
|
} elseif (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC', 'RaiseInvader', 'AutoDeleteInvader', 'ChangeCity', 'OpenNationBetting', 'FinishNationBetting', 'BlockScoutAction', 'UnblockScoutAction', 'AddGlobalBetray', 'LostUniqueItem', 'ProcessIncome', 'NoticeToHistoryLog'], true)) {
|
||||||
|
$args = $request['args'] ?? [];
|
||||||
|
if (!is_array($args)) {
|
||||||
|
throw new \InvalidArgumentException("{$actionName} args must be an array");
|
||||||
|
}
|
||||||
|
if ($actionName === 'CreateManyNPC' && count($args) > 2) {
|
||||||
|
throw new \InvalidArgumentException('CreateManyNPC args must have at most two entries');
|
||||||
|
}
|
||||||
|
if ($actionName === 'RaiseInvader' && count($args) > 4) {
|
||||||
|
throw new \InvalidArgumentException('RaiseInvader args must have at most four entries');
|
||||||
|
}
|
||||||
|
if ($actionName === 'ChangeCity' && count($args) !== 2) {
|
||||||
|
throw new \InvalidArgumentException('ChangeCity args must have exactly two entries');
|
||||||
|
}
|
||||||
|
if ($actionName === 'OpenNationBetting' && count($args) > 2) {
|
||||||
|
throw new \InvalidArgumentException('OpenNationBetting args must have at most two entries');
|
||||||
|
}
|
||||||
|
if ($actionName === 'FinishNationBetting' && count($args) !== 1) {
|
||||||
|
throw new \InvalidArgumentException('FinishNationBetting args must have exactly one entry');
|
||||||
|
}
|
||||||
|
if (in_array($actionName, ['BlockScoutAction', 'UnblockScoutAction'], true) && count($args) > 1) {
|
||||||
|
throw new \InvalidArgumentException("{$actionName} args must have at most one entry");
|
||||||
|
}
|
||||||
|
if ($actionName === 'AddGlobalBetray' && count($args) > 2) {
|
||||||
|
throw new \InvalidArgumentException('AddGlobalBetray args must have at most two entries');
|
||||||
|
}
|
||||||
|
if ($actionName === 'LostUniqueItem' && count($args) > 1) {
|
||||||
|
throw new \InvalidArgumentException('LostUniqueItem args must have at most one entry');
|
||||||
|
}
|
||||||
|
if ($actionName === 'ProcessIncome' && count($args) !== 1) {
|
||||||
|
throw new \InvalidArgumentException('ProcessIncome args must have exactly one entry');
|
||||||
|
}
|
||||||
|
if ($actionName === 'NoticeToHistoryLog' && (count($args) < 1 || count($args) > 2)) {
|
||||||
|
throw new \InvalidArgumentException('NoticeToHistoryLog args must have one or two entries');
|
||||||
|
}
|
||||||
|
$action = new $actionClass(...$args);
|
||||||
|
} else {
|
||||||
|
$action = new $actionClass();
|
||||||
|
}
|
||||||
|
$actionEnvironment = [
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month,
|
||||||
|
'startyear' => $startYear,
|
||||||
|
];
|
||||||
|
if (isset($environment['currentEventID'])) {
|
||||||
|
if (!is_int($environment['currentEventID'])) {
|
||||||
|
throw new \InvalidArgumentException('currentEventID must be an integer');
|
||||||
|
}
|
||||||
|
$actionEnvironment['currentEventID'] = $environment['currentEventID'];
|
||||||
|
}
|
||||||
|
if ($actionName === 'UpdateNationLevel') {
|
||||||
|
$killturn = $environment['killturn'] ?? null;
|
||||||
|
$turnterm = $environment['turnterm'] ?? null;
|
||||||
|
if (!is_int($killturn) || !is_int($turnterm) || $turnterm <= 0) {
|
||||||
|
throw new \InvalidArgumentException('UpdateNationLevel requires integer killturn and positive turnterm');
|
||||||
|
}
|
||||||
|
$actionEnvironment['killturn'] = $killturn;
|
||||||
|
$actionEnvironment['turnterm'] = $turnterm;
|
||||||
|
}
|
||||||
|
if (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC', 'RaiseNPCNation', 'RaiseInvader', 'ProvideNPCTroopLeader'], true)) {
|
||||||
|
$turnterm = $environment['turnterm'] ?? null;
|
||||||
|
$turntime = $environment['turntime'] ?? null;
|
||||||
|
$showImgLevel = $environment['show_img_level'] ?? 3;
|
||||||
|
$fiction = $environment['fiction'] ?? [0];
|
||||||
|
if (
|
||||||
|
!is_int($turnterm)
|
||||||
|
|| $turnterm <= 0
|
||||||
|
|| !is_int($turntime)
|
||||||
|
|| !is_int($showImgLevel)
|
||||||
|
|| !is_array($fiction)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"{$actionName} requires positive turnterm, game-tick turntime, integer show_img_level, and array fiction",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$actionEnvironment += [
|
||||||
|
'turnterm' => $turnterm,
|
||||||
|
'turntime' => $turntime,
|
||||||
|
'show_img_level' => $showImgLevel,
|
||||||
|
'stored_icons' => $environment['stored_icons'] ?? [],
|
||||||
|
'icon_path' => $environment['icon_path'] ?? '.',
|
||||||
|
'fiction' => $fiction,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if ($actionName === 'PreUpdateMonthly') {
|
||||||
|
if (!preUpdateMonthly()) {
|
||||||
|
throw new \RuntimeException('preUpdateMonthly failed');
|
||||||
|
}
|
||||||
|
} elseif ($actionName === 'PostUpdateMonthly') {
|
||||||
|
$seedYear = $environment['seedYear'] ?? null;
|
||||||
|
$seedMonth = $environment['seedMonth'] ?? null;
|
||||||
|
if (!is_int($seedYear) || !is_int($seedMonth)) {
|
||||||
|
throw new \InvalidArgumentException('PostUpdateMonthly requires seedYear and seedMonth');
|
||||||
|
}
|
||||||
|
postUpdateMonthly(new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||||
|
UniqueConst::$hiddenSeed,
|
||||||
|
'monthly',
|
||||||
|
$seedYear,
|
||||||
|
$seedMonth,
|
||||||
|
))));
|
||||||
|
} elseif ($actionName === 'MonthlyBoundary') {
|
||||||
|
$turntime = $environment['turntime'] ?? null;
|
||||||
|
if (!is_int($turntime)) {
|
||||||
|
throw new \InvalidArgumentException('MonthlyBoundary requires turntime');
|
||||||
|
}
|
||||||
|
$gameStorage = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$seedYear = (int)$gameStorage->year;
|
||||||
|
$seedMonth = (int)$gameStorage->month;
|
||||||
|
TurnExecutionHelper::runEventHandler($db, $gameStorage, Enums\EventTarget::PreMonth);
|
||||||
|
if (!preUpdateMonthly()) {
|
||||||
|
throw new \RuntimeException('preUpdateMonthly failed');
|
||||||
|
}
|
||||||
|
turnDate($turntime);
|
||||||
|
$gameStorage->resetCache();
|
||||||
|
if ((int)$gameStorage->month === 1) {
|
||||||
|
checkStatistic();
|
||||||
|
}
|
||||||
|
TurnExecutionHelper::runEventHandler($db, $gameStorage, Enums\EventTarget::Month);
|
||||||
|
postUpdateMonthly(new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||||
|
UniqueConst::$hiddenSeed,
|
||||||
|
'monthly',
|
||||||
|
$seedYear,
|
||||||
|
$seedMonth,
|
||||||
|
))));
|
||||||
|
} else {
|
||||||
|
$action->run($actionEnvironment);
|
||||||
|
}
|
||||||
|
unset($action);
|
||||||
|
gc_collect_cycles();
|
||||||
|
|
||||||
|
$after = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
|
$afterDetails = comparisonMonthlyDetails($snapshotRequest['observe'], $worldHistoryAfterId);
|
||||||
|
$createdGenerals = [];
|
||||||
|
if (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC', 'RaiseNPCNation', 'RaiseInvader', 'ProvideNPCTroopLeader'], true)) {
|
||||||
|
foreach ($db->query('SELECT * FROM general WHERE no > %i ORDER BY no', $generalIdBeforeAction) as $row) {
|
||||||
|
$generalId = (int)$row['no'];
|
||||||
|
$turnRows = $db->query(
|
||||||
|
'SELECT turn_idx, action, arg FROM general_turn WHERE general_id = %i ORDER BY turn_idx',
|
||||||
|
$generalId,
|
||||||
|
);
|
||||||
|
$createdGenerals[] = comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'no',
|
||||||
|
'name' => 'name',
|
||||||
|
'nationId' => 'nation',
|
||||||
|
'cityId' => 'city',
|
||||||
|
'leadership' => 'leadership',
|
||||||
|
'strength' => 'strength',
|
||||||
|
'intelligence' => 'intel',
|
||||||
|
'experience' => 'experience',
|
||||||
|
'dedication' => 'dedication',
|
||||||
|
'officerLevel' => 'officer_level',
|
||||||
|
'gold' => 'gold',
|
||||||
|
'rice' => 'rice',
|
||||||
|
'crew' => 'crew',
|
||||||
|
'crewTypeId' => 'crewtype',
|
||||||
|
'train' => 'train',
|
||||||
|
'atmos' => 'atmos',
|
||||||
|
'turnTime' => 'turntime',
|
||||||
|
'killturn' => 'killturn',
|
||||||
|
'age' => 'age',
|
||||||
|
'npcState' => 'npc',
|
||||||
|
'npcOriginalState' => 'npc_org',
|
||||||
|
'affinity' => 'affinity',
|
||||||
|
'personality' => 'personal',
|
||||||
|
'specialDomestic' => 'special',
|
||||||
|
'specialWar' => 'special2',
|
||||||
|
'specAge' => 'specage',
|
||||||
|
'specAge2' => 'specage2',
|
||||||
|
'bornYear' => 'bornyear',
|
||||||
|
'deadYear' => 'deadyear',
|
||||||
|
'picture' => 'picture',
|
||||||
|
'dex1' => 'dex1',
|
||||||
|
'dex2' => 'dex2',
|
||||||
|
'dex3' => 'dex3',
|
||||||
|
'dex4' => 'dex4',
|
||||||
|
'dex5' => 'dex5',
|
||||||
|
],
|
||||||
|
) + [
|
||||||
|
'turnCount' => count($turnRows),
|
||||||
|
'turnActions' => array_values(array_unique(array_column($turnRows, 'action'))),
|
||||||
|
'rankCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM rank_data WHERE general_id = %i',
|
||||||
|
$generalId,
|
||||||
|
),
|
||||||
|
'nonZeroRankCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM rank_data WHERE general_id = %i AND value != 0',
|
||||||
|
$generalId,
|
||||||
|
),
|
||||||
|
'troop' => $db->queryFirstRow(
|
||||||
|
'SELECT troop_leader AS id, nation AS nationId, name FROM troop WHERE troop_leader = %i',
|
||||||
|
$generalId,
|
||||||
|
) ?: null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$createdNations = [];
|
||||||
|
if (in_array($actionName, ['RaiseNPCNation', 'RaiseInvader'], true)) {
|
||||||
|
foreach ($db->query('SELECT * FROM nation WHERE nation > %i ORDER BY nation', $nationIdBeforeAction) as $row) {
|
||||||
|
$nationId = (int)$row['nation'];
|
||||||
|
$createdNations[] = comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'nation',
|
||||||
|
'name' => 'name',
|
||||||
|
'color' => 'color',
|
||||||
|
'capitalCityId' => 'capital',
|
||||||
|
'generalCount' => 'gennum',
|
||||||
|
'gold' => 'gold',
|
||||||
|
'rice' => 'rice',
|
||||||
|
'tech' => 'tech',
|
||||||
|
'level' => 'level',
|
||||||
|
'typeCode' => 'type',
|
||||||
|
'bill' => 'bill',
|
||||||
|
'rate' => 'rate',
|
||||||
|
'scout' => 'scout',
|
||||||
|
'war' => 'war',
|
||||||
|
'strategicCommandLimit' => 'strategic_cmd_limit',
|
||||||
|
'surrenderLimit' => 'surlimit',
|
||||||
|
'aux' => 'aux',
|
||||||
|
],
|
||||||
|
['aux'],
|
||||||
|
) + [
|
||||||
|
'nationTurnCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM nation_turn WHERE nation_id = %i',
|
||||||
|
$nationId,
|
||||||
|
),
|
||||||
|
'diplomacyCount' => (int)$db->queryFirstField(
|
||||||
|
'SELECT count(*) FROM diplomacy WHERE me = %i OR you = %i',
|
||||||
|
$nationId,
|
||||||
|
$nationId,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$response = [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'action' => $actionName,
|
||||||
|
'before' => $before,
|
||||||
|
'beforeDetails' => $beforeDetails,
|
||||||
|
'after' => $after,
|
||||||
|
'afterDetails' => $afterDetails,
|
||||||
|
];
|
||||||
|
if (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC'], true)) {
|
||||||
|
$response['createdGenerals'] = $createdGenerals;
|
||||||
|
}
|
||||||
|
if (in_array($actionName, ['RaiseNPCNation', 'RaiseInvader'], true)) {
|
||||||
|
$response['createdGenerals'] = $createdGenerals;
|
||||||
|
$response['createdNations'] = $createdNations;
|
||||||
|
}
|
||||||
|
if ($actionName === 'ProvideNPCTroopLeader') {
|
||||||
|
$response['createdGenerals'] = $createdGenerals;
|
||||||
|
$response['gameEnvironment'] = KVStorage::getStorage(DB::db(), 'game_env')->getValues([
|
||||||
|
'lastNPCTroopLeaderID',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if ($actionName === 'PreUpdateMonthly') {
|
||||||
|
$response['gameEnvironment'] = KVStorage::getStorage(DB::db(), 'game_env')->getValues([
|
||||||
|
'develcost',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if ($actionName === 'PostUpdateMonthly') {
|
||||||
|
$response['gameEnvironment'] = KVStorage::getStorage(DB::db(), 'game_env')->getValues([
|
||||||
|
'tournament',
|
||||||
|
'tnmt_trig',
|
||||||
|
'tnmt_pattern',
|
||||||
|
'tnmt_type',
|
||||||
|
'tnmt_auto',
|
||||||
|
'phase',
|
||||||
|
]);
|
||||||
|
$response['createdNeutralAuctions'] = array_map(
|
||||||
|
static fn(array $row): array => [
|
||||||
|
'id' => (int)$row['id'],
|
||||||
|
'type' => $row['type'],
|
||||||
|
'target' => $row['target'],
|
||||||
|
'detail' => Json::decode($row['detail']),
|
||||||
|
],
|
||||||
|
iterator_to_array(
|
||||||
|
$db->query(
|
||||||
|
'SELECT id, `type`, target, detail FROM ng_auction WHERE id > %i AND host_general_id = 0 ORDER BY id',
|
||||||
|
$auctionIdBeforeAction,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (in_array($actionName, ['OpenNationBetting', 'FinishNationBetting'], true)) {
|
||||||
|
$bettingStorage = KVStorage::getStorage(DB::db(), 'betting');
|
||||||
|
$response['betting'] = $bettingStorage->getAll();
|
||||||
|
$response['bets'] = iterator_to_array(
|
||||||
|
$db->query(
|
||||||
|
'SELECT betting_id AS bettingId, general_id AS generalId, user_id AS userId, betting_type AS selectionKey, amount FROM ng_betting ORDER BY id',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$response['createdEvents'] = array_map(
|
||||||
|
static fn(array $row): array => comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'id',
|
||||||
|
'targetCode' => 'target',
|
||||||
|
'priority' => 'priority',
|
||||||
|
'condition' => 'condition',
|
||||||
|
'action' => 'action',
|
||||||
|
],
|
||||||
|
['condition', 'action'],
|
||||||
|
),
|
||||||
|
iterator_to_array(
|
||||||
|
$db->query(
|
||||||
|
'SELECT id, target, priority, `condition`, action FROM event WHERE id > %i ORDER BY id',
|
||||||
|
$eventIdBeforeAction,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$response['gameEnvironment'] = KVStorage::getStorage(DB::db(), 'game_env')->getValues([
|
||||||
|
'last_betting_id',
|
||||||
|
]);
|
||||||
|
$response['inheritancePrevious'] = [];
|
||||||
|
foreach (comparisonIntegerList($request['observe']['ownerIds'] ?? [], 'ownerIds') as $ownerId) {
|
||||||
|
$value = KVStorage::getStorage(DB::db(), "inheritance_{$ownerId}")->getValue('previous');
|
||||||
|
$response['inheritancePrevious'][(string)$ownerId] = is_array($value) ? ($value[0] ?? 0) : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (in_array($actionName, ['BlockScoutAction', 'UnblockScoutAction'], true)) {
|
||||||
|
$response['gameEnvironment'] = KVStorage::getStorage(DB::db(), 'game_env')->getValues([
|
||||||
|
'block_change_scout',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if ($actionName === 'RaiseInvader') {
|
||||||
|
$response['createdEvents'] = array_map(
|
||||||
|
static fn(array $row): array => comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'id',
|
||||||
|
'targetCode' => 'target',
|
||||||
|
'priority' => 'priority',
|
||||||
|
'condition' => 'condition',
|
||||||
|
'action' => 'action',
|
||||||
|
],
|
||||||
|
['condition', 'action'],
|
||||||
|
),
|
||||||
|
iterator_to_array(
|
||||||
|
$db->query(
|
||||||
|
'SELECT id, target, priority, `condition`, action FROM event WHERE id > %i ORDER BY id',
|
||||||
|
$eventIdBeforeAction,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$response['createdDiplomacy'] = iterator_to_array(
|
||||||
|
$db->query(
|
||||||
|
'SELECT me AS fromNationId, you AS toNationId, state, term FROM diplomacy WHERE me > %i OR you > %i ORDER BY me, you',
|
||||||
|
$nationIdBeforeAction,
|
||||||
|
$nationIdBeforeAction,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$gameStorage = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
|
$response['gameEnvironment'] = $gameStorage->getValues([
|
||||||
|
'isunited',
|
||||||
|
'turnterm',
|
||||||
|
'block_change_scout',
|
||||||
|
'refreshLimit',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (in_array($actionName, ['AutoDeleteInvader', 'InvaderEnding'], true)) {
|
||||||
|
$gameStorage = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
|
$response['gameEnvironment'] = $gameStorage->getValues([
|
||||||
|
'isunited',
|
||||||
|
'turnterm',
|
||||||
|
'block_change_scout',
|
||||||
|
'refreshLimit',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (($request['compactOutput'] ?? false) === true) {
|
||||||
|
$observedGeneralTurns = [];
|
||||||
|
foreach (comparisonIntegerList($request['observe']['generalIds'] ?? [], 'generalIds') as $generalId) {
|
||||||
|
$observedGeneralTurns[(string)$generalId] = iterator_to_array(
|
||||||
|
$db->query(
|
||||||
|
'SELECT turn_idx AS turnIndex, action, arg FROM general_turn WHERE general_id = %i ORDER BY turn_idx',
|
||||||
|
$generalId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$response = [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'action' => $actionName,
|
||||||
|
'afterDetails' => $afterDetails,
|
||||||
|
'createdGeneralCount' => count($createdGenerals),
|
||||||
|
'firstCreatedGenerals' => array_slice($createdGenerals, 0, 3),
|
||||||
|
'createdNations' => $response['createdNations'] ?? [],
|
||||||
|
'createdEvents' => $response['createdEvents'] ?? [],
|
||||||
|
'createdDiplomacy' => $response['createdDiplomacy'] ?? [],
|
||||||
|
'gameEnvironment' => $response['gameEnvironment'] ?? [],
|
||||||
|
'logs' => $after['logs'],
|
||||||
|
'observedGeneralTurns' => $observedGeneralTurns,
|
||||||
|
'remainingEventIds' => array_map(
|
||||||
|
'intval',
|
||||||
|
$db->queryFirstColumn('SELECT id FROM event ORDER BY id'),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
echo json_encode(
|
||||||
|
$response,
|
||||||
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION,
|
||||||
|
), PHP_EOL;
|
||||||
|
} catch (\Throwable $throwable) {
|
||||||
|
fwrite(STDERR, $throwable::class . ': ' . $throwable->getMessage() . PHP_EOL);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
comparisonMonthlyEventTraceMain();
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli' || getenv('REF_DETERMINISTIC_INSTALL_ENABLED') !== '1') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
|
||||||
|
/** @return mixed */
|
||||||
|
function monthlySnapshotJson(mixed $value): mixed
|
||||||
|
{
|
||||||
|
if (!is_string($value) || $value === '') {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return json_decode($value, true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
} catch (\JsonException) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string, mixed> */
|
||||||
|
function monthlySnapshotPick(array $row, array $mapping, array $jsonColumns = []): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
foreach ($mapping as $target => $source) {
|
||||||
|
$value = $row[$source] ?? null;
|
||||||
|
$result[$target] = in_array($source, $jsonColumns, true)
|
||||||
|
? monthlySnapshotJson($value)
|
||||||
|
: $value;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$game = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$game->resetCache();
|
||||||
|
$clock = GameClock::fromStorage($game);
|
||||||
|
$world = $game->getValues([
|
||||||
|
'scenario', 'year', 'month', 'turnterm', 'turntime', 'starttime',
|
||||||
|
'init_year', 'init_month', 'develcost', 'killturn', 'isunited',
|
||||||
|
]);
|
||||||
|
$world['turntime'] = $clock->formatTick(Util::toInt($world['turntime']), true);
|
||||||
|
$world['starttime'] = $clock->formatTick(Util::toInt($world['starttime']), true);
|
||||||
|
|
||||||
|
$generals = [];
|
||||||
|
foreach ($db->query('SELECT * FROM general ORDER BY no') as $row) {
|
||||||
|
$general = monthlySnapshotPick($row, [
|
||||||
|
'id' => 'no', 'name' => 'name', 'nationId' => 'nation', 'cityId' => 'city',
|
||||||
|
'troopId' => 'troop', 'leadership' => 'leadership', 'strength' => 'strength',
|
||||||
|
'intelligence' => 'intel', 'experience' => 'experience', 'dedication' => 'dedication',
|
||||||
|
'officerLevel' => 'officer_level', 'injury' => 'injury', 'gold' => 'gold',
|
||||||
|
'rice' => 'rice', 'crew' => 'crew', 'crewTypeId' => 'crewtype', 'train' => 'train',
|
||||||
|
'atmos' => 'atmos', 'age' => 'age', 'npcState' => 'npc', 'turnTime' => 'turntime',
|
||||||
|
'recentWarTime' => 'recent_war', 'lastTurn' => 'last_turn', 'meta' => 'aux',
|
||||||
|
'affinity' => 'affinity', 'birthYear' => 'bornyear', 'deathYear' => 'deadyear',
|
||||||
|
'personality' => 'personal', 'specialDomestic' => 'special', 'specialWar' => 'special2',
|
||||||
|
'specAge' => 'specage', 'specAge2' => 'specage2',
|
||||||
|
'dex1' => 'dex1', 'dex2' => 'dex2', 'dex3' => 'dex3', 'dex4' => 'dex4', 'dex5' => 'dex5',
|
||||||
|
'killTurn' => 'killturn',
|
||||||
|
], ['last_turn', 'aux']);
|
||||||
|
foreach (['id', 'nationId', 'cityId', 'troopId', 'leadership', 'strength', 'intelligence',
|
||||||
|
'experience', 'dedication', 'officerLevel', 'injury', 'gold', 'rice', 'crew',
|
||||||
|
'crewTypeId', 'train', 'atmos', 'age', 'npcState', 'dex1', 'dex2', 'dex3',
|
||||||
|
'dex4', 'dex5', 'killTurn', 'affinity', 'birthYear', 'deathYear', 'specAge', 'specAge2'] as $key) {
|
||||||
|
$general[$key] = (int)$general[$key];
|
||||||
|
}
|
||||||
|
$general['turnTime'] = $clock->formatTick(Util::toInt($general['turnTime']), true);
|
||||||
|
$general['recentWarTime'] = $general['recentWarTime'] === null
|
||||||
|
? null
|
||||||
|
: $clock->formatTick(Util::toInt($general['recentWarTime']), true);
|
||||||
|
$generals[] = $general;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cities = [];
|
||||||
|
foreach ($db->query('SELECT * FROM city ORDER BY city') as $row) {
|
||||||
|
$city = monthlySnapshotPick($row, [
|
||||||
|
'id' => 'city', 'name' => 'name', 'nationId' => 'nation', 'level' => 'level',
|
||||||
|
'population' => 'pop', 'populationMax' => 'pop_max', 'agriculture' => 'agri',
|
||||||
|
'agricultureMax' => 'agri_max', 'commerce' => 'comm', 'commerceMax' => 'comm_max',
|
||||||
|
'security' => 'secu', 'securityMax' => 'secu_max', 'supplyState' => 'supply',
|
||||||
|
'frontState' => 'front', 'defence' => 'def', 'defenceMax' => 'def_max',
|
||||||
|
'wall' => 'wall', 'wallMax' => 'wall_max', 'state' => 'state', 'term' => 'term',
|
||||||
|
'trust' => 'trust', 'trade' => 'trade', 'conflict' => 'conflict',
|
||||||
|
], ['conflict']);
|
||||||
|
foreach (array_keys($city) as $key) {
|
||||||
|
if ($key !== 'name' && $key !== 'conflict' && $key !== 'trust') {
|
||||||
|
$city[$key] = (int)$city[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cities[] = $city;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nations = [];
|
||||||
|
foreach ($db->query('SELECT * FROM nation ORDER BY nation') as $row) {
|
||||||
|
$nation = monthlySnapshotPick($row, [
|
||||||
|
'id' => 'nation', 'name' => 'name', 'color' => 'color', 'capitalCityId' => 'capital',
|
||||||
|
'gold' => 'gold', 'rice' => 'rice', 'tech' => 'tech', 'level' => 'level',
|
||||||
|
'typeCode' => 'type', 'generalCount' => 'gennum', 'power' => 'power',
|
||||||
|
'war' => 'war', 'diplomacyLimit' => 'surlimit', 'capitalRevision' => 'capset',
|
||||||
|
'strategicCommandLimit' => 'strategic_cmd_limit', 'rate' => 'rate',
|
||||||
|
'rateTmp' => 'rate_tmp', 'bill' => 'bill', 'meta' => 'aux',
|
||||||
|
], ['aux']);
|
||||||
|
foreach (['id', 'capitalCityId', 'gold', 'rice', 'level', 'generalCount',
|
||||||
|
'power', 'war', 'diplomacyLimit', 'capitalRevision', 'strategicCommandLimit',
|
||||||
|
'rate', 'rateTmp', 'bill'] as $key) {
|
||||||
|
$nation[$key] = (int)$nation[$key];
|
||||||
|
}
|
||||||
|
$nation['tech'] = (float)$nation['tech'];
|
||||||
|
$nations[] = $nation;
|
||||||
|
}
|
||||||
|
|
||||||
|
$diplomacy = [];
|
||||||
|
foreach ($db->query('SELECT me, you, state, term, dead FROM diplomacy ORDER BY me, you') as $row) {
|
||||||
|
$diplomacy[] = [
|
||||||
|
'fromNationId' => (int)$row['me'], 'toNationId' => (int)$row['you'],
|
||||||
|
'state' => (int)$row['state'], 'term' => (int)$row['term'], 'dead' => (int)$row['dead'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'world' => $world,
|
||||||
|
'generals' => $generals,
|
||||||
|
'cities' => $cities,
|
||||||
|
'nations' => $nations,
|
||||||
|
'diplomacy' => $diplomacy,
|
||||||
|
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION), PHP_EOL;
|
||||||
@@ -0,0 +1,312 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli' || getenv('TURN_DIFFERENTIAL_ENABLED') !== '1') {
|
||||||
|
http_response_code(404);
|
||||||
|
fwrite(STDERR, "NPC possession comparison is disabled.\n");
|
||||||
|
exit(64);
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
$_SERVER['REMOTE_ADDR'] ??= '127.0.0.1';
|
||||||
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
|
||||||
|
final class ComparisonNpcTracingRandUtil extends RandUtil
|
||||||
|
{
|
||||||
|
/** @var list<float> */
|
||||||
|
public array $floatDraws = [];
|
||||||
|
|
||||||
|
public function nextFloat1(): float
|
||||||
|
{
|
||||||
|
$value = parent::nextFloat1();
|
||||||
|
$this->floatDraws[] = $value;
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string, mixed> */
|
||||||
|
function comparisonNpcRequest(): array
|
||||||
|
{
|
||||||
|
$request = json_decode(stream_get_contents(STDIN), true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
if (!is_array($request)) {
|
||||||
|
throw new \InvalidArgumentException('fixture must be a JSON object');
|
||||||
|
}
|
||||||
|
return $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return list<int> */
|
||||||
|
function comparisonNpcIntegerList(mixed $value, string $name): array
|
||||||
|
{
|
||||||
|
if (!is_array($value)) {
|
||||||
|
throw new \InvalidArgumentException("{$name} must be an array");
|
||||||
|
}
|
||||||
|
$result = [];
|
||||||
|
foreach ($value as $item) {
|
||||||
|
if (!is_int($item) || $item <= 0) {
|
||||||
|
throw new \InvalidArgumentException("{$name} must contain positive integers");
|
||||||
|
}
|
||||||
|
$result[] = $item;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<int, int> */
|
||||||
|
function comparisonNpcPreviousPick(mixed $value): array
|
||||||
|
{
|
||||||
|
if ($value === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!is_array($value)) {
|
||||||
|
throw new \InvalidArgumentException('previousPick must be an array');
|
||||||
|
}
|
||||||
|
$result = [];
|
||||||
|
foreach ($value as $item) {
|
||||||
|
if (
|
||||||
|
!is_array($item)
|
||||||
|
|| !isset($item['id'], $item['keepCount'])
|
||||||
|
|| !is_int($item['id'])
|
||||||
|
|| $item['id'] <= 0
|
||||||
|
|| !is_int($item['keepCount'])
|
||||||
|
|| $item['keepCount'] < 0
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('previousPick entries require positive id and non-negative keepCount');
|
||||||
|
}
|
||||||
|
$result[$item['id']] = $item['keepCount'];
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return list<array{id: int, leadership: int, strength: int, intel: int}> */
|
||||||
|
function comparisonNpcCandidateRows(): array
|
||||||
|
{
|
||||||
|
return array_map(
|
||||||
|
static fn(array $row): array => [
|
||||||
|
'id' => (int)$row['no'],
|
||||||
|
'leadership' => (int)$row['leadership'],
|
||||||
|
'strength' => (int)$row['strength'],
|
||||||
|
'intel' => (int)$row['intel'],
|
||||||
|
],
|
||||||
|
DB::db()->query('SELECT `no`, leadership, strength, intel FROM general WHERE npc=2'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string, mixed> */
|
||||||
|
function comparisonNpcState(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'candidates' => comparisonNpcCandidateRows(),
|
||||||
|
'tokens' => DB::db()->query(
|
||||||
|
'SELECT owner, valid_until, pick_more_from, pick_result, nonce FROM select_npc_token ORDER BY id',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $case
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
function comparisonNpcRunCase(array $case, string|int $hiddenSeed, int $owner, int $now, GameClock $clock): array
|
||||||
|
{
|
||||||
|
$db = DB::db();
|
||||||
|
$db->delete('select_npc_token', '1=1');
|
||||||
|
|
||||||
|
$insertReserved = static function (int $reservedOwner, array $reservedIds, int $validUntil) use ($db, $now): void {
|
||||||
|
if ($reservedIds === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$reservedPick = [];
|
||||||
|
foreach ($reservedIds as $id) {
|
||||||
|
$reservedPick[$id] = ['keepCnt' => 3];
|
||||||
|
}
|
||||||
|
$db->insert('select_npc_token', [
|
||||||
|
'owner' => $reservedOwner,
|
||||||
|
'valid_until' => $validUntil,
|
||||||
|
'pick_more_from' => $now,
|
||||||
|
'pick_result' => json_encode((object)$reservedPick, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE),
|
||||||
|
'nonce' => 1,
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
$reservedIds = comparisonNpcIntegerList($case['reservedIds'] ?? [], 'reservedIds');
|
||||||
|
$boundaryReservedIds = comparisonNpcIntegerList(
|
||||||
|
$case['boundaryReservedIds'] ?? [],
|
||||||
|
'boundaryReservedIds',
|
||||||
|
);
|
||||||
|
$expiredReservedIds = comparisonNpcIntegerList(
|
||||||
|
$case['expiredReservedIds'] ?? [],
|
||||||
|
'expiredReservedIds',
|
||||||
|
);
|
||||||
|
$expiredAt = $now - $clock->ticksFromSeconds(1);
|
||||||
|
$insertReserved($owner + 1, $reservedIds, GameClock::MAX_SAFE_TICK);
|
||||||
|
$insertReserved($owner + 2, $boundaryReservedIds, $now);
|
||||||
|
$insertReserved($owner + 3, $expiredReservedIds, $expiredAt);
|
||||||
|
|
||||||
|
$candidates = [];
|
||||||
|
$weights = [];
|
||||||
|
foreach (comparisonNpcCandidateRows() as $row) {
|
||||||
|
$id = $row['id'];
|
||||||
|
$candidates[$id] = $row + ['keepCnt' => 3];
|
||||||
|
$weights[$id] = NpcPossessionSelector::weight($row);
|
||||||
|
}
|
||||||
|
NpcPossessionSelector::removeReserved(
|
||||||
|
$candidates,
|
||||||
|
$weights,
|
||||||
|
$db->queryFirstColumn(
|
||||||
|
'SELECT pick_result FROM select_npc_token WHERE `owner`!=%i AND valid_until >=%i',
|
||||||
|
$owner,
|
||||||
|
$now,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$previousPick = comparisonNpcPreviousPick($case['previousPick'] ?? null);
|
||||||
|
$keepIds = comparisonNpcIntegerList($case['keepIds'] ?? [], 'keepIds');
|
||||||
|
$oldPick = [];
|
||||||
|
foreach ($previousPick as $id => $keepCount) {
|
||||||
|
if (!isset($candidates[$id])) {
|
||||||
|
throw new \InvalidArgumentException("previous candidate {$id} is not selectable");
|
||||||
|
}
|
||||||
|
$oldPick[$id] = $candidates[$id];
|
||||||
|
$oldPick[$id]['keepCnt'] = $keepCount;
|
||||||
|
}
|
||||||
|
$hasPreviousToken = ($case['hasPreviousToken'] ?? false) === true || $oldPick !== [];
|
||||||
|
if ($hasPreviousToken) {
|
||||||
|
$db->insert('select_npc_token', [
|
||||||
|
'owner' => $owner,
|
||||||
|
'valid_until' => GameClock::MAX_SAFE_TICK,
|
||||||
|
'pick_more_from' => $now,
|
||||||
|
'pick_result' => json_encode((object)$oldPick, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE),
|
||||||
|
'nonce' => 2,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$before = comparisonNpcState();
|
||||||
|
$keepSelection = NpcPossessionSelector::applyKeep($oldPick, $keepIds);
|
||||||
|
$picked = $keepSelection['picked'];
|
||||||
|
if ($hasPreviousToken && $keepSelection['cancelled']) {
|
||||||
|
return [
|
||||||
|
'name' => (string)($case['name'] ?? ''),
|
||||||
|
'cancelled' => true,
|
||||||
|
'seed' => null,
|
||||||
|
'candidateOrder' => array_keys($candidates),
|
||||||
|
'randomDraws' => [],
|
||||||
|
'draws' => [],
|
||||||
|
'pick' => array_map(
|
||||||
|
static fn(int $id, array $candidate): array => [
|
||||||
|
'id' => $id,
|
||||||
|
'keepCount' => (int)$candidate['keepCnt'],
|
||||||
|
],
|
||||||
|
array_keys($oldPick),
|
||||||
|
array_values($oldPick),
|
||||||
|
),
|
||||||
|
'selectionStateUnchanged' => comparisonNpcState() === $before,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seed = NpcPossessionSelector::buildSeed($hiddenSeed, $owner, $now);
|
||||||
|
$rng = new ComparisonNpcTracingRandUtil(new LiteHashDRBG($seed));
|
||||||
|
$draws = [];
|
||||||
|
$picked = NpcPossessionSelector::select(
|
||||||
|
$candidates,
|
||||||
|
$weights,
|
||||||
|
$picked,
|
||||||
|
$rng,
|
||||||
|
static function (int|string $id) use (&$draws): void {
|
||||||
|
$draws[] = (int)$id;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => (string)($case['name'] ?? ''),
|
||||||
|
'cancelled' => false,
|
||||||
|
'seed' => $seed,
|
||||||
|
'candidateOrder' => array_keys($candidates),
|
||||||
|
'randomDraws' => $rng->floatDraws,
|
||||||
|
'draws' => $draws,
|
||||||
|
'pick' => array_map(
|
||||||
|
static fn(int $id, array $candidate): array => [
|
||||||
|
'id' => $id,
|
||||||
|
'keepCount' => (int)$candidate['keepCnt'],
|
||||||
|
],
|
||||||
|
array_keys($picked),
|
||||||
|
array_values($picked),
|
||||||
|
),
|
||||||
|
'selectionStateUnchanged' => comparisonNpcState() === $before,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$request = comparisonNpcRequest();
|
||||||
|
$hiddenSeed = $request['hiddenSeed'] ?? null;
|
||||||
|
$owner = $request['owner'] ?? null;
|
||||||
|
$now = $request['now'] ?? null;
|
||||||
|
$candidateFixtures = $request['candidates'] ?? null;
|
||||||
|
$cases = $request['cases'] ?? null;
|
||||||
|
if (
|
||||||
|
(!is_string($hiddenSeed) && !is_int($hiddenSeed))
|
||||||
|
|| !is_int($owner)
|
||||||
|
|| $owner <= 0
|
||||||
|
|| !is_string($now)
|
||||||
|
|| !is_array($candidateFixtures)
|
||||||
|
|| !is_array($cases)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('fixture requires hiddenSeed, positive owner, now, candidates and cases');
|
||||||
|
}
|
||||||
|
$date = \DateTimeImmutable::createFromFormat('!Y-m-d H:i:s', $now);
|
||||||
|
if ($date === false || $date->format('Y-m-d H:i:s') !== $now) {
|
||||||
|
throw new \InvalidArgumentException('now must use Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$gameStorage = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$clock = GameClock::fromStorage($gameStorage);
|
||||||
|
$nowTick = $clock->dateTimeToTick($date);
|
||||||
|
$db->update('general', ['npc' => 1], '1=1');
|
||||||
|
$fixtureIds = [];
|
||||||
|
foreach ($candidateFixtures as $candidate) {
|
||||||
|
if (
|
||||||
|
!is_array($candidate)
|
||||||
|
|| !isset($candidate['id'], $candidate['leadership'], $candidate['strength'], $candidate['intel'])
|
||||||
|
|| !is_int($candidate['id'])
|
||||||
|
|| $candidate['id'] <= 0
|
||||||
|
|| !is_int($candidate['leadership'])
|
||||||
|
|| !is_int($candidate['strength'])
|
||||||
|
|| !is_int($candidate['intel'])
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('candidate entries require integer id and stats');
|
||||||
|
}
|
||||||
|
if ($db->queryFirstField('SELECT `no` FROM general WHERE `no`=%i', $candidate['id']) === null) {
|
||||||
|
throw new \RuntimeException("fixture general {$candidate['id']} does not exist");
|
||||||
|
}
|
||||||
|
$db->update(
|
||||||
|
'general',
|
||||||
|
[
|
||||||
|
'npc' => 2,
|
||||||
|
'leadership' => $candidate['leadership'],
|
||||||
|
'strength' => $candidate['strength'],
|
||||||
|
'intel' => $candidate['intel'],
|
||||||
|
],
|
||||||
|
'`no`=%i',
|
||||||
|
$candidate['id'],
|
||||||
|
);
|
||||||
|
$fixtureIds[] = $candidate['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = [];
|
||||||
|
foreach ($cases as $case) {
|
||||||
|
if (!is_array($case)) {
|
||||||
|
throw new \InvalidArgumentException('case must be an object');
|
||||||
|
}
|
||||||
|
$results[] = comparisonNpcRunCase($case, $hiddenSeed, $owner, $nowTick, $clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode(
|
||||||
|
[
|
||||||
|
'fixtureGeneralIds' => $fixtureIds,
|
||||||
|
'observedSqlOrder' => array_column(comparisonNpcCandidateRows(), 'id'),
|
||||||
|
'cases' => $results,
|
||||||
|
],
|
||||||
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT,
|
||||||
|
);
|
||||||
|
echo PHP_EOL;
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use sammo\DB;
|
||||||
|
use sammo\Event\Action\OpenNationBetting;
|
||||||
|
use sammo\GameClock;
|
||||||
|
use sammo\Json;
|
||||||
|
use sammo\KVStorage;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
require 'lib.php';
|
||||||
|
require 'func.php';
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$game = KVStorage::getStorage($db, 'game_env')->getAll();
|
||||||
|
$contract = [
|
||||||
|
'scenario' => (int)($game['scenario'] ?? 0),
|
||||||
|
'year' => (int)($game['year'] ?? 0),
|
||||||
|
'month' => (int)($game['month'] ?? 0),
|
||||||
|
'turnterm' => (int)($game['turnterm'] ?? 0),
|
||||||
|
'npcmode' => (int)($game['npcmode'] ?? 0),
|
||||||
|
];
|
||||||
|
if ($contract !== ['scenario' => 2601, 'year' => 186, 'month' => 1, 'turnterm' => 10, 'npcmode' => 2]) {
|
||||||
|
throw new RuntimeException('Ref GUI parity conditional fixture requires scenario2601 at 186-01.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$nationBettingCount = (int)$db->queryFirstField(
|
||||||
|
"SELECT COUNT(*) FROM storage
|
||||||
|
WHERE namespace = 'betting'
|
||||||
|
AND JSON_UNQUOTE(JSON_EXTRACT(value, '$.type')) = 'bettingNation'"
|
||||||
|
);
|
||||||
|
if ($nationBettingCount === 0) {
|
||||||
|
(new OpenNationBetting(4, 5000))->run($game);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uniqueCount = (int)$db->queryFirstField(
|
||||||
|
"SELECT COUNT(*) FROM ng_auction WHERE type = 'uniqueItem' AND finished = 0"
|
||||||
|
);
|
||||||
|
if ($uniqueCount === 0) {
|
||||||
|
$generalID = (int)$db->queryFirstField('SELECT no FROM general WHERE npc <= 2 ORDER BY no LIMIT 1');
|
||||||
|
if ($generalID <= 0) {
|
||||||
|
throw new RuntimeException('Ref GUI parity fixture requires at least one general.');
|
||||||
|
}
|
||||||
|
$gameStorage = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$clock = GameClock::fromStorage($gameStorage);
|
||||||
|
$openTick = $clock->nowTick();
|
||||||
|
$closeTick = GameClock::addTicks($openTick, $clock->ticksFromMinutes(24 * 60));
|
||||||
|
$latestBidCloseTick = GameClock::addTicks($openTick, $clock->ticksFromMinutes(2 * 24 * 60));
|
||||||
|
$openDate = $clock->tickToDateTime($openTick);
|
||||||
|
$detail = [
|
||||||
|
'title' => '손자병법 경매',
|
||||||
|
'hostName' => '청룡',
|
||||||
|
'amount' => 1,
|
||||||
|
'isReverse' => false,
|
||||||
|
'startBidAmount' => 1000,
|
||||||
|
'finishBidAmount' => null,
|
||||||
|
'remainCloseDateExtensionCnt' => 1,
|
||||||
|
'availableLatestBidCloseTick' => $latestBidCloseTick,
|
||||||
|
];
|
||||||
|
$db->insert('ng_auction', [
|
||||||
|
'type' => 'uniqueItem',
|
||||||
|
'finished' => 0,
|
||||||
|
'target' => 'che_서적_15_손자병법',
|
||||||
|
'host_general_id' => $generalID,
|
||||||
|
'req_resource' => 'inheritPoint',
|
||||||
|
'open_tick' => $openTick,
|
||||||
|
'close_tick' => $closeTick,
|
||||||
|
'detail' => Json::encode($detail),
|
||||||
|
]);
|
||||||
|
$auctionID = (int)$db->insertId();
|
||||||
|
$db->insert('ng_auction_bid', [
|
||||||
|
'auction_id' => $auctionID,
|
||||||
|
'owner' => null,
|
||||||
|
'general_id' => $generalID,
|
||||||
|
'amount' => 1000,
|
||||||
|
'date' => $openDate->format('Y-m-d H:i:s'),
|
||||||
|
'aux' => Json::encode(['generalName' => '청룡']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(
|
||||||
|
"Ref conditional capture fixtures: nation_betting=%d unique_auction=%d\n",
|
||||||
|
(int)$db->queryFirstField(
|
||||||
|
"SELECT COUNT(*) FROM storage
|
||||||
|
WHERE namespace = 'betting'
|
||||||
|
AND JSON_UNQUOTE(JSON_EXTRACT(value, '$.type')) = 'bettingNation'"
|
||||||
|
),
|
||||||
|
(int)$db->queryFirstField("SELECT COUNT(*) FROM ng_auction WHERE type = 'uniqueItem'")
|
||||||
|
);
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
|
||||||
|
$groups = [
|
||||||
|
'nation' => ['ActionNationType', 'ActionNationType'],
|
||||||
|
'domestic' => ['ActionSpecialDomestic', 'ActionSpecialDomestic'],
|
||||||
|
'war' => ['ActionSpecialWar', 'ActionSpecialWar'],
|
||||||
|
'personality' => ['ActionPersonality', 'ActionPersonality'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
foreach ($groups as $kind => [$directory, $namespace]) {
|
||||||
|
foreach (glob(__DIR__ . "/../sammo/{$directory}/*.php") ?: [] as $path) {
|
||||||
|
$key = basename($path, '.php');
|
||||||
|
if ($key === 'None' || str_starts_with($key, 'che_event_') || $key === 'che_거상') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$className = "\\sammo\\{$namespace}\\{$key}";
|
||||||
|
$trait = new $className();
|
||||||
|
$result[$kind][$key] = [
|
||||||
|
'name' => $trait->getName(),
|
||||||
|
'info' => $trait->getInfo(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
ksort($result[$kind]);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo Json::encode($result);
|
||||||
@@ -0,0 +1,804 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\RankColumn;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
$_SERVER['REMOTE_ADDR'] ??= '127.0.0.1';
|
||||||
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
require_once __DIR__ . '/turn_state_snapshot.php';
|
||||||
|
|
||||||
|
final class TurnComparisonTracingRNG implements RNG
|
||||||
|
{
|
||||||
|
private int $sequence = 0;
|
||||||
|
|
||||||
|
/** @var list<array<string, mixed>> */
|
||||||
|
public array $calls = [];
|
||||||
|
|
||||||
|
public function __construct(private readonly RNG $inner)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMaxInt(): int
|
||||||
|
{
|
||||||
|
return LiteHashDRBG::getMaxInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextBytes(int $bytes): string
|
||||||
|
{
|
||||||
|
$value = $this->inner->nextBytes($bytes);
|
||||||
|
$this->record('nextBytes', ['bytes' => $bytes], bin2hex($value));
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextBits(int $bits): string
|
||||||
|
{
|
||||||
|
$value = $this->inner->nextBits($bits);
|
||||||
|
$this->record('nextBits', ['bits' => $bits], bin2hex($value));
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextInt(?int $max = null): int
|
||||||
|
{
|
||||||
|
$value = $this->inner->nextInt($max);
|
||||||
|
$this->record('nextInt', ['maxInclusive' => $max], $value);
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextFloat1(): float
|
||||||
|
{
|
||||||
|
$value = $this->inner->nextFloat1();
|
||||||
|
$this->record('nextFloat1', [], $value);
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function record(string $operation, array $arguments, mixed $result): void
|
||||||
|
{
|
||||||
|
$this->calls[] = [
|
||||||
|
'seq' => $this->sequence++,
|
||||||
|
'operation' => $operation,
|
||||||
|
'arguments' => $arguments === [] ? (object)[] : $arguments,
|
||||||
|
'result' => $result,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string, mixed> */
|
||||||
|
function comparisonMappedPatch(array $row, array $mapping): array
|
||||||
|
{
|
||||||
|
$patch = [];
|
||||||
|
foreach ($mapping as $canonical => $legacy) {
|
||||||
|
if (array_key_exists($canonical, $row)) {
|
||||||
|
$patch[$legacy] = $row[$canonical];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
||||||
|
{
|
||||||
|
if ($setup === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!is_array($setup)) {
|
||||||
|
throw new \InvalidArgumentException('setup must be an object');
|
||||||
|
}
|
||||||
|
$db = DB::db();
|
||||||
|
$world = $setup['world'] ?? null;
|
||||||
|
if ($world !== null) {
|
||||||
|
if (!is_array($world)) {
|
||||||
|
throw new \InvalidArgumentException('setup.world must be an object');
|
||||||
|
}
|
||||||
|
$game = KVStorage::getStorage($db, 'game_env');
|
||||||
|
foreach (['year', 'month', 'startyear', 'init_year', 'init_month'] as $key) {
|
||||||
|
$fixtureKey = match ($key) {
|
||||||
|
'startyear' => 'startYear',
|
||||||
|
'init_year' => 'initYear',
|
||||||
|
'init_month' => 'initMonth',
|
||||||
|
default => $key,
|
||||||
|
};
|
||||||
|
if (!array_key_exists($fixtureKey, $world)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$value = $world[$fixtureKey];
|
||||||
|
if (
|
||||||
|
!is_int($value)
|
||||||
|
|| $value < 1
|
||||||
|
|| (in_array($key, ['month', 'init_month'], true) && $value > 12)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException("setup.world.{$fixtureKey} is invalid");
|
||||||
|
}
|
||||||
|
$game->setValue($key, $value);
|
||||||
|
}
|
||||||
|
$game->resetCache();
|
||||||
|
if (array_key_exists('hiddenSeed', $world)) {
|
||||||
|
$hiddenSeed = $world['hiddenSeed'];
|
||||||
|
if (!is_string($hiddenSeed) || $hiddenSeed === '' || strlen($hiddenSeed) > 256) {
|
||||||
|
throw new \InvalidArgumentException('setup.world.hiddenSeed is invalid');
|
||||||
|
}
|
||||||
|
UniqueConst::$hiddenSeed = $hiddenSeed;
|
||||||
|
}
|
||||||
|
// 비교 fixture는 전역 상태에 의존하지 않도록 effect 기본값을 null로 고정하고,
|
||||||
|
// 명시된 경우에만 해당 effect를 활성화합니다.
|
||||||
|
GameConst::$scenarioEffect = null;
|
||||||
|
if (array_key_exists('scenarioEffect', $world)) {
|
||||||
|
$scenarioEffect = $world['scenarioEffect'];
|
||||||
|
if ($scenarioEffect === '' || $scenarioEffect === 'None') {
|
||||||
|
$scenarioEffect = null;
|
||||||
|
}
|
||||||
|
if ($scenarioEffect !== null) {
|
||||||
|
if (!is_string($scenarioEffect) || getScenarioEffectClass($scenarioEffect) === null) {
|
||||||
|
throw new \InvalidArgumentException('setup.world.scenarioEffect is invalid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameConst::$scenarioEffect = $scenarioEffect;
|
||||||
|
}
|
||||||
|
if (array_key_exists('staticEventHandlers', $world)) {
|
||||||
|
$handlersByEvent = $world['staticEventHandlers'];
|
||||||
|
if (!is_array($handlersByEvent)) {
|
||||||
|
throw new \InvalidArgumentException('setup.world.staticEventHandlers must be an object');
|
||||||
|
}
|
||||||
|
foreach ($handlersByEvent as $eventType => $handlers) {
|
||||||
|
if (!is_string($eventType) || $eventType === '' || !is_array($handlers)) {
|
||||||
|
throw new \InvalidArgumentException('setup.world.staticEventHandlers is invalid');
|
||||||
|
}
|
||||||
|
foreach ($handlers as $handler) {
|
||||||
|
if (!is_string($handler) || $handler === '') {
|
||||||
|
throw new \InvalidArgumentException('setup.world.staticEventHandlers is invalid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameConst::$staticEventHandlers = $handlersByEvent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (['nations', 'cities', 'generals', 'troops', 'diplomacy'] as $collection) {
|
||||||
|
if (isset($setup[$collection]) && !is_array($setup[$collection])) {
|
||||||
|
throw new \InvalidArgumentException("setup.{$collection} must be an array");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$generalCooldowns = comparisonGeneralCooldownSelectors(
|
||||||
|
$setup['generalCooldowns'] ?? [],
|
||||||
|
'setup.generalCooldowns',
|
||||||
|
);
|
||||||
|
if ($generalCooldowns !== []) {
|
||||||
|
$nextExecuteStorage = KVStorage::getStorage($db, 'next_execute');
|
||||||
|
foreach ($setup['generalCooldowns'] as $entry) {
|
||||||
|
$nextAvailableTurn = $entry['nextAvailableTurn'] ?? null;
|
||||||
|
if (!is_int($nextAvailableTurn) || $nextAvailableTurn < 0) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'setup.generalCooldowns entries require a non-negative nextAvailableTurn',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$key = "next_execute_{$entry['generalId']}_{$entry['actionName']}";
|
||||||
|
$nextExecuteStorage->setValue($key, $nextAvailableTurn);
|
||||||
|
}
|
||||||
|
$nextExecuteStorage->resetCache();
|
||||||
|
}
|
||||||
|
if (isset($setup['randomFoundingCandidateCityIds'])) {
|
||||||
|
$candidateCityIds = comparisonIntegerList(
|
||||||
|
$setup['randomFoundingCandidateCityIds'],
|
||||||
|
'randomFoundingCandidateCityIds',
|
||||||
|
);
|
||||||
|
$db->update('city', ['level' => 4], '1 = 1');
|
||||||
|
if ($candidateCityIds !== []) {
|
||||||
|
$db->update('city', ['level' => 5], 'city IN %li', $candidateCityIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($setup['isolateWorld'] ?? false) === true) {
|
||||||
|
$generalIds = array_values(array_map(
|
||||||
|
static fn(array $row): int => (int)$row['id'],
|
||||||
|
$setup['generals'] ?? [],
|
||||||
|
));
|
||||||
|
$nationIds = array_values(array_map(
|
||||||
|
static fn(array $row): int => (int)$row['id'],
|
||||||
|
$setup['nations'] ?? [],
|
||||||
|
));
|
||||||
|
if ($generalIds === [] || $nationIds === []) {
|
||||||
|
throw new \InvalidArgumentException('isolateWorld requires generals and nations');
|
||||||
|
}
|
||||||
|
$generalTemplate = $db->queryFirstRow(
|
||||||
|
'SELECT * FROM general WHERE no IN %li ORDER BY no LIMIT 1',
|
||||||
|
$generalIds,
|
||||||
|
);
|
||||||
|
if ($generalTemplate === null) {
|
||||||
|
throw new \InvalidArgumentException('isolateWorld requires at least one existing fixture general');
|
||||||
|
}
|
||||||
|
$generalTemplateId = (int)$generalTemplate['no'];
|
||||||
|
$rankDataTemplate = $db->query(
|
||||||
|
'SELECT `type`, `value` FROM rank_data WHERE general_id = %i',
|
||||||
|
$generalTemplateId,
|
||||||
|
);
|
||||||
|
$db->delete('general_turn', 'general_id NOT IN %li', $generalIds);
|
||||||
|
$db->delete('rank_data', 'general_id NOT IN %li', $generalIds);
|
||||||
|
$db->delete('nation_turn', 'nation_id NOT IN %li', $nationIds);
|
||||||
|
$db->delete('troop', '1 = 1');
|
||||||
|
$db->delete('diplomacy', '1 = 1');
|
||||||
|
$db->delete('general', 'no NOT IN %li', $generalIds);
|
||||||
|
foreach ($generalIds as $generalId) {
|
||||||
|
if ($db->queryFirstField('SELECT no FROM general WHERE no = %i', $generalId) !== null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$newGeneral = $generalTemplate;
|
||||||
|
$newGeneral['no'] = $generalId;
|
||||||
|
$newGeneral['owner'] = 0;
|
||||||
|
$newGeneral['name'] = "fixture-general-{$generalId}";
|
||||||
|
$db->insert('general', $newGeneral);
|
||||||
|
}
|
||||||
|
foreach ($generalIds as $generalId) {
|
||||||
|
foreach ($rankDataTemplate as $rankRow) {
|
||||||
|
$rankData = [
|
||||||
|
'general_id' => $generalId,
|
||||||
|
'type' => $rankRow['type'],
|
||||||
|
'value' => $rankRow['value'],
|
||||||
|
];
|
||||||
|
$db->insertUpdate('rank_data', $rankData, $rankData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$db->delete('nation', 'nation NOT IN %li', $nationIds);
|
||||||
|
$db->update('city', [
|
||||||
|
'nation' => 0,
|
||||||
|
'supply' => 0,
|
||||||
|
'front' => 0,
|
||||||
|
'state' => 0,
|
||||||
|
'term' => 0,
|
||||||
|
'conflict' => '{}',
|
||||||
|
'officer_set' => 0,
|
||||||
|
], '1 = 1');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($setup['nations'] ?? [] as $row) {
|
||||||
|
if (!is_array($row) || !is_int($row['id'] ?? null) || $row['id'] < 1) {
|
||||||
|
throw new \InvalidArgumentException('setup.nations requires positive integer ids');
|
||||||
|
}
|
||||||
|
$data = comparisonMappedPatch($row, [
|
||||||
|
'id' => 'nation',
|
||||||
|
'name' => 'name',
|
||||||
|
'color' => 'color',
|
||||||
|
'capitalCityId' => 'capital',
|
||||||
|
'gold' => 'gold',
|
||||||
|
'rice' => 'rice',
|
||||||
|
'tech' => 'tech',
|
||||||
|
'level' => 'level',
|
||||||
|
'typeCode' => 'type',
|
||||||
|
'war' => 'war',
|
||||||
|
'diplomacyLimit' => 'surlimit',
|
||||||
|
'generalCount' => 'gennum',
|
||||||
|
'power' => 'power',
|
||||||
|
'capitalRevision' => 'capset',
|
||||||
|
'strategicCommandLimit' => 'strategic_cmd_limit',
|
||||||
|
]);
|
||||||
|
if (isset($row['meta'])) {
|
||||||
|
$data['aux'] = Json::encode($row['meta']);
|
||||||
|
}
|
||||||
|
$data += [
|
||||||
|
'name' => "fixture-nation-{$row['id']}",
|
||||||
|
'color' => '#777777',
|
||||||
|
'capital' => 0,
|
||||||
|
'gold' => 0,
|
||||||
|
'rice' => 0,
|
||||||
|
'level' => 1,
|
||||||
|
'type' => 'che_중립',
|
||||||
|
'aux' => '{}',
|
||||||
|
];
|
||||||
|
$db->insertUpdate('nation', $data, $data);
|
||||||
|
$nationStor = KVStorage::getStorage($db, $row['id'], 'nation_env');
|
||||||
|
if (($setup['isolateWorld'] ?? false) === true) {
|
||||||
|
$nationStor->deleteValue('recv_assist');
|
||||||
|
$nationStor->deleteValue('resp_assist');
|
||||||
|
}
|
||||||
|
if (array_key_exists('nationEnv', $row)) {
|
||||||
|
if (!is_array($row['nationEnv'])) {
|
||||||
|
throw new \InvalidArgumentException('setup.nations.nationEnv must be an object');
|
||||||
|
}
|
||||||
|
foreach ($row['nationEnv'] as $key => $value) {
|
||||||
|
if (!is_string($key) || $key === '') {
|
||||||
|
throw new \InvalidArgumentException('setup.nations.nationEnv keys must be non-empty strings');
|
||||||
|
}
|
||||||
|
$nationStor->setValue($key, $value);
|
||||||
|
}
|
||||||
|
$nationStor->resetCache();
|
||||||
|
}
|
||||||
|
if (array_key_exists('turnLastByOfficerLevel', $row)) {
|
||||||
|
$turnLastByOfficerLevel = $row['turnLastByOfficerLevel'];
|
||||||
|
if (!is_array($turnLastByOfficerLevel)) {
|
||||||
|
throw new \InvalidArgumentException('setup.nations.turnLastByOfficerLevel must be an object');
|
||||||
|
}
|
||||||
|
foreach ($turnLastByOfficerLevel as $officerLevel => $lastTurn) {
|
||||||
|
$officerLevel = filter_var($officerLevel, FILTER_VALIDATE_INT);
|
||||||
|
if (
|
||||||
|
$officerLevel === false
|
||||||
|
|| $officerLevel < 5
|
||||||
|
|| $officerLevel > 12
|
||||||
|
|| !is_array($lastTurn)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'setup.nations.turnLastByOfficerLevel requires officer levels 5 through 12'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$nationStor->setValue("turn_last_{$officerLevel}", $lastTurn);
|
||||||
|
}
|
||||||
|
$nationStor->resetCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (($setup['isolateWorld'] ?? false) === true && ($setup['nations'] ?? []) !== []) {
|
||||||
|
$maxNationId = max(array_map(
|
||||||
|
static fn(array $row): int => (int)$row['id'],
|
||||||
|
$setup['nations'],
|
||||||
|
));
|
||||||
|
$db->query('ALTER TABLE nation AUTO_INCREMENT = %i', $maxNationId + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($setup['cities'] ?? [] as $row) {
|
||||||
|
if (!is_array($row) || !is_int($row['id'] ?? null) || $row['id'] < 1) {
|
||||||
|
throw new \InvalidArgumentException('setup.cities requires positive integer ids');
|
||||||
|
}
|
||||||
|
$patch = comparisonMappedPatch($row, [
|
||||||
|
'nationId' => 'nation',
|
||||||
|
'level' => 'level',
|
||||||
|
'population' => 'pop',
|
||||||
|
'populationMax' => 'pop_max',
|
||||||
|
'agriculture' => 'agri',
|
||||||
|
'agricultureMax' => 'agri_max',
|
||||||
|
'commerce' => 'comm',
|
||||||
|
'commerceMax' => 'comm_max',
|
||||||
|
'security' => 'secu',
|
||||||
|
'securityMax' => 'secu_max',
|
||||||
|
'supplyState' => 'supply',
|
||||||
|
'frontState' => 'front',
|
||||||
|
'defence' => 'def',
|
||||||
|
'defenceMax' => 'def_max',
|
||||||
|
'wall' => 'wall',
|
||||||
|
'wallMax' => 'wall_max',
|
||||||
|
'state' => 'state',
|
||||||
|
'term' => 'term',
|
||||||
|
'trust' => 'trust',
|
||||||
|
'trade' => 'trade',
|
||||||
|
'officerSet' => 'officer_set',
|
||||||
|
]);
|
||||||
|
if (array_key_exists('conflictEntries', $row)) {
|
||||||
|
if (!is_array($row['conflictEntries'])) {
|
||||||
|
throw new \InvalidArgumentException('setup.cities.conflictEntries must be an array');
|
||||||
|
}
|
||||||
|
$orderedConflict = [];
|
||||||
|
foreach ($row['conflictEntries'] as $entry) {
|
||||||
|
if (
|
||||||
|
!is_array($entry)
|
||||||
|
|| count($entry) !== 2
|
||||||
|
|| !is_int($entry[0] ?? null)
|
||||||
|
|| $entry[0] < 1
|
||||||
|
|| !is_numeric($entry[1] ?? null)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'setup.cities.conflictEntries requires [positive nation id, numeric value] pairs'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$orderedConflict[$entry[0]] = $entry[1];
|
||||||
|
}
|
||||||
|
$patch['conflict'] = Json::encode($orderedConflict);
|
||||||
|
} elseif (array_key_exists('conflict', $row)) {
|
||||||
|
if (!is_array($row['conflict'])) {
|
||||||
|
throw new \InvalidArgumentException('setup.cities.conflict must be an object');
|
||||||
|
}
|
||||||
|
$patch['conflict'] = Json::encode($row['conflict']);
|
||||||
|
}
|
||||||
|
if ($patch !== []) {
|
||||||
|
$db->update('city', $patch, 'city = %i', $row['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($setup['generals'] ?? [] as $row) {
|
||||||
|
if (!is_array($row) || !is_int($row['id'] ?? null) || $row['id'] < 1) {
|
||||||
|
throw new \InvalidArgumentException('setup.generals requires positive integer ids');
|
||||||
|
}
|
||||||
|
$patch = comparisonMappedPatch($row, [
|
||||||
|
'name' => 'name',
|
||||||
|
'nationId' => 'nation',
|
||||||
|
'cityId' => 'city',
|
||||||
|
'troopId' => 'troop',
|
||||||
|
'leadership' => 'leadership',
|
||||||
|
'strength' => 'strength',
|
||||||
|
'intelligence' => 'intel',
|
||||||
|
'leadershipExp' => 'leadership_exp',
|
||||||
|
'strengthExp' => 'strength_exp',
|
||||||
|
'intelExp' => 'intel_exp',
|
||||||
|
'experience' => 'experience',
|
||||||
|
'dedication' => 'dedication',
|
||||||
|
'expLevel' => 'explevel',
|
||||||
|
'officerLevel' => 'officer_level',
|
||||||
|
'officerCityId' => 'officer_city',
|
||||||
|
'belong' => 'belong',
|
||||||
|
'permission' => 'permission',
|
||||||
|
'betray' => 'betray',
|
||||||
|
'makeLimit' => 'makelimit',
|
||||||
|
'injury' => 'injury',
|
||||||
|
'age' => 'age',
|
||||||
|
'gold' => 'gold',
|
||||||
|
'rice' => 'rice',
|
||||||
|
'crew' => 'crew',
|
||||||
|
'crewTypeId' => 'crewtype',
|
||||||
|
'train' => 'train',
|
||||||
|
'atmos' => 'atmos',
|
||||||
|
'dex1' => 'dex1',
|
||||||
|
'dex2' => 'dex2',
|
||||||
|
'dex3' => 'dex3',
|
||||||
|
'dex4' => 'dex4',
|
||||||
|
'dex5' => 'dex5',
|
||||||
|
'specAge' => 'specage',
|
||||||
|
'specAge2' => 'specage2',
|
||||||
|
'killTurn' => 'killturn',
|
||||||
|
'npcState' => 'npc',
|
||||||
|
'blockState' => 'block',
|
||||||
|
'specialDomestic' => 'special',
|
||||||
|
'specialWar' => 'special2',
|
||||||
|
'personality' => 'personal',
|
||||||
|
'itemHorse' => 'horse',
|
||||||
|
'itemWeapon' => 'weapon',
|
||||||
|
'itemBook' => 'book',
|
||||||
|
'itemExtra' => 'item',
|
||||||
|
]);
|
||||||
|
if (isset($row['meta'])) {
|
||||||
|
$patch['aux'] = Json::encode($row['meta']);
|
||||||
|
}
|
||||||
|
if (array_key_exists('penalty', $row)) {
|
||||||
|
if (!is_array($row['penalty'])) {
|
||||||
|
throw new \InvalidArgumentException('setup.generals.penalty must be an object');
|
||||||
|
}
|
||||||
|
$patch['penalty'] = Json::encode($row['penalty']);
|
||||||
|
}
|
||||||
|
if (isset($row['lastTurn']) && is_array($row['lastTurn'])) {
|
||||||
|
$patch['last_turn'] = Json::encode($row['lastTurn']);
|
||||||
|
}
|
||||||
|
if ($patch !== []) {
|
||||||
|
$db->update('general', $patch, 'no = %i', $row['id']);
|
||||||
|
}
|
||||||
|
if (array_key_exists('nationId', $row)) {
|
||||||
|
$db->update('rank_data', [
|
||||||
|
'nation_id' => $row['nationId'],
|
||||||
|
], 'general_id = %i', $row['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($setup['rankData'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row)
|
||||||
|
|| !is_int($row['generalId'] ?? null)
|
||||||
|
|| !is_string($row['type'] ?? null)
|
||||||
|
|| RankColumn::tryFrom($row['type']) === null
|
||||||
|
|| !is_int($row['value'] ?? null)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('invalid setup.rankData row');
|
||||||
|
}
|
||||||
|
$nationId = (int)($db->queryFirstField(
|
||||||
|
'SELECT nation FROM general WHERE no = %i',
|
||||||
|
$row['generalId'],
|
||||||
|
) ?? 0);
|
||||||
|
$db->insertUpdate('rank_data', [
|
||||||
|
'general_id' => $row['generalId'],
|
||||||
|
'nation_id' => $nationId,
|
||||||
|
'type' => $row['type'],
|
||||||
|
'value' => $row['value'],
|
||||||
|
], [
|
||||||
|
'nation_id' => $nationId,
|
||||||
|
'value' => $row['value'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (($setup['isolateWorld'] ?? false) === true && ($setup['generals'] ?? []) !== []) {
|
||||||
|
$maxGeneralId = max(array_map(
|
||||||
|
static fn(array $row): int => (int)$row['id'],
|
||||||
|
$setup['generals'],
|
||||||
|
));
|
||||||
|
$db->query('ALTER TABLE general AUTO_INCREMENT = %i', $maxGeneralId + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($setup['troops'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row)
|
||||||
|
|| !is_int($row['id'] ?? null)
|
||||||
|
|| !is_int($row['nationId'] ?? null)
|
||||||
|
|| !is_string($row['name'] ?? null)
|
||||||
|
|| $row['id'] < 1
|
||||||
|
|| $row['nationId'] < 1
|
||||||
|
|| $row['name'] === ''
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('setup.troops requires positive id/nationId and non-empty name');
|
||||||
|
}
|
||||||
|
$data = [
|
||||||
|
'troop_leader' => $row['id'],
|
||||||
|
'nation' => $row['nationId'],
|
||||||
|
'name' => $row['name'],
|
||||||
|
];
|
||||||
|
$db->insertUpdate('troop', $data, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($setup['diplomacy'] ?? [] as $row) {
|
||||||
|
if (
|
||||||
|
!is_array($row) ||
|
||||||
|
!is_int($row['fromNationId'] ?? null) ||
|
||||||
|
!is_int($row['toNationId'] ?? null) ||
|
||||||
|
$row['fromNationId'] < 1 ||
|
||||||
|
$row['toNationId'] < 1
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('setup.diplomacy requires positive integer nation ids');
|
||||||
|
}
|
||||||
|
$data = comparisonMappedPatch($row, [
|
||||||
|
'fromNationId' => 'me',
|
||||||
|
'toNationId' => 'you',
|
||||||
|
'state' => 'state',
|
||||||
|
'term' => 'term',
|
||||||
|
'dead' => 'dead',
|
||||||
|
]);
|
||||||
|
$data += ['state' => 3, 'term' => 0, 'dead' => 0];
|
||||||
|
$db->insertUpdate('diplomacy', $data, $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonRunTurnCommand(array $request): array
|
||||||
|
{
|
||||||
|
if (getenv('TURN_DIFFERENTIAL_ENABLED') !== '1') {
|
||||||
|
throw new \RuntimeException('TURN_DIFFERENTIAL_ENABLED=1 is required');
|
||||||
|
}
|
||||||
|
$kind = $request['kind'] ?? null;
|
||||||
|
if (!in_array($kind, ['general', 'nation', 'instantNation', 'troopJoinStaticEvent'], true)) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'kind must be general, nation, instantNation, or troopJoinStaticEvent',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$actorGeneralId = $request['actorGeneralId'] ?? null;
|
||||||
|
$action = $request['action'] ?? null;
|
||||||
|
$args = $request['args'] ?? null;
|
||||||
|
$includeLifecycle = $request['includeLifecycle'] ?? false;
|
||||||
|
if (!is_int($actorGeneralId) || $actorGeneralId < 1) {
|
||||||
|
throw new \InvalidArgumentException('actorGeneralId must be a positive integer');
|
||||||
|
}
|
||||||
|
if (!is_string($action) || $action === '') {
|
||||||
|
throw new \InvalidArgumentException('action must be a non-empty string');
|
||||||
|
}
|
||||||
|
if (!is_bool($includeLifecycle)) {
|
||||||
|
throw new \InvalidArgumentException('includeLifecycle must be a boolean');
|
||||||
|
}
|
||||||
|
if ($includeLifecycle && $kind !== 'general') {
|
||||||
|
throw new \InvalidArgumentException('includeLifecycle currently supports general commands only');
|
||||||
|
}
|
||||||
|
|
||||||
|
comparisonApplyTurnFixtureSetup($request['setup'] ?? null);
|
||||||
|
if ($includeLifecycle) {
|
||||||
|
DB::db()->insertUpdate('general_turn', [
|
||||||
|
'general_id' => $actorGeneralId,
|
||||||
|
'turn_idx' => 0,
|
||||||
|
'action' => $action,
|
||||||
|
'arg' => Json::encode($args),
|
||||||
|
'brief' => $action,
|
||||||
|
], [
|
||||||
|
'action' => $action,
|
||||||
|
'arg' => Json::encode($args),
|
||||||
|
'brief' => $action,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$snapshotRequest = ['observe' => $request['observe'] ?? []];
|
||||||
|
$before = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
|
$db = DB::db();
|
||||||
|
$gameStorage = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$gameStorage->resetCache();
|
||||||
|
$environment = $gameStorage->getAll();
|
||||||
|
if ($kind === 'troopJoinStaticEvent') {
|
||||||
|
if ($action !== \sammo\API\Troop\JoinTroop::class) {
|
||||||
|
throw new \InvalidArgumentException('troopJoinStaticEvent requires the JoinTroop API action');
|
||||||
|
}
|
||||||
|
$troopId = is_array($args) ? ($args['troopID'] ?? null) : null;
|
||||||
|
if (!is_int($troopId) || $troopId < 1) {
|
||||||
|
throw new \InvalidArgumentException('troopJoinStaticEvent requires a positive integer troopID');
|
||||||
|
}
|
||||||
|
$general = GeneralLite::createObjFromDB(
|
||||||
|
$actorGeneralId,
|
||||||
|
['troop'],
|
||||||
|
Enums\GeneralLiteQueryMode::Lite,
|
||||||
|
);
|
||||||
|
if ($general === null) {
|
||||||
|
throw new \RuntimeException('장수 정보를 불러올 수 없습니다.');
|
||||||
|
}
|
||||||
|
if ($general->getVar('troop') != 0) {
|
||||||
|
throw new \RuntimeException('이미 부대에 소속되어 있습니다.');
|
||||||
|
}
|
||||||
|
$nationId = $general->getNationID();
|
||||||
|
if ($nationId == 0) {
|
||||||
|
throw new \RuntimeException('국가에 소속되어 있지 않습니다.');
|
||||||
|
}
|
||||||
|
$troopExists = $db->queryFirstField(
|
||||||
|
'SELECT `troop_leader` FROM `troop` WHERE `troop_leader` = %i AND `nation` = %i',
|
||||||
|
$troopId,
|
||||||
|
$nationId,
|
||||||
|
);
|
||||||
|
if (!$troopExists) {
|
||||||
|
throw new \RuntimeException('부대가 올바르지 않습니다.');
|
||||||
|
}
|
||||||
|
|
||||||
|
GameConst::$staticEventHandlers = [
|
||||||
|
\sammo\API\Troop\JoinTroop::class => ['event_부대탑승즉시이동'],
|
||||||
|
];
|
||||||
|
$general->setVar('troop', $troopId);
|
||||||
|
StaticEventHandler::handleEvent($general, null, \sammo\API\Troop\JoinTroop::class, [], $args);
|
||||||
|
$general->applyDB($db);
|
||||||
|
$after = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'execution' => [
|
||||||
|
'kind' => $kind,
|
||||||
|
'actorGeneralId' => $actorGeneralId,
|
||||||
|
'action' => $action,
|
||||||
|
'args' => $args,
|
||||||
|
'seedDomain' => 'none',
|
||||||
|
'outcome' => ['completed' => true],
|
||||||
|
],
|
||||||
|
'before' => $before,
|
||||||
|
'after' => $after,
|
||||||
|
'rng' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$general = General::createObjFromDB($actorGeneralId);
|
||||||
|
if ($kind === 'instantNation') {
|
||||||
|
$command = buildNationCommandClass($action, $general, $environment, new LastTurn(), $args);
|
||||||
|
if (!$command->hasFullConditionMet()) {
|
||||||
|
throw new \RuntimeException($command->getFailString());
|
||||||
|
}
|
||||||
|
$completed = $command->run(NoRNG::rngInstance());
|
||||||
|
$command->setNextAvailable();
|
||||||
|
$general->getLogger()->flush();
|
||||||
|
$after = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'execution' => [
|
||||||
|
'kind' => $kind,
|
||||||
|
'actorGeneralId' => $actorGeneralId,
|
||||||
|
'action' => $action,
|
||||||
|
'args' => $args,
|
||||||
|
'seedDomain' => 'none',
|
||||||
|
'outcome' => [
|
||||||
|
'lastTurn' => (object)[],
|
||||||
|
'commandName' => $command->getName(),
|
||||||
|
'completed' => $completed,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'before' => $before,
|
||||||
|
'after' => $after,
|
||||||
|
'rng' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$turn = new TurnExecutionHelper($general);
|
||||||
|
$general->increaseInheritancePoint(Enums\InheritanceKey::lived_month, 1);
|
||||||
|
$preprocessRng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||||
|
UniqueConst::$hiddenSeed,
|
||||||
|
'preprocess',
|
||||||
|
(int)$environment['year'],
|
||||||
|
(int)$environment['month'],
|
||||||
|
$actorGeneralId,
|
||||||
|
)));
|
||||||
|
$turn->preprocessCommand($preprocessRng, $environment);
|
||||||
|
$seedDomain = $kind === 'general' ? 'generalCommand' : 'nationCommand';
|
||||||
|
$seed = Util::simpleSerialize(
|
||||||
|
UniqueConst::$hiddenSeed,
|
||||||
|
$seedDomain,
|
||||||
|
(int)$environment['year'],
|
||||||
|
(int)$environment['month'],
|
||||||
|
$actorGeneralId,
|
||||||
|
$action,
|
||||||
|
);
|
||||||
|
$tracingRng = new TurnComparisonTracingRNG(new LiteHashDRBG($seed));
|
||||||
|
$rng = new RandUtil($tracingRng);
|
||||||
|
if ($kind === 'general' && $action === 'che_견문') {
|
||||||
|
\sammo\TextDecoration\SightseeingMessage::setComparisonRng($rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($kind === 'general') {
|
||||||
|
$previousLastTurn = $general->getLastTurn();
|
||||||
|
$previousLastTurnRaw = $previousLastTurn->toRaw();
|
||||||
|
$command = buildGeneralCommandClass($action, $general, $environment, $args);
|
||||||
|
$commandFullConditionMet = $command->hasFullConditionMet();
|
||||||
|
$resultTurn = $turn->processCommand($rng, $command, false);
|
||||||
|
} else {
|
||||||
|
$nationStor = KVStorage::getStorage($db, $general->getNationID(), 'nation_env');
|
||||||
|
$lastNationTurnKey = "turn_last_{$general->getVar('officer_level')}";
|
||||||
|
$previousLastTurn = LastTurn::fromRaw($nationStor->getValue($lastNationTurnKey));
|
||||||
|
$previousLastTurnRaw = $previousLastTurn->toRaw();
|
||||||
|
$command = buildNationCommandClass($action, $general, $environment, $previousLastTurn, $args);
|
||||||
|
$commandFullConditionMet = $command->hasFullConditionMet();
|
||||||
|
$resultTurn = $turn->processNationCommand($rng, $command);
|
||||||
|
$nationStor->setValue($lastNationTurnKey, $resultTurn->toRaw());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($includeLifecycle) {
|
||||||
|
pullGeneralCommand($general->getID());
|
||||||
|
$general->increaseVarWithLimit(
|
||||||
|
'myset',
|
||||||
|
GameConst::$incDefSettingChange,
|
||||||
|
null,
|
||||||
|
GameConst::$maxDefSettingChange,
|
||||||
|
);
|
||||||
|
$turn->updateTurnTime();
|
||||||
|
}
|
||||||
|
$general->getLogger()->flush();
|
||||||
|
$turn->applyDB();
|
||||||
|
unset($turn);
|
||||||
|
$after = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
|
$resultTurnRaw = $resultTurn->toRaw();
|
||||||
|
$resultTerm = (int)($resultTurnRaw['term'] ?? 0);
|
||||||
|
$preReqTurn = $command->getPreReqTurn();
|
||||||
|
$acceptScoutCompleted = (
|
||||||
|
$action === 'che_등용수락'
|
||||||
|
&& is_array($args)
|
||||||
|
&& is_int($args['destNationID'] ?? null)
|
||||||
|
&& $general->getNationID() === $args['destNationID']
|
||||||
|
);
|
||||||
|
$foundNationCompleted = (
|
||||||
|
in_array($action, ['che_건국', 'cr_건국', 'che_무작위건국'], true)
|
||||||
|
&& is_array($args)
|
||||||
|
&& is_string($args['nationName'] ?? null)
|
||||||
|
&& DB::db()->queryFirstField(
|
||||||
|
'SELECT name FROM nation WHERE nation = %i',
|
||||||
|
$general->getNationID(),
|
||||||
|
) === $args['nationName']
|
||||||
|
);
|
||||||
|
$completedByState = (
|
||||||
|
$action === 'che_접경귀환'
|
||||||
|
&& $tracingRng->calls !== []
|
||||||
|
) || $acceptScoutCompleted || $foundNationCompleted || (($resultTurnRaw['command'] ?? null) === $command->getName()
|
||||||
|
&& (
|
||||||
|
($preReqTurn === 0 && $resultTerm === 0)
|
||||||
|
|| (
|
||||||
|
$preReqTurn > 0
|
||||||
|
&& ($previousLastTurnRaw['command'] ?? null) === $command->getName()
|
||||||
|
&& ($previousLastTurnRaw['arg'] ?? null) === $command->getArg()
|
||||||
|
&& (int)($previousLastTurnRaw['term'] ?? 0) === $preReqTurn
|
||||||
|
)
|
||||||
|
));
|
||||||
|
$completed = $commandFullConditionMet && $completedByState;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'execution' => [
|
||||||
|
'kind' => $kind,
|
||||||
|
'actorGeneralId' => $actorGeneralId,
|
||||||
|
'action' => $action,
|
||||||
|
'args' => $args,
|
||||||
|
'seedDomain' => $seedDomain,
|
||||||
|
'outcome' => [
|
||||||
|
'lastTurn' => $resultTurnRaw,
|
||||||
|
'commandName' => $command->getName(),
|
||||||
|
'completed' => $completed,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'before' => $before,
|
||||||
|
'after' => $after,
|
||||||
|
'rng' => $tracingRng->calls,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$input = stream_get_contents(STDIN);
|
||||||
|
$request = json_decode($input === '' ? '{}' : $input, true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
if (!is_array($request)) {
|
||||||
|
throw new \InvalidArgumentException('request must be an object');
|
||||||
|
}
|
||||||
|
echo json_encode(
|
||||||
|
comparisonRunTurnCommand($request),
|
||||||
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION,
|
||||||
|
), PHP_EOL;
|
||||||
|
} catch (\Throwable $throwable) {
|
||||||
|
fwrite(STDERR, $throwable::class . ': ' . $throwable->getMessage() . PHP_EOL);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,661 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
use sammo\Enums\RankColumn;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli') {
|
||||||
|
http_response_code(404);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
require_once 'lib.php';
|
||||||
|
require_once 'func.php';
|
||||||
|
|
||||||
|
/** @return list<int> */
|
||||||
|
function comparisonIntegerList(mixed $value, string $label): array
|
||||||
|
{
|
||||||
|
if ($value === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!is_array($value)) {
|
||||||
|
throw new \InvalidArgumentException("{$label} must be an array");
|
||||||
|
}
|
||||||
|
$result = [];
|
||||||
|
foreach ($value as $entry) {
|
||||||
|
if (!is_int($entry) || $entry < 0) {
|
||||||
|
throw new \InvalidArgumentException("{$label} entries must be non-negative integers");
|
||||||
|
}
|
||||||
|
$result[$entry] = $entry;
|
||||||
|
}
|
||||||
|
ksort($result, SORT_NUMERIC);
|
||||||
|
return array_values($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonJsonValue(mixed $value): mixed
|
||||||
|
{
|
||||||
|
if (!is_string($value) || $value === '') {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return json_decode($value, true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
} catch (\JsonException) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonOptionalCode(mixed $value): ?string
|
||||||
|
{
|
||||||
|
if (!is_string($value) || $value === '' || $value === 'None') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return list<array{generalId: int, actionName: string}> */
|
||||||
|
function comparisonGeneralCooldownSelectors(mixed $value, string $label): array
|
||||||
|
{
|
||||||
|
if ($value === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!is_array($value)) {
|
||||||
|
throw new \InvalidArgumentException("{$label} must be an array");
|
||||||
|
}
|
||||||
|
$result = [];
|
||||||
|
foreach ($value as $entry) {
|
||||||
|
if (!is_array($entry)) {
|
||||||
|
throw new \InvalidArgumentException("{$label} entries must be objects");
|
||||||
|
}
|
||||||
|
$generalId = $entry['generalId'] ?? null;
|
||||||
|
$actionName = $entry['actionName'] ?? null;
|
||||||
|
if (!is_int($generalId) || $generalId < 1 || !is_string($actionName) || $actionName === '') {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"{$label} entries require a positive generalId and non-empty actionName",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$result["{$generalId}:{$actionName}"] = [
|
||||||
|
'generalId' => $generalId,
|
||||||
|
'actionName' => $actionName,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
ksort($result, SORT_STRING);
|
||||||
|
return array_values($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return list<array{nationId: int, actionName: string}> */
|
||||||
|
function comparisonNationCooldownSelectors(mixed $value, string $label): array
|
||||||
|
{
|
||||||
|
if ($value === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!is_array($value)) {
|
||||||
|
throw new \InvalidArgumentException("{$label} must be an array");
|
||||||
|
}
|
||||||
|
$result = [];
|
||||||
|
foreach ($value as $entry) {
|
||||||
|
if (!is_array($entry)) {
|
||||||
|
throw new \InvalidArgumentException("{$label} entries must be objects");
|
||||||
|
}
|
||||||
|
$nationId = $entry['nationId'] ?? null;
|
||||||
|
$actionName = $entry['actionName'] ?? null;
|
||||||
|
if (!is_int($nationId) || $nationId < 1 || !is_string($actionName) || $actionName === '') {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"{$label} entries require a positive nationId and non-empty actionName",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$result["{$nationId}:{$actionName}"] = [
|
||||||
|
'nationId' => $nationId,
|
||||||
|
'actionName' => $actionName,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
ksort($result, SORT_STRING);
|
||||||
|
return array_values($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return list<array{fromNationId: int, toNationId: int}> */
|
||||||
|
function comparisonDiplomacyPairSelectors(mixed $value, string $label): array
|
||||||
|
{
|
||||||
|
if ($value === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!is_array($value)) {
|
||||||
|
throw new \InvalidArgumentException("{$label} must be an array");
|
||||||
|
}
|
||||||
|
$result = [];
|
||||||
|
foreach ($value as $entry) {
|
||||||
|
if (!is_array($entry)) {
|
||||||
|
throw new \InvalidArgumentException("{$label} entries must be objects");
|
||||||
|
}
|
||||||
|
$fromNationId = $entry['fromNationId'] ?? null;
|
||||||
|
$toNationId = $entry['toNationId'] ?? null;
|
||||||
|
if (!is_int($fromNationId) || $fromNationId < 1 || !is_int($toNationId) || $toNationId < 1) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"{$label} entries require positive fromNationId and toNationId",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$result["{$fromNationId}:{$toNationId}"] = [
|
||||||
|
'fromNationId' => $fromNationId,
|
||||||
|
'toNationId' => $toNationId,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
ksort($result, SORT_STRING);
|
||||||
|
return array_values($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string, mixed> $row */
|
||||||
|
function comparisonPickRow(array $row, array $mapping, array $jsonKeys = []): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
foreach ($mapping as $canonical => $legacy) {
|
||||||
|
if (!array_key_exists($legacy, $row)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$value = $row[$legacy];
|
||||||
|
if (in_array($legacy, $jsonKeys, true)) {
|
||||||
|
$value = comparisonJsonValue($value);
|
||||||
|
}
|
||||||
|
$result[$canonical] = $value;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param list<int> $ids */
|
||||||
|
function comparisonRowsById(string $table, string $idColumn, array $ids): array
|
||||||
|
{
|
||||||
|
$db = DB::db();
|
||||||
|
$rows = [];
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
$row = $db->queryFirstRow(
|
||||||
|
"SELECT * FROM `{$table}` WHERE `{$idColumn}` = %i",
|
||||||
|
$id,
|
||||||
|
);
|
||||||
|
if ($row !== null) {
|
||||||
|
$rows[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonTurnStateSnapshot(array $request): array
|
||||||
|
{
|
||||||
|
$db = DB::db();
|
||||||
|
$observe = $request['observe'] ?? [];
|
||||||
|
if (!is_array($observe)) {
|
||||||
|
throw new \InvalidArgumentException('observe must be an object');
|
||||||
|
}
|
||||||
|
$generalIds = comparisonIntegerList($observe['generalIds'] ?? [], 'generalIds');
|
||||||
|
$cityIds = comparisonIntegerList($observe['cityIds'] ?? [], 'cityIds');
|
||||||
|
$nationIds = comparisonIntegerList($observe['nationIds'] ?? [], 'nationIds');
|
||||||
|
if (($observe['allGenerals'] ?? false) === true) {
|
||||||
|
$generalIds = array_map('intval', $db->queryFirstColumn('SELECT no FROM general ORDER BY no'));
|
||||||
|
}
|
||||||
|
if (($observe['allCities'] ?? false) === true) {
|
||||||
|
$cityIds = array_map('intval', $db->queryFirstColumn('SELECT city FROM city ORDER BY city'));
|
||||||
|
}
|
||||||
|
if (($observe['allNations'] ?? false) === true) {
|
||||||
|
$nationIds = array_map('intval', $db->queryFirstColumn('SELECT nation FROM nation ORDER BY nation'));
|
||||||
|
}
|
||||||
|
$logAfterId = $observe['logAfterId'] ?? 0;
|
||||||
|
$messageAfterId = $observe['messageAfterId'] ?? 0;
|
||||||
|
$includeNationHistoryLogs = $observe['includeNationHistoryLogs'] ?? false;
|
||||||
|
$includeGlobalHistoryLogs = $observe['includeGlobalHistoryLogs'] ?? false;
|
||||||
|
$generalCooldownSelectors = comparisonGeneralCooldownSelectors(
|
||||||
|
$observe['generalCooldowns'] ?? [],
|
||||||
|
'generalCooldowns',
|
||||||
|
);
|
||||||
|
$nationCooldownSelectors = comparisonNationCooldownSelectors(
|
||||||
|
$observe['nationCooldowns'] ?? [],
|
||||||
|
'nationCooldowns',
|
||||||
|
);
|
||||||
|
$diplomacyPairSelectors = comparisonDiplomacyPairSelectors(
|
||||||
|
$observe['diplomacyPairs'] ?? [],
|
||||||
|
'diplomacyPairs',
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
!is_int($logAfterId)
|
||||||
|
|| $logAfterId < 0
|
||||||
|
|| !is_int($messageAfterId)
|
||||||
|
|| $messageAfterId < 0
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException('logAfterId and messageAfterId must be non-negative integers');
|
||||||
|
}
|
||||||
|
if (!is_bool($includeNationHistoryLogs)) {
|
||||||
|
throw new \InvalidArgumentException('includeNationHistoryLogs must be a boolean');
|
||||||
|
}
|
||||||
|
if (!is_bool($includeGlobalHistoryLogs)) {
|
||||||
|
throw new \InvalidArgumentException('includeGlobalHistoryLogs must be a boolean');
|
||||||
|
}
|
||||||
|
|
||||||
|
$game = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$game->resetCache();
|
||||||
|
$clock = GameClock::fromStorage($game);
|
||||||
|
$worldValues = $game->getValues([
|
||||||
|
'year',
|
||||||
|
'month',
|
||||||
|
'turnterm',
|
||||||
|
'turntime',
|
||||||
|
'isunited',
|
||||||
|
'scenario',
|
||||||
|
'init_year',
|
||||||
|
'init_month',
|
||||||
|
'develcost',
|
||||||
|
'killturn',
|
||||||
|
]);
|
||||||
|
$nextExecuteStorage = KVStorage::getStorage($db, 'next_execute');
|
||||||
|
$nextExecuteStorage->resetCache();
|
||||||
|
$generalCooldowns = array_map(
|
||||||
|
static function (array $selector) use ($nextExecuteStorage): array {
|
||||||
|
$key = "next_execute_{$selector['generalId']}_{$selector['actionName']}";
|
||||||
|
$value = $nextExecuteStorage->getValue($key);
|
||||||
|
return [
|
||||||
|
...$selector,
|
||||||
|
'nextAvailableTurn' => is_int($value) ? $value : null,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
$generalCooldownSelectors,
|
||||||
|
);
|
||||||
|
$nationCooldowns = array_map(
|
||||||
|
static function (array $selector) use ($db): array {
|
||||||
|
$nationStorage = KVStorage::getStorage($db, $selector['nationId'], 'nation_env');
|
||||||
|
$nationStorage->resetCache();
|
||||||
|
$value = $nationStorage->getValue("next_execute_{$selector['actionName']}");
|
||||||
|
return [
|
||||||
|
...$selector,
|
||||||
|
'nextAvailableTurn' => is_int($value) ? $value : null,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
$nationCooldownSelectors,
|
||||||
|
);
|
||||||
|
|
||||||
|
$generals = array_map(
|
||||||
|
static function (array $row) use ($clock): array {
|
||||||
|
$result = comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'no',
|
||||||
|
'name' => 'name',
|
||||||
|
'nationId' => 'nation',
|
||||||
|
'cityId' => 'city',
|
||||||
|
'troopId' => 'troop',
|
||||||
|
'leadership' => 'leadership',
|
||||||
|
'strength' => 'strength',
|
||||||
|
'intelligence' => 'intel',
|
||||||
|
'experience' => 'experience',
|
||||||
|
'dedication' => 'dedication',
|
||||||
|
'expLevel' => 'explevel',
|
||||||
|
'officerLevel' => 'officer_level',
|
||||||
|
'officerCityId' => 'officer_city',
|
||||||
|
'belong' => 'belong',
|
||||||
|
'permission' => 'permission',
|
||||||
|
'betray' => 'betray',
|
||||||
|
'makeLimit' => 'makelimit',
|
||||||
|
'injury' => 'injury',
|
||||||
|
'gold' => 'gold',
|
||||||
|
'rice' => 'rice',
|
||||||
|
'crew' => 'crew',
|
||||||
|
'crewTypeId' => 'crewtype',
|
||||||
|
'train' => 'train',
|
||||||
|
'atmos' => 'atmos',
|
||||||
|
'age' => 'age',
|
||||||
|
'npcState' => 'npc',
|
||||||
|
'turnTime' => 'turntime',
|
||||||
|
'recentWarTime' => 'recent_war',
|
||||||
|
'lastTurn' => 'last_turn',
|
||||||
|
'meta' => 'aux',
|
||||||
|
'penalty' => 'penalty',
|
||||||
|
'leadershipExp' => 'leadership_exp',
|
||||||
|
'strengthExp' => 'strength_exp',
|
||||||
|
'intelExp' => 'intel_exp',
|
||||||
|
'dex1' => 'dex1',
|
||||||
|
'dex2' => 'dex2',
|
||||||
|
'dex3' => 'dex3',
|
||||||
|
'dex4' => 'dex4',
|
||||||
|
'dex5' => 'dex5',
|
||||||
|
'specAge' => 'specage',
|
||||||
|
'specAge2' => 'specage2',
|
||||||
|
'killTurn' => 'killturn',
|
||||||
|
'mySet' => 'myset',
|
||||||
|
'specialDomestic' => 'special',
|
||||||
|
'specialWar' => 'special2',
|
||||||
|
'personality' => 'personal',
|
||||||
|
'itemHorse' => 'horse',
|
||||||
|
'itemWeapon' => 'weapon',
|
||||||
|
'itemBook' => 'book',
|
||||||
|
'itemExtra' => 'item',
|
||||||
|
],
|
||||||
|
['last_turn', 'aux', 'penalty'],
|
||||||
|
);
|
||||||
|
foreach ([
|
||||||
|
'specialDomestic',
|
||||||
|
'specialWar',
|
||||||
|
'personality',
|
||||||
|
'itemHorse',
|
||||||
|
'itemWeapon',
|
||||||
|
'itemBook',
|
||||||
|
'itemExtra',
|
||||||
|
] as $key) {
|
||||||
|
$result[$key] = comparisonOptionalCode($result[$key] ?? null);
|
||||||
|
}
|
||||||
|
$result['turnTime'] = $clock->formatTick(Util::toInt($row['turntime']), true);
|
||||||
|
$result['recentWarTime'] = $row['recent_war'] === null
|
||||||
|
? null
|
||||||
|
: $clock->formatTick(Util::toInt($row['recent_war']), true);
|
||||||
|
$result['maxBelong'] = (int)($result['meta']['max_belong'] ?? 0);
|
||||||
|
$ownerId = (int)($row['owner'] ?? 0);
|
||||||
|
$activeActionPoints = 0;
|
||||||
|
if ($ownerId > 0) {
|
||||||
|
$inheritanceStorage = KVStorage::getStorage(DB::db(), "inheritance_{$ownerId}");
|
||||||
|
$inheritanceStorage->resetCache();
|
||||||
|
$stored = $inheritanceStorage->getValue('active_action');
|
||||||
|
if (is_array($stored) && (is_int($stored[0] ?? null) || is_float($stored[0] ?? null))) {
|
||||||
|
$activeActionPoints = $stored[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$result['hasOwner'] = $ownerId > 0;
|
||||||
|
$result['inheritActiveActionPoints'] = $activeActionPoints;
|
||||||
|
return $result;
|
||||||
|
},
|
||||||
|
comparisonRowsById('general', 'no', $generalIds),
|
||||||
|
);
|
||||||
|
$rankTypes = array_map(
|
||||||
|
static fn(RankColumn $column): string => $column->value,
|
||||||
|
RankColumn::cases(),
|
||||||
|
);
|
||||||
|
$rankData = $generalIds === []
|
||||||
|
? []
|
||||||
|
: iterator_to_array($db->query(
|
||||||
|
'SELECT general_id AS generalId, nation_id AS nationId, `type`, `value`'
|
||||||
|
. ' FROM rank_data WHERE general_id IN %li AND `type` IN %ls'
|
||||||
|
. ' ORDER BY general_id, `type`',
|
||||||
|
$generalIds,
|
||||||
|
$rankTypes,
|
||||||
|
));
|
||||||
|
|
||||||
|
$cities = array_map(
|
||||||
|
static fn(array $row): array => comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'city',
|
||||||
|
'name' => 'name',
|
||||||
|
'nationId' => 'nation',
|
||||||
|
'level' => 'level',
|
||||||
|
'population' => 'pop',
|
||||||
|
'populationMax' => 'pop_max',
|
||||||
|
'agriculture' => 'agri',
|
||||||
|
'agricultureMax' => 'agri_max',
|
||||||
|
'commerce' => 'comm',
|
||||||
|
'commerceMax' => 'comm_max',
|
||||||
|
'security' => 'secu',
|
||||||
|
'securityMax' => 'secu_max',
|
||||||
|
'supplyState' => 'supply',
|
||||||
|
'frontState' => 'front',
|
||||||
|
'defence' => 'def',
|
||||||
|
'defenceMax' => 'def_max',
|
||||||
|
'wall' => 'wall',
|
||||||
|
'wallMax' => 'wall_max',
|
||||||
|
'state' => 'state',
|
||||||
|
'term' => 'term',
|
||||||
|
'trust' => 'trust',
|
||||||
|
'trade' => 'trade',
|
||||||
|
'conflict' => 'conflict',
|
||||||
|
'officerSet' => 'officer_set',
|
||||||
|
],
|
||||||
|
['conflict'],
|
||||||
|
),
|
||||||
|
comparisonRowsById('city', 'city', $cityIds),
|
||||||
|
);
|
||||||
|
|
||||||
|
$nations = array_map(
|
||||||
|
static function (array $row) use ($db): array {
|
||||||
|
$projected = comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'nation',
|
||||||
|
'name' => 'name',
|
||||||
|
'color' => 'color',
|
||||||
|
'capitalCityId' => 'capital',
|
||||||
|
'gold' => 'gold',
|
||||||
|
'rice' => 'rice',
|
||||||
|
'tech' => 'tech',
|
||||||
|
'level' => 'level',
|
||||||
|
'typeCode' => 'type',
|
||||||
|
'generalCount' => 'gennum',
|
||||||
|
'power' => 'power',
|
||||||
|
'war' => 'war',
|
||||||
|
'diplomacyLimit' => 'surlimit',
|
||||||
|
'capitalRevision' => 'capset',
|
||||||
|
'strategicCommandLimit' => 'strategic_cmd_limit',
|
||||||
|
'meta' => 'aux',
|
||||||
|
],
|
||||||
|
['aux'],
|
||||||
|
);
|
||||||
|
$nationStor = KVStorage::getStorage($db, (int)$row['nation'], 'nation_env');
|
||||||
|
$receivedAssist = $nationStor->getValue('recv_assist');
|
||||||
|
if (is_array($receivedAssist) && $receivedAssist !== []) {
|
||||||
|
$projected['meta']['recv_assist'] = $receivedAssist;
|
||||||
|
}
|
||||||
|
$respondedAssist = $nationStor->getValue('resp_assist');
|
||||||
|
if (is_array($respondedAssist) && $respondedAssist !== []) {
|
||||||
|
$projected['meta']['resp_assist'] = $respondedAssist;
|
||||||
|
}
|
||||||
|
return $projected;
|
||||||
|
},
|
||||||
|
comparisonRowsById('nation', 'nation', $nationIds),
|
||||||
|
);
|
||||||
|
|
||||||
|
$diplomacyPairs = [];
|
||||||
|
foreach ($nationIds as $fromNationId) {
|
||||||
|
foreach ($nationIds as $toNationId) {
|
||||||
|
if ($fromNationId === $toNationId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$diplomacyPairs["{$fromNationId}:{$toNationId}"] = [
|
||||||
|
'fromNationId' => $fromNationId,
|
||||||
|
'toNationId' => $toNationId,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($diplomacyPairSelectors as $pair) {
|
||||||
|
$diplomacyPairs["{$pair['fromNationId']}:{$pair['toNationId']}"] = $pair;
|
||||||
|
}
|
||||||
|
ksort($diplomacyPairs, SORT_STRING);
|
||||||
|
|
||||||
|
$diplomacy = [];
|
||||||
|
foreach ($diplomacyPairs as $pair) {
|
||||||
|
$row = $db->queryFirstRow(
|
||||||
|
'SELECT me, you, state, term, dead FROM diplomacy WHERE me = %i AND you = %i',
|
||||||
|
$pair['fromNationId'],
|
||||||
|
$pair['toNationId'],
|
||||||
|
);
|
||||||
|
if ($row !== null) {
|
||||||
|
$diplomacy[] = comparisonPickRow($row, [
|
||||||
|
'fromNationId' => 'me',
|
||||||
|
'toNationId' => 'you',
|
||||||
|
'state' => 'state',
|
||||||
|
'term' => 'term',
|
||||||
|
'dead' => 'dead',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$generalTurns = [];
|
||||||
|
foreach ($generalIds as $generalId) {
|
||||||
|
foreach ($db->query(
|
||||||
|
'SELECT general_id, turn_idx, action, arg FROM general_turn WHERE general_id = %i ORDER BY turn_idx',
|
||||||
|
$generalId,
|
||||||
|
) as $row) {
|
||||||
|
$generalTurns[] = comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
['generalId' => 'general_id', 'turnIndex' => 'turn_idx', 'action' => 'action', 'args' => 'arg'],
|
||||||
|
['arg'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$nationTurns = [];
|
||||||
|
foreach ($nationIds as $nationId) {
|
||||||
|
foreach ($db->query(
|
||||||
|
'SELECT nation_id, officer_level, turn_idx, action, arg FROM nation_turn WHERE nation_id = %i ORDER BY officer_level, turn_idx',
|
||||||
|
$nationId,
|
||||||
|
) as $row) {
|
||||||
|
$nationTurns[] = comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'nationId' => 'nation_id',
|
||||||
|
'officerLevel' => 'officer_level',
|
||||||
|
'turnIndex' => 'turn_idx',
|
||||||
|
'action' => 'action',
|
||||||
|
'args' => 'arg',
|
||||||
|
],
|
||||||
|
['arg'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$logs = [];
|
||||||
|
if ($generalIds !== []) {
|
||||||
|
foreach ($db->query(
|
||||||
|
'SELECT id, general_id, log_type, year, month, text FROM general_record WHERE id > %i ORDER BY id',
|
||||||
|
$logAfterId,
|
||||||
|
) as $row) {
|
||||||
|
if ((int)$row['general_id'] !== 0 && !in_array((int)$row['general_id'], $generalIds, true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$generalId = (int)$row['general_id'];
|
||||||
|
$category = (string)$row['log_type'];
|
||||||
|
if ($category === 'battle') {
|
||||||
|
$category = 'battle_detail';
|
||||||
|
} elseif ($generalId === 0) {
|
||||||
|
$category = 'summary';
|
||||||
|
}
|
||||||
|
$logs[] = comparisonPickRow($row, [
|
||||||
|
'id' => 'id',
|
||||||
|
'generalId' => 'general_id',
|
||||||
|
'year' => 'year',
|
||||||
|
'month' => 'month',
|
||||||
|
'text' => 'text',
|
||||||
|
]) + [
|
||||||
|
'scope' => $generalId === 0 ? 'system' : 'general',
|
||||||
|
'category' => $category,
|
||||||
|
'nationId' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($includeNationHistoryLogs && $nationIds !== []) {
|
||||||
|
foreach ($db->query(
|
||||||
|
'SELECT id, nation_id, year, month, text FROM world_history WHERE nation_id IN %li ORDER BY id',
|
||||||
|
$nationIds,
|
||||||
|
) as $row) {
|
||||||
|
$logs[] = comparisonPickRow($row, [
|
||||||
|
'id' => 'id',
|
||||||
|
'nationId' => 'nation_id',
|
||||||
|
'year' => 'year',
|
||||||
|
'month' => 'month',
|
||||||
|
'text' => 'text',
|
||||||
|
]) + [
|
||||||
|
'scope' => 'nation',
|
||||||
|
'category' => 'history',
|
||||||
|
'generalId' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($includeGlobalHistoryLogs) {
|
||||||
|
foreach ($db->query(
|
||||||
|
'SELECT id, nation_id, year, month, text FROM world_history WHERE nation_id = 0 ORDER BY id',
|
||||||
|
) as $row) {
|
||||||
|
$logs[] = comparisonPickRow($row, [
|
||||||
|
'id' => 'id',
|
||||||
|
'nationId' => 'nation_id',
|
||||||
|
'year' => 'year',
|
||||||
|
'month' => 'month',
|
||||||
|
'text' => 'text',
|
||||||
|
]) + [
|
||||||
|
'scope' => 'system',
|
||||||
|
'category' => 'history',
|
||||||
|
'generalId' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$messages = array_map(
|
||||||
|
static function (array $row) use ($clock): array {
|
||||||
|
$result = comparisonPickRow(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
'id' => 'id',
|
||||||
|
'mailbox' => 'mailbox',
|
||||||
|
'type' => 'type',
|
||||||
|
'sourceId' => 'src',
|
||||||
|
'destinationId' => 'dest',
|
||||||
|
'createdAt' => 'time',
|
||||||
|
'payload' => 'message',
|
||||||
|
],
|
||||||
|
['message'],
|
||||||
|
);
|
||||||
|
$result['createdAt'] = $clock->formatTick(Util::toInt($row['time']), true);
|
||||||
|
return $result;
|
||||||
|
},
|
||||||
|
$db->query(
|
||||||
|
'SELECT id, mailbox, type, src, dest, time, message FROM message WHERE id > %i ORDER BY id',
|
||||||
|
$messageAfterId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'world' => [
|
||||||
|
'year' => (int)$worldValues['year'],
|
||||||
|
'month' => (int)$worldValues['month'],
|
||||||
|
'tickMinutes' => (int)$worldValues['turnterm'],
|
||||||
|
'turnTime' => $clock->formatTick(Util::toInt($worldValues['turntime']), true),
|
||||||
|
'isUnited' => (int)$worldValues['isunited'],
|
||||||
|
'scenarioId' => (int)$worldValues['scenario'],
|
||||||
|
'initYear' => (int)$worldValues['init_year'],
|
||||||
|
'initMonth' => (int)$worldValues['init_month'],
|
||||||
|
'develCost' => (int)$worldValues['develcost'],
|
||||||
|
'killTurn' => (int)$worldValues['killturn'],
|
||||||
|
'generalCooldowns' => $generalCooldowns,
|
||||||
|
'nationCooldowns' => $nationCooldowns,
|
||||||
|
],
|
||||||
|
'generals' => $generals,
|
||||||
|
'rankData' => $rankData,
|
||||||
|
'cities' => $cities,
|
||||||
|
'nations' => $nations,
|
||||||
|
'diplomacy' => $diplomacy,
|
||||||
|
'generalTurns' => $generalTurns,
|
||||||
|
'nationTurns' => $nationTurns,
|
||||||
|
'logs' => $logs,
|
||||||
|
'messages' => $messages,
|
||||||
|
'watermarks' => [
|
||||||
|
'logId' => (int)($db->queryFirstField('SELECT COALESCE(MAX(id), 0) FROM general_record') ?? 0),
|
||||||
|
'historyLogId' => (int)($db->queryFirstField('SELECT COALESCE(MAX(id), 0) FROM world_history') ?? 0),
|
||||||
|
'messageId' => (int)($db->queryFirstField('SELECT COALESCE(MAX(id), 0) FROM message') ?? 0),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function comparisonTurnStateSnapshotMain(): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$input = stream_get_contents(STDIN);
|
||||||
|
$request = json_decode($input === '' ? '{}' : $input, true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
if (!is_array($request)) {
|
||||||
|
throw new \InvalidArgumentException('request must be an object');
|
||||||
|
}
|
||||||
|
echo json_encode(
|
||||||
|
comparisonTurnStateSnapshot($request),
|
||||||
|
JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION,
|
||||||
|
), PHP_EOL;
|
||||||
|
} catch (\Throwable $throwable) {
|
||||||
|
fwrite(STDERR, $throwable::class . ': ' . $throwable->getMessage() . PHP_EOL);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (realpath((string)($_SERVER['SCRIPT_FILENAME'] ?? '')) === __FILE__) {
|
||||||
|
comparisonTurnStateSnapshotMain();
|
||||||
|
}
|
||||||
@@ -51,6 +51,22 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.picture_choice {
|
||||||
|
margin: 8px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.picture_choice label,
|
||||||
|
.event_picture label {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
margin: 4px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.picture_choice img {
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
.custom_picture {
|
.custom_picture {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -61,4 +77,4 @@
|
|||||||
|
|
||||||
.custom_stat {
|
.custom_stat {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
+127
-127
@@ -112,7 +112,7 @@ function GetImageURL($imgsvr, $filepath = '')
|
|||||||
function checkLimit($refreshScore = null)
|
function checkLimit($refreshScore = null)
|
||||||
{
|
{
|
||||||
$session = Session::getInstance();
|
$session = Session::getInstance();
|
||||||
if ($session->userGrade >= 4) {
|
if ($session->userGrade >= 6) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,7 +630,11 @@ function generalInfo(General $generalObj)
|
|||||||
$injury = "건강";
|
$injury = "건강";
|
||||||
}
|
}
|
||||||
|
|
||||||
$remaining = (new \DateTimeImmutable($generalObj->getTurnTime()))->diff(new \DateTimeImmutable())->i;
|
$clock = GameClock::fromStorage(KVStorage::getStorage(DB::db(), 'game_env'));
|
||||||
|
$remaining = max(0, intdiv(
|
||||||
|
$generalObj->getTurnTick() - $clock->nowTick(),
|
||||||
|
$clock->ticksFromMinutes(1),
|
||||||
|
));
|
||||||
|
|
||||||
if ($nation['color'] == "") {
|
if ($nation['color'] == "") {
|
||||||
$nation['color'] = "#000000";
|
$nation['color'] = "#000000";
|
||||||
@@ -921,45 +925,37 @@ function banner()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTurn($date, int $turnterm, int $turn = 1, bool $withFraction = true)
|
function addTurn(int $tick, int $turnterm, int $turn = 1, bool $withFraction = true): int
|
||||||
{
|
{
|
||||||
$date = new \DateTime($date);
|
return $tick + GameClock::TICKS_PER_TURN * $turn;
|
||||||
$target = $turnterm * $turn;
|
}
|
||||||
$date->add(new \DateInterval("PT{$target}M"));
|
|
||||||
if ($withFraction) {
|
function subTurn(int $tick, int $turnterm, int $turn = 1, bool $withFraction = true): int
|
||||||
return $date->format('Y-m-d H:i:s.u');
|
{
|
||||||
}
|
return $tick - GameClock::TICKS_PER_TURN * $turn;
|
||||||
return $date->format('Y-m-d H:i:s');
|
}
|
||||||
}
|
|
||||||
|
function cutTurn(int $tick, int $turnterm, bool $withFraction = true): int
|
||||||
function subTurn($date, int $turnterm, int $turn = 1, bool $withFraction = true)
|
{
|
||||||
{
|
$remainder = $tick % GameClock::TICKS_PER_TURN;
|
||||||
$date = new \DateTime($date);
|
if ($remainder < 0) {
|
||||||
$target = $turnterm * $turn;
|
$remainder += GameClock::TICKS_PER_TURN;
|
||||||
$date->sub(new \DateInterval("PT{$target}M"));
|
}
|
||||||
if ($withFraction) {
|
return $tick - $remainder;
|
||||||
return $date->format('Y-m-d H:i:s.u');
|
}
|
||||||
}
|
|
||||||
return $date->format('Y-m-d H:i:s');
|
/** 시나리오 초기화 입력인 벽시계를 기존 01:00 기준 월 경계로 정렬합니다. */
|
||||||
}
|
function cutTurnDateTime(string $date, int $turnterm, bool $withFraction = true): string
|
||||||
|
{
|
||||||
function cutTurn($date, int $turnterm, bool $withFraction = true)
|
$dateObj = new \DateTime($date);
|
||||||
{
|
$baseDate = new \DateTime($dateObj->format('Y-m-d'));
|
||||||
$date = new \DateTime($date);
|
$baseDate->sub(new \DateInterval('P1D'));
|
||||||
|
$baseDate->add(new \DateInterval('PT1H'));
|
||||||
$baseDate = new \DateTime($date->format('Y-m-d'));
|
$diffMin = intdiv($dateObj->getTimestamp() - $baseDate->getTimestamp(), 60);
|
||||||
$baseDate->sub(new \DateInterval("P1D"));
|
$diffMin -= $diffMin % $turnterm;
|
||||||
$baseDate->add(new \DateInterval("PT1H"));
|
$baseDate->add(new \DateInterval("PT{$diffMin}M"));
|
||||||
|
return $baseDate->format($withFraction ? 'Y-m-d H:i:s.u' : 'Y-m-d H:i:s');
|
||||||
$diffMin = intdiv($date->getTimeStamp() - $baseDate->getTimeStamp(), 60);
|
}
|
||||||
$diffMin -= $diffMin % $turnterm;
|
|
||||||
|
|
||||||
$baseDate->add(new \DateInterval("PT{$diffMin}M"));
|
|
||||||
if ($withFraction) {
|
|
||||||
return $baseDate->format('Y-m-d H:i:s.u');
|
|
||||||
}
|
|
||||||
return $baseDate->format('Y-m-d H:i:s');
|
|
||||||
}
|
|
||||||
|
|
||||||
function cutDay($date, int $turnterm, bool $withFraction = true)
|
function cutDay($date, int $turnterm, bool $withFraction = true)
|
||||||
{
|
{
|
||||||
@@ -1001,15 +997,13 @@ function increaseRefresh($type = "", $cnt = 1)
|
|||||||
$generalID = $session->generalID;
|
$generalID = $session->generalID;
|
||||||
$userGrade = $session->userGrade;
|
$userGrade = $session->userGrade;
|
||||||
|
|
||||||
$dateObj = new \DateTimeImmutable();
|
$db = DB::db();
|
||||||
$date = TimeUtil::format($dateObj, false);
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$date = GameClock::fromStorage($gameStor)->nowTick();
|
||||||
$db = DB::db();
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
|
||||||
$isunited = $gameStor->isunited;
|
$isunited = $gameStor->isunited;
|
||||||
$opentime = $gameStor->opentime;
|
$opentime = $gameStor->opentime;
|
||||||
|
|
||||||
if ($userGrade == 6) {
|
if ($userGrade >= 6) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($isunited == 2) {
|
if ($isunited == 2) {
|
||||||
@@ -1047,7 +1041,7 @@ function increaseRefresh($type = "", $cnt = 1)
|
|||||||
|
|
||||||
$logDB = FileDB::db($logPath, $serverPath . '/../f_install/sql/api_log.sql');
|
$logDB = FileDB::db($logPath, $serverPath . '/../f_install/sql/api_log.sql');
|
||||||
|
|
||||||
$ip = $_SERVER['REMOTE_ADDR'] ?? 'local';
|
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? 'local';
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
$logDB->insert('api_log', [
|
$logDB->insert('api_log', [
|
||||||
@@ -1088,12 +1082,12 @@ function updateTraffic()
|
|||||||
if(count($recentTraffic) >= 5){
|
if(count($recentTraffic) >= 5){
|
||||||
array_shift($recentTraffic);
|
array_shift($recentTraffic);
|
||||||
}
|
}
|
||||||
$recentTraffic[] = [
|
$recentTraffic[] = [
|
||||||
'year'=>$admin['year'],
|
'year'=>$admin['year'],
|
||||||
'month' => $admin['month'],
|
'month' => $admin['month'],
|
||||||
'refresh' => $admin['refresh'],
|
'refresh' => $admin['refresh'],
|
||||||
'online' => $online,
|
'online' => $online,
|
||||||
'date' => TimeUtil::now(),
|
'date' => GameClock::fromStorage($gameStor)->formatNow(),
|
||||||
];
|
];
|
||||||
$gameStor->recentTraffic = $recentTraffic;
|
$gameStor->recentTraffic = $recentTraffic;
|
||||||
|
|
||||||
@@ -1107,7 +1101,7 @@ function CheckOverhead()
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
[$turnterm, $refreshLimit] = $gameStor->getValuesAsArray(['turnterm', 'refreshLimit']);
|
[$turnterm, $refreshLimit] = $gameStor->getValuesAsArray(['turnterm', 'refreshLimit']);
|
||||||
|
|
||||||
$nextRefreshLimit = Util::round(pow($turnterm, 0.6) * 3) * 10;
|
$nextRefreshLimit = Util::round(pow($turnterm, 0.6) * 3) * GameConst::$refreshLimitCoef;
|
||||||
|
|
||||||
|
|
||||||
if ($nextRefreshLimit != $refreshLimit) {
|
if ($nextRefreshLimit != $refreshLimit) {
|
||||||
@@ -1145,18 +1139,19 @@ function unlock(): bool
|
|||||||
return $db->affectedRows() > 0;
|
return $db->affectedRows() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function timeover(): bool
|
function timeover(): bool
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
list($turnterm, $turntime) = $gameStor->getValuesAsArray(['turnterm', 'turntime']);
|
list($turnterm, $turntime) = $gameStor->getValuesAsArray(['turnterm', 'turntime']);
|
||||||
$diff = (new \DateTime())->getTimestamp() - (new \DateTime($turntime))->getTimestamp();
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
$diff = $clock->nowTick() - Util::toInt($turntime);
|
||||||
|
|
||||||
$t = min($turnterm, 5);
|
$t = min($turnterm, 5);
|
||||||
|
|
||||||
$term = $diff;
|
$term = $clock->ticksFromSeconds($t);
|
||||||
if ($term >= $t || $term < 0) {
|
if ($diff >= $term || $diff < 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -1169,9 +1164,8 @@ function checkDelay()
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
//서버정보
|
//서버정보
|
||||||
$now = new \DateTimeImmutable();
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
$turntime = new \DateTimeImmutable($gameStor->turntime);
|
$timeMinDiff = intdiv($clock->nowTick() - Util::toInt($gameStor->turntime), $clock->ticksFromMinutes(1));
|
||||||
$timeMinDiff = intdiv($now->getTimestamp() - $turntime->getTimestamp(), 60);
|
|
||||||
|
|
||||||
// 1턴이상 갱신 없었으면 서버 지연
|
// 1턴이상 갱신 없었으면 서버 지연
|
||||||
$term = $gameStor->turnterm;
|
$term = $gameStor->turnterm;
|
||||||
@@ -1185,20 +1179,17 @@ function checkDelay()
|
|||||||
//지연 해야할 밀린 턴 횟수
|
//지연 해야할 밀린 턴 횟수
|
||||||
$iter = intdiv($timeMinDiff, $term);
|
$iter = intdiv($timeMinDiff, $term);
|
||||||
if ($iter > $threshold) {
|
if ($iter > $threshold) {
|
||||||
$minute = $iter * $term;
|
$minute = $iter * $term;
|
||||||
$newTurntime = $turntime->add(new \DateInterval("PT{$minute}M"));
|
$delayTick = $clock->ticksFromMinutes($minute);
|
||||||
$newNextTurntime = $turntime->add(new \DateInterval("PT{$term}M"));
|
$gameStor->turntime = Util::toInt($gameStor->turntime) + $delayTick;
|
||||||
$gameStor->turntime = $newTurntime->format('Y-m-d H:i:s');
|
$gameStor->starttime = Util::toInt($gameStor->starttime) + $delayTick;
|
||||||
$gameStor->starttime = (new \DateTimeImmutable($gameStor->starttime))
|
|
||||||
->add(new \DateInterval("PT{$minute}M"))
|
$db->update('general', [
|
||||||
->format('Y-m-d H:i:s');
|
'turntime' => $db->sqleval('turntime + %i', $delayTick)
|
||||||
|
], true);
|
||||||
$db->update('general', [
|
$db->update('ng_auction', [
|
||||||
'turntime' => $db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
|
'close_tick' => $db->sqleval('close_tick + %i', $delayTick)
|
||||||
], 'turntime<=DATE_ADD(turntime, INTERVAL %i MINUTE)', $term);
|
], 'finished = 0');
|
||||||
$db->update('ng_auction', [
|
|
||||||
'close_date' => $db->sqleval('DATE_ADD(close_date, INTERVAL %i MINUTE)', $minute)
|
|
||||||
], 'finished = 0');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1247,17 +1238,15 @@ function updateOnline()
|
|||||||
$gameStor->online_nation = join(', ', $onlineNation);
|
$gameStor->online_nation = join(', ', $onlineNation);
|
||||||
}
|
}
|
||||||
|
|
||||||
function turnDate($curtime)
|
function turnDate($curtime)
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$admin = $gameStor->getValues(['startyear', 'starttime', 'turnterm', 'year', 'month']);
|
$admin = $gameStor->getValues(['startyear', 'starttime', 'turnterm', 'year', 'month']);
|
||||||
|
|
||||||
$turn = $admin['starttime'];
|
$turn = $admin['starttime'];
|
||||||
$curturn = cutTurn($curtime, $admin['turnterm']);
|
$curturn = cutTurn(Util::toInt($curtime), $admin['turnterm']);
|
||||||
$term = $admin['turnterm'];
|
$num = intdiv($curturn - Util::toInt($turn), GameClock::TICKS_PER_TURN);
|
||||||
|
|
||||||
$num = intdiv((strtotime($curturn) - strtotime($turn)), $term * 60);
|
|
||||||
|
|
||||||
$date = $admin['startyear'] * 12;
|
$date = $admin['startyear'] * 12;
|
||||||
$date += $num;
|
$date += $num;
|
||||||
@@ -1387,12 +1376,14 @@ function CheckHall($no)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$unitedDate = TimeUtil::now();
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
$unitedDate = $clock->formatTick($clock->nowTick());
|
||||||
$nation = $generalObj->getStaticNation();
|
$nation = $generalObj->getStaticNation();
|
||||||
|
|
||||||
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games');
|
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games');
|
||||||
|
|
||||||
[$scenarioIdx, $scenarioName, $startTime] = $gameStor->getValuesAsArray(['scenario', 'scenario_text', 'starttime']);
|
[$scenarioIdx, $scenarioName, $startTick] = $gameStor->getValuesAsArray(['scenario', 'scenario_text', 'starttime']);
|
||||||
|
$startTime = $clock->formatTick(Util::toInt($startTick));
|
||||||
|
|
||||||
$ownerName = $generalObj->getVar('owner_name');
|
$ownerName = $generalObj->getVar('owner_name');
|
||||||
if ($generalObj->getVar('owner')) {
|
if ($generalObj->getVar('owner')) {
|
||||||
@@ -1401,8 +1392,11 @@ function CheckHall($no)
|
|||||||
|
|
||||||
foreach ($types as [$typeName, $valueType]) {
|
foreach ($types as [$typeName, $valueType]) {
|
||||||
|
|
||||||
if ($valueType === 'natural') {
|
if ($valueType === 'natural') {
|
||||||
$value = $generalObj->getVar($typeName);
|
$value = $generalObj->getVar($typeName);
|
||||||
|
if (in_array($typeName, ['dex1', 'dex2', 'dex3', 'dex4', 'dex5'], true)) {
|
||||||
|
$value = CentennialAllStarGrowthService::recordableValue($generalObj, $typeName);
|
||||||
|
}
|
||||||
} else if ($valueType === 'rank') {
|
} else if ($valueType === 'rank') {
|
||||||
$value = $generalObj->getRankVar(RankColumn::from($typeName));
|
$value = $generalObj->getRankVar(RankColumn::from($typeName));
|
||||||
} else if ($valueType === 'calc') {
|
} else if ($valueType === 'calc') {
|
||||||
@@ -1669,8 +1663,6 @@ function tryUniqueItemLottery(RandUtil $rng, General $general, string $acquireTy
|
|||||||
$prob = 1 / ($genCount * $itemTypeCnt * 0.7 / 3); // 투표율 70%, 설문조사 한번에 2~3개 등장
|
$prob = 1 / ($genCount * $itemTypeCnt * 0.7 / 3); // 투표율 70%, 설문조사 한번에 2~3개 등장
|
||||||
} else if ($acquireType == '랜덤 임관') {
|
} else if ($acquireType == '랜덤 임관') {
|
||||||
$prob = 1 / ($genCount * $itemTypeCnt / 10 / 2); // 랜임시 2개(10%) 등장(200명중 20명 랜임시도?)
|
$prob = 1 / ($genCount * $itemTypeCnt / 10 / 2); // 랜임시 2개(10%) 등장(200명중 20명 랜임시도?)
|
||||||
} else if ($acquireType == '건국') {
|
|
||||||
$prob = 1 / ($genCount * $itemTypeCnt / 10 / 4); // 건국시 4개(20%) 등장(200명시 20국 정도 됨)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$prob *= GameConst::$uniqueTrialCoef;
|
$prob *= GameConst::$uniqueTrialCoef;
|
||||||
@@ -1684,6 +1676,9 @@ function tryUniqueItemLottery(RandUtil $rng, General $general, string $acquireTy
|
|||||||
//포인트로 랜덤 유니크 획득
|
//포인트로 랜덤 유니크 획득
|
||||||
$prob = 1;
|
$prob = 1;
|
||||||
}
|
}
|
||||||
|
else if ($acquireType == '건국') {
|
||||||
|
$prob = 1; // 건국시 100%
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Util::range($maxCnt) as $_idx) {
|
foreach (Util::range($maxCnt) as $_idx) {
|
||||||
if ($rng->nextBool($prob)) {
|
if ($rng->nextBool($prob)) {
|
||||||
@@ -1701,12 +1696,21 @@ function tryUniqueItemLottery(RandUtil $rng, General $general, string $acquireTy
|
|||||||
return giveRandomUniqueItem($rng, $general, $acquireType);
|
return giveRandomUniqueItem($rng, $general, $acquireType);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAdmin()
|
function getAdmin()
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
return $gameStor->getAll();
|
$admin = $gameStor->getAll();
|
||||||
}
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
foreach (['turntime', 'starttime', 'opentime', 'tnmt_time'] as $key) {
|
||||||
|
if (($admin[$key] ?? null) !== null) {
|
||||||
|
$admin["{$key}_display"] = $clock->formatTick(Util::toInt($admin[$key]), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$admin['clock_now_tick'] = $clock->nowTick();
|
||||||
|
$admin['clock_now_display'] = $clock->formatTick($admin['clock_now_tick'], true);
|
||||||
|
return $admin;
|
||||||
|
}
|
||||||
|
|
||||||
/** @return General[] */
|
/** @return General[] */
|
||||||
function deleteNation(General $lord, bool $applyDB): array
|
function deleteNation(General $lord, bool $applyDB): array
|
||||||
@@ -1784,11 +1788,13 @@ function deleteNation(General $lord, bool $applyDB): array
|
|||||||
// 부대 삭제
|
// 부대 삭제
|
||||||
$db->delete('troop', 'nation=%i', $nationID);
|
$db->delete('troop', 'nation=%i', $nationID);
|
||||||
|
|
||||||
// 국가 삭제
|
// 국가 삭제
|
||||||
$db->insert('ng_old_nations', [
|
$gameDate = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'))->formatNow();
|
||||||
'server_id' => UniqueConst::$serverID,
|
$db->insert('ng_old_nations', [
|
||||||
'nation' => $nationID,
|
'server_id' => UniqueConst::$serverID,
|
||||||
'data' => Json::encode($nation)
|
'nation' => $nationID,
|
||||||
|
'date' => $gameDate,
|
||||||
|
'data' => Json::encode($nation)
|
||||||
]);
|
]);
|
||||||
$db->delete('nation', 'nation=%i', $nationID);
|
$db->delete('nation', 'nation=%i', $nationID);
|
||||||
$db->delete('nation_turn', 'nation_id=%i', $nationID);
|
$db->delete('nation_turn', 'nation_id=%i', $nationID);
|
||||||
@@ -2195,35 +2201,29 @@ function SabotageInjury(RandUtil $rng, array $cityGeneralList, string $reason):
|
|||||||
return $injuryCount;
|
return $injuryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandTurn(RandUtil $rng, $term, ?\DateTimeInterface $baseDateTime = null)
|
function getRandTurn(RandUtil $rng, int $term, ?int $baseTick = null): int
|
||||||
{
|
{
|
||||||
if ($baseDateTime === null) {
|
$db = DB::db();
|
||||||
$baseDateTime = new \DateTimeImmutable();
|
$clock = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'));
|
||||||
} else if ($baseDateTime instanceof \DateTime) {
|
$baseTick ??= $clock->nowTick();
|
||||||
$baseDateTime = \DateTimeImmutable::createFromMutable($baseDateTime);
|
|
||||||
} else if ($baseDateTime instanceof \DateTimeImmutable) {
|
$randSecond = $rng->nextRangeInt(0, 60 * $term - 1);
|
||||||
//do Nothing
|
$randMicrosecond = $rng->nextRangeInt(0, 999999); // 레거시 RNG 소비 6자리 유지
|
||||||
} else {
|
|
||||||
throw new MustNotBeReachedException();
|
return $baseTick
|
||||||
}
|
+ $clock->ticksFromSeconds($randSecond)
|
||||||
|
+ intdiv($randMicrosecond * $clock->ticksPerSecond(), 1_000_000);
|
||||||
$randSecond = $rng->nextRangeInt(0, 60 * $term - 1);
|
}
|
||||||
$randFraction = $rng->nextRangeInt(0, 999999) / 1000000; //6자리 소수
|
|
||||||
|
function getRandTurn2(RandUtil $rng, int $term, ?int $baseTick = null): int
|
||||||
return TimeUtil::format($baseDateTime->add(TimeUtil::secondsToDateInterval($randSecond + $randFraction)), true);
|
{
|
||||||
}
|
$db = DB::db();
|
||||||
|
$clock = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'));
|
||||||
function getRandTurn2(RandUtil $rng, $term, ?\DateTimeInterface $baseDateTime = null)
|
$baseTick ??= $clock->nowTick();
|
||||||
{
|
$randSecond = $rng->nextRangeInt(0, 60 * $term - 1);
|
||||||
if ($baseDateTime === null) {
|
$randMicrosecond = $rng->nextRangeInt(0, 999999); // 레거시 RNG 소비 6자리 유지
|
||||||
$baseDateTime = new \DateTimeImmutable();
|
|
||||||
} else if ($baseDateTime instanceof \DateTime) {
|
return $baseTick
|
||||||
$baseDateTime = \DateTimeImmutable::createFromMutable($baseDateTime);
|
- $clock->ticksFromSeconds($randSecond)
|
||||||
} else {
|
- intdiv($randMicrosecond * $clock->ticksPerSecond(), 1_000_000);
|
||||||
throw new MustNotBeReachedException();
|
}
|
||||||
}
|
|
||||||
$randSecond = $rng->nextRangeInt(0, 60 * $term - 1);
|
|
||||||
$randFraction = $rng->nextRangeInt(0, 999999) / 1000000; //6자리 소수
|
|
||||||
|
|
||||||
return $baseDateTime->sub(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s.u');
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -62,11 +62,12 @@ function processAuction()
|
|||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$now = TimeUtil::now();
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$nowTick = GameClock::fromStorage($gameStor)->nowTick();
|
||||||
|
|
||||||
$auctionList = $db->queryAllLists(
|
$auctionList = $db->queryAllLists(
|
||||||
'SELECT id, `type` FROM ng_auction WHERE `close_date` <= %s AND finished = 0',
|
'SELECT id, `type` FROM ng_auction WHERE `close_tick` <= %i AND finished = 0',
|
||||||
$now
|
$nowTick
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$auctionList) {
|
if (!$auctionList) {
|
||||||
|
|||||||
+72
-37
@@ -42,15 +42,21 @@ function pushGeneralCommand(int $generalID, int $turnCnt=1){
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$db->update('general_turn', [
|
$db->query(
|
||||||
'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt)
|
'UPDATE general_turn AS dst
|
||||||
], 'general_id=%i ORDER BY turn_idx DESC', $generalID);
|
LEFT JOIN general_turn AS src
|
||||||
$db->update('general_turn', [
|
ON src.general_id = dst.general_id
|
||||||
'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxTurn),
|
AND src.turn_idx = dst.turn_idx - %i
|
||||||
'action'=>'휴식',
|
SET dst.action = IF(src.id IS NULL, %s, src.action),
|
||||||
'arg'=>'{}',
|
dst.arg = IF(src.id IS NULL, %s, src.arg),
|
||||||
'brief'=>'휴식'
|
dst.brief = IF(src.id IS NULL, %s, src.brief)
|
||||||
], 'general_id=%i AND turn_idx >= %i', $generalID, GameConst::$maxTurn);
|
WHERE dst.general_id = %i',
|
||||||
|
$turnCnt,
|
||||||
|
'휴식',
|
||||||
|
'{}',
|
||||||
|
'휴식',
|
||||||
|
$generalID
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pullGeneralCommand(int $generalID, int $turnCnt=1){
|
function pullGeneralCommand(int $generalID, int $turnCnt=1){
|
||||||
@@ -67,15 +73,21 @@ function pullGeneralCommand(int $generalID, int $turnCnt=1){
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$db->update('general_turn', [
|
$db->query(
|
||||||
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxTurn),
|
'UPDATE general_turn AS dst
|
||||||
'action'=>'휴식',
|
LEFT JOIN general_turn AS src
|
||||||
'arg'=>'{}',
|
ON src.general_id = dst.general_id
|
||||||
'brief'=>'휴식'
|
AND src.turn_idx = dst.turn_idx + %i
|
||||||
], 'general_id=%i AND turn_idx < %i', $generalID, $turnCnt);
|
SET dst.action = IF(src.id IS NULL, %s, src.action),
|
||||||
$db->update('general_turn', [
|
dst.arg = IF(src.id IS NULL, %s, src.arg),
|
||||||
'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt)
|
dst.brief = IF(src.id IS NULL, %s, src.brief)
|
||||||
], 'general_id=%i ORDER BY turn_idx ASC', $generalID);
|
WHERE dst.general_id = %i',
|
||||||
|
$turnCnt,
|
||||||
|
'휴식',
|
||||||
|
'{}',
|
||||||
|
'휴식',
|
||||||
|
$generalID
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function repeatGeneralCommand(int $generalId, int $turnCnt){
|
function repeatGeneralCommand(int $generalId, int $turnCnt){
|
||||||
@@ -126,15 +138,23 @@ function pushNationCommand(int $nationID, int $officerLevel, int $turnCnt=1){
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$db->update('nation_turn', [
|
$db->query(
|
||||||
'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt)
|
'UPDATE nation_turn AS dst
|
||||||
], 'nation_id=%i AND officer_level=%i ORDER BY turn_idx DESC', $nationID, $officerLevel);
|
LEFT JOIN nation_turn AS src
|
||||||
$db->update('nation_turn', [
|
ON src.nation_id = dst.nation_id
|
||||||
'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxChiefTurn),
|
AND src.officer_level = dst.officer_level
|
||||||
'action'=>'휴식',
|
AND src.turn_idx = dst.turn_idx - %i
|
||||||
'arg'=>'{}',
|
SET dst.action = IF(src.id IS NULL, %s, src.action),
|
||||||
'brief'=>'휴식'
|
dst.arg = IF(src.id IS NULL, %s, src.arg),
|
||||||
], 'nation_id=%i AND officer_level=%i AND turn_idx >= %i ORDER BY turn_idx ASC', $nationID, $officerLevel, GameConst::$maxChiefTurn);
|
dst.brief = IF(src.id IS NULL, %s, src.brief)
|
||||||
|
WHERE dst.nation_id = %i AND dst.officer_level = %i',
|
||||||
|
$turnCnt,
|
||||||
|
'휴식',
|
||||||
|
'{}',
|
||||||
|
'휴식',
|
||||||
|
$nationID,
|
||||||
|
$officerLevel
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pullNationCommand(int $nationID, int $officerLevel, int $turnCnt=1){
|
function pullNationCommand(int $nationID, int $officerLevel, int $turnCnt=1){
|
||||||
@@ -157,15 +177,23 @@ function pullNationCommand(int $nationID, int $officerLevel, int $turnCnt=1){
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$db->update('nation_turn', [
|
$db->query(
|
||||||
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxChiefTurn),
|
'UPDATE nation_turn AS dst
|
||||||
'action'=>'휴식',
|
LEFT JOIN nation_turn AS src
|
||||||
'arg'=>'{}',
|
ON src.nation_id = dst.nation_id
|
||||||
'brief'=>'휴식',
|
AND src.officer_level = dst.officer_level
|
||||||
], 'nation_id=%i AND officer_level=%i AND turn_idx < %i', $nationID, $officerLevel, $turnCnt);
|
AND src.turn_idx = dst.turn_idx + %i
|
||||||
$db->update('nation_turn', [
|
SET dst.action = IF(src.id IS NULL, %s, src.action),
|
||||||
'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt)
|
dst.arg = IF(src.id IS NULL, %s, src.arg),
|
||||||
], 'nation_id=%i AND officer_level=%i ORDER BY turn_idx ASC', $nationID, $officerLevel);
|
dst.brief = IF(src.id IS NULL, %s, src.brief)
|
||||||
|
WHERE dst.nation_id = %i AND dst.officer_level = %i',
|
||||||
|
$turnCnt,
|
||||||
|
'휴식',
|
||||||
|
'{}',
|
||||||
|
'휴식',
|
||||||
|
$nationID,
|
||||||
|
$officerLevel
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function repeatNationCommand(int $nationID, int $officerLevel, int $turnCnt){
|
function repeatNationCommand(int $nationID, int $officerLevel, int $turnCnt){
|
||||||
@@ -481,10 +509,17 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
|
|||||||
}
|
}
|
||||||
|
|
||||||
_setNationCommand($commandObj, $turnList);
|
_setNationCommand($commandObj, $turnList);
|
||||||
|
|
||||||
|
if($general->getNPCType() < 2){
|
||||||
|
//유저장인 경우에는 턴 리필
|
||||||
|
$general->updateVarWithLimit('killturn', $env['killturn'], $general->getVar('killturn'));
|
||||||
|
$general->applyDB($db);
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'brief'=>$commandObj->getBrief(),
|
'brief'=>$commandObj->getBrief(),
|
||||||
'arg_test'=>true,
|
'arg_test'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-1
@@ -457,6 +457,29 @@ function buildWarUnitTriggerClass(?string $type, WarUnit $unit, ?array $args = n
|
|||||||
return $class->newInstanceArgs(array_merge([$unit], $args));
|
return $class->newInstanceArgs(array_merge([$unit], $args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStaticEventClass(string $type){
|
||||||
|
static $basePath = __NAMESPACE__.'\\StaticEvent\\';
|
||||||
|
$classPath = ($basePath.$type);
|
||||||
|
|
||||||
|
if(class_exists($classPath)){
|
||||||
|
return $classPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \InvalidArgumentException("{$type}은 StaticEvent가 아님");
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildStaticEventClass(?string $type):BaseStaticEvent{
|
||||||
|
static $cache = [];
|
||||||
|
if(key_exists($type, $cache)){
|
||||||
|
return $cache[$type];
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = getStaticEventClass($type);
|
||||||
|
$obj = new $class();
|
||||||
|
$cache[$type] = $obj;
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
function getGeneralPoolClass(string $type){
|
function getGeneralPoolClass(string $type){
|
||||||
static $basePath = __NAMESPACE__.'\\GeneralPool\\';
|
static $basePath = __NAMESPACE__.'\\GeneralPool\\';
|
||||||
$classPath = ($basePath.$type);
|
$classPath = ($basePath.$type);
|
||||||
@@ -663,7 +686,7 @@ function TechLimit($startYear, $year, $tech) : bool {
|
|||||||
$relYear = $year - $startYear;
|
$relYear = $year - $startYear;
|
||||||
|
|
||||||
$relMaxTech = Util::valueFit(
|
$relMaxTech = Util::valueFit(
|
||||||
floor($relYear / 5) + 1,
|
floor($relYear / GameConst::$techLevelIncYear) + GameConst::$initialAllowedTechLevel,
|
||||||
1,
|
1,
|
||||||
GameConst::$maxTechLevel
|
GameConst::$maxTechLevel
|
||||||
);
|
);
|
||||||
|
|||||||
+60
-18
@@ -319,7 +319,38 @@ function postUpdateMonthly(RandUtil $rng)
|
|||||||
|
|
||||||
//약간의 랜덤치 부여 (95% ~ 105%)
|
//약간의 랜덤치 부여 (95% ~ 105%)
|
||||||
|
|
||||||
$nation['power'] = Util::round($nation['power'] * $rng->nextRange(0.95, 1.05));
|
$powerMultiplier = $rng->nextRange(0.95, 1.05);
|
||||||
|
$basePower = $nation['power'];
|
||||||
|
$nation['power'] = Util::round($basePower * $powerMultiplier);
|
||||||
|
$traceNationIDs = getenv('REF_TRACE_NATION_POWER_IDS');
|
||||||
|
if (
|
||||||
|
PHP_SAPI === 'cli'
|
||||||
|
&& getenv('REF_DETERMINISTIC_INSTALL_ENABLED') === '1'
|
||||||
|
&& is_string($traceNationIDs)
|
||||||
|
&& in_array((string) $nationID, explode(',', $traceNationIDs), true)
|
||||||
|
) {
|
||||||
|
$traceComponents = $db->queryFirstRow('SELECT
|
||||||
|
((A.gold + A.rice) + (SELECT SUM(gold + rice) FROM general WHERE nation = A.nation)) / 100 AS resourcePowerRaw,
|
||||||
|
ROUND(((A.gold + A.rice) + (SELECT SUM(gold + rice) FROM general WHERE nation = A.nation)) / 100) AS resourcePower,
|
||||||
|
A.tech AS techPower,
|
||||||
|
(SELECT 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) AS cityPowerRaw,
|
||||||
|
(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) FROM city WHERE nation = A.nation AND supply = 1) AS cityPower,
|
||||||
|
(SELECT SUM((ra.value + 1000) / (rb.value + 1000) * (CASE WHEN g.npc < 2 THEN 1.2 ELSE 1 END) * (CASE WHEN g.leadership >= 40 THEN g.leadership ELSE 0 END) * 2 + (SQRT(g.intel * g.strength) * 2 + g.leadership / 2) / 2)
|
||||||
|
FROM general g
|
||||||
|
LEFT JOIN rank_data ra ON g.no = ra.general_id AND ra.type = \'killcrew_person\'
|
||||||
|
LEFT JOIN rank_data rb ON g.no = rb.general_id AND rb.type = \'deathcrew_person\'
|
||||||
|
WHERE g.nation = A.nation) AS generalPower,
|
||||||
|
(SELECT SUM(experience + dedication) / 100 FROM general WHERE nation = A.nation) AS experiencePowerRaw,
|
||||||
|
(SELECT ROUND(SUM(experience + dedication) / 100) FROM general WHERE nation = A.nation) AS experiencePower
|
||||||
|
FROM nation A WHERE A.nation = %i', $nationID) ?? [];
|
||||||
|
fwrite(STDOUT, 'NATION_POWER_TRACE ' . Json::encode([
|
||||||
|
'nationId' => $nationID,
|
||||||
|
...$traceComponents,
|
||||||
|
'basePower' => $basePower,
|
||||||
|
'multiplier' => $powerMultiplier,
|
||||||
|
'power' => $nation['power'],
|
||||||
|
]) . PHP_EOL);
|
||||||
|
}
|
||||||
$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']));
|
||||||
|
|
||||||
@@ -559,7 +590,7 @@ function checkStatistic()
|
|||||||
|
|
||||||
$nationHist = '';
|
$nationHist = '';
|
||||||
foreach (GameConst::$availableNationType as $nationType) {
|
foreach (GameConst::$availableNationType as $nationType) {
|
||||||
if (!Util::array_get($nationHists[$nationType])) {
|
if (!($nationHists[$nationType] ?? null)) {
|
||||||
$nationHists[$nationType] = '-';
|
$nationHists[$nationType] = '-';
|
||||||
}
|
}
|
||||||
$nationHist .= getNationType($nationType) . "({$nationHists[$nationType]}), ";
|
$nationHist .= getNationType($nationType) . "({$nationHists[$nationType]}), ";
|
||||||
@@ -651,16 +682,24 @@ function checkStatistic()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function convForOldGeneral(array $general, int $year, int $month)
|
function convForOldGeneral(array $general, int $year, int $month)
|
||||||
{
|
{
|
||||||
$general['history'] = getGeneralHistoryLogAll($general['no']);
|
$general['history'] = getGeneralHistoryLogAll($general['no']);
|
||||||
return [
|
$clock = GameClock::fromStorage(KVStorage::getStorage(DB::db(), 'game_env'));
|
||||||
|
$turnTimeDisplay = $clock->formatTick(Util::toInt($general['turntime']), true);
|
||||||
|
$general['turntime_tick'] = Util::toInt($general['turntime']);
|
||||||
|
$general['turntime'] = $turnTimeDisplay;
|
||||||
|
if ($general['recent_war'] !== null) {
|
||||||
|
$general['recent_war_tick'] = Util::toInt($general['recent_war']);
|
||||||
|
$general['recent_war'] = $clock->formatTick(Util::toInt($general['recent_war']), true);
|
||||||
|
}
|
||||||
|
return [
|
||||||
'server_id' => UniqueConst::$serverID,
|
'server_id' => UniqueConst::$serverID,
|
||||||
'general_no' => $general['no'],
|
'general_no' => $general['no'],
|
||||||
'owner' => $general['owner'],
|
'owner' => $general['owner'],
|
||||||
'name' => $general['name'],
|
'name' => $general['name'],
|
||||||
'last_yearmonth' => $year * 100 + $month,
|
'last_yearmonth' => $year * 100 + $month,
|
||||||
'turntime' => $general['turntime'],
|
'turntime' => $turnTimeDisplay,
|
||||||
'data' => Json::encode($general)
|
'data' => Json::encode($general)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -734,7 +773,7 @@ function checkEmperior()
|
|||||||
|
|
||||||
/** @var int[] */
|
/** @var int[] */
|
||||||
$auctionList = $db->queryFirstColumn(
|
$auctionList = $db->queryFirstColumn(
|
||||||
'SELECT `id` FROM `ng_auction` WHERE `type` = %s AND `finished` = 0 ORDER BY `close_date` ASC',
|
'SELECT `id` FROM `ng_auction` WHERE `type` = %s AND `finished` = 0 ORDER BY `close_tick` ASC',
|
||||||
AuctionType::UniqueItem->value
|
AuctionType::UniqueItem->value
|
||||||
);
|
);
|
||||||
foreach($auctionList as $auctionID){
|
foreach($auctionList as $auctionID){
|
||||||
@@ -830,20 +869,23 @@ function checkEmperior()
|
|||||||
$nation['aux'] += $nationStor->max_power ?? [];
|
$nation['aux'] += $nationStor->max_power ?? [];
|
||||||
$nation['history'] = getNationHistoryLogAll($nation['nation']);
|
$nation['history'] = getNationHistoryLogAll($nation['nation']);
|
||||||
|
|
||||||
storeOldGenerals(0, $admin['year'], $admin['month']);
|
storeOldGenerals(0, $admin['year'], $admin['month']);
|
||||||
storeOldGenerals($nation['nation'], $admin['year'], $admin['month']);
|
storeOldGenerals($nation['nation'], $admin['year'], $admin['month']);
|
||||||
|
$gameDate = GameClock::fromStorage($gameStor)->formatNow();
|
||||||
$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'],
|
||||||
|
'date' => $gameDate,
|
||||||
|
'data' => Json::encode($nation)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$noNationGeneral = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=0');
|
$noNationGeneral = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=0');
|
||||||
$db->insert('ng_old_nations', [
|
$db->insert('ng_old_nations', [
|
||||||
'server_id' => UniqueConst::$serverID,
|
'server_id' => UniqueConst::$serverID,
|
||||||
'nation' => 0,
|
'nation' => 0,
|
||||||
'data' => Json::encode([
|
'date' => $gameDate,
|
||||||
|
'data' => Json::encode([
|
||||||
'nation' => 0,
|
'nation' => 0,
|
||||||
'name' => '재야',
|
'name' => '재야',
|
||||||
'generals' => $noNationGeneral
|
'generals' => $noNationGeneral
|
||||||
|
|||||||
+6
-2
@@ -4,6 +4,10 @@ namespace sammo;
|
|||||||
|
|
||||||
function printLimitMsg($turntime)
|
function printLimitMsg($turntime)
|
||||||
{
|
{
|
||||||
|
if (is_int($turntime) || (is_string($turntime) && ctype_digit(ltrim($turntime, '-')))) {
|
||||||
|
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
|
$turntime = GameClock::fromStorage($gameStor)->formatTick(Util::toInt($turntime), true);
|
||||||
|
}
|
||||||
//FIXME: template로 이동.
|
//FIXME: template로 이동.
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -138,7 +142,7 @@ function JSCitiesBasedOnDistance(int $cityNo, int $maxDistance = 1): array{
|
|||||||
$distanceList = searchDistance($cityNo, $maxDistance, true);
|
$distanceList = searchDistance($cityNo, $maxDistance, true);
|
||||||
$result = [];
|
$result = [];
|
||||||
for ($dist = 1; $dist <= $maxDistance; $dist++) {
|
for ($dist = 1; $dist <= $maxDistance; $dist++) {
|
||||||
$result[$dist] = Util::array_get($distanceList[$dist], []);
|
$result[$dist] = $distanceList[$dist] ?? [];
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -152,7 +156,7 @@ function printCitiesBasedOnDistance(int $cityNo, int $maxDistance = 1): string
|
|||||||
for ($dist = 1; $dist <= $maxDistance; $dist++) {
|
for ($dist = 1; $dist <= $maxDistance; $dist++) {
|
||||||
$cityList = array_map(function ($cityID) {
|
$cityList = array_map(function ($cityID) {
|
||||||
return CityConst::byID($cityID)->name;
|
return CityConst::byID($cityID)->name;
|
||||||
}, Util::array_get($distanceList[$dist], []));
|
}, $distanceList[$dist] ?? []);
|
||||||
|
|
||||||
$cityStr = join(', ', $cityList);
|
$cityStr = join(', ', $cityList);
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,12 @@ function chiefTurnTable()
|
|||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
function templateLimitMsg(string $turntime): string
|
function templateLimitMsg(string $turntime): string
|
||||||
{
|
{
|
||||||
|
if (ctype_digit(ltrim($turntime, '-'))) {
|
||||||
|
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
|
$turntime = GameClock::fromStorage($gameStor)->formatTick(Util::toInt($turntime), true);
|
||||||
|
}
|
||||||
return "이미 너무 많은 접속을 하셨습니다. 다음 턴에 다시 시도해주세요. (턴시간: {$turntime})";
|
return "이미 너무 많은 접속을 하셨습니다. 다음 턴에 다시 시도해주세요. (턴시간: {$turntime})";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ function disaster(RandUtil $rng) {
|
|||||||
[$queryColumns,,] = General::mergeQueryColumn();
|
[$queryColumns,,] = General::mergeQueryColumn();
|
||||||
$generalListByCity = Util::arrayGroupBy(
|
$generalListByCity = Util::arrayGroupBy(
|
||||||
$db->query(
|
$db->query(
|
||||||
'SELECT %l FROM general WHERE city IN %li',
|
'SELECT %l FROM general WHERE city IN %li ORDER BY city, no',
|
||||||
Util::formatListOfBackticks($queryColumns),
|
Util::formatListOfBackticks($queryColumns),
|
||||||
Util::squeezeFromArray($targetCityList, 'city')
|
Util::squeezeFromArray($targetCityList, 'city')
|
||||||
),
|
),
|
||||||
|
|||||||
+26
-10
@@ -15,12 +15,21 @@ function calcTournamentTerm(int $turnTerm): int{
|
|||||||
|
|
||||||
function processTournament()
|
function processTournament()
|
||||||
{
|
{
|
||||||
|
if (
|
||||||
|
getenv('REF_DETERMINISTIC_INSTALL_ENABLED') === '1'
|
||||||
|
&& getenv('REF_DETERMINISTIC_TOURNAMENT_MODE') === 'hold'
|
||||||
|
) {
|
||||||
|
// Tournament randomness is independent from the monthly hidden-seed
|
||||||
|
// stream. Keep it out of deterministic monthly comparisons.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'tnmt_auto', 'tnmt_time', 'turnterm', 'last_tournament_betting_id']);
|
$admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'tnmt_auto', 'tnmt_time', 'turnterm', 'last_tournament_betting_id']);
|
||||||
$now = new \DateTime();
|
$offset = intdiv($clock->nowTick() - Util::toInt($admin['tnmt_time']), $clock->ticksPerSecond());
|
||||||
$offset = $now->getTimestamp() - (new \DateTime($admin['tnmt_time']))->getTimestamp();
|
|
||||||
|
|
||||||
//수동일땐 무시
|
//수동일땐 무시
|
||||||
if (!$admin['tnmt_auto']) {
|
if (!$admin['tnmt_auto']) {
|
||||||
@@ -122,10 +131,10 @@ function processTournament()
|
|||||||
if ($tnmt == 6) {
|
if ($tnmt == 6) {
|
||||||
$betTerm = Util::valueFit($unit * 60, null, 3600);
|
$betTerm = Util::valueFit($unit * 60, null, 3600);
|
||||||
//처리 초 더한 날짜
|
//처리 초 더한 날짜
|
||||||
$dt = date("Y-m-d H:i:s", strtotime($admin['tnmt_time']) + $unit * $i + $betTerm);
|
|
||||||
$gameStor->tournament = $tnmt;
|
$gameStor->tournament = $tnmt;
|
||||||
$gameStor->phase = $phase;
|
$gameStor->phase = $phase;
|
||||||
$gameStor->tnmt_time = $dt;
|
$gameStor->tnmt_time = Util::toInt($admin['tnmt_time'])
|
||||||
|
+ $clock->ticksFromSeconds($unit * $i + $betTerm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +142,7 @@ function processTournament()
|
|||||||
$second = $unit * $iter;
|
$second = $unit * $iter;
|
||||||
$gameStor->tournament = $tnmt;
|
$gameStor->tournament = $tnmt;
|
||||||
$gameStor->phase = $phase;
|
$gameStor->phase = $phase;
|
||||||
$gameStor->tnmt_time = (new \DateTimeImmutable($admin['tnmt_time']))->add(new \DateInterval("PT{$second}S"))->format('Y-m-d H:i:s');
|
$gameStor->tnmt_time = Util::toInt($admin['tnmt_time']) + $clock->ticksFromSeconds($second);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTournamentTermText(int $turnTerm)
|
function getTournamentTermText(int $turnTerm)
|
||||||
@@ -160,7 +169,8 @@ function getTournamentTime()
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
list($tnmt, $tnmt_time) = $gameStor->getValuesAsArray(['tournament', 'tnmt_time']);
|
list($tnmt, $tnmt_time) = $gameStor->getValuesAsArray(['tournament', 'tnmt_time']);
|
||||||
$dt = substr($tnmt_time, 11, 5);
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
$dt = substr($clock->formatTick(Util::toInt($tnmt_time)), 11, 5);
|
||||||
switch ($tnmt) {
|
switch ($tnmt) {
|
||||||
case 1:
|
case 1:
|
||||||
$tnmt = "개막시간 {$dt}";
|
$tnmt = "개막시간 {$dt}";
|
||||||
@@ -284,9 +294,11 @@ function startTournament($type)
|
|||||||
$admin = $gameStor->getValues(['year', 'month', 'turnterm']);
|
$admin = $gameStor->getValues(['year', 'month', 'turnterm']);
|
||||||
$turnTerm = $admin['turnterm'];
|
$turnTerm = $admin['turnterm'];
|
||||||
$unit = calcTournamentTerm($turnTerm);
|
$unit = calcTournamentTerm($turnTerm);
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
|
||||||
$gameStor->tnmt_auto = true;
|
$gameStor->tnmt_auto = true;
|
||||||
$gameStor->tnmt_time = (new \DateTimeImmutable())->add(new \DateInterval("PT{$unit}M"))->format('Y-m-d H:i:s');
|
// 기존 startTournament은 unit을 분으로 더하므로 그 계약을 유지합니다.
|
||||||
|
$gameStor->tnmt_time = $clock->nowTick() + $clock->ticksFromMinutes($unit);
|
||||||
$gameStor->tournament = 1;
|
$gameStor->tournament = 1;
|
||||||
$gameStor->tnmt_type = $type;
|
$gameStor->tnmt_type = $type;
|
||||||
$gameStor->last_tournament_betting_id = 0;
|
$gameStor->last_tournament_betting_id = 0;
|
||||||
@@ -1153,21 +1165,25 @@ function fight($tnmt_type, $tnmt, $phs, $group, $g1, $g2, $type)
|
|||||||
];
|
];
|
||||||
|
|
||||||
//막판 분노
|
//막판 분노
|
||||||
|
$factor1 = 1.0;
|
||||||
|
$factor2 = 1.0;
|
||||||
$ratio = rand() % 300;
|
$ratio = rand() % 300;
|
||||||
if ($e1 / 5 > $energy1 && $damage1 > $damage2 && $gen1[$tp] >= $ratio) {
|
if ($e1 / 5 > $energy1 && $damage1 > $damage2 && $gen1[$tp] >= $ratio) {
|
||||||
$damage2 *= Util::round((rand() % 301 + 200) / 100); // 200 ~ 500%
|
$factor2 = Util::round((rand() % 301 + 200) / 100); // 200 ~ 500%
|
||||||
$critical1 = 1;
|
$critical1 = 1;
|
||||||
$str = Util::choiceRandom($crticialSkillMap[$tnmt_type]);
|
$str = Util::choiceRandom($crticialSkillMap[$tnmt_type]);
|
||||||
$log[] = "<S>●</> <Y>{$gen1['name']}</>의 분노의 <M>{$str}</> 공격!";
|
$log[] = "<S>●</> <Y>{$gen1['name']}</>의 분노의 <M>{$str}</> 공격!";
|
||||||
}
|
}
|
||||||
$ratio = rand() % 300;
|
$ratio = rand() % 300;
|
||||||
if ($e2 / 5 > $energy2 && $damage2 > $damage1 && $gen2[$tp] >= $ratio) {
|
if ($e2 / 5 > $energy2 && $damage2 > $damage1 && $gen2[$tp] >= $ratio) {
|
||||||
$damage1 *= Util::round((rand() % 301 + 200) / 100); // 200 ~ 500%
|
$factor1 = Util::round((rand() % 301 + 200) / 100); // 200 ~ 500%
|
||||||
$critical2 = 1;
|
$critical2 = 1;
|
||||||
|
|
||||||
$str = Util::choiceRandom($crticialSkillMap[$tnmt_type]);
|
$str = Util::choiceRandom($crticialSkillMap[$tnmt_type]);
|
||||||
$log[] = "<S>●</> <Y>{$gen2['name']}</>의 분노의 <M>{$str}</> 공격!";
|
$log[] = "<S>●</> <Y>{$gen2['name']}</>의 분노의 <M>{$str}</> 공격!";
|
||||||
}
|
}
|
||||||
|
$damage1 *= $factor1;
|
||||||
|
$damage2 *= $factor2;
|
||||||
|
|
||||||
//1합 승부
|
//1합 승부
|
||||||
if ($phase == 1) {
|
if ($phase == 1) {
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -7,6 +7,7 @@ include "func.php";
|
|||||||
Session::requireLogin()->loginGame()->setReadOnly();
|
Session::requireLogin()->loginGame()->setReadOnly();
|
||||||
|
|
||||||
$mapName = GameConst::$mapName;
|
$mapName = GameConst::$mapName;
|
||||||
|
$frontClock = GameClock::fromStorage(KVStorage::getStorage(DB::db(), 'game_env'));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -28,7 +29,7 @@ $mapName = GameConst::$mapName;
|
|||||||
|
|
||||||
'maxTurn' => GameConst::$maxTurn,
|
'maxTurn' => GameConst::$maxTurn,
|
||||||
'maxPushTurn' => 12,
|
'maxPushTurn' => 12,
|
||||||
'serverNow' => TimeUtil::now(false),
|
'serverNow' => $frontClock->formatTick($frontClock->nowTick()),
|
||||||
]
|
]
|
||||||
], false) ?>
|
], false) ?>
|
||||||
<?= WebUtil::printJS('../d_shared/common_path.js') ?>
|
<?= WebUtil::printJS('../d_shared/common_path.js') ?>
|
||||||
@@ -42,4 +43,4 @@ $mapName = GameConst::$mapName;
|
|||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -7,10 +7,10 @@ include "func.php";
|
|||||||
|
|
||||||
$session = Session::requireLogin();
|
$session = Session::requireLogin();
|
||||||
|
|
||||||
if ($session->userGrade < 5) {
|
if ($session->userGrade < 6) {
|
||||||
die('관리자 아님');
|
die('관리자 아님');
|
||||||
}
|
}
|
||||||
if ($session->userGrade == 5) {
|
if ($session->userGrade == 6) {
|
||||||
die('DB 리셋 권한을 가지고 있지 않습니다.');
|
die('DB 리셋 권한을 가지고 있지 않습니다.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-12
@@ -25,21 +25,24 @@ if(!$reserved){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$reservedDate = new \DateTime($reserved['date']);
|
$reservedDate = new \DateTimeImmutable($reserved['date']);
|
||||||
$now = new \DateTime();
|
$now = GameClock::readWallTime();
|
||||||
|
|
||||||
|
|
||||||
$status = 'not_yet';
|
$status = 'not_yet';
|
||||||
|
|
||||||
list($isUnited, $lastTurn) = $gameStor->getValuesAsArray(['isunited', 'turntime']);
|
list($isUnited, $unitedWallAnchor) = $gameStor->getValuesAsArray(['isunited', 'autoreset_united_wall_anchor']);
|
||||||
if($isUnited === null || $lastTurn === null){
|
if($isUnited === null){
|
||||||
$isUnited = 2;
|
$isUnited = 2;
|
||||||
$lastTurn = '2000-01-01';
|
}
|
||||||
}
|
$lastTurn = null;
|
||||||
|
if($isUnited > 0){
|
||||||
if($lastTurn !== null){
|
if(!is_string($unitedWallAnchor) || $unitedWallAnchor === ''){
|
||||||
$lastTurn = new \DateTime($lastTurn);
|
$unitedWallAnchor = TimeUtil::format($now, true);
|
||||||
}
|
$gameStor->autoreset_united_wall_anchor = $unitedWallAnchor;
|
||||||
|
}
|
||||||
|
$lastTurn = new \DateTimeImmutable($unitedWallAnchor);
|
||||||
|
}
|
||||||
|
|
||||||
if($lastTurn === null){
|
if($lastTurn === null){
|
||||||
//이미 리셋된 상태임
|
//이미 리셋된 상태임
|
||||||
@@ -99,4 +102,4 @@ $result['affected']=1;
|
|||||||
$prefix = DB::prefix();
|
$prefix = DB::prefix();
|
||||||
ServConfig::getServerList()[$prefix]->openServer();
|
ServConfig::getServerList()[$prefix]->openServer();
|
||||||
|
|
||||||
Json::die($result);
|
Json::die($result);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
|||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
$clock = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'));
|
||||||
|
|
||||||
$isSecretBoard = Util::getPost('isSecret', 'bool', false);
|
$isSecretBoard = Util::getPost('isSecret', 'bool', false);
|
||||||
$title = Util::getPost('title');
|
$title = Util::getPost('title');
|
||||||
@@ -67,7 +68,7 @@ $icon = GetImageURL($me['imgsvr'], $me['picture']);
|
|||||||
$db->insert('board', [
|
$db->insert('board', [
|
||||||
'nation_no'=>$me['nation'],
|
'nation_no'=>$me['nation'],
|
||||||
'is_secret'=>$isSecretBoard,
|
'is_secret'=>$isSecretBoard,
|
||||||
'date'=>TimeUtil::now(),
|
'date'=>$clock->formatNow(),
|
||||||
'general_no'=>$me['no'],
|
'general_no'=>$me['no'],
|
||||||
'author'=>$me['name'],
|
'author'=>$me['name'],
|
||||||
'author_icon'=>$icon,
|
'author_icon'=>$icon,
|
||||||
@@ -79,4 +80,4 @@ Json::die([
|
|||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success',
|
'reason'=>'success',
|
||||||
'row_id'=>$db->insertId()
|
'row_id'=>$db->insertId()
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
|||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
$clock = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'));
|
||||||
|
|
||||||
$articleNo = Util::getPost('articleNo', 'int');
|
$articleNo = Util::getPost('articleNo', 'int');
|
||||||
$text = Util::getPost('text');
|
$text = Util::getPost('text');
|
||||||
@@ -73,7 +74,7 @@ else if ($isSecretBoard && $permission < 2) {
|
|||||||
$db->insert('comment', [
|
$db->insert('comment', [
|
||||||
'nation_no'=>$me['nation'],
|
'nation_no'=>$me['nation'],
|
||||||
'is_secret'=>$isSecretBoard,
|
'is_secret'=>$isSecretBoard,
|
||||||
'date'=>TimeUtil::now(),
|
'date'=>$clock->formatNow(),
|
||||||
'document_no'=>$articleNo,
|
'document_no'=>$articleNo,
|
||||||
'general_no'=>$me['no'],
|
'general_no'=>$me['no'],
|
||||||
'author'=>$me['name'],
|
'author'=>$me['name'],
|
||||||
@@ -84,4 +85,4 @@ Json::die([
|
|||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success',
|
'reason'=>'success',
|
||||||
'row_id'=>$db->insertId()
|
'row_id'=>$db->insertId()
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ else{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$now = new \DateTime();
|
$now = Message::gameNow();
|
||||||
$unlimited = new \DateTime('9999-12-31');
|
$unlimited = new \DateTime('9999-12-31');
|
||||||
|
|
||||||
if(in_array($stateOpt, ['try_destroy_src', 'try_destroy_dest'])){
|
if(in_array($stateOpt, ['try_destroy_src', 'try_destroy_dest'])){
|
||||||
@@ -138,4 +138,4 @@ Json::die([
|
|||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success',
|
'reason'=>'success',
|
||||||
'state'=>$lastState
|
'state'=>$lastState
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ $destNation = getNationStaticInfo($letter['dest_nation_id']);
|
|||||||
$src = new MessageTarget($me['no'], $me['name'], $destNation['nation'], $destNation['name'], $destNation['color'], $me['icon']);
|
$src = new MessageTarget($me['no'], $me['name'], $destNation['nation'], $destNation['name'], $destNation['color'], $me['icon']);
|
||||||
$dest = new MessageTarget(0, '', $srcNation['nation'], $srcNation['name'], $srcNation['color']);
|
$dest = new MessageTarget(0, '', $srcNation['nation'], $srcNation['name'], $srcNation['color']);
|
||||||
|
|
||||||
$now = new \DateTime();
|
$now = Message::gameNow();
|
||||||
$unlimited = new \DateTime('9999-12-31');
|
$unlimited = new \DateTime('9999-12-31');
|
||||||
|
|
||||||
if($isAgree){
|
if($isAgree){
|
||||||
@@ -133,4 +133,4 @@ $msgID = $msg->send();
|
|||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ $destNation = getNationStaticInfo($letter['dest_nation_id']);
|
|||||||
$src = new MessageTarget($me['no'], $me['name'], $srcNation['nation'], $srcNation['name'], $srcNation['color'], $me['icon']);
|
$src = new MessageTarget($me['no'], $me['name'], $srcNation['nation'], $srcNation['name'], $srcNation['color'], $me['icon']);
|
||||||
$dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']);
|
$dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']);
|
||||||
|
|
||||||
$now = new \DateTime();
|
$now = Message::gameNow();
|
||||||
$unlimited = new \DateTime('9999-12-31');
|
$unlimited = new \DateTime('9999-12-31');
|
||||||
|
|
||||||
$aux['reason'] = [
|
$aux['reason'] = [
|
||||||
@@ -91,4 +91,4 @@ $msgID = $msg->send();
|
|||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ else{
|
|||||||
|
|
||||||
$me['icon'] = GetImageURL($me['imgsvr'], $me['picture']);
|
$me['icon'] = GetImageURL($me['imgsvr'], $me['picture']);
|
||||||
|
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
$gameNow = $clock->nowDateTime();
|
||||||
$db->insert('ng_diplomacy', [
|
$db->insert('ng_diplomacy', [
|
||||||
'src_nation_id'=>$srcNation['nation'],
|
'src_nation_id'=>$srcNation['nation'],
|
||||||
'dest_nation_id'=>$destNation['nation'],
|
'dest_nation_id'=>$destNation['nation'],
|
||||||
@@ -147,7 +149,7 @@ $db->insert('ng_diplomacy', [
|
|||||||
'state'=>'proposed',
|
'state'=>'proposed',
|
||||||
'text_brief'=>$textBrief,
|
'text_brief'=>$textBrief,
|
||||||
'text_detail'=>$textDetail,
|
'text_detail'=>$textDetail,
|
||||||
'date'=>TimeUtil::now(),
|
'date'=>TimeUtil::format($gameNow),
|
||||||
'src_signer'=>$me['no'],
|
'src_signer'=>$me['no'],
|
||||||
'dest_signer'=>null,
|
'dest_signer'=>null,
|
||||||
'aux'=>Json::encode([
|
'aux'=>Json::encode([
|
||||||
@@ -168,7 +170,7 @@ $newLetterNo = $db->insertId();
|
|||||||
$src = new MessageTarget($me['no'], $me['name'], $srcNation['nation'], $srcNation['name'], $srcNation['color'], $me['icon']);
|
$src = new MessageTarget($me['no'], $me['name'], $srcNation['nation'], $srcNation['name'], $srcNation['color'], $me['icon']);
|
||||||
$dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']);
|
$dest = new MessageTarget(0, '', $destNation['nation'], $destNation['name'], $destNation['color']);
|
||||||
|
|
||||||
$now = new \DateTime();
|
$now = \DateTime::createFromImmutable($gameNow);
|
||||||
$unlimited = new \DateTime('9999-12-31');
|
$unlimited = new \DateTime('9999-12-31');
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($newLetterNo, '이');
|
$josaYi = JosaUtil::pick($newLetterNo, '이');
|
||||||
@@ -195,4 +197,4 @@ Json::die([
|
|||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success',
|
'reason'=>'success',
|
||||||
'row_id'=>$db->insertId()
|
'row_id'=>$db->insertId()
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ else{
|
|||||||
$availableNextCall = $session->availableNextCallGetCityList??'2000-01-01 00:00:00';
|
$availableNextCall = $session->availableNextCallGetCityList??'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 < 6){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>"도시 목록은 10초에 한번 갱신 가능합니다.\n다음 시간 : ".$availableNextCall
|
'reason'=>"도시 목록은 10초에 한번 갱신 가능합니다.\n다음 시간 : ".$availableNextCall
|
||||||
|
|||||||
@@ -16,12 +16,10 @@ $session = Session::requireLogin([])->setReadOnly();
|
|||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
|
|
||||||
$oNow = new \DateTimeImmutable();
|
|
||||||
|
|
||||||
$now = $oNow->format('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
$now = $clock->nowTick();
|
||||||
|
|
||||||
$oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i', $userID);
|
$oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i', $userID);
|
||||||
if($oldGeneral !== null){
|
if($oldGeneral !== null){
|
||||||
@@ -44,25 +42,19 @@ if($npcmode!=1){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$token = $db->queryFirstRow('SELECT * FROM select_npc_token WHERE `owner`=%i AND `valid_until`>=%s', $userID, $now);
|
$token = $db->queryFirstRow('SELECT * FROM select_npc_token WHERE `owner`=%i AND `valid_until`>=%i', $userID, $now);
|
||||||
$pickResult = [];
|
$pickResult = [];
|
||||||
|
|
||||||
|
|
||||||
if($token && $refresh){
|
if($token && $refresh){
|
||||||
$pickMoreFrom = (new \DateTime($token['pick_more_from']))->getTimestamp();
|
$pickMoreFrom = Util::toInt($token['pick_more_from']);
|
||||||
$nowT = $oNow->getTimestamp();
|
|
||||||
|
|
||||||
if($nowT >= $pickMoreFrom){
|
if($now >= $pickMoreFrom){
|
||||||
$oldPickResult = Json::decode($token['pick_result']);
|
$oldPickResult = Json::decode($token['pick_result']);
|
||||||
|
|
||||||
foreach($keepResult as $keepId){
|
$keepSelection = NpcPossessionSelector::applyKeep($oldPickResult, $keepResult);
|
||||||
if(\key_exists($keepId, $oldPickResult) && $oldPickResult[$keepId]['keepCnt'] > 0){
|
$pickResult = $keepSelection['picked'];
|
||||||
$pickResult[$keepId] = $oldPickResult[$keepId];
|
if($keepSelection['cancelled']){
|
||||||
$pickResult[$keepId]['keepCnt']-=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($pickResult) == count($oldPickResult)){
|
|
||||||
$refresh = false;
|
$refresh = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,15 +67,16 @@ if($token && $refresh){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($token && !$refresh){
|
if($token && !$refresh){
|
||||||
$pickMoreFrom = (new \DateTime($token['pick_more_from']))->getTimestamp();
|
$pickMoreFrom = Util::toInt($token['pick_more_from']);
|
||||||
$nowT = $oNow->getTimestamp();
|
|
||||||
|
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'pick'=>Json::decode($token['pick_result']),
|
'pick'=>Json::decode($token['pick_result']),
|
||||||
'pickMoreFrom'=>$token['pick_more_from'],
|
'pickMoreFrom'=>$clock->formatTick($pickMoreFrom),
|
||||||
'pickMoreSeconds'=>$pickMoreFrom-$nowT,
|
'pickMoreSeconds'=>intdiv($pickMoreFrom - $now, $clock->ticksPerSecond()),
|
||||||
'validUntil'=>$token['valid_until']
|
'validUntil'=>$clock->formatTick(Util::toInt($token['valid_until'])),
|
||||||
|
'validForSeconds'=>max(0, intdiv(Util::toInt($token['valid_until']) - $now, $clock->ticksPerSecond())),
|
||||||
|
'clockMode'=>$clock->getMode(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,43 +89,30 @@ foreach($db->query('SELECT `no`, `name`, leadership, strength, intel, nation, im
|
|||||||
$general['personal'] = buildPersonalityClass($general['personal'])->getName();
|
$general['personal'] = buildPersonalityClass($general['personal'])->getName();
|
||||||
$general['nation'] = getNationStaticInfo($general['nation'])['name'];
|
$general['nation'] = getNationStaticInfo($general['nation'])['name'];
|
||||||
$candidates[$general['no']] = $general + ['keepCnt'=>KEEP_CNT];
|
$candidates[$general['no']] = $general + ['keepCnt'=>KEEP_CNT];
|
||||||
$allStat = $general['leadership'] + $general['strength'] + $general['intel'];
|
$weight[$general['no']] = NpcPossessionSelector::weight($general);
|
||||||
$weight[$general['no']] = pow($allStat, 1.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($db->queryFirstColumn('SELECT pick_result FROM select_npc_token WHERE `owner`!=%i AND valid_until >=%s', $userID, $now) as $reserved){
|
NpcPossessionSelector::removeReserved(
|
||||||
$reserved = Json::decode($reserved);
|
$candidates,
|
||||||
foreach(array_keys($reserved) as $reservedNPC){
|
$weight,
|
||||||
if(key_exists($reservedNPC, $weight)){
|
$db->queryFirstColumn('SELECT pick_result FROM select_npc_token WHERE `owner`!=%i AND valid_until >=%i', $userID, $now),
|
||||||
unset($candidates[$reservedNPC]);
|
);
|
||||||
unset($weight[$reservedNPC]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
$rng = new RandUtil(new LiteHashDRBG(NpcPossessionSelector::buildSeed(
|
||||||
UniqueConst::$hiddenSeed,
|
UniqueConst::$hiddenSeed,
|
||||||
'SelectNPCToken',
|
|
||||||
$userID,
|
$userID,
|
||||||
$now,
|
$now,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$pickLimit = min(count($candidates), 5);
|
$pickResult = NpcPossessionSelector::select($candidates, $weight, $pickResult, $rng);
|
||||||
|
|
||||||
while(count($pickResult) < $pickLimit){
|
|
||||||
$generalID = $rng->choiceUsingWeight($weight);
|
|
||||||
if(!key_exists($generalID, $pickResult)){
|
|
||||||
$pickResult[$generalID] = $candidates[$generalID];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newNonce = random_int(0, 0xfffffff);
|
$newNonce = random_int(0, 0xfffffff);
|
||||||
|
|
||||||
$validSecond = max(VALID_SECOND, $turnterm*40);
|
$validSecond = max(VALID_SECOND, $turnterm*40);
|
||||||
$pickMoreSecond = max(PICK_MORE_SECOND, Util::round(pow($turnterm, 0.672)*8));
|
$pickMoreSecond = max(PICK_MORE_SECOND, Util::round(pow($turnterm, 0.672)*8));
|
||||||
|
|
||||||
$validUntil = $oNow->add(new \DateInterval(sprintf('PT%dS', $validSecond)));
|
$validUntil = $now + $clock->ticksFromSeconds($validSecond);
|
||||||
$pickMoreFrom = $oNow->add(new \DateInterval(sprintf('PT%dS', $pickMoreSecond)));
|
$pickMoreFrom = $now + $clock->ticksFromSeconds($pickMoreSecond);
|
||||||
|
|
||||||
$db->delete('select_npc_token', 'valid_until < %s', $now);
|
$db->delete('select_npc_token', 'valid_until < %s', $now);
|
||||||
|
|
||||||
@@ -140,8 +120,8 @@ $inserted = 0;
|
|||||||
|
|
||||||
if($token){
|
if($token){
|
||||||
$db->update('select_npc_token', [
|
$db->update('select_npc_token', [
|
||||||
'valid_until'=>$validUntil->format('Y-m-d H:i:s'),
|
'valid_until'=>$validUntil,
|
||||||
'pick_more_from'=>$pickMoreFrom->format('Y-m-d H:i:s'),
|
'pick_more_from'=>$pickMoreFrom,
|
||||||
'pick_result'=>Json::encode($pickResult),
|
'pick_result'=>Json::encode($pickResult),
|
||||||
'nonce'=>$newNonce
|
'nonce'=>$newNonce
|
||||||
], 'owner = %i AND nonce = %i', $userID, $token['nonce']);
|
], 'owner = %i AND nonce = %i', $userID, $token['nonce']);
|
||||||
@@ -152,8 +132,8 @@ if($token){
|
|||||||
else{
|
else{
|
||||||
$db->insertIgnore('select_npc_token', [
|
$db->insertIgnore('select_npc_token', [
|
||||||
'owner'=>$userID,
|
'owner'=>$userID,
|
||||||
'valid_until'=>$validUntil->format('Y-m-d H:i:s'),
|
'valid_until'=>$validUntil,
|
||||||
'pick_more_from'=>'2000-01-01 01:00:00',
|
'pick_more_from'=>$now,
|
||||||
'pick_result'=>Json::encode($pickResult),
|
'pick_result'=>Json::encode($pickResult),
|
||||||
'nonce'=>$newNonce
|
'nonce'=>$newNonce
|
||||||
]);
|
]);
|
||||||
@@ -173,7 +153,9 @@ if($inserted === 0){
|
|||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'pick'=>$pickResult,
|
'pick'=>$pickResult,
|
||||||
'pickMoreFrom'=>($inserted===-1)?$pickMoreFrom->format('Y-m-d H:i:s'):'2000-01-01 01:00:00',
|
'pickMoreFrom'=>$clock->formatTick(($inserted===-1)?$pickMoreFrom:$now),
|
||||||
'pickMoreSeconds'=>($inserted===-1)?$pickMoreSecond:0,
|
'pickMoreSeconds'=>($inserted===-1)?$pickMoreSecond:0,
|
||||||
'validUntil'=>$validUntil->format('Y-m-d H:i:s')
|
'validUntil'=>$clock->formatTick($validUntil),
|
||||||
]);
|
'validForSeconds'=>max(0, intdiv($validUntil - $now, $clock->ticksPerSecond())),
|
||||||
|
'clockMode'=>$clock->getMode(),
|
||||||
|
]);
|
||||||
|
|||||||
+34
-14
@@ -10,7 +10,23 @@ function sortTokens(&$tokens){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function putInfoText(&$info){
|
function putInfoText(&$info, ?array $currentTargetEnv){
|
||||||
|
if (($info['event100Growth'] ?? false) === true) {
|
||||||
|
if ($currentTargetEnv === null) {
|
||||||
|
$displayStats = CentennialAllStarGrowthService::calculateUserInitialStats($info);
|
||||||
|
$info['selectionStatLabel'] = '시작 능력치';
|
||||||
|
} else {
|
||||||
|
$displayStats = CentennialAllStarGrowthService::calculateUserCurrentTargetStats(
|
||||||
|
$info,
|
||||||
|
$currentTargetEnv
|
||||||
|
);
|
||||||
|
$info['selectionStatLabel'] = '현재 변경 기준 능력치';
|
||||||
|
}
|
||||||
|
$info['selectionLeadership'] = $displayStats['leadership'];
|
||||||
|
$info['selectionStrength'] = $displayStats['strength'];
|
||||||
|
$info['selectionIntel'] = $displayStats['intel'];
|
||||||
|
}
|
||||||
|
|
||||||
if(key_exists('specialDomestic', $info)){
|
if(key_exists('specialDomestic', $info)){
|
||||||
$class = buildGeneralSpecialDomesticClass($info['specialDomestic']);
|
$class = buildGeneralSpecialDomesticClass($info['specialDomestic']);
|
||||||
$info['specialDomesticName'] = $class->getName();
|
$info['specialDomesticName'] = $class->getName();
|
||||||
@@ -27,14 +43,13 @@ function putInfoText(&$info){
|
|||||||
$session = Session::requireLogin([])->setReadOnly();
|
$session = Session::requireLogin([])->setReadOnly();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
$oNow = new \DateTimeImmutable();
|
$db = DB::db();
|
||||||
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
$now = $clock->nowTick();
|
||||||
|
|
||||||
$now = $oNow->format('Y-m-d H:i:s');
|
$eventEnv = $gameStor->getValues(['npcmode', 'startyear', 'year', 'month']);
|
||||||
|
$npcmode = $eventEnv['npcmode'];
|
||||||
$db = DB::db();
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
|
||||||
|
|
||||||
$npcmode = $gameStor->getValue('npcmode');
|
|
||||||
if($npcmode!=2){
|
if($npcmode!=2){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
@@ -42,7 +57,8 @@ if($npcmode!=2){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rawGeneral = $db->queryFirstRow('SELECT no, aux FROM general WHERE `owner` = %i', $userID);
|
$rawGeneral = $db->queryFirstRow('SELECT no, aux FROM general WHERE `owner` = %i', $userID);
|
||||||
|
$currentTargetEnv = $rawGeneral ? $eventEnv : null;
|
||||||
if($rawGeneral){
|
if($rawGeneral){
|
||||||
$generalAux = Json::decode($rawGeneral['aux']);
|
$generalAux = Json::decode($rawGeneral['aux']);
|
||||||
if(key_exists('next_change', $generalAux)&& $generalAux['next_change'] > $now){
|
if(key_exists('next_change', $generalAux)&& $generalAux['next_change'] > $now){
|
||||||
@@ -62,7 +78,7 @@ if($tokens){
|
|||||||
foreach($tokens as $token){
|
foreach($tokens as $token){
|
||||||
$valid_until = $token['reserved_until'];
|
$valid_until = $token['reserved_until'];
|
||||||
$info = Json::decode($token['info']);
|
$info = Json::decode($token['info']);
|
||||||
putInfoText($info);
|
putInfoText($info, $currentTargetEnv);
|
||||||
$info['uniqueName'] = $token['unique_name'];
|
$info['uniqueName'] = $token['unique_name'];
|
||||||
$pick[] = $info;
|
$pick[] = $info;
|
||||||
}
|
}
|
||||||
@@ -70,7 +86,9 @@ if($tokens){
|
|||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'pick'=>$pick,
|
'pick'=>$pick,
|
||||||
'validUntil'=>$valid_until
|
'validUntil'=>$clock->formatTick(Util::toInt($valid_until)),
|
||||||
|
'validForSeconds'=>max(0, intdiv(Util::toInt($valid_until) - $now, $clock->ticksPerSecond())),
|
||||||
|
'clockMode'=>$clock->getMode(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,12 +101,14 @@ $valid_until = null;
|
|||||||
foreach(pickGeneralFromPool($db, $rng, $userID, 14) as $pickObj){
|
foreach(pickGeneralFromPool($db, $rng, $userID, 14) as $pickObj){
|
||||||
$valid_until = $pickObj->getValidUntil();
|
$valid_until = $pickObj->getValidUntil();
|
||||||
$info = $pickObj->getInfo();
|
$info = $pickObj->getInfo();
|
||||||
putInfoText($info);
|
putInfoText($info, $currentTargetEnv);
|
||||||
$pick[] = $info;
|
$pick[] = $info;
|
||||||
}
|
}
|
||||||
sortTokens($pick);//좀 무식하지만..
|
sortTokens($pick);//좀 무식하지만..
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'pick'=>$pick,
|
'pick'=>$pick,
|
||||||
'validUntil'=>$valid_until
|
'validUntil'=>$valid_until === null ? null : $clock->formatTick(Util::toInt($valid_until)),
|
||||||
]);
|
'validForSeconds'=>$valid_until === null ? 0 : max(0, intdiv(Util::toInt($valid_until) - $now, $clock->ticksPerSecond())),
|
||||||
|
'clockMode'=>$clock->getMode(),
|
||||||
|
]);
|
||||||
|
|||||||
+12
-4
@@ -199,8 +199,16 @@ if($reserve_open){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Json::die(ResetHelper::buildScenario(
|
$installTime = TimeUtil::format(GameClock::readWallTime(), false);
|
||||||
|
if (getenv('REF_DETERMINISTIC_INSTALL_ENABLED') === '1') {
|
||||||
|
$comparisonInstallAt = getenv('REF_INSTALL_AT');
|
||||||
|
if (!is_string($comparisonInstallAt) || $comparisonInstallAt === '') {
|
||||||
|
throw new \RuntimeException('REF_INSTALL_AT is required for deterministic comparison install');
|
||||||
|
}
|
||||||
|
$installTime = (new \DateTimeImmutable($comparisonInstallAt))->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
Json::die(ResetHelper::buildScenario(
|
||||||
$turnterm,
|
$turnterm,
|
||||||
$sync,
|
$sync,
|
||||||
$scenario,
|
$scenario,
|
||||||
@@ -211,7 +219,7 @@ try{
|
|||||||
$show_img_level,
|
$show_img_level,
|
||||||
!!$tournament_trig,
|
!!$tournament_trig,
|
||||||
$join_mode,
|
$join_mode,
|
||||||
TimeUtil::now(),
|
$installTime,
|
||||||
$autorun_user
|
$autorun_user
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -220,4 +228,4 @@ catch(\Exception $e){
|
|||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>$e->getMessage()
|
'reason'=>$e->getMessage()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-4
@@ -24,9 +24,9 @@ $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', 'killturn']);
|
||||||
|
|
||||||
$me = $db->queryFirstRow('SELECT no,nation,officer_level,penalty from general where owner=%i', $userID);
|
$me = $db->queryFirstRow('SELECT no,npc,nation,officer_level,penalty from general where owner=%i', $userID);
|
||||||
$myOfficerLevel = $me['officer_level'];
|
$myOfficerLevel = $me['officer_level'];
|
||||||
$nationID = $me['nation'];
|
$nationID = $me['nation'];
|
||||||
$myPenalty = Json::decode($me['penalty'] ?? '{}');
|
$myPenalty = Json::decode($me['penalty'] ?? '{}');
|
||||||
@@ -144,7 +144,7 @@ function do도시임명(General $general, int $cityID, int $targetOfficerLevel):
|
|||||||
return '올바르지 않은 도시입니다';
|
return '올바르지 않은 도시입니다';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($general->getVar(GeneralColumn::officer_level) >= 4 && $myPenalty[PenaltyKey::NoChiefChange->value] ?? false) {
|
if ($general->getVar(GeneralColumn::officer_level) >= 4 && ($myPenalty[PenaltyKey::NoChiefChange->value] ?? false)) {
|
||||||
return '수뇌인 장수를 변경할 수 없는 상태입니다.';
|
return '수뇌인 장수를 변경할 수 없는 상태입니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ function do추방(General $general, int $myOfficerLevel): ?string
|
|||||||
$src,
|
$src,
|
||||||
$src,
|
$src,
|
||||||
$str,
|
$str,
|
||||||
new \DateTime(),
|
Message::gameNow(),
|
||||||
new \DateTime('9999-12-31'),
|
new \DateTime('9999-12-31'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
@@ -342,6 +342,10 @@ if ($action == "임명") {
|
|||||||
'reason' => $result
|
'reason' => $result
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
//수뇌의 삭턴 리필
|
||||||
|
$db->update('general', [
|
||||||
|
'killturn' => $db->sqleval('GREATEST(%b, %i)', 'killturn', $gameStor->getValue('killturn')),
|
||||||
|
], 'no=%i', $me['no']);
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => true,
|
'result' => true,
|
||||||
'reason' => 'success'
|
'reason' => 'success'
|
||||||
@@ -356,6 +360,10 @@ if ($action == "임명") {
|
|||||||
'reason' => $result
|
'reason' => $result
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
//수뇌의 삭턴 리필
|
||||||
|
$db->update('general', [
|
||||||
|
'killturn' => $db->sqleval('GREATEST(%b, %i)', 'killturn', $gameStor->getValue('killturn')),
|
||||||
|
], 'no=%i', $me['no']);
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => true,
|
'result' => true,
|
||||||
'reason' => 'success'
|
'reason' => 'success'
|
||||||
@@ -376,6 +384,10 @@ if ($action == "추방") {
|
|||||||
'reason' => $result
|
'reason' => $result
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
//수뇌의 삭턴 리필
|
||||||
|
$db->update('general', [
|
||||||
|
'killturn' => $db->sqleval('GREATEST(%b, %i)', 'killturn', $gameStor->getValue('killturn')),
|
||||||
|
], 'no=%i', $me['no']);
|
||||||
Json::die([
|
Json::die([
|
||||||
'result' => true,
|
'result' => true,
|
||||||
'reason' => 'success'
|
'reason' => 'success'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ include('func.php');
|
|||||||
|
|
||||||
$session = Session::requireLogin([])->setReadOnly();
|
$session = Session::requireLogin([])->setReadOnly();
|
||||||
|
|
||||||
if(Session::getInstance()->userGrade < 5){
|
if(Session::getInstance()->userGrade < 6){
|
||||||
Json::die([
|
Json::die([
|
||||||
'reason'=>'권한이 부족합니다.'
|
'reason'=>'권한이 부족합니다.'
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ $db = DB::db();
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$rootDB = RootDB::db();
|
$rootDB = RootDB::db();
|
||||||
|
|
||||||
$oNow = new \DateTimeImmutable();
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
$now = $oNow->format('Y-m-d H:i:s');
|
$now = $clock->nowTick();
|
||||||
|
|
||||||
$member = $rootDB->queryFirstRow('SELECT `name`, `penalty` FROM member WHERE `NO`=%i', $userID);
|
$member = $rootDB->queryFirstRow('SELECT `name`, `penalty` FROM member WHERE `NO`=%i', $userID);
|
||||||
if(!$member){
|
if(!$member){
|
||||||
@@ -41,7 +41,7 @@ $penaltyInfo = array_merge($memberPenalty['any'] ?? [], $memberPenalty[DB::prefi
|
|||||||
|
|
||||||
$penalty = [];
|
$penalty = [];
|
||||||
foreach($penaltyInfo as $penaltyKey => $penaltyValue){
|
foreach($penaltyInfo as $penaltyKey => $penaltyValue){
|
||||||
if($penaltyValue['expire'] ?? 0 > TimeUtil::now()){
|
if(($penaltyValue['expire'] ?? 0) > TimeUtil::now()){
|
||||||
$penalty[$penaltyKey] = $penaltyValue['value'];
|
$penalty[$penaltyKey] = $penaltyValue['value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,4 +139,4 @@ $rootDB->insert('member_log', [
|
|||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -8,10 +8,20 @@ WebUtil::requireAJAX();
|
|||||||
|
|
||||||
$pick = Util::getPost('pick');
|
$pick = Util::getPost('pick');
|
||||||
$leadership = Util::getPost('leadership', 'int', GameConst::$defaultStatMin);
|
$leadership = Util::getPost('leadership', 'int', GameConst::$defaultStatMin);
|
||||||
$strength = Util::getPost('leadership', 'int', GameConst::$defaultStatMin);
|
$isCentennialAllStar = CentennialAllStarGrowthService::isActive();
|
||||||
$intel = Util::getPost('leadership', 'int', GameConst::$defaultStatMin);
|
$strength = Util::getPost(
|
||||||
|
$isCentennialAllStar ? 'strength' : 'leadership',
|
||||||
|
'int',
|
||||||
|
GameConst::$defaultStatMin
|
||||||
|
);
|
||||||
|
$intel = Util::getPost(
|
||||||
|
$isCentennialAllStar ? 'intel' : 'leadership',
|
||||||
|
'int',
|
||||||
|
GameConst::$defaultStatMin
|
||||||
|
);
|
||||||
$personal = Util::getPost('personal', 'string', null);
|
$personal = Util::getPost('personal', 'string', null);
|
||||||
$use_own_picture = Util::getPost('use_own_picture', 'bool', false);
|
$use_own_picture = Util::getPost('use_own_picture', 'bool', false);
|
||||||
|
$pictureSource = Util::getPost('picture_source', 'string', 'selected');
|
||||||
|
|
||||||
|
|
||||||
if(!$pick){
|
if(!$pick){
|
||||||
@@ -27,8 +37,8 @@ $db = DB::db();
|
|||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
$rootDB = RootDB::db();
|
$rootDB = RootDB::db();
|
||||||
$oNow = new \DateTimeImmutable();
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
$now = $oNow->format('Y-m-d H:i:s');
|
$now = $clock->nowTick();
|
||||||
|
|
||||||
$hasGeneralID = $db->queryFirstField('SELECT no FROM general WHERE owner = %i', $userID);
|
$hasGeneralID = $db->queryFirstField('SELECT no FROM general WHERE owner = %i', $userID);
|
||||||
if($hasGeneralID){
|
if($hasGeneralID){
|
||||||
@@ -60,16 +70,39 @@ if(!$selectInfo){
|
|||||||
}
|
}
|
||||||
$selectInfo = Json::decode($selectInfo);
|
$selectInfo = Json::decode($selectInfo);
|
||||||
|
|
||||||
$ownerInfo = RootDB::db()->queryFirstRow('SELECT `name`,`picture`,`imgsvr` FROM member WHERE `NO`=%i',$userID);
|
$ownerInfo = RootDB::db()->queryFirstRow(
|
||||||
if(!$ownerInfo){
|
'SELECT `name`,`picture`,`imgsvr`,`grade` FROM member WHERE `NO`=%i',
|
||||||
|
$userID
|
||||||
|
);
|
||||||
|
if(!$ownerInfo){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'멤버 정보를 가져오지 못했습니다.'
|
'reason'=>'멤버 정보를 가져오지 못했습니다.'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
if ($isCentennialAllStar) {
|
||||||
|
if (!in_array($pictureSource, ['selected', 'own'], true)) {
|
||||||
$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2');
|
Json::die([
|
||||||
|
'result' => false,
|
||||||
|
'reason' => '올바르지 않은 전콘 선택입니다.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if ($pictureSource === 'own') {
|
||||||
|
$canUseOwnPicture = in_array('picture', GameConst::$generalPoolAllowOption, true)
|
||||||
|
&& $env['show_img_level'] >= 1
|
||||||
|
&& $ownerInfo['grade'] >= 1
|
||||||
|
&& $ownerInfo['picture'] !== '';
|
||||||
|
if (!$canUseOwnPicture) {
|
||||||
|
Json::die([
|
||||||
|
'result' => false,
|
||||||
|
'reason' => '사용할 수 있는 내 전콘이 없습니다.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2');
|
||||||
|
|
||||||
if ($gencount >= $maxgeneral) {
|
if ($gencount >= $maxgeneral) {
|
||||||
Json::die([
|
Json::die([
|
||||||
@@ -80,12 +113,25 @@ if ($gencount >= $maxgeneral) {
|
|||||||
|
|
||||||
$poolClass = getGeneralPoolClass(GameConst::$targetGeneralPool);
|
$poolClass = getGeneralPoolClass(GameConst::$targetGeneralPool);
|
||||||
/** @var AbsGeneralPool */
|
/** @var AbsGeneralPool */
|
||||||
$pickedGeneral = new $poolClass($db, $selectInfo, $now);
|
if ($isCentennialAllStar) {
|
||||||
|
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||||
|
UniqueConst::$hiddenSeed,
|
||||||
|
'selectPickedGeneral',
|
||||||
|
$userID,
|
||||||
|
$pick
|
||||||
|
)));
|
||||||
|
$pickedGeneral = new $poolClass($db, $rng, $selectInfo, $now);
|
||||||
|
} else {
|
||||||
|
$pickedGeneral = new $poolClass($db, $selectInfo, $now);
|
||||||
|
}
|
||||||
|
|
||||||
$builder = $pickedGeneral->getGeneralBuilder();
|
$builder = $pickedGeneral->getGeneralBuilder();
|
||||||
|
if ($isCentennialAllStar) {
|
||||||
|
CentennialAllStarGrowthService::prepareInitialUser($builder, $selectInfo);
|
||||||
|
}
|
||||||
|
|
||||||
foreach(GameConst::$generalPoolAllowOption as $allowOption){
|
foreach(GameConst::$generalPoolAllowOption as $allowOption){
|
||||||
if($allowOption == 'stat'){
|
if($allowOption == 'stat' && !$isCentennialAllStar){
|
||||||
$leadership = Util::valueFit($leadership, GameConst::$defaultStatMin, GameConst::$defaultStatMax);
|
$leadership = Util::valueFit($leadership, GameConst::$defaultStatMin, GameConst::$defaultStatMax);
|
||||||
$strength = Util::valueFit($strength, GameConst::$defaultStatMin, GameConst::$defaultStatMax);
|
$strength = Util::valueFit($strength, GameConst::$defaultStatMin, GameConst::$defaultStatMax);
|
||||||
$intel = Util::valueFit($intel, GameConst::$defaultStatMin, GameConst::$defaultStatMax);
|
$intel = Util::valueFit($intel, GameConst::$defaultStatMin, GameConst::$defaultStatMax);
|
||||||
@@ -98,14 +144,23 @@ foreach(GameConst::$generalPoolAllowOption as $allowOption){
|
|||||||
}
|
}
|
||||||
$builder->setStat($leadership, $strength, $intel);
|
$builder->setStat($leadership, $strength, $intel);
|
||||||
}
|
}
|
||||||
else if($allowOption == 'picture' && $use_own_picture){
|
else if(
|
||||||
$builder->setPicture($ownerInfo['imgsvr'], $ownerInfo['picture']);
|
$allowOption == 'picture'
|
||||||
|
&& (
|
||||||
|
(!$isCentennialAllStar && $use_own_picture)
|
||||||
|
|| ($isCentennialAllStar && $pictureSource === 'own')
|
||||||
|
)
|
||||||
|
){
|
||||||
|
$builder->setPicture($ownerInfo['imgsvr'], $ownerInfo['picture']);
|
||||||
}
|
}
|
||||||
else if($allowOption == 'ego'){
|
else if($allowOption == 'ego'){
|
||||||
if(!$personal || $personal == 'Random'){
|
if(!$personal || $personal == 'Random'){
|
||||||
$personal = Util::choiceRandom(GameConst::$availablePersonality);
|
$personal = Util::choiceRandom(GameConst::$availablePersonality);
|
||||||
}
|
}
|
||||||
if(!array_search($personal, GameConst::$availablePersonality)){
|
$invalidPersonal = $isCentennialAllStar
|
||||||
|
? !in_array($personal, GameConst::$availablePersonality, true)
|
||||||
|
: !array_search($personal, GameConst::$availablePersonality);
|
||||||
|
if($invalidPersonal){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
'reason'=>'올바르지 않은 성격입니다.'
|
'reason'=>'올바르지 않은 성격입니다.'
|
||||||
@@ -113,7 +168,7 @@ foreach(GameConst::$generalPoolAllowOption as $allowOption){
|
|||||||
}
|
}
|
||||||
$builder->setEgo($personal);
|
$builder->setEgo($personal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$userNick = $ownerInfo['name'];
|
$userNick = $ownerInfo['name'];
|
||||||
|
|
||||||
@@ -121,8 +176,29 @@ $builder->setOwner($userID);
|
|||||||
$builder->setOwnerName($userNick);
|
$builder->setOwnerName($userNick);
|
||||||
$builder->setKillturn(5);
|
$builder->setKillturn(5);
|
||||||
$builder->setNPCType(0);
|
$builder->setNPCType(0);
|
||||||
$builder->setAuxVar('next_change', TimeUtil::nowAddMinutes(12 * $env['turnterm']));
|
$builder->setAuxVar('next_change', $now + GameClock::TICKS_PER_TURN * 12);
|
||||||
|
$builder->setAuxVar(
|
||||||
|
'prestart_delete_after',
|
||||||
|
addTurn($now, $env['turnterm'], GameConst::$minTurnDieOnPrestart)
|
||||||
|
);
|
||||||
$builder->fillRemainSpecAsZero($env);
|
$builder->fillRemainSpecAsZero($env);
|
||||||
|
if ($isCentennialAllStar) {
|
||||||
|
$candidateCities = $db->queryFirstColumn(
|
||||||
|
'SELECT city FROM city WHERE level >= 5 AND level <= 6 AND nation = 0'
|
||||||
|
);
|
||||||
|
if (!$candidateCities) {
|
||||||
|
$candidateCities = $db->queryFirstColumn(
|
||||||
|
'SELECT city FROM city WHERE level >= 5 AND level <= 6'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!$candidateCities) {
|
||||||
|
Json::die([
|
||||||
|
'result' => false,
|
||||||
|
'reason' => '장수를 생성할 소·중성이 없습니다.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$builder->setCityID($rng->choice($candidateCities));
|
||||||
|
}
|
||||||
$builder->build($env);
|
$builder->build($env);
|
||||||
$generalID = $builder->getGeneralID();
|
$generalID = $builder->getGeneralID();
|
||||||
if(!$generalID){
|
if(!$generalID){
|
||||||
@@ -167,4 +243,4 @@ $rootDB->insert('member_log', [
|
|||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ if(!class_exists('\\sammo\\DB')){
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
$clock = GameClock::fromStorage($gameStor);
|
||||||
|
|
||||||
if(file_exists(__DIR__.'/.htaccess')){
|
if(file_exists(__DIR__.'/.htaccess')){
|
||||||
$reserved = $db->queryFirstRow(
|
$reserved = $db->queryFirstRow(
|
||||||
@@ -75,8 +76,10 @@ $admin['maxUserCnt'] = $admin['maxgeneral'];
|
|||||||
$admin['npcMode'] = $admin['npcmode'];
|
$admin['npcMode'] = $admin['npcmode'];
|
||||||
$admin['turnTerm'] = $admin['turnterm'];
|
$admin['turnTerm'] = $admin['turnterm'];
|
||||||
$admin['isUnited'] = $admin['isunited'];
|
$admin['isUnited'] = $admin['isunited'];
|
||||||
|
$admin['isOpen'] = $clock->nowTick() >= Util::toInt($admin['opentime']);
|
||||||
|
$admin['opentime'] = $clock->formatTick(Util::toInt($admin['opentime']));
|
||||||
$admin['starttime'] = substr($admin['opentime'], 5, 11);
|
$admin['starttime'] = substr($admin['opentime'], 5, 11);
|
||||||
$admin['turntime'] = substr($admin['turntime'], 5, 11);
|
$admin['turntime'] = substr($clock->formatTick(Util::toInt($admin['turntime'])), 5, 11);
|
||||||
unset($admin['npcmode']);
|
unset($admin['npcmode']);
|
||||||
unset($admin['maxgeneral']);
|
unset($admin['maxgeneral']);
|
||||||
unset($admin['turnterm']);
|
unset($admin['turnterm']);
|
||||||
@@ -131,4 +134,4 @@ if($general){
|
|||||||
Json::die([
|
Json::die([
|
||||||
'game'=>$admin,
|
'game'=>$admin,
|
||||||
'me'=>$me?:null
|
'me'=>$me?:null
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ $penaltyInfo = array_merge($memberPenalty['any'] ?? [], $memberPenalty[DB::prefi
|
|||||||
|
|
||||||
$penalty = [];
|
$penalty = [];
|
||||||
foreach ($penaltyInfo as $penaltyKey => $penaltyValue) {
|
foreach ($penaltyInfo as $penaltyKey => $penaltyValue) {
|
||||||
if ($penaltyValue['expire'] ?? 0 > TimeUtil::now()) {
|
if (($penaltyValue['expire'] ?? 0) > TimeUtil::now()) {
|
||||||
$penalty[$penaltyKey] = $penaltyValue['value'];
|
$penalty[$penaltyKey] = $penaltyValue['value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ if ($permission < 3) {
|
|||||||
function applyNationPolicy($policy, $nationID, $generalName): ?string
|
function applyNationPolicy($policy, $nationID, $generalName): ?string
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
$gameNow = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'))->formatNow();
|
||||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||||
|
|
||||||
$defaultPolicy = AutorunNationPolicy::$defaultPolicy;
|
$defaultPolicy = AutorunNationPolicy::$defaultPolicy;
|
||||||
@@ -139,7 +140,7 @@ function applyNationPolicy($policy, $nationID, $generalName): ?string
|
|||||||
|
|
||||||
$nationPolicyRoot['values'] = $nationPolicy;
|
$nationPolicyRoot['values'] = $nationPolicy;
|
||||||
$nationPolicyRoot['valueSetter'] = $generalName;
|
$nationPolicyRoot['valueSetter'] = $generalName;
|
||||||
$nationPolicyRoot['valueSetTime'] = TimeUtil::now();
|
$nationPolicyRoot['valueSetTime'] = $gameNow;
|
||||||
$nationStor->npc_nation_policy = $nationPolicyRoot;
|
$nationStor->npc_nation_policy = $nationPolicyRoot;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -147,6 +148,7 @@ function applyNationPolicy($policy, $nationID, $generalName): ?string
|
|||||||
function applyNationPriority($priority, $nationID, $generalName): ?string
|
function applyNationPriority($priority, $nationID, $generalName): ?string
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
$gameNow = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'))->formatNow();
|
||||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||||
$nationPolicyRoot = $nationStor->npc_nation_policy;
|
$nationPolicyRoot = $nationStor->npc_nation_policy;
|
||||||
|
|
||||||
@@ -158,7 +160,7 @@ function applyNationPriority($priority, $nationID, $generalName): ?string
|
|||||||
}
|
}
|
||||||
$nationPolicyRoot['priority'] = $priority;
|
$nationPolicyRoot['priority'] = $priority;
|
||||||
$nationPolicyRoot['prioritySetter'] = $generalName;
|
$nationPolicyRoot['prioritySetter'] = $generalName;
|
||||||
$nationPolicyRoot['prioritySetTime'] = TimeUtil::now();
|
$nationPolicyRoot['prioritySetTime'] = $gameNow;
|
||||||
$nationStor->npc_nation_policy = $nationPolicyRoot;
|
$nationStor->npc_nation_policy = $nationPolicyRoot;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -166,6 +168,7 @@ function applyNationPriority($priority, $nationID, $generalName): ?string
|
|||||||
function applyGeneralPriority($priority, $nationID, $generalName): ?string
|
function applyGeneralPriority($priority, $nationID, $generalName): ?string
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
$gameNow = GameClock::fromStorage(KVStorage::getStorage($db, 'game_env'))->formatNow();
|
||||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||||
$generalPolicyRoot = $nationStor->npc_general_policy;
|
$generalPolicyRoot = $nationStor->npc_general_policy;
|
||||||
|
|
||||||
@@ -206,7 +209,7 @@ function applyGeneralPriority($priority, $nationID, $generalName): ?string
|
|||||||
|
|
||||||
$generalPolicyRoot['priority'] = $priority;
|
$generalPolicyRoot['priority'] = $priority;
|
||||||
$generalPolicyRoot['prioritySetter'] = $generalName;
|
$generalPolicyRoot['prioritySetter'] = $generalName;
|
||||||
$generalPolicyRoot['prioritySetTime'] = TimeUtil::now();
|
$generalPolicyRoot['prioritySetTime'] = $gameNow;
|
||||||
$nationStor->npc_general_policy = $generalPolicyRoot;
|
$nationStor->npc_general_policy = $generalPolicyRoot;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ $month = $query['month'];
|
|||||||
$repeatCnt = $query['repeatCnt'];
|
$repeatCnt = $query['repeatCnt'];
|
||||||
|
|
||||||
$rawAttacker = $query['attackerGeneral'];
|
$rawAttacker = $query['attackerGeneral'];
|
||||||
$rawAttacker['turntime'] = TimeUtil::now();
|
$battleClock = GameClock::fromStorage(KVStorage::getStorage(DB::db(), 'game_env'));
|
||||||
|
$rawAttacker['turntime'] = $battleClock->formatTick($battleClock->nowTick());
|
||||||
$rawAttackerCity = $query['attackerCity'];
|
$rawAttackerCity = $query['attackerCity'];
|
||||||
$rawAttackerNation = $query['attackerNation'];
|
$rawAttackerNation = $query['attackerNation'];
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user