refac: 감찰부 vue3 재 작성 (#222)

- 장수 정보, 추가 정보 vue3 component
- b_battleCenter -> v_battleCenter

Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/222
This commit was merged in pull request #222.
This commit is contained in:
2022-07-16 15:49:23 +09:00
parent 800106f9cb
commit 43a95979e1
16 changed files with 632 additions and 87 deletions
+2 -2
View File
@@ -18,12 +18,12 @@ class GetGeneralLog extends GetNationGeneralLog
$v = new Validator($this->args);
$v
->rule('required', [
'type',
'reqType',
])
->rule('int', [
'reqTo',
])
->rule('in', 'type', [
->rule('in', 'reqType', [
self::GENERAL_HISTORY,
self::GENERAL_ACTION,
self::BATTLE_RESULT,
+8 -7
View File
@@ -9,11 +9,12 @@ use sammo\Validator;
use function sammo\checkLimit;
use function sammo\checkSecretPermission;
use function sammo\getBattleDetailLogMore;
use function sammo\getBattleDetailLogRecent;
use function sammo\getBattleResultMore;
use function sammo\getBattleResultRecent;
use function sammo\getGeneralActionLogMore;
use function sammo\getGeneralActionLogRecent;
use function sammo\getGeneralHistoryLogAll;
use function sammo\getGeneralHistoryLogWithLogID;
class GetGeneralLog extends \sammo\BaseAPI
{
@@ -28,13 +29,13 @@ class GetGeneralLog extends \sammo\BaseAPI
$v
->rule('required', [
'generalID',
'type',
'reqType',
])
->rule('integer', [
'generalID',
'reqTo',
])
->rule('in', 'type', [
->rule('in', 'reqType', [
self::GENERAL_HISTORY,
self::GENERAL_ACTION,
self::BATTLE_RESULT,
@@ -76,7 +77,7 @@ class GetGeneralLog extends \sammo\BaseAPI
return '같은 나라의 장수가 아닙니다.';
}
$reqType = $this->args['type'];
$reqType = $this->args['reqType'];
if (
$reqType === self::GENERAL_ACTION &&
$testGeneralNPCType < 2 &&
@@ -103,7 +104,7 @@ class GetGeneralLog extends \sammo\BaseAPI
$userID = $session->userID;
$targetGeneralID = $this->getTargetGeneralID($session);
$reqType = $this->args['type'];
$reqType = $this->args['reqType'];
$reqTo = $this->args['reqTo'] ?? null;
$db = DB::db();
@@ -124,7 +125,7 @@ class GetGeneralLog extends \sammo\BaseAPI
'result' => true,
'reqType' => $reqType,
'generalID' => $targetGeneralID,
'log' => getGeneralHistoryLogAll($targetGeneralID)
'log' => getGeneralHistoryLogWithLogID($targetGeneralID)
];
}
@@ -156,7 +157,7 @@ class GetGeneralLog extends \sammo\BaseAPI
'reqType' => $reqType,
'generalID' => $targetGeneralID,
'log' => $reqTo === null
? getBattleResultRecent($targetGeneralID, 30)
? getBattleDetailLogRecent($targetGeneralID, 30)
: getBattleDetailLogMore($targetGeneralID, $reqTo, 30)
];
}
+104
View File
@@ -0,0 +1,104 @@
<?php
namespace sammo\API\Nation;
use sammo\DB;
use sammo\GameConst;
use sammo\General;
use sammo\KVStorage;
use sammo\LastTurn;
use sammo\Session;
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
{
public function validateArgs(): ?string
{
$v = new Validator($this->args);
$v->rule('boolean', 'full');
if (!$v->validate()) {
return $v->errorStr();
}
return null;
}
public function getRequiredSessionMode(): int
{
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
}
public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag)
{
$userID = $session->userID;
$db = DB::db();
$nationID = $db->queryFirstField('SELECT nation FROM general WHERE `owner` = %i', $userID);
if (!$nationID) {
return [
'result' => true,
'nation' => getNationStaticInfo(0)
];
}
$isFull = $this->args['full'] ?? false;
if(!$isFull){
$nation = getNationStaticInfo($nationID);
return [
'result' => true,
'nation' => $nation,
];
}
$generalObj = General::createGeneralObjFromDB($session->generalID, null, 1);
$gameStor = KVStorage::getStorage($db, 'game_env');
$gameEnv = $gameStor->getValues(['year', 'month', 'startyear']);
$nation = $db->queryFirstRow(
'SELECT nation, `name`, color, capital, gennum, gold, rice, bill, rate, secretlimit, chief_set, scout, war, strategic_cmd_limit, surlimit, tech, `power`, `level`, `type` FROM nation WHERE id = %i',
$nationID
);
$nationStor = \sammo\KVStorage::getStorage($db, $nationID, 'nation_env');
$nationStor->cacheAll();
//전략 정보를 매번 읽어와야하나?
$impossibleStrategicCommandLists = [];
$strategicCommandLists = GameConst::$availableChiefCommand['전략'];
$yearMonth = Util::joinYearMonth($gameEnv['year'], $gameEnv['month']);
foreach ($strategicCommandLists as $command) {
$cmd = buildNationCommandClass($command, $generalObj, $gameEnv, new LastTurn());
$nextAvailableTurn = $cmd->getNextAvailableTurn();
if ($nextAvailableTurn > $yearMonth) {
$impossibleStrategicCommandLists[] = [$cmd->getName(), $nextAvailableTurn - $yearMonth];
}
}
$troopName = [];
foreach ($db->queryAllLists('SELECT troop_leader, name FROM troop WHERE nation=%i', $nationID) as [$troopID, $tName]) {
$troopName[$troopID] = $tName;
}
return [
'result' => true,
'nation' => $nation,
'impossibleStrategicCommandLists' => $impossibleStrategicCommandLists,
'troops' => $troopName,
];
}
}