From e09fdefa6892a5a7630a530e4a69d6acb5fd863c Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 5 Jul 2022 22:23:23 +0900 Subject: [PATCH] =?UTF-8?q?feat,game:=20=EC=82=AC=EC=A0=84=20=EA=B1=B0?= =?UTF-8?q?=EB=B3=91=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20?= =?UTF-8?q?=EA=B1=B4=EA=B5=AD=EC=9D=80=20=EA=B2=8C=EC=9E=84=20=EA=B0=9C?= =?UTF-8?q?=EC=8B=9C=202=ED=84=B4=EC=A7=B8=EB=B6=80=ED=84=B0=20=EA=B0=80?= =?UTF-8?q?=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/b_myPage.php | 12 ++- .../API/General/BuildNationCandidate.php | 82 +++++++++++++++++++ hwe/sammo/API/General/DieOnPrestart.php | 6 +- hwe/sammo/Command/General/che_건국.php | 12 ++- hwe/ts/SammoAPI.ts | 1 + hwe/ts/myPage.ts | 20 +++++ 6 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 hwe/sammo/API/General/BuildNationCandidate.php diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php index ed355e8b..8517d91e 100644 --- a/hwe/b_myPage.php +++ b/hwe/b_myPage.php @@ -6,6 +6,7 @@ include "lib.php"; include "func.php"; $showDieOnPrestartBtn = false; +$showBuildNationCandidateBtn = false; $availableDieOnPrestart = false; //로그인 검사 @@ -31,12 +32,16 @@ if ($myset > 0) { $targetTime = addTurn($me->getVar('lastrefresh'), $gameStor->turnterm, 2); if ($gameStor->turntime <= $gameStor->opentime) { //서버 가오픈시 할 수 있는 행동 - if ($me->getNPCType() == 0) { + if ($me->getNPCType() == 0 && $me->getNationID() == 0) { $showDieOnPrestartBtn = true; if ($targetTime <= TimeUtil::now()) { $availableDieOnPrestart = true; } } + + if($me->getNationID() == 0){ + $showBuildNationCandidateBtn = true; + } } $use_treatment = $me->getAuxVar('use_treatment') ?? 10; @@ -127,6 +132,11 @@ $use_auto_nation_turn = $me->getAuxVar('use_auto_nation_turn') ?? 1;

+ + 서버 개시 이전 거병(2턴부터 건국 가능)
+

+ + npcmode == 2 && $me->getNPCType() == 0) : ?> 다른 장수 선택 (getAuxVar('next_change') ?? TimeUtil::now(), 0, 19) ?> 부터)


diff --git a/hwe/sammo/API/General/BuildNationCandidate.php b/hwe/sammo/API/General/BuildNationCandidate.php new file mode 100644 index 00000000..7f8ff4d2 --- /dev/null +++ b/hwe/sammo/API/General/BuildNationCandidate.php @@ -0,0 +1,82 @@ +userID; + + $db = DB::db(); + $gameStor = KVStorage::getStorage($db, 'game_env'); + $gameStor->cacheValues(['opentime', 'turntime']); + + $general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc,lastrefresh FROM general WHERE owner=%i AND npc = 0', $userID); + + if (!$general) { + return '장수가 없습니다'; + } + + $generalID = $general['no']; + + increaseRefresh("사전 거병", 1); + + if ($gameStor->turntime > $gameStor->opentime) { + return '게임이 시작되었습니다.'; + } + + if ($general['nation'] != 0) { + return '이미 국가에 소속되어있습니다.'; + } + + $env = $gameStor->getAll(); + + $generalObj = General::createGeneralObjFromDB($general['no']); + + $cmd = new che_거병($generalObj, $env); + $failReason = $cmd->testFullConditionMet(); + if ($failReason !== null) { + return $failReason; + } + + $rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize( + UniqueConst::$hiddenSeed, + 'BuildNationCandidate', + $generalID, + ))); + $result = $cmd->run($rng); + + if(!$result){ + return '거병을 실패했습니다.'; + } + + return null; + } +} diff --git a/hwe/sammo/API/General/DieOnPrestart.php b/hwe/sammo/API/General/DieOnPrestart.php index d0e61386..25dd5091 100644 --- a/hwe/sammo/API/General/DieOnPrestart.php +++ b/hwe/sammo/API/General/DieOnPrestart.php @@ -36,7 +36,7 @@ class DieOnPrestart extends \sammo\BaseAPI $gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor->cacheValues(['turnterm', 'opentime', 'turntime', 'year', 'month']); - $general = $db->queryFirstRow('SELECT no,name,owner_name,npc,lastrefresh FROM general WHERE owner=%i AND npc = 0', $userID); + $general = $db->queryFirstRow('SELECT no,name,nation,owner_name,npc,lastrefresh FROM general WHERE owner=%i AND npc = 0', $userID); if (!$general) { return '장수가 없습니다'; @@ -49,6 +49,10 @@ class DieOnPrestart extends \sammo\BaseAPI return '게임이 시작되었습니다.'; } + if ($general['nation'] != 0){ + return '이미 국가에 소속되어있습니다.'; + } + //서버 가오픈시 할 수 있는 행동 $targetTime = addTurn($general['lastrefresh'], $gameStor->turnterm, 2); if ($targetTime > TimeUtil::now()) { diff --git a/hwe/sammo/Command/General/che_건국.php b/hwe/sammo/Command/General/che_건국.php index 7fc17f98..1e6747c1 100644 --- a/hwe/sammo/Command/General/che_건국.php +++ b/hwe/sammo/Command/General/che_건국.php @@ -139,6 +139,16 @@ class che_건국 extends Command\GeneralCommand $general = $this->generalObj; $date = $general->getTurnTime($general::TURNTIME_HM); $generalName = $general->getName(); + $logger = $general->getLogger(); + + $initYearMonth = Util::joinYearMonth($env['init_year'], $env['init_month']); + $yearMonth = Util::joinYearMonth($env['year'], $env['month']); + if($yearMonth <= $initYearMonth){ + $logger->pushGeneralActionLog("다음 턴부터 건국할 수 있습니다. <1>$date"); + $this->alternative = new che_인재탐색($general, $this->env, null); + return false; + } + $josaYi = JosaUtil::pick($generalName, '이'); $nationName = $this->arg['nationName']; @@ -149,7 +159,7 @@ class che_건국 extends Command\GeneralCommand $josaUl = JosaUtil::pick($nationName, '을'); - $logger = $general->getLogger(); + $nationTypeClass = buildNationTypeClass($nationType); $nationTypeName = $nationTypeClass->getName(); diff --git a/hwe/ts/SammoAPI.ts b/hwe/ts/SammoAPI.ts index b09d2ea5..bf6e3a48 100644 --- a/hwe/ts/SammoAPI.ts +++ b/hwe/ts/SammoAPI.ts @@ -126,6 +126,7 @@ const apiRealPath = { itemType: ItemTypeKey; }>, DieOnPrestart: POST as APICallT, + BuildNationCandidate: POST as APICallT, }, Global: { GeneralList: GET as APICallT, diff --git a/hwe/ts/myPage.ts b/hwe/ts/myPage.ts index 7b1cb17c..354a8cd3 100644 --- a/hwe/ts/myPage.ts +++ b/hwe/ts/myPage.ts @@ -150,6 +150,26 @@ $(function ($) { location.replace('..'); }); + $('#buildNationCandidate').on('click', async function (e) { + e.preventDefault(); + + if(!confirm('거병 이후 장수를 삭제할 수 없게됩니다. 거병하시겠습니까?')){ + return false; + } + + try { + await SammoAPI.General.BuildNationCandidate(); + } + catch (e) { + console.log(e); + alert(`실패했습니다: ${e}`); + location.reload(); + return; + } + + location.reload(); + }); + $('#vacation').on('click', async function (e) { e.preventDefault(); if (!confirm('휴가 기능을 신청할까요?')) {