From 4159f9f830e27252960e9f2d5c907bf549c80d86 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 16 Sep 2021 00:31:28 +0900 Subject: [PATCH] =?UTF-8?q?InheritAction:=20UI=20=ED=84=B4=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94,=20=EC=A0=84=ED=88=AC=20=ED=8A=B9=EA=B8=B0?= =?UTF-8?q?=20=EC=B4=88=EA=B8=B0=ED=99=94,=20=EB=9E=9C=EB=8D=A4=20?= =?UTF-8?q?=EC=9C=A0=EB=8B=88=ED=81=AC=20-=20=ED=84=B4=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=EC=97=90=20=EB=B2=84=EA=B7=B8=EA=B0=80=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=EB=93=AF=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/InheritAction/BuyRandomUnique.php | 2 +- .../API/InheritAction/BuySpecificUnique.php | 2 +- .../API/InheritAction/ResetSpecialWar.php | 4 +- hwe/sammo/API/InheritAction/ResetTurnTime.php | 6 +- .../API/InheritAction/SetNextSpecialWar.php | 6 +- hwe/ts/inheritPoint.vue | 154 ++++++++++++++++-- hwe/v_inheritPoint.php | 26 ++- 7 files changed, 174 insertions(+), 26 deletions(-) diff --git a/hwe/sammo/API/InheritAction/BuyRandomUnique.php b/hwe/sammo/API/InheritAction/BuyRandomUnique.php index 4f707346..6aaf56b4 100644 --- a/hwe/sammo/API/InheritAction/BuyRandomUnique.php +++ b/hwe/sammo/API/InheritAction/BuyRandomUnique.php @@ -45,7 +45,7 @@ class BuyRandomUnique extends \sammo\BaseAPI } $general->setAuxVar('inheritRandomUnique', TimeUtil::now()); - $inheritStor->setValue('previous', $previousPoint - GameConst::$inheritItemRandomPoint); + $inheritStor->setValue('previous', [$previousPoint - GameConst::$inheritItemRandomPoint, 'BuyRandomUnique']); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/BuySpecificUnique.php b/hwe/sammo/API/InheritAction/BuySpecificUnique.php index a91d24bb..ee355f5f 100644 --- a/hwe/sammo/API/InheritAction/BuySpecificUnique.php +++ b/hwe/sammo/API/InheritAction/BuySpecificUnique.php @@ -72,7 +72,7 @@ class BuySpecificUnique extends \sammo\BaseAPI $itemTrials[$itemKey] = $amount; $general->setAuxVar('inheritUniqueTrial', $itemTrials); - $inheritStor->setValue('previous', $previousPoint - $amount); + $inheritStor->setValue('previous', [$previousPoint - $amount, ['BuySpecificUnique', $itemKey, $amount]]); $trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]); $general->applyDB($db); return null; diff --git a/hwe/sammo/API/InheritAction/ResetSpecialWar.php b/hwe/sammo/API/InheritAction/ResetSpecialWar.php index d2f2ef18..a22e6395 100644 --- a/hwe/sammo/API/InheritAction/ResetSpecialWar.php +++ b/hwe/sammo/API/InheritAction/ResetSpecialWar.php @@ -50,7 +50,7 @@ class ResetSpecialWar extends \sammo\BaseAPI $db = DB::db(); $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); - $previousPoint = $inheritStor->getValue('previous') ?? 0; + $previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0]; if ($previousPoint < $reqPoint) { return '충분한 유산 포인트를 가지고 있지 않습니다.'; } @@ -62,7 +62,7 @@ class ResetSpecialWar extends \sammo\BaseAPI $general->setAuxVar('inheritResetSpecialWar', $nextLevel); $general->setVar('special2', 'None'); - $inheritStor->setValue('previous', $previousPoint - $reqPoint); + $inheritStor->setValue('previous', [$previousPoint - $reqPoint, 'ResetSpecialWar']); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/ResetTurnTime.php b/hwe/sammo/API/InheritAction/ResetTurnTime.php index 6c813b0d..b4120874 100644 --- a/hwe/sammo/API/InheritAction/ResetTurnTime.php +++ b/hwe/sammo/API/InheritAction/ResetTurnTime.php @@ -46,7 +46,7 @@ class ResetTurnTime extends \sammo\BaseAPI $db = DB::db(); $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); - $previousPoint = $inheritStor->getValue('previous') ?? 0; + $previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0]; if ($previousPoint < $reqPoint) { return '충분한 유산 포인트를 가지고 있지 않습니다.'; } @@ -60,13 +60,13 @@ class ResetTurnTime extends \sammo\BaseAPI $afterTurn = Util::randRange($turnTerm * -60 / 2, $turnTerm * 60 / 2); $turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($afterTurn)); - if($turnTime <= $serverTurnTimeObj){ + if ($turnTime <= $serverTurnTimeObj) { $turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($turnTerm * 60)); } $general->setVar('turntime', TimeUtil::format($turnTime, true)); $general->setAuxVar('inheritResetTurnTime', $nextLevel); - $inheritStor->setValue('previous', $previousPoint - $reqPoint); + $inheritStor->setValue('previous', [$previousPoint - $reqPoint, 'ResetTurnTime']); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php index 9bd458de..195e50d8 100644 --- a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php +++ b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php @@ -54,7 +54,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI return '이미 그 특기를 예약하였습니다.'; } - if($inheritSpecificSpecialWar !== null){ + if ($inheritSpecificSpecialWar !== null) { return '이미 예약한 특기가 있습니다.'; } @@ -62,13 +62,13 @@ class SetNextSpecialWar extends \sammo\BaseAPI $db = DB::db(); $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); - $previousPoint = $inheritStor->getValue('previous') ?? 0; + $previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0]; if ($previousPoint < $reqAmount) { return '충분한 유산 포인트를 가지고 있지 않습니다.'; } $general->setAuxVar('inheritSpecificSpecialWar', $type); - $inheritStor->setValue('previous', $previousPoint - $reqAmount); + $inheritStor->setValue('previous', [$previousPoint - $reqAmount, ['SetNextSpecialWar', $type]]); $general->applyDB($db); return null; } diff --git a/hwe/ts/inheritPoint.vue b/hwe/ts/inheritPoint.vue index ea5ff200..7edba2bd 100644 --- a/hwe/ts/inheritPoint.vue +++ b/hwe/ts/inheritPoint.vue @@ -62,14 +62,16 @@
{{ info.info }}
필요 포인트: - {{ - inheritBuffCost[inheritBuff[buffKey]] - - inheritBuffCost[prevInheritBuff[buffKey] ?? 0] - }}
{{ info.info }}
필요 포인트: + {{ + inheritActionCost.buff[inheritBuff[buffKey]] - + inheritActionCost.buff[prevInheritBuff[buffKey] ?? 0] + }}
-
+
-
+
+
+
+
랜덤 턴 초기화
+ 구입 +
+
+ 다음 턴이 랜덤으로 바뀝니다.
필요 포인트: {{ inheritActionCost.resetTurnTime }}
+
+
+
+
+
랜덤 유니크 획득
+ 구입 +
+
+ 다음 턴에 랜덤 유니크를 얻습니다.
필요 포인트: {{ inheritActionCost.randomUnique }}
+
+
+
+
+
+ 즉시 전투 특기 초기화 +
+ 구입 +
+
+ 즉시 전투 특기를 초기화합니다.
필요 포인트: {{ inheritActionCost.resetSpecialWar }}
+
+
+
+ + + + + @@ -231,7 +295,15 @@ const inheritBuffHelpText: Record< }; declare const maxInheritBuff: number; -declare const inheritBuffCost: number[]; +declare const inheritActionCost: { + buff: number[]; + resetTurnTime: number; + resetSpecialWar: number; + randomUnique: number; +}; + +declare const resetTurnTimeLevel: number; +declare const resetSpecialWarLevel: number; export default defineComponent({ name: "InheritPoint", @@ -260,7 +332,9 @@ export default defineComponent({ inheritBuff, prevInheritBuff: currentInheritBuff, maxInheritBuff, - inheritBuffCost, + inheritActionCost, + resetTurnTimeLevel, + resetSpecialWarLevel, }; }, methods: { @@ -275,7 +349,8 @@ export default defineComponent({ return; } const cost = - this.inheritBuffCost[level] - this.inheritBuffCost[prevLevel]; + this.inheritActionCost.buff[level] - + this.inheritActionCost.buff[prevLevel]; if (this.items.previous < cost) { alert("유산 포인트가 부족합니다."); return; @@ -298,11 +373,11 @@ export default defineComponent({ method: "post", responseType: "json", data: { - path: 'InheritAction/BuyHiddenBuff', + path: "InheritAction/BuyHiddenBuff", args: { type: buffKey, level, - } + }, }, }); result = response.data; @@ -315,7 +390,60 @@ export default defineComponent({ return; } - alert('성공했습니다.'); + alert("성공했습니다."); + //TODO: 페이지 새로고침 필요없이 하도록 + location.reload(); + }, + async buySimple( + type: "ResetTurnTime" | "BuyRandomUnique" | "ResetSpecialWar" + ) { + const costMap: Record = { + ResetTurnTime: inheritActionCost.resetTurnTime, + ResetSpecialWar: inheritActionCost.resetSpecialWar, + BuyRandomUnique: inheritActionCost.randomUnique, + }; + + const cost = costMap[type]; + if (cost === undefined) { + alert(`올바르지 않은 타입:${type}`); + return; + } + + const messageMap: Record = { + ResetTurnTime: `${cost} 포인트로 턴을 초기화 하시겠습니까?`, + ResetSpecialWar: `${cost} 포인트로 전투 특기를 초기화 하시겠습니까?`, + BuyRandomUnique: `${cost} 포인트로 랜덤 유니크를 구입하시겠습니까?`, + }; + if (this.items.previous < cost) { + alert("유산 포인트가 부족합니다."); + return; + } + if (!confirm(messageMap[type])) { + return; + } + + let result: InvalidResponse; + try { + const response = await axios({ + url: "api.php", + method: "post", + responseType: "json", + data: { + path: `InheritAction/${type}`, + args: {}, + }, + }); + result = response.data; + if (!result.result) { + throw result.reason; + } + } catch (e) { + console.error(e); + alert(`실패했습니다: ${e}`); + return; + } + + alert("성공했습니다."); //TODO: 페이지 새로고침 필요없이 하도록 location.reload(); }, diff --git a/hwe/v_inheritPoint.php b/hwe/v_inheritPoint.php index 27a6da92..0b244dfc 100644 --- a/hwe/v_inheritPoint.php +++ b/hwe/v_inheritPoint.php @@ -21,12 +21,25 @@ foreach (array_keys(General::INHERITANCE_KEY) as $key) { } $currentInheritBuff = []; -foreach ($me->getAuxVar('inheritBuff') as $buff=>$buffLevel){ - if(!key_exists($buff,TriggerInheritBuff::BUFF_KEY_TEXT)){ +foreach ($me->getAuxVar('inheritBuff') as $buff => $buffLevel) { + if (!key_exists($buff, TriggerInheritBuff::BUFF_KEY_TEXT)) { continue; } $currentInheritBuff[$buff] = $buffLevel; } + +function calcResetAttrPoint($level) +{ + while (count(GameConst::$inheritResetAttrPointBase) <= $level) { + $baseLen = count(GameConst::$inheritResetAttrPointBase); + GameConst::$inheritResetAttrPointBase[] = GameConst::$inheritResetAttrPointBase[$baseLen - 1] + GameConst::$inheritResetAttrPointBase[$baseLen - 2]; + } + return GameConst::$inheritResetAttrPointBase[$level]; +} + + +$resetTurnTimeLevel = $me->getAuxVar('inheritResetTurnTime')??0; +$resetSpecialWarLevel = $me->getAuxVar('inheritResetSpecialWar')??0; ?> @@ -46,7 +59,14 @@ foreach ($me->getAuxVar('inheritBuff') as $buff=>$buffLevel){ 'items' => $items, 'currentInheritBuff' => $currentInheritBuff, 'maxInheritBuff' => TriggerInheritBuff::MAX_STEP, - 'inheritBuffCost' => GameConst::$inheritBuffPoints, + 'resetTurnTimeLevel' => $resetTurnTimeLevel, + 'resetSpecialWarLevel' => $resetSpecialWarLevel, + 'inheritActionCost' => [ + 'buff' => GameConst::$inheritBuffPoints, + 'resetTurnTime' => calcResetAttrPoint($resetTurnTimeLevel), + 'resetSpecialWar' => calcResetAttrPoint($resetSpecialWarLevel), + 'randomUnique' => GameConst::$inheritItemRandomPoint, + ], ]) ?>