From 857038cb50cafcbaee9e23b2e9e63ab5e2e7b4c4 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 7 May 2022 14:57:23 +0900 Subject: [PATCH 1/8] wip --- hwe/sammo/API/Nation/GetNationInfo.php | 108 ++++++++++++++++++ hwe/ts/PageBattleCenter.vue | 115 ++++++++++++++++++++ hwe/ts/components/GeneralSupplementCard.vue | 14 +-- hwe/ts/v_battleCenter.ts | 20 ++++ hwe/v_battleCenter.php | 43 ++++++++ 5 files changed, 292 insertions(+), 8 deletions(-) create mode 100644 hwe/sammo/API/Nation/GetNationInfo.php create mode 100644 hwe/ts/PageBattleCenter.vue create mode 100644 hwe/ts/v_battleCenter.ts create mode 100644 hwe/v_battleCenter.php diff --git a/hwe/sammo/API/Nation/GetNationInfo.php b/hwe/sammo/API/Nation/GetNationInfo.php new file mode 100644 index 00000000..4394c363 --- /dev/null +++ b/hwe/sammo/API/Nation/GetNationInfo.php @@ -0,0 +1,108 @@ +userID; + + $db = DB::db(); + $nationID = $db->queryFirstField('SELECT nation FROM general WHERE `owner` = %i', $userID); + + if(!$nationID){ + return [ + 'result' => true, + 'nation' => getNationStaticInfo(0) + ]; + } + + + + $targetGeneralID = $this->getTargetGeneralID($session); + $reqType = $this->args['type']; + $reqTo = $this->args['reqTo'] ?? null; + + + $me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,permission,penalty from general where owner=%i', $userID); + + $con = checkLimit($me['con']); + if ($con >= 2) { + return '접속 제한입니다.'; + } + + $permissionResult = $this->checkPermission($me); + if ($permissionResult !== null) { + return $permissionResult; + } + + if ($reqType == static::GENERAL_HISTORY) { + return [ + 'result' => true, + 'reqType' => $reqType, + 'generalID' => $targetGeneralID, + 'log' => getGeneralHistoryLogAll($targetGeneralID) + ]; + } + + if ($reqType == static::GENERAL_ACTION) { + return [ + 'result' => true, + 'reqType' => $reqType, + 'generalID' => $targetGeneralID, + 'log' => $reqTo === null + ? getGeneralActionLogRecent($targetGeneralID, 30) + : getGeneralActionLogMore($targetGeneralID, $reqTo, 30) + ]; + } + + if ($reqType == static::BATTLE_RESULT) { + return [ + 'result' => true, + 'reqType' => $reqType, + 'generalID' => $targetGeneralID, + 'log' => $reqTo === null + ? getBattleResultRecent($targetGeneralID, 30) + : getBattleResultMore($targetGeneralID, $reqTo, 30) + ]; + } + + if ($reqType == static::BATTLE_DETAIL) { + return [ + 'result' => true, + 'reqType' => $reqType, + 'generalID' => $targetGeneralID, + 'log' => $reqTo === null + ? getBattleResultRecent($targetGeneralID, 30) + : getBattleDetailLogMore($targetGeneralID, $reqTo, 30) + ]; + } + + return '잘못된 요청입니다: ' . $reqType; + } +} diff --git a/hwe/ts/PageBattleCenter.vue b/hwe/ts/PageBattleCenter.vue new file mode 100644 index 00000000..408e6af2 --- /dev/null +++ b/hwe/ts/PageBattleCenter.vue @@ -0,0 +1,115 @@ + + + + diff --git a/hwe/ts/components/GeneralSupplementCard.vue b/hwe/ts/components/GeneralSupplementCard.vue index 44220ff4..6bd27e6b 100644 --- a/hwe/ts/components/GeneralSupplementCard.vue +++ b/hwe/ts/components/GeneralSupplementCard.vue @@ -38,7 +38,7 @@
피살
{{ general.deathcrew.toLocaleString() }}
-
+
숙련도
-
+
예약턴
- -
NPC
+
+ {{ turn.brief }} +
@@ -69,6 +66,7 @@ import { formatDexLevel, type DexInfo } from "@/utilGame/formatDexLevel"; import { formatHonor } from "@/utilGame/formatHonor"; const props = defineProps<{ general: GeneralListItemP1; + showCommandList?: boolean; }>(); const dexList = computed((): [string, number, DexInfo][] => { diff --git a/hwe/ts/v_battleCenter.ts b/hwe/ts/v_battleCenter.ts new file mode 100644 index 00000000..e098d642 --- /dev/null +++ b/hwe/ts/v_battleCenter.ts @@ -0,0 +1,20 @@ +import "@scss/nationGeneral.scss"; +import "ag-grid-community/dist/styles/ag-grid.css"; +import "ag-grid-community/dist/styles/ag-theme-balham-dark.css"; + +import { createApp } from 'vue' +import PageBattleCenter from '@/PageBattleCenter.vue'; +import { BootstrapVue3, BToastPlugin } from 'bootstrap-vue-3'; +import { auto500px } from './util/auto500px'; +import { htmlReady } from "./util/htmlReady"; +import { insertCustomCSS } from "./util/customCSS"; + + + + +auto500px(); + +htmlReady(() => { + insertCustomCSS(); +}); +createApp(PageBattleCenter).use(BootstrapVue3).use(BToastPlugin).mount('#app'); \ No newline at end of file diff --git a/hwe/v_battleCenter.php b/hwe/v_battleCenter.php new file mode 100644 index 00000000..0bdcbb64 --- /dev/null +++ b/hwe/v_battleCenter.php @@ -0,0 +1,43 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game_env'); +$gen = Util::getReq('gen', 'int'); +?> + + + + + + + + <?= UniqueConst::$serverName ?>: 감찰부 + [ + 'serverNick' => DB::prefix(), + 'mapName' => GameConst::$mapName, + 'unitSet' => GameConst::$unitSet, + ], + 'queryValues' => [ + 'generalID' => $gen, + ] + ], false) ?> + + + + + + + +
+ + + \ No newline at end of file -- 2.54.0 From 11a8efac859a8dc2b678c4de33ce46211eb237c4 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Thu, 14 Jul 2022 22:48:03 +0900 Subject: [PATCH 2/8] wip --- hwe/sammo/API/Nation/GetNationInfo.php | 144 +++++++++++-------------- 1 file changed, 62 insertions(+), 82 deletions(-) diff --git a/hwe/sammo/API/Nation/GetNationInfo.php b/hwe/sammo/API/Nation/GetNationInfo.php index 4394c363..e0823ae0 100644 --- a/hwe/sammo/API/Nation/GetNationInfo.php +++ b/hwe/sammo/API/Nation/GetNationInfo.php @@ -3,9 +3,15 @@ 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; @@ -18,91 +24,65 @@ use function sammo\getNationStaticInfo; class GetNationInfo extends \sammo\BaseAPI { - public function validateArgs(): ?string - { - return null; + 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) + { + $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) + ]; } - public function getRequiredSessionMode(): int - { - return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY; + $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]; + } } - 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) - ]; - } - - - - $targetGeneralID = $this->getTargetGeneralID($session); - $reqType = $this->args['type']; - $reqTo = $this->args['reqTo'] ?? null; - - - $me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,permission,penalty from general where owner=%i', $userID); - - $con = checkLimit($me['con']); - if ($con >= 2) { - return '접속 제한입니다.'; - } - - $permissionResult = $this->checkPermission($me); - if ($permissionResult !== null) { - return $permissionResult; - } - - if ($reqType == static::GENERAL_HISTORY) { - return [ - 'result' => true, - 'reqType' => $reqType, - 'generalID' => $targetGeneralID, - 'log' => getGeneralHistoryLogAll($targetGeneralID) - ]; - } - - if ($reqType == static::GENERAL_ACTION) { - return [ - 'result' => true, - 'reqType' => $reqType, - 'generalID' => $targetGeneralID, - 'log' => $reqTo === null - ? getGeneralActionLogRecent($targetGeneralID, 30) - : getGeneralActionLogMore($targetGeneralID, $reqTo, 30) - ]; - } - - if ($reqType == static::BATTLE_RESULT) { - return [ - 'result' => true, - 'reqType' => $reqType, - 'generalID' => $targetGeneralID, - 'log' => $reqTo === null - ? getBattleResultRecent($targetGeneralID, 30) - : getBattleResultMore($targetGeneralID, $reqTo, 30) - ]; - } - - if ($reqType == static::BATTLE_DETAIL) { - return [ - 'result' => true, - 'reqType' => $reqType, - 'generalID' => $targetGeneralID, - 'log' => $reqTo === null - ? getBattleResultRecent($targetGeneralID, 30) - : getBattleDetailLogMore($targetGeneralID, $reqTo, 30) - ]; - } - - return '잘못된 요청입니다: ' . $reqType; + $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, + ]; + } } -- 2.54.0 From cc158344843855a6a23f694e817ef4ce666cbce2 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 15 Jul 2022 00:29:51 +0900 Subject: [PATCH 3/8] =?UTF-8?q?wip:=20=EC=B6=9C=EB=A0=A5=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/Nation/GetNationInfo.php | 18 ++++++++++++++++- hwe/templates/commandButton.php | 2 +- hwe/ts/PageBattleCenter.vue | 14 ++++++++++++- hwe/ts/SammoAPI.ts | 3 ++- hwe/ts/build_exports.json | 1 + hwe/ts/defs/API/Nation.ts | 28 +++++++++++++++++++++++++- 6 files changed, 61 insertions(+), 5 deletions(-) diff --git a/hwe/sammo/API/Nation/GetNationInfo.php b/hwe/sammo/API/Nation/GetNationInfo.php index e0823ae0..fe0c2fd0 100644 --- a/hwe/sammo/API/Nation/GetNationInfo.php +++ b/hwe/sammo/API/Nation/GetNationInfo.php @@ -26,7 +26,13 @@ class GetNationInfo extends \sammo\BaseAPI { public function validateArgs(): ?string { - return null; + $v = new Validator($this->args); + $v->rule('boolean', 'full'); + + if (!$v->validate()) { + return $v->errorStr(); + } + return null; } public function getRequiredSessionMode(): int @@ -48,6 +54,16 @@ class GetNationInfo extends \sammo\BaseAPI ]; } + $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'); diff --git a/hwe/templates/commandButton.php b/hwe/templates/commandButton.php index 2fc26597..29c513c7 100644 --- a/hwe/templates/commandButton.php +++ b/hwe/templates/commandButton.php @@ -13,7 +13,7 @@ '>세력 장수 중원 정보 현재 도시 -'>감 찰 부 +'>감 찰 부 유산 관리 내 정보&설정 diff --git a/hwe/ts/PageBattleCenter.vue b/hwe/ts/PageBattleCenter.vue index 408e6af2..d393515d 100644 --- a/hwe/ts/PageBattleCenter.vue +++ b/hwe/ts/PageBattleCenter.vue @@ -14,7 +14,7 @@
- + @@ -41,6 +41,7 @@ import { unwrap } from "@/util/unwrap"; import { merge2DArrToObjectArr } from "@/util/merge2DArrToObjectArr"; import { getNpcColor } from "@/common_legacy"; import GeneralBasicCard from "./components/GeneralBasicCard.vue"; +import type { NationStaticItem } from "./defs"; const toasts = unwrap(useToast()); @@ -57,12 +58,15 @@ const orderBy = ref("turntime"); const targetGeneral = ref(); const targetGeneralID = ref(queryValues.generalID ?? undefined); +const nationInfo = ref(); + watch([generalList, targetGeneralID], ([generalList, targetGeneralID]) => { if (targetGeneralID === undefined) return; targetGeneral.value = generalList.get(targetGeneralID); }); watch([generalList, orderBy], ([generalList, orderBy]) => { + console.log(generalList); const list = Array.from(generalList.values()); list.sort((a, b) => { const [, getter, isAsc] = textMap[orderBy]; @@ -90,16 +94,24 @@ async function reload(): Promise { console.log("갱신 시도"); try { + const nationP = SammoAPI.Nation.GetNationInfo({}); const { column, list, permission, troops, env } = await SammoAPI.Nation.GeneralList(); + if (permission === 0) { throw "권한이 부족합니다."; } + console.log(list); const rawGeneralList = merge2DArrToObjectArr(column, list); + const newList = new Map(); for (const general of rawGeneralList) { newList.set(general.no, general); } + generalList.value = newList; + + const { nation } = await nationP; + nationInfo.value = nation; } catch (e) { toasts.danger({ title: "오류", diff --git a/hwe/ts/SammoAPI.ts b/hwe/ts/SammoAPI.ts index bf6e3a48..9ac1395e 100644 --- a/hwe/ts/SammoAPI.ts +++ b/hwe/ts/SammoAPI.ts @@ -18,7 +18,7 @@ import type { BettingDetailResponse, BettingListResponse } from "./defs/API/Bett import type { ReserveBulkCommandResponse, ReserveCommandResponse, ReservedCommandResponse } from "./defs/API/Command"; import type { ChiefResponse } from "./defs/API/NationCommand"; import type { inheritBuffType, InheritLogResponse } from "./defs/API/InheritAction"; -import type { SetBlockWarResponse, GeneralListResponse as NationGeneralListResponse } from "./defs/API/Nation"; +import type { SetBlockWarResponse, GeneralListResponse as NationGeneralListResponse, LiteNationInfoResponse, NationInfoResponse } from "./defs/API/Nation"; import type { UploadImageResponse } from "./defs/API/Misc"; import type { GeneralLogType, GetGeneralLogResponse, JoinArgs } from "./defs/API/General"; import type { @@ -231,6 +231,7 @@ const apiRealPath = { troopID: number; troopName: string; }>, + GetNationInfo: GET as APICallT<{full?: boolean}, NationInfoResponse>, }, Vote: { AddComment: POST as APICallT<{ diff --git a/hwe/ts/build_exports.json b/hwe/ts/build_exports.json index 20065ecc..51550860 100644 --- a/hwe/ts/build_exports.json +++ b/hwe/ts/build_exports.json @@ -23,6 +23,7 @@ }, "ingame_vue": { "v_auction": "v_auction.ts", + "v_battleCenter": "v_battleCenter.ts", "v_inheritPoint": "v_inheritPoint.ts", "v_board": "v_board.ts", "v_cachedMap": "v_cachedMap", diff --git a/hwe/ts/defs/API/Nation.ts b/hwe/ts/defs/API/Nation.ts index a1f64fe4..b51d68cc 100644 --- a/hwe/ts/defs/API/Nation.ts +++ b/hwe/ts/defs/API/Nation.ts @@ -1,4 +1,4 @@ -import type { ValuesOf, TurnObj } from "@/defs"; +import type { ValuesOf, TurnObj, NationStaticItem } from "@/defs"; import type { GameObjClassKey } from "@/defs/GameObj"; import type { ValidResponse } from "@/SammoAPI"; @@ -127,3 +127,29 @@ export type RawGeneralListP2 = ValidResponse & { } export type GeneralListResponse = RawGeneralListP0 | RawGeneralListP1 | RawGeneralListP2; + +export type NationItem = NationStaticItem & { + gold: number; + rice: number; + bill: number; + rate: number; + secretlimit: number; + chief_set: number; + scout: number; + war: number; + strategic_cmd_limit: number; + surlimit: number; + tech: number; +} + +export type LiteNationInfoResponse = ValidResponse & { + nation: NationStaticItem; +} + +export type NationInfoResponse = (ValidResponse & { + nation: NationStaticItem; +}) | (ValidResponse &{ + nation: NationItem; + impossibleStrategicCommandLists: [string, number][]; + troops: Record; +}) \ No newline at end of file -- 2.54.0 From 52164f8da77a95cbfaad55ec1b1e8403fb0e493d Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 15 Jul 2022 01:29:05 +0900 Subject: [PATCH 4/8] =?UTF-8?q?wip:=20=EC=9E=A5=EC=88=98=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=EC=B9=B4=EB=93=9C=20=EC=B1=84=EC=83=89=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/ts/PageBattleCenter.vue | 5 +- hwe/ts/components/GeneralBasicCard.vue | 93 +++++++++++++++++--------- hwe/ts/components/SammoBar.vue | 30 +++++++-- 3 files changed, 88 insertions(+), 40 deletions(-) diff --git a/hwe/ts/PageBattleCenter.vue b/hwe/ts/PageBattleCenter.vue index d393515d..23223f14 100644 --- a/hwe/ts/PageBattleCenter.vue +++ b/hwe/ts/PageBattleCenter.vue @@ -14,7 +14,10 @@ - +
+ +
+ diff --git a/hwe/ts/components/GeneralBasicCard.vue b/hwe/ts/components/GeneralBasicCard.vue index d4304ae2..a0438ee9 100644 --- a/hwe/ts/components/GeneralBasicCard.vue +++ b/hwe/ts/components/GeneralBasicCard.vue @@ -1,5 +1,5 @@