forked from devsam/core
Compare commits
54
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66ed8635dd | ||
|
|
311c485cec | ||
|
|
5b5cf4e6d3 | ||
|
|
428ec0d0ed | ||
|
|
96c5f987d6 | ||
|
|
f0ae28b087 | ||
|
|
fa4a266d77 | ||
|
|
32e854858e
|
||
|
|
f13371e679 | ||
|
|
2420f594a6
|
||
|
|
b7b0a1050c
|
||
|
|
d2a90157b9
|
||
|
|
a32cb3a2c0
|
||
|
|
7c0a3a6955
|
||
|
|
7d2e2945a1 | ||
|
|
dc526c7359 | ||
|
|
6c4cb484da | ||
|
|
d41246de9d | ||
|
|
6d40783224
|
||
|
|
6eb6014e80
|
||
|
|
103cf3f882
|
||
|
|
5969e0c82b
|
||
|
|
945f9027dd
|
||
|
|
0bf3145042
|
||
|
|
905669755f
|
||
|
|
57b12e8c04
|
||
|
|
eccd883edc
|
||
|
|
895b134cd0
|
||
|
|
7258573e4d
|
||
|
|
cbdfa6f6fc
|
||
|
|
ed25c58410
|
||
|
|
16cfa46864
|
||
|
|
e54a0a6668
|
||
|
|
eb545724ea
|
||
|
|
7858b48bad
|
||
|
|
a4ed41edbe
|
||
|
|
b5a9e52c43
|
||
|
|
c6166d3295
|
||
|
|
9520d29109
|
||
|
|
3edfff146e | ||
|
|
38416ccdf8
|
||
|
|
eeb5eabd12
|
||
|
|
41273f97db
|
||
|
|
0e23677e1b | ||
|
|
0f085c7f36
|
||
|
|
bd90076441
|
||
|
|
1801bdf55b
|
||
|
|
f27f0edfb6
|
||
|
|
02f23e7db4
|
||
|
|
9871e24811 | ||
|
|
a7dac2ce15 | ||
|
|
ed1d2cbf0d | ||
|
|
06ca32802b
|
||
|
|
568b45f93a
|
+2
-5
@@ -15,9 +15,8 @@ return [
|
||||
// Note that the **only** effect of choosing `'5.6'` is to infer
|
||||
// that functions removed in php 7.0 exist.
|
||||
// (See `backward_compatibility_checks` for additional options)
|
||||
"target_php_version" => '8.1',
|
||||
"minimum_target_php_version" => '8.1',
|
||||
'backward_compatibility_checks ' => true,
|
||||
"target_php_version" => '8.2',
|
||||
"minimum_target_php_version" => '8.2',
|
||||
'minimum_severity' => \Phan\Issue::SEVERITY_NORMAL,
|
||||
|
||||
'file_list' => [
|
||||
@@ -29,8 +28,6 @@ return [
|
||||
'hwe/_admin1_submit.php',
|
||||
'hwe/_admin2.php',
|
||||
'hwe/_admin2_submit.php',
|
||||
'hwe/_admin4.php',
|
||||
'hwe/_admin4_submit.php',
|
||||
'hwe/_admin5.php',
|
||||
'hwe/_admin5_submit.php',
|
||||
'hwe/_admin7.php',
|
||||
|
||||
@@ -33,7 +33,7 @@ $src = MessageTarget::buildQuick($session->generalID);
|
||||
$genObjList = [];
|
||||
$env = [];
|
||||
if ($genlist) {
|
||||
$genObjList = General::createGeneralObjListFromDB($genlist);
|
||||
$genObjList = General::createObjListFromDB($genlist);
|
||||
$env = $gameStor->cacheAll();
|
||||
}
|
||||
switch ($btn) {
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ if (!$gen) {
|
||||
$gen = $generalBasicList[0]['no'];
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($gen, null, GeneralQueryMode::FullWithAccessLog);
|
||||
$generalObj = General::createObjFromDB($gen, null, GeneralQueryMode::FullWithAccessLog);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
@@ -26,7 +26,7 @@ foreach ($db->queryFirstColumn(
|
||||
}
|
||||
|
||||
$inheritPointManager = InheritancePointManager::getInstance();
|
||||
foreach(General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
|
||||
foreach(General::createObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc = 0')) as $genObj){
|
||||
$inheritPointManager->mergeTotalInheritancePoint($genObj);
|
||||
$inheritPointManager->applyInheritanceUser($genObj->getVar('owner'));
|
||||
}
|
||||
+18
-33
@@ -12,34 +12,19 @@ $gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
increaseRefresh("갱신정보", 1);
|
||||
|
||||
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxrefresh', 'maxonline']);
|
||||
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxrefresh', 'maxonline', 'recentTraffic']);
|
||||
|
||||
$log = getRawFileLogRecent(__DIR__ . '/logs/' . UniqueConst::$serverID . '/_traffic.txt', 11, 100);
|
||||
|
||||
$date = [];
|
||||
$year = [];
|
||||
$month = [];
|
||||
$refresh = [];
|
||||
$online = [];
|
||||
$recentTraffic = $admin['recentTraffic'] ?? [];
|
||||
|
||||
$curonline = getOnlineNum();
|
||||
foreach ($log as $i => $value) {
|
||||
$parse = Json::decode($value);
|
||||
if (is_array($parse) === false) {
|
||||
continue;
|
||||
}
|
||||
if (count($parse) < 5) {
|
||||
continue;
|
||||
}
|
||||
$date[$i] = $parse[0];
|
||||
$year[$i] = $parse[1];
|
||||
$month[$i] = $parse[2];
|
||||
$refresh[$i] = $parse[3];
|
||||
$online[$i] = $parse[4];
|
||||
}
|
||||
$year[] = $admin['year'];
|
||||
$month[] = $admin['month'];
|
||||
$date[] = TimeUtil::now();
|
||||
|
||||
$recentTraffic[] = [
|
||||
'year' => $admin['year'],
|
||||
'month' => $admin['month'],
|
||||
'refresh' => $admin['refresh'],
|
||||
'online' => $curonline,
|
||||
'date' => TimeUtil::now()
|
||||
];
|
||||
|
||||
if ($admin['maxrefresh'] == 0) {
|
||||
$admin['maxrefresh'] = 1;
|
||||
@@ -113,13 +98,13 @@ if ($admin['maxonline'] < $curonline) {
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$refresh[] = $admin['refresh'];
|
||||
foreach ($refresh as $i => $value) {
|
||||
foreach ($recentTraffic as $trafficItem) {
|
||||
$value = $trafficItem['refresh'];
|
||||
$w = round($value / $admin['maxrefresh'] * 100, 1);
|
||||
$color = getTrafficColor($w);
|
||||
$dt = substr($date[$i], 11, 5); ?>
|
||||
$dt = substr($trafficItem['date'], 11, 5); ?>
|
||||
<tr height=30>
|
||||
<td width=100 align=center><?= $year[$i] ?>년 <?= $month[$i] ?>월</td>
|
||||
<td width=100 align=center><?= $trafficItem['year'] ?>년 <?= $trafficItem['month'] ?>월</td>
|
||||
<td width=60 align=center class='bg2'><?= $dt ?></td>
|
||||
<td width=2 align=center class='bg1'></td>
|
||||
<td width=320>
|
||||
@@ -154,13 +139,13 @@ if ($admin['maxonline'] < $curonline) {
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$online[] = $curonline;
|
||||
foreach ($online as $i => $value) {
|
||||
foreach ($recentTraffic as $trafficItem) {
|
||||
$value = $trafficItem['online'];
|
||||
$w = round($value / $admin['maxonline'] * 100, 1);
|
||||
$color = getTrafficColor($w);
|
||||
$dt = substr($date[$i], 11, 5); ?>
|
||||
$dt = substr($trafficItem['date'], 11, 5); ?>
|
||||
<tr height=30>
|
||||
<td width=100 align=center><?= $year[$i] ?>년 <?= $month[$i] ?>월</td>
|
||||
<td width=100 align=center><?= $trafficItem['year'] ?>년 <?= $trafficItem['month'] ?>월</td>
|
||||
<td width=60 align=center class='bg2'><?= $dt ?></td>
|
||||
<td width=2 align=center class='bg1'></td>
|
||||
<td width=320>
|
||||
|
||||
+8
-7
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\RankColumn;
|
||||
|
||||
@@ -506,28 +507,28 @@ if ($str3) {
|
||||
$tournamentType = [
|
||||
'전 력 전' => [
|
||||
'종합',
|
||||
function (General $general) {
|
||||
function (GeneralLite $general) {
|
||||
return $general->getVar('leadership') + $general->getVar('strength') + $general->getVar('intel');
|
||||
},
|
||||
'tt',
|
||||
],
|
||||
'통 솔 전' => [
|
||||
'통솔',
|
||||
function (General $general) {
|
||||
function (GeneralLite $general) {
|
||||
return $general->getVar('leadership');
|
||||
},
|
||||
'tl',
|
||||
],
|
||||
'일 기 토' => [
|
||||
'무력',
|
||||
function (General $general) {
|
||||
function (GeneralLite $general) {
|
||||
return $general->getVar('strength');
|
||||
},
|
||||
'ts',
|
||||
],
|
||||
'설 전' => [
|
||||
'지력',
|
||||
function (General $general) {
|
||||
function (GeneralLite $general) {
|
||||
return $general->getVar('intel');
|
||||
},
|
||||
'ti',
|
||||
@@ -564,12 +565,12 @@ if ($str3) {
|
||||
$winColumn = RankColumn::from("{$rankColumn}w");
|
||||
$drawColumn = RankColumn::from("{$rankColumn}d");
|
||||
$loseColumn = RankColumn::from("{$rankColumn}l");
|
||||
$tournamentRankerList = General::createGeneralObjListFromDB(
|
||||
$tournamentRankerList = GeneralLite::createObjListFromDB(
|
||||
$db->queryFirstColumn('SELECT general_id FROM rank_data WHERE `type`= %s ORDER BY value DESC LIMIT 40', $gameColumn->value),
|
||||
[$prizeColumn->value, $gameColumn->value, $winColumn->value, $drawColumn->value, $loseColumn->value, 'leadership', 'strength', 'intel', 'no', 'npc', 'name'],
|
||||
GeneralQueryMode::Core
|
||||
GeneralLiteQueryMode::Core
|
||||
);
|
||||
usort($tournamentRankerList, function (General $lhs, General $rhs) use ($gameColumn, $winColumn, $drawColumn, $loseColumn) {
|
||||
usort($tournamentRankerList, function (GeneralLite $lhs, GeneralLite $rhs) use ($gameColumn, $winColumn, $drawColumn, $loseColumn) {
|
||||
$result = - ($lhs->getRankVar($gameColumn) <=> $rhs->getRankVar($gameColumn));
|
||||
if ($result !== 0) return $result;
|
||||
$result = - (
|
||||
|
||||
@@ -327,8 +327,7 @@ $templates = new \League\Plates\Engine('templates');
|
||||
|
||||
if ($ourGeneral && !$isNPC) {
|
||||
$turnText = [];
|
||||
$generalObj = new General($general, null, null, null, null, null, null, false);
|
||||
foreach ($generalTurnList[$generalObj->getID()] as $turnRawIdx => $turn) {
|
||||
foreach ($generalTurnList[$general['no']] as $turnRawIdx => $turn) {
|
||||
$turnIdx = $turnRawIdx + 1;
|
||||
$turnText[] = "{$turnIdx} : $turn";
|
||||
}
|
||||
|
||||
+20
-5
@@ -24,7 +24,7 @@ $gameStor->cacheValues(['turntime', 'opentime', 'autorun_user', 'npcmode']);
|
||||
|
||||
increaseRefresh("내정보", 1);
|
||||
|
||||
$me = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||
$me = General::createObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||
|
||||
$myset = $me->getVar('myset');
|
||||
if ($myset > 0) {
|
||||
@@ -37,7 +37,8 @@ $lastRefresh = $db->queryFirstField(
|
||||
'SELECT %b FROM %b WHERE %b = %i',
|
||||
GeneralAccessLogColumn::lastRefresh->value,
|
||||
TableName::generalAccessLog->value,
|
||||
GeneralAccessLogColumn::generalID->value, $generalID
|
||||
GeneralAccessLogColumn::generalID->value,
|
||||
$generalID
|
||||
);
|
||||
|
||||
$targetTime = addTurn($lastRefresh, $gameStor->turnterm, GameConst::$minTurnDieOnPrestart);
|
||||
@@ -50,13 +51,19 @@ if ($gameStor->turntime <= $gameStor->opentime) {
|
||||
}
|
||||
}
|
||||
|
||||
if($me->getNationID() == 0){
|
||||
if ($me->getNationID() == 0) {
|
||||
$showBuildNationCandidateBtn = true;
|
||||
}
|
||||
}
|
||||
|
||||
$use_treatment = $me->getAuxVar('use_treatment') ?? 10;
|
||||
$use_auto_nation_turn = $me->getAuxVar('use_auto_nation_turn') ?? 1;
|
||||
|
||||
$changeDefence999Train = -3;
|
||||
$changeDefence999Atmos = -6;
|
||||
$changeDefence999Train = $me->onCalcDomestic('changeDefenceTrain', "train999", $changeDefence999Train);
|
||||
$changeDefence999Atmos = $me->onCalcDomestic('changeDefenceTrain', "atmos999", $changeDefence999Atmos);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -128,7 +135,10 @@ $use_auto_nation_turn = $me->getAuxVar('use_auto_nation_turn') ?? 1;
|
||||
<?php foreach ([90, 80, 60, 40] as $targetDefenceTrain) : ?>
|
||||
<option value='<?= $targetDefenceTrain ?>' <?= $me->getVar('defence_train') == $targetDefenceTrain ? "selected" : ""; ?>><?= formatDefenceTrain($targetDefenceTrain) ?>(훈사<?= $targetDefenceTrain ?>)</option>
|
||||
<?php endforeach; ?>
|
||||
<option value=999 <?= $me->getVar('defence_train') == 999 ? "selected" : ""; ?>><?= formatDefenceTrain(999) ?>[훈련 -3, 사기 -6]</option>
|
||||
<option value=999 <?= $me->getVar('defence_train') == 999 ? "selected" : ""; ?>><?= formatDefenceTrain(999) ?>
|
||||
<?php if($changeDefence999Train != 0 || $changeDefence999Train != 0):
|
||||
?>[<?=$changeDefence999Train!=0?"훈련 {$changeDefence999Train},":''?><?=$changeDefence999Atmos!=0?"사기 {$changeDefence999Atmos}":''
|
||||
?>]<?php endif?></option>
|
||||
</select>
|
||||
】<br><br>
|
||||
<input type=<?= $submit ?> id='set_my_setting' name=btn style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px; value=설정저장><br>
|
||||
@@ -150,6 +160,11 @@ $use_auto_nation_turn = $me->getAuxVar('use_auto_nation_turn') ?? 1;
|
||||
<button type="button" id='buildNationCandidate' style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>사전 거병</button><br><br>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (GameConst::$availableInstantAction['instantRetreat'] ?? false) : ?>
|
||||
거리 3칸 이내 아국 도시로 즉시 이동<br>
|
||||
<button type="button" id='instantRetreat' style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>접경 귀환</button><br><br>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($gameStor->npcmode == 2 && $me->getNPCType() == 0) : ?>
|
||||
다른 장수 선택 (<?= substr($me->getAuxVar('next_change') ?? TimeUtil::now(), 0, 19) ?> 부터)<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>
|
||||
@@ -178,7 +193,7 @@ $use_auto_nation_turn = $me->getAuxVar('use_auto_nation_turn') ?? 1;
|
||||
<div class="row mx-1">
|
||||
<div class="btn-group" role="group">
|
||||
<?php foreach ($me->getItems() as $itemKey => $item) : ?>
|
||||
<button type="button" data-item-type='<?=$itemKey?>' class="drop-item-btn btn btn-primary <?= $item->getName() == '-' ? 'disabled' : '' ?>"><?= $item->getName() ?></button>
|
||||
<button type="button" data-item-type='<?= $itemKey ?>' class="drop-item-btn btn btn-primary <?= $item->getName() == '-' ? 'disabled' : '' ?>"><?= $item->getName() ?></button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ $me = $db->queryFirstRow(
|
||||
'SELECT no,tournament,refresh_score,turntime from `general`
|
||||
LEFT JOIN general_access_log AS l ON `general`.no = l.general_id where owner=%i', $userID
|
||||
);
|
||||
|
||||
$generalID = $me['no'];
|
||||
$admin = $gameStor->getValues(['tournament', 'phase', 'turnterm', 'tnmt_msg', 'tnmt_type', 'develcost', 'tnmt_trig']);
|
||||
$turnTerm = $admin['turnterm'];
|
||||
|
||||
|
||||
+17
-5
@@ -149,7 +149,7 @@ function getRandGenName(RandUtil $rng)
|
||||
|
||||
|
||||
|
||||
function cityInfo(General $generalObj)
|
||||
function cityInfo(GeneralLite $generalObj)
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
@@ -1070,7 +1070,7 @@ function updateTraffic()
|
||||
$online = getOnlineNum();
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']);
|
||||
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh', 'recentTraffic']);
|
||||
/** @var array{year:int,month:int,refresh:int,maxonline:int,maxrefresh:int} $admin */
|
||||
|
||||
if ($admin['maxrefresh'] < $admin['refresh']) {
|
||||
@@ -1083,6 +1083,19 @@ function updateTraffic()
|
||||
$gameStor->maxrefresh = $admin['maxrefresh'];
|
||||
$gameStor->maxonline = $admin['maxonline'];
|
||||
|
||||
$recentTraffic = $admin['recentTraffic'] ?? [];
|
||||
if(count($recentTraffic) >= 5){
|
||||
array_shift($recentTraffic);
|
||||
}
|
||||
$recentTraffic[] = [
|
||||
'year'=>$admin['year'],
|
||||
'month' => $admin['month'],
|
||||
'refresh' => $admin['refresh'],
|
||||
'online' => $online,
|
||||
'date' => TimeUtil::now(),
|
||||
];
|
||||
$gameStor->recentTraffic = $recentTraffic;
|
||||
|
||||
$db->update('general_access_log', ['refresh' => 0], true);
|
||||
}
|
||||
|
||||
@@ -1324,7 +1337,7 @@ function CheckHall($no)
|
||||
["betrate", 'calc'],
|
||||
];
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($no);
|
||||
$generalObj = General::createObjFromDB($no);
|
||||
|
||||
$ttw = $generalObj->getRankVar(RankColumn::ttw);
|
||||
$ttd = $generalObj->getRankVar(RankColumn::ttd);
|
||||
@@ -1714,14 +1727,13 @@ function deleteNation(General $lord, bool $applyDB): array
|
||||
$logger->pushGlobalHistoryLog("<R><b>【멸망】</b></><D><b>{$nationName}</b></>{$josaUn} <R>멸망</>했습니다.");
|
||||
|
||||
|
||||
$nationGeneralList = General::createGeneralObjListFromDB(
|
||||
$nationGeneralList = General::createObjListFromDB(
|
||||
$db->queryFirstColumn(
|
||||
'SELECT `no` FROM general WHERE nation=%i AND no != %i',
|
||||
$nationID,
|
||||
$lordID
|
||||
),
|
||||
['npc', 'owner', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'belong', 'aux'],
|
||||
GeneralQueryMode::Lite,
|
||||
);
|
||||
$nationGeneralList[$lordID] = $lord;
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ function setGeneralCommand(int $generalID, array $rawTurnList, string $command,
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$env = $gameStor->getAll();
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
try{
|
||||
$commandObj = buildGeneralCommandClass($command, $general, $env, $arg);
|
||||
@@ -425,7 +425,7 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$env = $gameStor->getAll();
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
if($general->getVar('officer_level') < 5){
|
||||
return [
|
||||
|
||||
@@ -256,6 +256,41 @@ function buildItemClass(?string $type):BaseItem{
|
||||
return $obj;
|
||||
}
|
||||
|
||||
function getScenarioEffectClass(?string $type){
|
||||
if($type === null || $type === ''){
|
||||
$type = 'None';
|
||||
}
|
||||
|
||||
static $basePath = __NAMESPACE__.'\\ActionScenarioEffect\\';
|
||||
$classPath = ($basePath.$type);
|
||||
|
||||
if(class_exists($classPath)){
|
||||
return $classPath;
|
||||
}
|
||||
|
||||
$classPath = ($basePath.'che_'.$type);
|
||||
if(class_exists($classPath)){
|
||||
return $classPath;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("{$type}은 시나리오 효과 클래스가 아님");
|
||||
}
|
||||
|
||||
function buildScenarioEffectClass(?string $type):iAction{
|
||||
static $cache = [];
|
||||
if($type === null){
|
||||
$type = 'None';
|
||||
}
|
||||
if(key_exists($type, $cache)){
|
||||
return $cache[$type];
|
||||
}
|
||||
$class = getScenarioEffectClass($type);
|
||||
|
||||
$obj = new $class();
|
||||
$cache[$type]= $obj;
|
||||
return $obj;
|
||||
}
|
||||
|
||||
function getGeneralSpecialDomesticClass(?string $type){
|
||||
if($type === null || $type === ''){
|
||||
$type = GameConst::$defaultSpecialDomestic;
|
||||
|
||||
@@ -451,7 +451,7 @@ function checkWander(RandUtil $rng)
|
||||
|
||||
$wanderers = $db->queryFirstColumn('SELECT general.`no` FROM general LEFT JOIN nation ON general.nation = nation.nation WHERE nation.`level` = 0 AND general.`officer_level` = 12');
|
||||
|
||||
foreach (General::createGeneralObjListFromDB($wanderers) as $wanderer) {
|
||||
foreach (General::createObjListFromDB($wanderers) as $wanderer) {
|
||||
$wanderCmd = buildGeneralCommandClass('che_해산', $wanderer, $admin);
|
||||
if ($wanderCmd->hasFullConditionMet()) {
|
||||
$logger = $wanderer->getLogger();
|
||||
@@ -743,7 +743,7 @@ function checkEmperior()
|
||||
}
|
||||
|
||||
$inheritPointManager = InheritancePointManager::getInstance();
|
||||
$allUserGenerals = General::createGeneralObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc < 2'));
|
||||
$allUserGenerals = General::createObjListFromDB($db->queryFirstColumn('SELECT `no` FROM general WHERE npc < 2'));
|
||||
foreach ($allUserGenerals as $genObj) {
|
||||
if ($genObj->getNationID() == $nationID) {
|
||||
if ($genObj->getVar('officer_level') > 4) {
|
||||
|
||||
@@ -364,7 +364,14 @@ function disaster(RandUtil $rng) {
|
||||
$logger->flush();
|
||||
|
||||
if (!$isGood) {
|
||||
$generalListByCity = Util::arrayGroupBy($db->query('SELECT no, name, nation, city, officer_level, injury, leadership, strength, intel, horse, weapon, book, item, crew, crewtype, atmos, train, special, special2 FROM general WHERE city IN %li', Util::squeezeFromArray($targetCityList, 'city')), 'city');
|
||||
[$queryColumns,,] = General::mergeQueryColumn();
|
||||
$generalListByCity = Util::arrayGroupBy(
|
||||
$db->query(
|
||||
'SELECT %l FROM general WHERE city IN %li',
|
||||
Util::formatListOfBackticks($queryColumns),
|
||||
Util::squeezeFromArray($targetCityList, 'city')
|
||||
),
|
||||
'city');
|
||||
//NOTE: 쿼리 1번이지만 복잡하기 vs 쿼리 여러번이지만 조금 더 깔끔하기
|
||||
foreach ($targetCityList as $city) {
|
||||
$affectRatio = Util::valueFit($city['secu'] / $city['secu_max'] / 0.8, 0, 1);
|
||||
|
||||
@@ -882,7 +882,7 @@ function setGift($tnmt_type, $tnmt, $phase)
|
||||
//포상 장수 이름, 금액
|
||||
$resultHelper[$generalID]['reward'] += $cost;
|
||||
$resultHelper[$generalID]['msg'] = "<span class='ev_highlight'>4강 진출</span>";
|
||||
General::createGeneralObjFromDB($generalID)->increaseInheritancePoint(InheritanceKey::tournament, 10);
|
||||
General::createObjFromDB($generalID)->increaseInheritancePoint(InheritanceKey::tournament, 10);
|
||||
}
|
||||
//결승자 명성 돈
|
||||
$cost = $admin['develcost'] * 6;
|
||||
@@ -946,7 +946,7 @@ function setGift($tnmt_type, $tnmt, $phase)
|
||||
$winnerLogger->pushGlobalHistoryLog("<B><b>【대회】</b></><C>{$tp}</> 대회에서 <Y>{$winner['name']}</>{$josaYiWinner} <C>우승</>, <Y>{$runnerUp['name']}</>{$josaYiRunnerUp} <C>준우승</>을 차지하여 천하에 이름을 떨칩니다!", ActionLogger::EVENT_YEAR_MONTH);
|
||||
$winnerLogger->pushGlobalHistoryLog("<B><b>【대회】</b></><C>{$tp}</> 대회의 <S>우승자</>에게는 <C>{$winnerRewardText}</>, <S>준우승자</>에겐 <C>{$runnerUpRewardText}</>의 <S>상금</>과 약간의 <S>명성</>이 주어집니다!", ActionLogger::EVENT_YEAR_MONTH);
|
||||
|
||||
$generalObjList = General::createGeneralObjListFromDB(array_keys($resultHelper));
|
||||
$generalObjList = General::createObjListFromDB(array_keys($resultHelper));
|
||||
|
||||
foreach ($resultHelper as $generalID => $general) {
|
||||
$rewardText = number_format($general['reward']);
|
||||
|
||||
+22
-14
@@ -199,17 +199,25 @@ if($reserve_open){
|
||||
]);
|
||||
}
|
||||
|
||||
Json::die(ResetHelper::buildScenario(
|
||||
$turnterm,
|
||||
$sync,
|
||||
$scenario,
|
||||
$fiction,
|
||||
$extend,
|
||||
$block_general_create,
|
||||
$npcmode,
|
||||
$show_img_level,
|
||||
!!$tournament_trig,
|
||||
$join_mode,
|
||||
TimeUtil::now(),
|
||||
$autorun_user
|
||||
));
|
||||
try{
|
||||
Json::die(ResetHelper::buildScenario(
|
||||
$turnterm,
|
||||
$sync,
|
||||
$scenario,
|
||||
$fiction,
|
||||
$extend,
|
||||
$block_general_create,
|
||||
$npcmode,
|
||||
$show_img_level,
|
||||
!!$tournament_trig,
|
||||
$join_mode,
|
||||
TimeUtil::now(),
|
||||
$autorun_user
|
||||
));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$e->getMessage()
|
||||
]);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\MessageType;
|
||||
|
||||
@@ -46,12 +47,7 @@ if($destGeneralID==0){
|
||||
$general->setVar('nation', $nationID);
|
||||
}
|
||||
else{
|
||||
$general = General::createGeneralObjFromDB($destGeneralID, [
|
||||
'name', 'leadership', 'strength', 'intel', 'gold','rice',
|
||||
'troop','officer_level','npc','picture','imgsvr',
|
||||
'permission','penalty','belong', 'crewtype',
|
||||
'experience', 'dedication', 'betray', 'dedlevel', 'explevel', 'makelimit', 'aux',
|
||||
], GeneralQueryMode::Lite);
|
||||
$general = General::createObjFromDB($destGeneralID);
|
||||
|
||||
if($general instanceof DummyGeneral){
|
||||
Json::die([
|
||||
|
||||
@@ -89,7 +89,7 @@ $db->update('general', [
|
||||
'aux'=>Json::encode($genAux)
|
||||
], 'owner <= 0 AND npc = 2 AND no = %i', $pick);
|
||||
$db->insertIgnore('general_access_log', [
|
||||
GeneralAccessLogColumn::generalID->value => $generalID,
|
||||
GeneralAccessLogColumn::generalID->value => $pick,
|
||||
GeneralAccessLogColumn::userID->value => $userID,
|
||||
GeneralAccessLogColumn::lastRefresh->value => $now,
|
||||
]);
|
||||
|
||||
@@ -36,15 +36,19 @@ if($tnmt < 0 || $tnmt > 1){
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$me = General::createGeneralObjFromDB($generalID);
|
||||
$me = General::createObjFromDB($generalID);
|
||||
|
||||
|
||||
if($defence_train !== $me->getVar('defence_train')){
|
||||
if($defence_train == 999){
|
||||
$me->increaseVar('myset', -1);
|
||||
$me->setVar('defence_train', $defence_train);
|
||||
$me->increaseVarWithLimit('train', -3, 20);
|
||||
$me->increaseVarWithLimit('atmos', -6, 20);
|
||||
$affectedTrain = -3;
|
||||
$affectedAtmos = -6;
|
||||
$affectedTrain = $me->onCalcDomestic('changeDefenceTrain', "train{$defence_train}", $affectedTrain);
|
||||
$affectedAtmos = $me->onCalcDomestic('changeDefenceTrain', "atmos{$defence_train}", $affectedAtmos);
|
||||
$me->increaseVarWithLimit('train', $affectedTrain, 20, GameConst::$maxTrainByWar);
|
||||
$me->increaseVarWithLimit('atmos', $affectedAtmos, 20, GameConst::$maxAtmosByWar);
|
||||
}
|
||||
else{
|
||||
$me->increaseVar('myset', -1);
|
||||
|
||||
@@ -66,7 +66,7 @@ if(!$ownerInfo){
|
||||
$info = Json::decode($info);
|
||||
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($generalID);
|
||||
$generalObj = General::createObjFromDB($generalID);
|
||||
$oldGeneralName = $generalObj->getName();
|
||||
$db->update('select_pool', [
|
||||
'general_id'=>-$generalID,
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ if ($limitState >= 2) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($me['no'], null, GeneralQueryMode::FullWithAccessLog);
|
||||
$generalObj = General::createObjFromDB($me['no'], null, GeneralQueryMode::FullWithAccessLog);
|
||||
$generalObj->setRawCity($db->queryFirstRow('SELECT * FROM city WHERE city = %i', $generalObj->getCityID()));
|
||||
$scenario = $gameStor->scenario_text;
|
||||
|
||||
|
||||
+23
-7
@@ -37,12 +37,12 @@ function processWar(string $warSeed, General $attackerGeneral, array $rawAttacke
|
||||
|
||||
$city = new WarUnitCity($rng, $rawDefenderCity, $rawDefenderNation, $year, $month, $startYear);
|
||||
|
||||
$defenderIDList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i AND nation!=0 and crew > 0 and rice>(crew/100) and train>=defence_train and atmos>=defence_train', $city->getVar('nation'), $city->getVar('city'));
|
||||
$defenderGeneralList = General::createGeneralObjListFromDB($defenderIDList, null);
|
||||
$defenderCityGeneralIDList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i AND nation!=0', $city->getVar('nation'), $city->getVar('city'));
|
||||
$defenderCityGeneralList = General::createObjListFromDB($defenderCityGeneralIDList, null);
|
||||
|
||||
/** @var WarUnit[] */
|
||||
$defenderList = [];
|
||||
foreach($defenderGeneralList as $defenderGeneral){
|
||||
foreach($defenderCityGeneralList as $defenderGeneral){
|
||||
$defenderGeneral->setRawCity($rawDefenderCity);
|
||||
$defenderCandidate = new WarUnitGeneral($rng, $defenderGeneral, $rawDefenderNation, false);
|
||||
if(extractBattleOrder($defenderCandidate, $attacker) <= 0){
|
||||
@@ -186,7 +186,7 @@ function processWar(string $warSeed, General $attackerGeneral, array $rawAttacke
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'join_mode' => $joinMode,
|
||||
], $attacker->getGeneral(), $city->getRaw());
|
||||
], $attacker->getGeneral(), $city->getRaw(), $defenderCityGeneralList);
|
||||
}
|
||||
|
||||
function extractBattleOrder(WarUnit $defender, WarUnit $attacker)
|
||||
@@ -529,8 +529,9 @@ function getConquerNation($city): int
|
||||
return Util::array_first_key($conflict);
|
||||
}
|
||||
|
||||
function ConquerCity(array $admin, General $general, array $city)
|
||||
function ConquerCity(array $admin, General $general, array $city, array $defenderCityGeneralList)
|
||||
{
|
||||
/** @var General[] $defenderCityGeneralList */
|
||||
$db = DB::db();
|
||||
|
||||
$year = $admin['year'];
|
||||
@@ -585,6 +586,21 @@ function ConquerCity(array $admin, General $general, array $city)
|
||||
if(TurnExecutionHelper::runEventHandler($db, $gameStor, EventTarget::OccupyCity)){
|
||||
$gameStor->cacheAll();
|
||||
}
|
||||
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||
UniqueConst::$hiddenSeed,
|
||||
'ConquerCity',
|
||||
$year,
|
||||
$month,
|
||||
$attackerNationID,
|
||||
$attackerID,
|
||||
$cityID
|
||||
)));
|
||||
foreach($defenderCityGeneralList as $defenderCityGeneral){
|
||||
$defenderCityGeneral->onArbitraryAction($defenderCityGeneral, $rng, 'ConquerCity', null, [
|
||||
'attacker' => $general
|
||||
]);
|
||||
$defenderCityGeneral->applyDB($db);
|
||||
}
|
||||
|
||||
|
||||
// 국가 멸망시
|
||||
@@ -596,10 +612,10 @@ function ConquerCity(array $admin, General $general, array $city)
|
||||
|
||||
$lord = new General($db->queryFirstRow(
|
||||
'SELECT %l FROM general WHERE nation = %i AND officer_level = %i LIMIT 1',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn(['npc', 'gold', 'rice', 'experience', 'explevel', 'belong', 'dedication', 'dedlevel', 'aux'], GeneralQueryMode::Lite)[0]),
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0]),
|
||||
$defenderNationID,
|
||||
12
|
||||
), null, null, $city, $loseNation, $year, $month, false);
|
||||
), null, null, $city, $loseNation, $year, $month);
|
||||
|
||||
$josaUl = JosaUtil::pick($defenderNationName, '을');
|
||||
$attackerLogger->pushNationalHistoryLog("<D><b>{$defenderNationName}</b></>{$josaUl} 정복");
|
||||
|
||||
@@ -39,7 +39,7 @@ class BidBuyRiceAuction extends \sammo\BaseAPI
|
||||
$amount = $this->args['amount'];
|
||||
|
||||
$generalID = $session->generalID;
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
$auction = new AuctionBuyRice($auctionID, $general);
|
||||
$result = $auction->bid($amount, true);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class BidSellRiceAuction extends \sammo\BaseAPI
|
||||
$amount = $this->args['amount'];
|
||||
|
||||
$generalID = $session->generalID;
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
$auction = new AuctionSellRice($auctionID, $general);
|
||||
$result = $auction->bid($amount, true);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class BidUniqueAuction extends \sammo\BaseAPI
|
||||
$tryExtendCloseDate = $this->args['extendCloseDate'] ?? false;
|
||||
|
||||
$generalID = $session->generalID;
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
$auction = new AuctionUniqueItem($auctionID, $general);
|
||||
$result = $auction->bid($amount, $tryExtendCloseDate);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class GetUniqueItemAuctionDetail extends \sammo\BaseAPI
|
||||
$inheritMgr = InheritancePointManager::getInstance();
|
||||
//preveious라서 column을 최대한 비울 수 있다.
|
||||
$remainPoint = $inheritMgr->getInheritancePoint(
|
||||
General::createGeneralObjFromDB($generalID, ['owner'], GeneralQueryMode::Core),
|
||||
General::createObjFromDB($generalID),
|
||||
InheritanceKey::previous
|
||||
);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class OpenBuyRiceAuction extends \sammo\BaseAPI
|
||||
$finishBidAmount = $this->args['finishBidAmount'];
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -66,7 +66,7 @@ class OpenSellRiceAuction extends \sammo\BaseAPI
|
||||
$finishBidAmount = $this->args['finishBidAmount'];
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -57,7 +57,7 @@ class OpenUniqueAuction extends \sammo\BaseAPI
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$itemObj = buildItemClass($itemID);
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -59,7 +59,7 @@ class BuildNationCandidate extends \sammo\BaseAPI
|
||||
|
||||
$env = $gameStor->getAll();
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($general['no']);
|
||||
$generalObj = General::createObjFromDB($general['no']);
|
||||
|
||||
$validCmd = false;
|
||||
foreach(GameConst::$availableGeneralCommand as $cmdList){
|
||||
|
||||
@@ -68,7 +68,7 @@ class DieOnPrestart extends \sammo\BaseAPI
|
||||
return "아직 삭제할 수 없습니다. {$targetTimeShort} 부터 가능합니다.";
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($general['no']);
|
||||
$generalObj = General::createObjFromDB($general['no']);
|
||||
if ($generalObj instanceof DummyGeneral) {
|
||||
trigger_error("올바르지 않은 삭제 프로세스 $userID", E_USER_WARNING);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class DropItem extends \sammo\BaseAPI
|
||||
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag): null | string | array | APIRecoveryType
|
||||
{
|
||||
$generalID = $session->generalID;
|
||||
$me = General::createGeneralObjFromDB($generalID);
|
||||
$me = General::createObjFromDB($generalID);
|
||||
|
||||
$itemType = $this->args['itemType'];
|
||||
$item = $me->getItem($itemType);
|
||||
|
||||
@@ -21,7 +21,7 @@ class GetCommandTable extends \sammo\BaseAPI{
|
||||
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag): null | string | array | APIRecoveryType
|
||||
{
|
||||
$generalID = $session->generalID;
|
||||
$me = General::createGeneralObjFromDB($generalID);
|
||||
$me = General::createObjFromDB($generalID);
|
||||
$commandTable = getCommandTable($me);
|
||||
|
||||
return [
|
||||
|
||||
@@ -534,7 +534,7 @@ class GetFrontInfo extends \sammo\BaseAPI
|
||||
{
|
||||
$generalID = $session->generalID;
|
||||
//NOTE: 이 경우 staticNation 정보를 조회한다.
|
||||
$general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||
$general = General::createObjFromDB($generalID, null, GeneralQueryMode::FullWithAccessLog);
|
||||
$nationID = $general->getNationID();
|
||||
$cityID = $general->getCityID();
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\General;
|
||||
|
||||
use sammo\DB;
|
||||
use sammo\DummyGeneral;
|
||||
use sammo\Enums\APIRecoveryType;
|
||||
use sammo\Enums\GeneralAccessLogColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\Session;
|
||||
use sammo\General;
|
||||
use sammo\JosaUtil;
|
||||
use sammo\KVStorage;
|
||||
use sammo\LiteHashDRBG;
|
||||
use sammo\RandUtil;
|
||||
use sammo\TimeUtil;
|
||||
use sammo\UniqueConst;
|
||||
use sammo\Util;
|
||||
|
||||
use function sammo\addTurn;
|
||||
use function sammo\buildGeneralCommandClass;
|
||||
use function sammo\increaseRefresh;
|
||||
|
||||
class InstantRetreat extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_GAME_LOGIN;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag): null | string | array | APIRecoveryType
|
||||
{
|
||||
|
||||
if(!(GameConst::$availableInstantAction['instantRetreat'] ?? false)){
|
||||
return '접경귀환을 사용할 수 없는 시나리오입니다.';
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$gameStor->cacheAll();
|
||||
|
||||
$general = General::createObjFromDB($session->generalID);
|
||||
|
||||
if (!$general) {
|
||||
return '장수가 없습니다';
|
||||
}
|
||||
|
||||
increaseRefresh("접경귀환", 1);
|
||||
|
||||
$commandObj = buildGeneralCommandClass('che_접경귀환', $general, $gameStor->getAll(true));
|
||||
$logger = $general->getLogger();
|
||||
|
||||
if (!$commandObj->hasFullConditionMet()) {
|
||||
$logger->pushGeneralActionLog($commandObj->getFailString());
|
||||
$reason = $commandObj->getFailString();
|
||||
return $reason;
|
||||
}
|
||||
|
||||
$result = $commandObj->run(new RandUtil(
|
||||
new LiteHashDRBG(Util::simpleSerialize(
|
||||
UniqueConst::$hiddenSeed,
|
||||
'InstantRetreat',
|
||||
$general->getID(),
|
||||
$gameStor->year,
|
||||
$gameStor->month,
|
||||
$general->getCityID(),
|
||||
))
|
||||
));
|
||||
|
||||
if (!$result) {
|
||||
return '가까운 아국 도시가 없습니다.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class BuyHiddenBuff extends \sammo\BaseAPI
|
||||
$type = $this->args['type'];
|
||||
$level = $this->args['level'];
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class BuyRandomUnique extends \sammo\BaseAPI
|
||||
$userID = $session->userID;
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if($userID != $general->getVar('owner')){
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\InheritAction;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\APIRecoveryType;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
use sammo\LiteHashDRBG;
|
||||
use sammo\RandUtil;
|
||||
use sammo\TimeUtil;
|
||||
use sammo\UniqueConst;
|
||||
use sammo\UserLogger;
|
||||
use sammo\Util;
|
||||
|
||||
class CalcResetTurnTimeRange extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag): null | string | array | APIRecoveryType
|
||||
{
|
||||
$userID = $session->userID;
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$turnTerm, $serverTurnTime] = $gameStor->getValuesAsArray(['turnterm', 'turntime']);
|
||||
|
||||
$currTurnTime = new DateTimeImmutable($general->getTurnTime());
|
||||
$serverTurnTimeObj = new DateTimeImmutable($serverTurnTime);
|
||||
|
||||
$minTurnTime = $currTurnTime->add(TimeUtil::secondsToDateInterval($turnTerm * -30));
|
||||
$maxTurnTime = $currTurnTime->add(TimeUtil::secondsToDateInterval($turnTerm * 30));
|
||||
|
||||
$timeDiff = $serverTurnTimeObj->diff($minTurnTime);
|
||||
$timeDiffSec = TimeUtil::DateIntervalToSeconds($timeDiff);
|
||||
if($timeDiffSec > 0){
|
||||
$minTurnTime = $minTurnTime->add(TimeUtil::secondsToDateInterval($timeDiffSec));
|
||||
$maxTurnTime = $maxTurnTime->add(TimeUtil::secondsToDateInterval($timeDiffSec));
|
||||
}
|
||||
|
||||
return [
|
||||
'result' => true,
|
||||
'timeDiffSec' => $timeDiffSec,
|
||||
'minTurnTime' => TimeUtil::format($minTurnTime, false),
|
||||
'maxTurnTime' => TimeUtil::format($maxTurnTime, false),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class ResetSpecialWar extends \sammo\BaseAPI
|
||||
$userID = $session->userID;
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ResetTurnTime extends \sammo\BaseAPI
|
||||
$userID = $session->userID;
|
||||
$generalID = $session->generalID;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI
|
||||
|
||||
$type = $this->args['type'];
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID);
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace sammo\API\Nation;
|
||||
use ArrayObject;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\APIRecoveryType;
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\General;
|
||||
use sammo\GeneralLite;
|
||||
use sammo\Session;
|
||||
use sammo\Util;
|
||||
|
||||
@@ -165,7 +167,7 @@ class GeneralList extends \sammo\BaseAPI
|
||||
|
||||
|
||||
|
||||
[$queryColumns, $rankColumns, $accessLogColumns] = General::mergeQueryColumn(array_keys(static::$viewColumns), GeneralQueryMode::Lite);
|
||||
[$queryColumns, $rankColumns, $accessLogColumns] = GeneralLite::mergeQueryColumn(array_keys(static::$viewColumns), GeneralLiteQueryMode::Lite);
|
||||
|
||||
$rawGeneralList = Util::convertArrayToDict(
|
||||
$db->query(
|
||||
|
||||
@@ -14,14 +14,6 @@ use sammo\Util;
|
||||
use sammo\Validator;
|
||||
|
||||
use function sammo\buildNationCommandClass;
|
||||
use function sammo\checkLimit;
|
||||
use function sammo\checkSecretPermission;
|
||||
use function sammo\getBattleDetailLogMore;
|
||||
use function sammo\getBattleResultMore;
|
||||
use function sammo\getBattleResultRecent;
|
||||
use function sammo\getGeneralActionLogMore;
|
||||
use function sammo\getGeneralActionLogRecent;
|
||||
use function sammo\getGeneralHistoryLogAll;
|
||||
use function sammo\getNationStaticInfo;
|
||||
|
||||
class GetNationInfo extends \sammo\BaseAPI
|
||||
@@ -66,7 +58,7 @@ class GetNationInfo extends \sammo\BaseAPI
|
||||
];
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($session->generalID, null, GeneralQueryMode::FullWithoutIAction);
|
||||
$generalObj = General::createObjFromDB($session->generalID);
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$gameEnv = $gameStor->getValues(['year', 'month', 'startyear']);
|
||||
|
||||
@@ -12,6 +12,7 @@ use sammo\General;
|
||||
use sammo\Json;
|
||||
use sammo\KVStorage;
|
||||
use sammo\TimeUtil;
|
||||
use sammo\Util;
|
||||
|
||||
use function sammo\checkLimit;
|
||||
use function sammo\checkSecretPermission;
|
||||
@@ -42,7 +43,8 @@ class GetReservedCommand extends \sammo\BaseAPI
|
||||
|
||||
$me = $db->queryFirstRow(
|
||||
'SELECT no,nation,officer_level,refresh_score,turntime,belong,penalty,permission FROM `general`
|
||||
LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i', $userID
|
||||
LEFT JOIN general_access_log AS l ON `general`.no = l.general_id WHERE owner=%i',
|
||||
$userID
|
||||
);
|
||||
|
||||
$nationLevel = $db->queryFirstField('SELECT level FROM nation WHERE nation = %i', $me['nation']);
|
||||
@@ -62,7 +64,11 @@ class GetReservedCommand extends \sammo\BaseAPI
|
||||
[$turnTerm, $year, $month, $lastExecute] = $gameStor->getValuesAsArray(['turnterm', 'year', 'month', 'turntime']);
|
||||
|
||||
$generals = [];
|
||||
foreach ($db->query('SELECT no,name,turntime,npc,city,nation,officer_level FROM general WHERE nation = %i AND officer_level >= 5', $nationID) as $rawGeneral) {
|
||||
foreach ($db->query(
|
||||
'SELECT %l FROM general WHERE nation = %i AND officer_level >= 5',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0]),
|
||||
$nationID
|
||||
) as $rawGeneral) {
|
||||
$generals[$rawGeneral['officer_level']] = new General($rawGeneral, null, null, null, null, $year, $month, false);
|
||||
}
|
||||
|
||||
@@ -113,7 +119,7 @@ class GetReservedCommand extends \sammo\BaseAPI
|
||||
];
|
||||
}
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($session->generalID, null, GeneralQueryMode::FullWithoutIAction);
|
||||
$generalObj = General::createObjFromDB($session->generalID);
|
||||
|
||||
|
||||
return [
|
||||
|
||||
@@ -6,8 +6,10 @@ use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\DTO\VoteComment;
|
||||
use sammo\Enums\APIRecoveryType;
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\General;
|
||||
use sammo\GeneralLite;
|
||||
use sammo\Session;
|
||||
use sammo\TimeUtil;
|
||||
use sammo\Validator;
|
||||
@@ -41,7 +43,7 @@ class AddComment extends \sammo\BaseAPI
|
||||
$text = mb_substr($this->args['text'], 0, 200);
|
||||
|
||||
$generalID = $session->generalID;
|
||||
$general = General::createGeneralObjFromDB($generalID, null, GeneralQueryMode::Core);
|
||||
$general = GeneralLite::createObjFromDB($generalID, null, GeneralLiteQueryMode::Core);
|
||||
$generalName = $general->getName();
|
||||
$nationID = $general->getNationID();
|
||||
$nationName = $general->getStaticNation()['name'];
|
||||
|
||||
@@ -106,7 +106,7 @@ class Vote extends \sammo\BaseAPI
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$voteReward = $gameStor->getValue('develcost') * 5;
|
||||
|
||||
$general = General::createGeneralObjFromDB($generalID, ['gold', 'horse', 'weapon', 'book', 'item', 'npc', 'imgsvr', 'picture', 'aux'], GeneralQueryMode::Lite);
|
||||
$general = General::createObjFromDB($generalID, null, GeneralQueryMode::Full);
|
||||
$general->increaseVar('gold', $voteReward);
|
||||
$uniqueRng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||
UniqueConst::$hiddenSeed,
|
||||
|
||||
@@ -21,7 +21,7 @@ class che_무기_02_단궁 extends \sammo\BaseStatItem{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 102, 0.01, 10, 30),
|
||||
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||
new che_저격발동($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 102)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class che_무기_07_맥궁 extends \sammo\BaseStatItem{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 107, 0.2, 20, 40),
|
||||
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||
new che_저격발동($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 107)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class che_무기_09_동호비궁 extends \sammo\BaseStatItem{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 109, 0.2, 20, 40, 20),
|
||||
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||
new che_저격발동($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 109)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class che_무기_11_이광궁 extends \sammo\BaseStatItem{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 111, 0.10, 20, 40, 10),
|
||||
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||
new che_저격발동($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 111)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class che_무기_13_양유기궁 extends \sammo\BaseStatItem{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 113, 0.1, 20, 40, 10),
|
||||
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||
new che_저격발동($unit, che_저격시도::TYPE_ITEM + che_저격시도::TYPE_DEDUP_TYPE_BASE * 113)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class che_저격_매화수전 extends \sammo\BaseItem{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, che_저격시도::TYPE_ITEM+BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*304, 0.5, 20, 40),
|
||||
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||
new che_저격발동($unit, che_저격시도::TYPE_ITEM+BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*304)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class che_저격_비도 extends \sammo\BaseItem{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, che_저격시도::TYPE_ITEM+BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*305, 0.5, 20, 40),
|
||||
new che_저격발동($unit, che_저격발동::TYPE_ITEM)
|
||||
new che_저격발동($unit, che_저격시도::TYPE_ITEM+BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*305)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class che_저격_수극 extends \sammo\BaseItem{
|
||||
protected $buyable = true;
|
||||
protected $reqSecu = 1000;
|
||||
|
||||
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, BaseWarUnitTrigger::TYPE_CONSUMABLE_ITEM, 1, 20, 40),
|
||||
new che_저격발동($unit, BaseWarUnitTrigger::TYPE_CONSUMABLE_ITEM)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace sammo\ActionScenarioEffect;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class None implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
protected $id = -1;
|
||||
protected $name = '-';
|
||||
protected $info = '';
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\ActionScenarioEffect;
|
||||
|
||||
use \sammo\iAction;
|
||||
use sammo\WarUnit;
|
||||
use sammo\WarUnitCity;
|
||||
use sammo\WarUnitTrigger\che_전멸시페이즈증가;
|
||||
use sammo\WarUnitTriggerCaller;
|
||||
|
||||
class event_StrongAttacker implements iAction
|
||||
{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
public function getWarPowerMultiplier(WarUnit $unit): array
|
||||
{
|
||||
if ($unit instanceof WarUnitCity) {
|
||||
return [1, 1];
|
||||
}
|
||||
if ($unit->getOppose() instanceof WarUnitCity) {
|
||||
return [1, 1];
|
||||
}
|
||||
|
||||
if ($unit->isAttacker()) {
|
||||
return [1.4, 0.7143];
|
||||
}
|
||||
return [1, 1];
|
||||
}
|
||||
|
||||
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux = null): float
|
||||
{
|
||||
if ($turnType == 'changeDefenceTrain') {
|
||||
return 0;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller
|
||||
{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_전멸시페이즈증가($unit),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class che_event_저격 extends \sammo\BaseSpecial{
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_저격시도($unit, che_저격시도::TYPE_NONE, 0.5, 20, 40),
|
||||
new che_저격발동($unit)
|
||||
new che_저격발동($unit, che_저격시도::TYPE_NONE)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ abstract class Auction
|
||||
if ($bidItem->generalID === $this->general->getID()) {
|
||||
$oldBidder = $this->general;
|
||||
} else {
|
||||
$oldBidder = General::createGeneralObjFromDB($bidItem->generalID);
|
||||
$oldBidder = General::createObjFromDB($bidItem->generalID);
|
||||
}
|
||||
|
||||
if ($this->info->reqResource === ResourceType::inheritancePoint) {
|
||||
@@ -267,7 +267,7 @@ abstract class Auction
|
||||
if ($isRollback) {
|
||||
$highestBid = $this->getHighestBid();
|
||||
if ($highestBid !== null) {
|
||||
$this->refundBid($highestBid, "{$this->info->id}번 {$this->info->detail->title} 경매가 취소되었습니다.");
|
||||
$this->refundBid($highestBid, "{$this->info->id}번 {$this->info->detail->title}가 취소되었습니다.");
|
||||
}
|
||||
$this->rollbackAuction();
|
||||
}
|
||||
@@ -485,7 +485,7 @@ abstract class Auction
|
||||
}
|
||||
}
|
||||
|
||||
$bidder = General::createGeneralObjFromDB($highestBid->generalID);
|
||||
$bidder = General::createObjFromDB($highestBid->generalID);
|
||||
$failReason = $this->finishAuction($highestBid, $bidder);
|
||||
if ($failReason === null) {
|
||||
$this->closeAuction();
|
||||
|
||||
@@ -116,7 +116,7 @@ abstract class AuctionBasicResource extends Auction
|
||||
} else if ($this->info->hostGeneralID == 0) {
|
||||
$auctionHost = $this->genDummy();
|
||||
} else {
|
||||
$auctionHost = General::createGeneralObjFromDB($this->info->hostGeneralID);
|
||||
$auctionHost = General::createObjFromDB($this->info->hostGeneralID);
|
||||
}
|
||||
|
||||
$hostRes = static::$hostRes;
|
||||
@@ -164,7 +164,7 @@ abstract class AuctionBasicResource extends Auction
|
||||
} else if ($this->info->hostGeneralID == 0) {
|
||||
$auctionHost = $this->genDummy();
|
||||
} else {
|
||||
$auctionHost = General::createGeneralObjFromDB($this->info->hostGeneralID);
|
||||
$auctionHost = General::createObjFromDB($this->info->hostGeneralID);
|
||||
}
|
||||
|
||||
$highestBid = $this->getHighestBid();
|
||||
@@ -175,7 +175,7 @@ abstract class AuctionBasicResource extends Auction
|
||||
if ($this->general->getID() === $highestBid->generalID) {
|
||||
$bidder = $this->general;
|
||||
} else {
|
||||
$bidder = General::createGeneralObjFromDB($highestBid->generalID);
|
||||
$bidder = General::createObjFromDB($highestBid->generalID);
|
||||
}
|
||||
|
||||
$hostRes = static::$hostRes;
|
||||
|
||||
@@ -19,7 +19,7 @@ class AutorunGeneralPolicy{
|
||||
static $소집해제 = '소집해제';
|
||||
|
||||
static $출병 = '출병';
|
||||
|
||||
|
||||
//static $NPC증여 = 'NPC증여';
|
||||
static $NPC헌납 = 'NPC헌납';
|
||||
static $NPC사망대비 = 'NPC사망대비';
|
||||
@@ -31,12 +31,12 @@ class AutorunGeneralPolicy{
|
||||
static $귀환 = '귀환';
|
||||
//static $전투이동 = '전투이동';
|
||||
//static $내정이동 = '내정이동';
|
||||
|
||||
|
||||
static $국가선택 = '국가선택';
|
||||
static $집합 = '집합';
|
||||
static $건국 = '건국';
|
||||
static $선양 = '선양';
|
||||
|
||||
|
||||
|
||||
|
||||
static public array $default_priority = [
|
||||
@@ -74,7 +74,7 @@ class AutorunGeneralPolicy{
|
||||
public $can소집해제 = true;
|
||||
|
||||
public $can출병 = true;
|
||||
|
||||
|
||||
//public $canNPC증여 = true;
|
||||
public $canNPC헌납 = true;
|
||||
|
||||
@@ -91,7 +91,7 @@ class AutorunGeneralPolicy{
|
||||
|
||||
public array $priority;
|
||||
|
||||
function doNPCState(General $general){
|
||||
function doNPCState(GeneralBase $general){
|
||||
$npc = $general->getNPCType();
|
||||
$nationID = $general->getNationID();
|
||||
|
||||
@@ -115,7 +115,7 @@ class AutorunGeneralPolicy{
|
||||
|
||||
}
|
||||
|
||||
function __construct(General $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env){
|
||||
function __construct(GeneralBase $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env){
|
||||
$this->priority = static::$default_priority;
|
||||
|
||||
if($serverPolicy && key_exists('priority', $serverPolicy)){
|
||||
@@ -165,7 +165,7 @@ class AutorunGeneralPolicy{
|
||||
$this->can전투준비 = false;
|
||||
|
||||
$this->can출병 = false;
|
||||
|
||||
|
||||
//$this->canNPC증여 = false;
|
||||
$this->canNPC헌납 = false;
|
||||
|
||||
@@ -194,9 +194,9 @@ class AutorunGeneralPolicy{
|
||||
$this->can금쌀구매 = true;
|
||||
$this->can상인무시 = true;
|
||||
break;
|
||||
case 'recruit_high':
|
||||
case 'recruit_high':
|
||||
$this->can모병 = true;
|
||||
case 'recruit':
|
||||
case 'recruit':
|
||||
$this->can징병 = true;
|
||||
$this->can소집해제 = true;
|
||||
$this->can금쌀구매 = true;
|
||||
|
||||
@@ -179,7 +179,7 @@ class AutorunNationPolicy {
|
||||
'cureThreshold'=>10,
|
||||
];
|
||||
|
||||
function __construct(General $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env)
|
||||
function __construct(GeneralBase $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env)
|
||||
{
|
||||
foreach(static::$defaultPolicy as $policy=>$value){
|
||||
$this->{$policy} = $value;
|
||||
|
||||
@@ -6,6 +6,7 @@ use Ds\Map;
|
||||
use sammo\DTO\BettingInfo;
|
||||
use sammo\DTO\BettingItem;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
use sammo\Enums\RankColumn;
|
||||
|
||||
class Betting
|
||||
@@ -351,6 +352,8 @@ class Betting
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$pointManager = InheritancePointManager::getInstance();
|
||||
|
||||
if ($this->info->reqInheritancePoint) {
|
||||
/** @var Map<int,UserLogger> */
|
||||
$loggers = new Map();
|
||||
@@ -362,11 +365,8 @@ class Betting
|
||||
$userID = $rewardItem['userID'];
|
||||
$amount = $rewardItem['amount'];
|
||||
|
||||
$inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}");
|
||||
$previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0];
|
||||
$nextPoint = $previousPoint + $amount;
|
||||
$inheritStor->setValue('previous', [$nextPoint, 0]);
|
||||
$inheritStor->invalidateCacheValue('previous'); //XXX: 실제로는 previous 값을 사용할 수 없도록 락을 걸어야 한다.
|
||||
$nextPoint = $pointManager->increaseInheritancePointRaw($userID, InheritanceKey::previous, $amount);
|
||||
$previousPoint = $nextPoint - $amount;//역산
|
||||
|
||||
$generalID = $rewardItem['generalID'];
|
||||
$db->update('rank_data', [
|
||||
@@ -402,7 +402,7 @@ class Betting
|
||||
$userLogger->flush();
|
||||
}
|
||||
} else {
|
||||
$generalList = General::createGeneralObjListFromDB(array_unique(Util::squeezeFromArray($rewardList, 'generalID')), ['gold', 'npc', 'betgold'], GeneralQueryMode::Lite);
|
||||
$generalList = General::createObjListFromDB(array_unique(Util::squeezeFromArray($rewardList, 'generalID')));
|
||||
foreach ($rewardList as $rewardItem) {
|
||||
$gambler = $generalList[$rewardItem['generalID']];
|
||||
$reward = Util::round($rewardItem['amount']);
|
||||
|
||||
@@ -7,11 +7,7 @@ use \sammo\{
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
DummyGeneral,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command,
|
||||
ScoutMessage
|
||||
};
|
||||
@@ -77,7 +73,7 @@ class che_등용 extends Command\GeneralCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation', 'experience', 'dedication'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
@@ -68,7 +68,7 @@ class che_등용수락 extends Command\GeneralCommand{
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID'], null);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID'], ['gennum', 'scout']);
|
||||
|
||||
@@ -169,7 +169,7 @@ class che_등용수락 extends Command\GeneralCommand{
|
||||
$logger->pushGeneralActionLog("<D>{$destNationName}</>{$josaRo} 망명하여 수도로 이동합니다.");
|
||||
$destLogger->pushGeneralActionLog("<Y>{$generalName}</> 등용에 성공했습니다.");
|
||||
|
||||
$logger->pushGeneralHistoryLog("<D>{$destNationName}</>{$josaRo} 망명");
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>{$josaRo} 망명");
|
||||
$destLogger->pushGeneralHistoryLog("<Y>{$generalName}</> 등용에 성공");
|
||||
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>{$josaRo} <S>망명</>하였습니다.");
|
||||
@@ -212,4 +212,4 @@ class che_등용수락 extends Command\GeneralCommand{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class che_모반시도 extends Command\GeneralCommand{
|
||||
|
||||
$lordID = $db->queryFirstField('SELECT no FROM general WHERE nation = %i AND officer_level = 12', $nationID);
|
||||
|
||||
$lordGeneral = General::createGeneralObjFromDB($lordID);
|
||||
$lordGeneral = General::createObjFromDB($lordID);
|
||||
|
||||
$generalName = $general->getName();
|
||||
$lordName = $lordGeneral->getName();
|
||||
|
||||
@@ -66,7 +66,7 @@ class che_선양 extends Command\GeneralCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
|
||||
@@ -84,7 +84,7 @@ class che_장수대상임관 extends Command\GeneralCommand{
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneralID = $this->arg['destGeneralID'];
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($destGeneralID);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->destGeneralObj->getVar('nation'), ['gennum', 'scout']);
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\CityConst;
|
||||
|
||||
use function sammo\searchDistance;
|
||||
|
||||
class che_접경귀환 extends Command\GeneralCommand{
|
||||
static protected $actionName = '접경귀환';
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::NotOccupiedCity()
|
||||
];
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$general = $this->generalObj;
|
||||
$cityID = $general->getCityID();
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$distanceList = searchDistance($cityID, 3, true);
|
||||
|
||||
$occupiedCityList = new \Ds\Set($db->queryFirstColumn(
|
||||
'SELECT city FROM city WHERE nation = %i AND city IN %li AND supply = 1',
|
||||
$general->getNationID(),
|
||||
array_merge(...$distanceList)
|
||||
));
|
||||
|
||||
$nearestCityList = [];
|
||||
foreach($distanceList as $cityList){
|
||||
foreach($cityList as $cityID){
|
||||
if($occupiedCityList->contains($cityID)){
|
||||
$nearestCityList[] = $cityID;
|
||||
}
|
||||
}
|
||||
if($nearestCityList){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$nearestCityList){
|
||||
$logger->pushGeneralActionLog("3칸 이내에 아국 도시가 없습니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
$destCityID = $rng->choice($nearestCityList);
|
||||
$destCityName = CityConst::byID($destCityID)->name;
|
||||
|
||||
$josaRo = JosaUtil::pick($destCityName, '로');
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>{$josaRo} 접경귀환했습니다.");
|
||||
$general->setVar('city', $destCityID);
|
||||
|
||||
//TODO: InstantAction일때에만 설정하지 않는게 나은데..
|
||||
//$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class che_증여 extends Command\GeneralCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
|
||||
@@ -269,7 +269,7 @@ class che_화계 extends Command\GeneralCommand
|
||||
$destCityGeneralList = [];
|
||||
|
||||
$cityGeneralID = $db->queryFirstColumn('SELECT no FROM general WHERE city = %i AND nation = %i', $destCityID, $destNationID);
|
||||
$destCityGeneralList = General::createGeneralObjListFromDB($cityGeneralID, ['name', 'city', 'nation', 'officer_level', 'leadership', 'horse', 'strength', 'weapon', 'intel', 'book', 'item', 'last_turn', 'injury', 'special', 'special2', 'injury', 'crewtype', 'crew', 'atmos', 'train']);
|
||||
$destCityGeneralList = General::createObjListFromDB($cityGeneralID, ['name', 'city', 'nation', 'officer_level', 'leadership', 'horse', 'strength', 'weapon', 'intel', 'book', 'item', 'last_turn', 'injury', 'special', 'special2', 'injury', 'crewtype', 'crew', 'atmos', 'train']);
|
||||
foreach ($destCityGeneralList as &$destCityGeneral) {
|
||||
$destCityGeneral->setRawCity($this->destCity);
|
||||
unset($destCityGeneral);
|
||||
|
||||
@@ -182,6 +182,7 @@ class che_급습 extends Command\NationCommand
|
||||
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <M>{$commandName}</>{$josaUl} 발동");
|
||||
$destNationLogger->flush();
|
||||
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
||||
|
||||
$db->update('nation', [
|
||||
|
||||
@@ -92,7 +92,7 @@ class che_몰수 extends Command\NationCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation', 'imgsvr', 'picture'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
$env = $this->env;
|
||||
|
||||
@@ -72,7 +72,7 @@ class che_발령 extends Command\NationCommand
|
||||
{
|
||||
$this->setDestCity($this->arg['destCityID']);
|
||||
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
if ($this->arg['destGeneralID'] == $this->getGeneral()->getID()) {
|
||||
|
||||
@@ -156,7 +156,7 @@ class che_백성동원 extends Command\NationCommand
|
||||
'wall' => $db->sqleval('GREATEST(wall_max * 0.8, wall)'),
|
||||
], 'city=%i', $destCityID);
|
||||
|
||||
$logger->pushGeneralHistoryLog('<M>백성동원</>을 발동');
|
||||
$logger->pushGeneralHistoryLog("<G><b>{$destCityName}</b></>에 <M>백성동원</>을 발동");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$destCityName}</b></>에 <M>백성동원</>을 발동");
|
||||
|
||||
$db->update('nation', [
|
||||
|
||||
@@ -104,7 +104,7 @@ class che_불가침수락 extends Command\NationCommand
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ class che_불가침제의 extends Command\NationCommand
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
ConstraintHelper::DifferentDestNation(),
|
||||
ConstraintHelper::DisallowDiplomacyBetweenStatus([
|
||||
0 => '아국과 이미 교전중입니다.',
|
||||
1 => '아국과 이미 선포중입니다.',
|
||||
|
||||
@@ -78,7 +78,7 @@ class che_불가침파기수락 extends Command\NationCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@ class che_선전포고 extends Command\NationCommand
|
||||
$destLogger = new ActionLogger(0, $destNationID, $env['year'], $env['month']);
|
||||
|
||||
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>에 선전 포고 했습니다.<1>$date</>");
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>에 선전 포고");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 선전 포고");
|
||||
$destLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 선전 포고");
|
||||
|
||||
|
||||
@@ -179,6 +179,7 @@ class che_이호경식 extends Command\NationCommand
|
||||
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <M>{$commandName}</>{$josaUl} 발동");
|
||||
$destNationLogger->flush();
|
||||
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <M>{$commandName}</>{$josaUl} 발동");
|
||||
|
||||
$db->update('nation', [
|
||||
|
||||
@@ -87,7 +87,7 @@ class che_종전수락 extends Command\NationCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], null, GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
$this->setDestNation($this->arg['destNationID']);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class che_포상 extends Command\NationCommand
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], GeneralQueryMode::Lite);
|
||||
$destGeneral = General::createObjFromDB($this->arg['destGeneralID']);
|
||||
$this->setDestGeneral($destGeneral);
|
||||
|
||||
if($this->arg['destGeneralID'] == $this->getGeneral()->getID()){
|
||||
|
||||
@@ -228,6 +228,7 @@ class che_피장파장 extends Command\NationCommand
|
||||
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} 아국에 <G><b>{$cmd->getName()}</b></> <M>{$commandName}</>{$josaUl} 발동");
|
||||
$destNationLogger->flush();
|
||||
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>에 <G><b>{$cmd->getName()}</b></> <M>{$commandName}</>{$josaUl} 발동");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <G><b>{$cmd->getName()}</b></> <M>{$commandName}</>{$josaUl} 발동");
|
||||
|
||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||
|
||||
@@ -95,7 +95,7 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
$broadcastMessage = "<Y>{$generalName}</>{$josaYi} <M>필사즉생</>을 발동하였습니다.";
|
||||
|
||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no != %i', $nationID, $generalID);
|
||||
foreach(General::createGeneralObjListFromDB($targetGeneralList, ['train', 'atmos'], GeneralQueryMode::Lite) as $targetGeneral){
|
||||
foreach(General::createObjListFromDB($targetGeneralList) as $targetGeneral){
|
||||
$targetGeneral->getLogger()->pushGeneralActionLog($broadcastMessage, ActionLogger::PLAIN);
|
||||
if($targetGeneral->getVar('train') < 100){
|
||||
$targetGeneral->setVar('train', 100);
|
||||
|
||||
@@ -163,7 +163,7 @@ class che_허보 extends Command\NationCommand
|
||||
$destNationCityList = $db->queryFirstColumn('SELECT city FROM city WHERE nation = %i AND supply = 1', $destNationID);
|
||||
|
||||
$targetGeneralList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city=%i', $destNationID, $destCityID);
|
||||
foreach (General::createGeneralObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral) {
|
||||
foreach (General::createObjListFromDB($targetGeneralList) as $targetGeneralID => $targetGeneral) {
|
||||
$targetLogger = $targetGeneral->getLogger();
|
||||
$targetLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@ class AvailableRecruitCrewType extends Constraint{
|
||||
}
|
||||
|
||||
$crewType = GameUnitConst::byID($this->arg);
|
||||
if($crewType->isValid($ownCities, $ownRegions, $year = $startyear, $tech)){
|
||||
if($crewType->isValid($ownCities, $ownRegions, $year - $startyear, $tech)){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "현재 선택할 수 없는 병종입니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +156,10 @@ class ConstraintHelper{
|
||||
return [__FUNCTION__];
|
||||
}
|
||||
|
||||
static function NotOccupiedCity():array{
|
||||
return [__FUNCTION__];
|
||||
}
|
||||
|
||||
static function NotOccupiedDestCity():array{
|
||||
return [__FUNCTION__];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
class NotOccupiedCity extends Constraint{
|
||||
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_CITY;
|
||||
|
||||
public function checkInputValues(bool $throwExeception=true):bool{
|
||||
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!key_exists('nation', $this->general)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require nation in general");
|
||||
}
|
||||
|
||||
if(!key_exists('nation', $this->city)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require nation in city");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function test():bool{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
if($this->city['nation'] != $this->general['nation']){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "아국입니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class ReqGeneralCrewMargin extends Constraint{
|
||||
throw new \InvalidArgumentException("{$this->arg} is invalid crewtype");
|
||||
}
|
||||
|
||||
foreach(['leadership','strength','intel','crew','crewtype','nation','officer_level'] as $key){
|
||||
foreach(['leadership','strength','intel','crew','crewtype','nation','officer_level','aux'] as $key){
|
||||
if(!key_exists($key, $this->general)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require {$key} in general");
|
||||
@@ -39,7 +39,7 @@ class ReqGeneralCrewMargin extends Constraint{
|
||||
|
||||
//XXX: 왜 General -> obj -> General 변환을 하고 있나?
|
||||
//FIXME: RankVar, city에 따라 통솔이 바뀐다면 이 부분에 문제가 발생.
|
||||
$generalObj = new General($this->general, null, null, null, null, null, null, true);
|
||||
$generalObj = new General($this->general, null, null, null, null, 180, 1);
|
||||
|
||||
if($reqCrewType->id != $generalObj->getCrewTypeObj()->id){
|
||||
return true;
|
||||
|
||||
@@ -76,7 +76,7 @@ class DiplomaticMessage extends Message{
|
||||
|
||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||
|
||||
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Lite);
|
||||
$destGeneralObj = General::createObjFromDB($this->dest->generalID);
|
||||
|
||||
$commandObj = buildNationCommandClass('che_불가침수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
|
||||
'destNationID'=>$this->src->nationID,
|
||||
@@ -100,7 +100,7 @@ class DiplomaticMessage extends Message{
|
||||
protected function cancelNA(){
|
||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||
|
||||
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Lite);
|
||||
$destGeneralObj = General::createObjFromDB($this->dest->generalID);
|
||||
|
||||
$commandObj = buildNationCommandClass('che_불가침파기수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
|
||||
'destNationID'=>$this->src->nationID,
|
||||
@@ -122,7 +122,7 @@ class DiplomaticMessage extends Message{
|
||||
protected function stopWar(){
|
||||
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||
|
||||
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], GeneralQueryMode::Lite);
|
||||
$destGeneralObj = General::createObjFromDB($this->dest->generalID);
|
||||
|
||||
$commandObj = buildNationCommandClass('che_종전수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
|
||||
'destNationID'=>$this->src->nationID,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Enums\InheritanceKey;
|
||||
|
||||
class DummyGeneralLite extends GeneralLite
|
||||
{
|
||||
public function __construct(bool $initLogger = true)
|
||||
{
|
||||
$raw = [
|
||||
'no' => 0,
|
||||
'name' => 'Dummy',
|
||||
'npc' => 3,
|
||||
'city' => 0,
|
||||
'nation' => 0,
|
||||
'officer_level' => 0,
|
||||
'crewtype' => -1,
|
||||
'turntime' => '2012-03-04 05:06:07.000000',
|
||||
'experience' => 0,
|
||||
'dedication' => 0,
|
||||
'gold' => 0,
|
||||
'rice' => 0,
|
||||
'leadership' => 10,
|
||||
'strength' => 10,
|
||||
'intel' => 10,
|
||||
'imgsvr' => 0,
|
||||
'picture' => 'default.jpg',
|
||||
];
|
||||
|
||||
$this->raw = $raw;
|
||||
|
||||
if ($initLogger) {
|
||||
$this->initLogger(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function applyDB($db): bool
|
||||
{
|
||||
if ($this->logger) {
|
||||
$this->initLogger($this->logger->getYear(), $this->logger->getMonth());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Enums;
|
||||
|
||||
// mergeQueryColumn, createGeneralLiteObjListFromDB, createGeneralLiteObjFromDB 호출시 column 특수 모드 지정
|
||||
enum GeneralLiteQueryMode: int
|
||||
{
|
||||
/** 장수 식별을 위한 최소한의 정보, logger 초기화 없음 */
|
||||
case Core = 0;
|
||||
/** 게임 내에서 필수 이벤트 처리를 위한 정보 */
|
||||
case Lite = 1;
|
||||
/** 게임 내 모든 이벤트 처리를 위한 정보 */
|
||||
case Full = 2;
|
||||
}
|
||||
@@ -5,12 +5,6 @@ namespace sammo\Enums;
|
||||
// mergeQueryColumn, createGeneralObjListFromDB, createGeneralObjFromDB 호출시 column 특수 모드 지정
|
||||
enum GeneralQueryMode: int
|
||||
{
|
||||
/** 장수 식별을 위한 최소한의 정보, logger 초기화 없음 */
|
||||
case Core = 0;
|
||||
/** 게임 내에서 필수 이벤트 처리를 위한 정보, iAction 제외 */
|
||||
case Lite = 1;
|
||||
/** 게임 내 모든 이벤트 처리를 위한 정보, iAction 제외 */
|
||||
case FullWithoutIAction = 2;
|
||||
/** 게임 내 모든 이벤트 처리를 위한 정보, iAction 포함 */
|
||||
case Full = 3;
|
||||
/** 접속 정보를 포함한 모든 정보 */
|
||||
|
||||
@@ -28,7 +28,7 @@ class LostUniqueItem extends \sammo\Event\Action
|
||||
if (!$generalIDList) {
|
||||
return;
|
||||
}
|
||||
$generals = General::createGeneralObjListFromDB($generalIDList);
|
||||
$generals = General::createObjListFromDB($generalIDList);
|
||||
|
||||
$lostItems = [];
|
||||
$totalLostCnt = 0;
|
||||
|
||||
@@ -18,7 +18,7 @@ class MergeInheritPointRank extends \sammo\Event\Action
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
$generals = General::createGeneralObjListFromDB(null, null);
|
||||
$generals = General::createObjListFromDB(null, null);
|
||||
|
||||
$points = new Map();
|
||||
$points->allocate(count($generals));
|
||||
|
||||
@@ -39,7 +39,11 @@ class ProcessIncome extends \sammo\Event\Action
|
||||
|
||||
$nationList = $db->query('SELECT name,nation,capital,gold,level,rate_tmp,bill,type from nation');
|
||||
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,gold,officer_level,dedication,city FROM general WHERE npc != 5'), 'nation');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE npc != 5',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0])
|
||||
), 'nation');
|
||||
|
||||
//국가별 처리
|
||||
foreach ($nationList as $nation) {
|
||||
@@ -119,7 +123,11 @@ class ProcessIncome extends \sammo\Event\Action
|
||||
|
||||
$nationList = $db->query('SELECT name,level,nation,capital,rice,rate_tmp,bill,type from nation');
|
||||
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,rice,officer_level,dedication,city FROM general WHERE npc != 5'), 'nation');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE npc != 5',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0])
|
||||
), 'nation');
|
||||
|
||||
//국가별 처리
|
||||
foreach ($nationList as $nation) {
|
||||
|
||||
@@ -84,7 +84,7 @@ class ProvideNPCTroopLeader extends \sammo\Event\Action
|
||||
'troop' => $npcID
|
||||
], 'no=%i', $npcID);
|
||||
|
||||
$cmd = buildGeneralCommandClass('che_집합', General::createGeneralObjFromDB($npcID), $env);
|
||||
$cmd = buildGeneralCommandClass('che_집합', General::createObjFromDB($npcID), $env);
|
||||
_setGeneralCommand($cmd, iterator_to_array(Util::range(GameConst::$maxTurn)));
|
||||
$NPCTroopLeaderCnt += 1;
|
||||
$gameStor->lastNPCTroopLeaderID = $lastNPCTroopLeaderID;
|
||||
|
||||
@@ -112,7 +112,12 @@ class RaiseDisaster extends \sammo\Event\Action
|
||||
$logger->flush();
|
||||
|
||||
if (!$isGood) {
|
||||
$generalListByCity = Util::arrayGroupBy($db->query('SELECT no, name, nation, city, officer_level, injury, leadership, strength, intel, horse, weapon, book, item, crew, crewtype, atmos, train, special, special2 FROM general WHERE city IN %li', Util::squeezeFromArray($targetCityList, 'city')), 'city');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalListByCity = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE city IN %li',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0]),
|
||||
Util::squeezeFromArray($targetCityList, 'city')),
|
||||
'city');
|
||||
//NOTE: 쿼리 1번이지만 복잡하기 vs 쿼리 여러번이지만 조금 더 깔끔하기
|
||||
foreach ($targetCityList as $city) {
|
||||
$affectRatio = Util::valueFit($city['secu'] / $city['secu_max'] / 0.8, 0, 1);
|
||||
|
||||
@@ -140,7 +140,7 @@ class UpdateNationLevel extends \sammo\Event\Action
|
||||
$nation['nation'],
|
||||
$targetKillTurn
|
||||
);
|
||||
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux']);
|
||||
$nationGenList = General::createObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux']);
|
||||
$chiefID = null;
|
||||
|
||||
$uniqueLotteryWeightList = [];
|
||||
@@ -215,7 +215,7 @@ class UpdateNationLevel extends \sammo\Event\Action
|
||||
}
|
||||
|
||||
if ($chiefID) {
|
||||
$chiefObj = General::createGeneralObjFromDB($chiefID, ['belong', 'npc', 'aux'], GeneralQueryMode::Lite);
|
||||
$chiefObj = General::createObjFromDB($chiefID);
|
||||
$chiefObj->increaseInheritancePoint(InheritanceKey::unifier, 250 * $levelDiff);
|
||||
$chiefObj->applyDB($db);
|
||||
}
|
||||
|
||||
@@ -225,6 +225,19 @@ class GameConstBase
|
||||
public static $inheritSpecificSpecialPoint = 4000;
|
||||
public static $inheritResetAttrPointBase = [1000, 1000, 2000, 3000];//필요하면 늘려서 쓰기
|
||||
|
||||
/** @var ?string */
|
||||
public static $scenarioEffect = null;
|
||||
|
||||
public static $defaultInstantAction = [
|
||||
'dieOnPrestart' => true,
|
||||
'buildNationCandidate' => true,
|
||||
];
|
||||
|
||||
public static $availableInstantAction = [
|
||||
'dieOnPrestart' => true,
|
||||
'buildNationCandidate' => true,
|
||||
];
|
||||
|
||||
public static $allItems = [
|
||||
'horse' => [
|
||||
'che_명마_01_노기' => 0, 'che_명마_02_조랑' => 0, 'che_명마_03_노새' => 0,
|
||||
|
||||
+39
-245
@@ -10,27 +10,20 @@ use sammo\Enums\InheritanceKey;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\WarUnitTrigger as WarUnitTrigger;
|
||||
|
||||
class General implements iAction
|
||||
class General extends GeneralBase implements iAction
|
||||
{
|
||||
use LazyVarUpdater;
|
||||
use LazyVarAndAuxUpdater;
|
||||
|
||||
protected $raw = [];
|
||||
protected $rawCity = null;
|
||||
|
||||
|
||||
/** @var Map<RankColumn,int|float> */
|
||||
/** @var Map<RankColumn,int> */
|
||||
protected Map $rankVarRead;
|
||||
/** @var Map<RankColumn,int|float> */
|
||||
/** @var Map<RankColumn,int> */
|
||||
protected Map $rankVarIncrease;
|
||||
/** @var Map<RankColumn,int|float> */
|
||||
/** @var Map<RankColumn,int> */
|
||||
protected Map $rankVarSet;
|
||||
|
||||
/** @var Map<GeneralAccessLogColumn,int|float> */
|
||||
/** @var Map<GeneralAccessLogColumn,int|float|string> */
|
||||
protected ?Map $accessLogRead;
|
||||
|
||||
/** @var \sammo\ActionLogger */
|
||||
protected $logger;
|
||||
|
||||
protected $activatedSkill = [];
|
||||
protected $logActivatedSkill = [];
|
||||
protected $isFinished = false;
|
||||
@@ -49,47 +42,26 @@ class General implements iAction
|
||||
protected $itemObjs = [];
|
||||
/** @var ?iAction */
|
||||
protected $inheritBuffObj = null;
|
||||
/** @var ?iAction */
|
||||
protected $scenarioEffect = null;
|
||||
|
||||
/** @var ?GameUnitDetail */
|
||||
protected $crewType = null;
|
||||
|
||||
protected $lastTurn = null;
|
||||
protected $resultTurn = null;
|
||||
|
||||
const TURNTIME_FULL_MS = -1;
|
||||
const TURNTIME_FULL = 0;
|
||||
const TURNTIME_HMS = 1;
|
||||
const TURNTIME_HM = 2;
|
||||
|
||||
protected $calcCache = [];
|
||||
|
||||
protected static $prohibitedDirectUpdateVars = [
|
||||
//Reason: iAction
|
||||
'leadership' => 1,
|
||||
'power' => 1,
|
||||
'intel' => 1,
|
||||
'nation' => 2,
|
||||
'officer_level' => 1,
|
||||
//NOTE: officerLevelObj로 인해 국가의 '레벨'이 바뀌는 것도 조심해야 하나, 국가 레벨의 변경은 월 초/말에만 일어남.
|
||||
'special' => 1,
|
||||
'special2' => 1,
|
||||
'personal' => 1,
|
||||
'horse' => 1,
|
||||
'weapon' => 1,
|
||||
'book' => 1,
|
||||
'item' => 1
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param array $raw DB row값.
|
||||
* @param null|Map<RankColumn,int|float> $rawRank
|
||||
* @param null|Map<GeneralAccessLogColumn,int> $rawAccessLog
|
||||
* @param null|array $city DB city 테이블의 row값
|
||||
* @param int|null $year 게임 연도
|
||||
* @param int|null $month 게임 월
|
||||
* @param bool $fullConstruct iAction, 및 ActionLogger 초기화 여부, false인 경우 no, name, city, nation, officer_level 정도로 초기화 가능
|
||||
* @param int $year 게임 연도
|
||||
* @param int $month 게임 월
|
||||
*/
|
||||
public function __construct(array $raw, ?Map $rawRank, ?Map $rawAccessLog, ?array $city, ?array $nation, ?int $year, ?int $month, bool $fullConstruct = true)
|
||||
public function __construct(array $raw, ?Map $rawRank, ?Map $rawAccessLog, ?array $city, ?array $nation, int $year, int $month)
|
||||
{
|
||||
//TODO: 밖에서 가져오도록 하면 버그 확률이 높아짐. 필요한 raw 값을 직접 구해야함.
|
||||
|
||||
@@ -106,9 +78,7 @@ class General implements iAction
|
||||
$this->resultTurn = $this->lastTurn->duplicate();
|
||||
}
|
||||
|
||||
if ($year !== null && $month !== null) {
|
||||
$this->initLogger($year, $month);
|
||||
}
|
||||
$this->initLogger($year, $month);
|
||||
|
||||
if ($rawRank) {
|
||||
$this->rankVarRead = $rawRank;
|
||||
@@ -122,10 +92,6 @@ class General implements iAction
|
||||
$this->rankVarIncrease = new Map();
|
||||
$this->rankVarSet = new Map();
|
||||
|
||||
if (!$fullConstruct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->nationType = buildNationTypeClass($nation['type']);
|
||||
$this->officerLevelObj = new TriggerOfficerLevel($this->raw, $nation['level']);
|
||||
|
||||
@@ -141,41 +107,14 @@ class General implements iAction
|
||||
$this->itemObjs['book'] = buildItemClass($raw['book']);
|
||||
$this->itemObjs['item'] = buildItemClass($raw['item']);
|
||||
|
||||
if (key_exists('aux', $this->raw)) {
|
||||
$rawInheritBuff = $this->getAuxVar('inheritBuff');
|
||||
if ($rawInheritBuff !== null) {
|
||||
$this->inheritBuffObj = new TriggerInheritBuff($rawInheritBuff);
|
||||
}
|
||||
$rawInheritBuff = $this->getAuxVar('inheritBuff');
|
||||
if ($rawInheritBuff !== null) {
|
||||
$this->inheritBuffObj = new TriggerInheritBuff($rawInheritBuff);
|
||||
}
|
||||
}
|
||||
|
||||
function initLogger(int $year, int $month)
|
||||
{
|
||||
$this->logger = new ActionLogger(
|
||||
$this->getVar('no'),
|
||||
$this->getVar('nation'),
|
||||
$year,
|
||||
$month,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
function getTurnTime(int $short = self::TURNTIME_FULL_MS)
|
||||
{
|
||||
return [
|
||||
self::TURNTIME_FULL_MS => function ($turntime) {
|
||||
return $turntime;
|
||||
},
|
||||
self::TURNTIME_FULL => function ($turntime) {
|
||||
return substr($turntime, 0, 19);
|
||||
},
|
||||
self::TURNTIME_HMS => function ($turntime) {
|
||||
return substr($turntime, 11, 8);
|
||||
},
|
||||
self::TURNTIME_HM => function ($turntime) {
|
||||
return substr($turntime, 11, 5);
|
||||
},
|
||||
][$short]($this->getVar('turntime'));
|
||||
if(GameConst::$scenarioEffect){
|
||||
$this->scenarioEffect = buildScenarioEffectClass(GameConst::$scenarioEffect);
|
||||
}
|
||||
}
|
||||
|
||||
function setItem(string $itemKey = 'item', ?string $itemCode)
|
||||
@@ -200,11 +139,6 @@ class General implements iAction
|
||||
return $this->itemObjs[$itemKey];
|
||||
}
|
||||
|
||||
function getNPCType(): int
|
||||
{
|
||||
return $this->raw['npc'];
|
||||
}
|
||||
|
||||
/** @return BaseItem[] */
|
||||
function getItems(): array
|
||||
{
|
||||
@@ -281,48 +215,13 @@ class General implements iAction
|
||||
}
|
||||
}
|
||||
|
||||
function getName(): string
|
||||
{
|
||||
return $this->raw['name'];
|
||||
}
|
||||
|
||||
function getInfo(): string
|
||||
{
|
||||
//iAction용 info로는 적절하지 않음
|
||||
return '';
|
||||
}
|
||||
|
||||
function getID(): int
|
||||
{
|
||||
return $this->raw['no'];
|
||||
}
|
||||
|
||||
function getRawCity(): ?array
|
||||
{
|
||||
return $this->rawCity;
|
||||
}
|
||||
|
||||
function setRawCity(?array $city)
|
||||
{
|
||||
$this->rawCity = $city;
|
||||
}
|
||||
|
||||
function getCityID(): int
|
||||
{
|
||||
return $this->raw['city'];
|
||||
}
|
||||
|
||||
function getNationID(): int
|
||||
{
|
||||
return $this->raw['nation'];
|
||||
}
|
||||
|
||||
function getStaticNation(): array
|
||||
{
|
||||
return getNationStaticInfo($this->raw['nation']);
|
||||
}
|
||||
|
||||
function getLogger(): ?ActionLogger
|
||||
function getLogger(): ActionLogger
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
@@ -459,20 +358,7 @@ class General implements iAction
|
||||
$statValue = Util::clamp($statValue, 0, GameConst::$maxLevel);
|
||||
|
||||
if ($withIActionObj) {
|
||||
foreach ([
|
||||
$this->nationType,
|
||||
$this->officerLevelObj,
|
||||
$this->specialDomesticObj,
|
||||
$this->specialWarObj,
|
||||
$this->personalityObj,
|
||||
$this->inheritBuffObj,
|
||||
] as $actionObj) {
|
||||
if ($actionObj !== null) {
|
||||
$statValue = $actionObj->onCalcStat($this, $statName, $statValue);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->itemObjs as $actionObj) {
|
||||
foreach ($this->getActionList() as $actionObj) {
|
||||
if ($actionObj !== null) {
|
||||
$statValue = $actionObj->onCalcStat($this, $statName, $statValue);
|
||||
}
|
||||
@@ -505,17 +391,6 @@ class General implements iAction
|
||||
return $this->getStatValue('intel', $withInjury, $withIActionObj, $withStatAdjust, $useFloor);
|
||||
}
|
||||
|
||||
function getDex(GameUnitDetail $crewType)
|
||||
{
|
||||
$armType = $crewType->armType;
|
||||
|
||||
if ($armType == GameUnitConst::T_CASTLE) {
|
||||
$armType = GameUnitConst::T_SIEGE;
|
||||
}
|
||||
|
||||
return $this->getVar("dex{$armType}");
|
||||
}
|
||||
|
||||
function addDex(GameUnitDetail $crewType, float $exp, bool $affectTrainAtmos = false)
|
||||
{
|
||||
$armType = $crewType->armType;
|
||||
@@ -593,8 +468,11 @@ class General implements iAction
|
||||
}
|
||||
}
|
||||
|
||||
function updateVar(string $key, $value)
|
||||
function updateVar(string|\BackedEnum $key, $value)
|
||||
{
|
||||
if($key instanceof \BackedEnum){
|
||||
$key = $key->value;
|
||||
}
|
||||
if (($this->raw[$key] ?? null) === $value) {
|
||||
return;
|
||||
}
|
||||
@@ -890,6 +768,7 @@ class General implements iAction
|
||||
$this->personalityObj,
|
||||
$this->crewType,
|
||||
$this->inheritBuffObj,
|
||||
$this->scenarioEffect
|
||||
], $this->itemObjs);
|
||||
}
|
||||
|
||||
@@ -1032,85 +911,6 @@ class General implements iAction
|
||||
return $caller;
|
||||
}
|
||||
|
||||
static public function mergeQueryColumn(?array $reqColumns = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array
|
||||
{
|
||||
$minimumColumn = ['no', 'name', 'npc', 'city', 'nation', 'officer_level', 'officer_city'];
|
||||
$defaultEventColumn = [
|
||||
'no', 'name', 'npc', 'owner', 'city', 'nation', 'officer_level', 'officer_city',
|
||||
'special', 'special2', 'personal',
|
||||
'horse', 'weapon', 'book', 'item', 'last_turn', 'aux',
|
||||
];
|
||||
$fullColumn = [
|
||||
'no', 'name', 'owner', 'owner_name', 'picture', 'imgsvr', 'nation', 'city', 'troop', 'injury', 'affinity',
|
||||
'leadership', 'leadership_exp', 'strength', 'strength_exp', 'intel', 'intel_exp', 'weapon', 'book', 'horse', 'item',
|
||||
'experience', 'dedication', 'officer_level', 'officer_city', 'gold', 'rice', 'crew', 'crewtype', 'train', 'atmos', 'turntime',
|
||||
'makelimit', 'killturn', 'block', 'dedlevel', 'explevel', 'age', 'startage', 'belong',
|
||||
'personal', 'special', 'special2', 'defence_train', 'tnmt', 'npc', 'npc_org', 'deadyear', 'npcmsg',
|
||||
'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'betray',
|
||||
'recent_war', 'last_turn', 'myset',
|
||||
'specage', 'specage2', 'aux', 'permission', 'penalty',
|
||||
];
|
||||
$fullAcessLogColumn = [
|
||||
GeneralAccessLogColumn::refreshScore,
|
||||
GeneralAccessLogColumn::refreshScoreTotal,
|
||||
];
|
||||
|
||||
if ($reqColumns === null) {
|
||||
switch ($queryMode) {
|
||||
case GeneralQueryMode::Core:
|
||||
return [$minimumColumn, [], []];
|
||||
case GeneralQueryMode::Lite:
|
||||
return [$defaultEventColumn, [], []];
|
||||
case GeneralQueryMode::FullWithoutIAction:
|
||||
case GeneralQueryMode::Full:
|
||||
return [$fullColumn, RankColumn::cases(), []];
|
||||
case GeneralQueryMode::FullWithAccessLog:
|
||||
return [$fullColumn, RankColumn::cases(), $fullAcessLogColumn];
|
||||
}
|
||||
}
|
||||
|
||||
/** @var RankColumn[] */
|
||||
$rankColumn = [];
|
||||
$subColumn = [];
|
||||
$accessLogColumn = [];
|
||||
foreach ($reqColumns as $column) {
|
||||
if ($column instanceof RankColumn) {
|
||||
$rankColumn[] = $column;
|
||||
continue;
|
||||
}
|
||||
if ($column instanceof GeneralAccessLogColumn) {
|
||||
$accessLogColumn[] = $column;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$enumKey = RankColumn::tryFrom($column);
|
||||
if ($enumKey !== null) {
|
||||
$rankColumn[] = $enumKey;
|
||||
continue;
|
||||
}
|
||||
$enumKey = GeneralAccessLogColumn::tryFrom($column);
|
||||
if ($enumKey !== null) {
|
||||
$accessLogColumn[] = $enumKey;
|
||||
continue;
|
||||
}
|
||||
$subColumn[] = $column;
|
||||
}
|
||||
|
||||
switch ($queryMode) {
|
||||
case GeneralQueryMode::Core:
|
||||
case GeneralQueryMode::Lite:
|
||||
return [array_unique(array_merge($minimumColumn, $subColumn)), $rankColumn, $accessLogColumn];
|
||||
case GeneralQueryMode::FullWithoutIAction:
|
||||
case GeneralQueryMode::Full:
|
||||
return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn, $accessLogColumn];
|
||||
case GeneralQueryMode::FullWithAccessLog:
|
||||
return [array_unique(array_merge($fullColumn, $subColumn)), $rankColumn, array_unique(array_merge($fullAcessLogColumn, $accessLogColumn))];
|
||||
default:
|
||||
throw new \RuntimeException('invalid query mode');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?int[] $generalIDList
|
||||
* @param null|array<string|RankColumn> $column
|
||||
@@ -1118,20 +918,15 @@ class General implements iAction
|
||||
* @return \sammo\General[]
|
||||
* @throws MustNotBeReachedException
|
||||
*/
|
||||
static public function createGeneralObjListFromDB(?array $generalIDList, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array
|
||||
static public function createObjListFromDB(?array $generalIDList, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array
|
||||
{
|
||||
if ($generalIDList === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
if ($queryMode->value > 0) {
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
} else {
|
||||
$year = null;
|
||||
$month = null;
|
||||
}
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
|
||||
/**
|
||||
* @var string[] $column
|
||||
@@ -1196,25 +991,24 @@ class General implements iAction
|
||||
$result[$generalID] = new DummyGeneral($queryMode->value > 0);
|
||||
continue;
|
||||
}
|
||||
if ($rawRanks->hasKey($generalID) && $rawRanks[$generalID]->count() !== count($rankColumn)) {
|
||||
/** @var Map<RankColumn,int|float> */
|
||||
$generalRankValues = $rawRanks[$generalID] ?? new Map();
|
||||
if ($generalRankValues->count() !== count($rankColumn)) {
|
||||
throw new \RuntimeException('column의 수가 일치하지 않음 : ' . $generalID);
|
||||
}
|
||||
$result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID] ?? null, $rawAccessLogs[$generalID] ?? null, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full->value);
|
||||
|
||||
$generalAccessLog = $rawAccessLogs[$generalID] ?? new Map();
|
||||
$result[$generalID] = new static($rawGenerals[$generalID], $generalRankValues, $generalAccessLog, null, null, $year, $month);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
static public function createGeneralObjFromDB(int $generalID, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): self
|
||||
static public function createObjFromDB(int $generalID, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): self
|
||||
{
|
||||
$db = DB::db();
|
||||
if ($queryMode->value > 0) {
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
} else {
|
||||
$year = null;
|
||||
$month = null;
|
||||
}
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
|
||||
/**
|
||||
* @var string[] $column
|
||||
@@ -1268,7 +1062,7 @@ class General implements iAction
|
||||
}
|
||||
|
||||
|
||||
$general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month, $queryMode->value >= GeneralQueryMode::Full->value);
|
||||
$general = new static($rawGeneral, $rawRankValues, $rawAccessLog, null, null, $year, $month);
|
||||
|
||||
return $general;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user