inheritStore: 버프/디버프 구매 UI
This commit is contained in:
@@ -65,15 +65,15 @@ class BuyHiddenBuff extends \sammo\BaseAPI
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}");
|
$inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}");
|
||||||
$previousPoint = $inheritStor->getValue('previous') ?? 0;
|
$previousPoint = ($inheritStor->getValue('previous') ?? [0,0])[0];
|
||||||
if ($previousPoint < $reqAmount) {
|
if ($previousPoint < $reqAmount) {
|
||||||
return '충분한 유산 포인트를 가지고 있지 않습니다.';
|
return '충분한 유산 포인트를 가지고 있지 않습니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$inheritBuffList[$type] = $level;
|
$inheritBuffList[$type] = $level;
|
||||||
$general->setAuxVar('inheritBuff', $inheritBuffList);
|
$general->setAuxVar('inheritBuff', $inheritBuffList);
|
||||||
$inheritStor->setValue('previous', $previousPoint - $reqAmount);
|
$inheritStor->setValue('previous', [$previousPoint - $reqAmount, [$type, $level]]);
|
||||||
$general->flushUpdateValues();
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class BuyRandomUnique extends \sammo\BaseAPI
|
|||||||
|
|
||||||
$general->setAuxVar('inheritRandomUnique', TimeUtil::now());
|
$general->setAuxVar('inheritRandomUnique', TimeUtil::now());
|
||||||
$inheritStor->setValue('previous', $previousPoint - GameConst::$inheritItemRandomPoint);
|
$inheritStor->setValue('previous', $previousPoint - GameConst::$inheritItemRandomPoint);
|
||||||
$general->flushUpdateValues();
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class BuySpecificUnique extends \sammo\BaseAPI
|
|||||||
$general->setAuxVar('inheritUniqueTrial', $itemTrials);
|
$general->setAuxVar('inheritUniqueTrial', $itemTrials);
|
||||||
$inheritStor->setValue('previous', $previousPoint - $amount);
|
$inheritStor->setValue('previous', $previousPoint - $amount);
|
||||||
$trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]);
|
$trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]);
|
||||||
$general->flushUpdateValues();
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class ResetSpecialWar extends \sammo\BaseAPI
|
|||||||
$general->setAuxVar('inheritResetSpecialWar', $nextLevel);
|
$general->setAuxVar('inheritResetSpecialWar', $nextLevel);
|
||||||
$general->setVar('special2', 'None');
|
$general->setVar('special2', 'None');
|
||||||
$inheritStor->setValue('previous', $previousPoint - $reqPoint);
|
$inheritStor->setValue('previous', $previousPoint - $reqPoint);
|
||||||
$general->flushUpdateValues();
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class ResetTurnTime extends \sammo\BaseAPI
|
|||||||
$general->setVar('turntime', TimeUtil::format($turnTime, true));
|
$general->setVar('turntime', TimeUtil::format($turnTime, true));
|
||||||
$general->setAuxVar('inheritResetTurnTime', $nextLevel);
|
$general->setAuxVar('inheritResetTurnTime', $nextLevel);
|
||||||
$inheritStor->setValue('previous', $previousPoint - $reqPoint);
|
$inheritStor->setValue('previous', $previousPoint - $reqPoint);
|
||||||
$general->flushUpdateValues();
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI
|
|||||||
|
|
||||||
$general->setAuxVar('inheritSpecificSpecialWar', $type);
|
$general->setAuxVar('inheritSpecificSpecialWar', $type);
|
||||||
$inheritStor->setValue('previous', $previousPoint - $reqAmount);
|
$inheritStor->setValue('previous', $previousPoint - $reqAmount);
|
||||||
$general->flushUpdateValues();
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+181
-1
@@ -3,7 +3,7 @@
|
|||||||
<div
|
<div
|
||||||
id="container"
|
id="container"
|
||||||
class="tb_layout bg0"
|
class="tb_layout bg0"
|
||||||
style="width: 1000px; margin: auto; border: solid 1px #888888"
|
style="max-width: 1000px; margin: auto; border: solid 1px #888888"
|
||||||
>
|
>
|
||||||
<div id="inheritance_list">
|
<div id="inheritance_list">
|
||||||
<template v-for="(text, key) in inheritanceViewText" :key="key">
|
<template v-for="(text, key) in inheritanceViewText" :key="key">
|
||||||
@@ -34,6 +34,58 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="inheritance_store">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col"><div class="bg1 a-center">유산 포인트 상점</div></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div
|
||||||
|
class="col col-md-4 col-6"
|
||||||
|
v-for="(info, buffKey) in inheritBuffHelpText"
|
||||||
|
:key="buffKey"
|
||||||
|
>
|
||||||
|
<div class="row">
|
||||||
|
<label
|
||||||
|
class="col col-sm-6 col-form-label"
|
||||||
|
:for="`buff-${buffKey}`"
|
||||||
|
>{{ info.title }}</label
|
||||||
|
>
|
||||||
|
<div class="col col-sm-6">
|
||||||
|
<b-form-input
|
||||||
|
:id="`buff-${buffKey}`"
|
||||||
|
type="number"
|
||||||
|
v-model="inheritBuff[buffKey]"
|
||||||
|
:min="prevInheritBuff[buffKey] ?? 0"
|
||||||
|
:max="maxInheritBuff"
|
||||||
|
></b-form-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="text-align: right">
|
||||||
|
<small class="form-text text-muted"
|
||||||
|
>{{ info.info }}<br /><span style="color:white">필요 포인트:
|
||||||
|
{{
|
||||||
|
inheritBuffCost[inheritBuff[buffKey]] -
|
||||||
|
inheritBuffCost[prevInheritBuff[buffKey] ?? 0]
|
||||||
|
}}</span></small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="row px-4" style="margin-bottom:1em;">
|
||||||
|
<b-button
|
||||||
|
variant="secondary"
|
||||||
|
@click="inheritBuff[buffKey] = prevInheritBuff[buffKey] ?? 0"
|
||||||
|
class="col col-md-6 col-4 offset-md-0 offset-4"
|
||||||
|
>리셋</b-button
|
||||||
|
><b-button
|
||||||
|
variant="primary"
|
||||||
|
class="col col-md-6 col-4"
|
||||||
|
@click="buyInheritBuff(buffKey)"
|
||||||
|
>구입</b-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -45,6 +97,8 @@ import "../scss/game_bg.scss";
|
|||||||
import TopBackBar from "./components/TopBackBar.vue";
|
import TopBackBar from "./components/TopBackBar.vue";
|
||||||
import { sum } from "lodash";
|
import { sum } from "lodash";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { InvalidResponse } from "./defs";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
type InheritanceType =
|
type InheritanceType =
|
||||||
| "previous"
|
| "previous"
|
||||||
@@ -121,9 +175,73 @@ const inheritanceViewText: Record<
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type inheritBuffType =
|
||||||
|
| "warAvoidRatio"
|
||||||
|
| "warCriticalRatio"
|
||||||
|
| "warMagicTrialProb"
|
||||||
|
| "domesticSuccessProb"
|
||||||
|
| "domesticFailProb"
|
||||||
|
| "warAvoidRatioOppose"
|
||||||
|
| "warCriticalRatioOppose"
|
||||||
|
| "warMagicTrialProbOppose";
|
||||||
|
|
||||||
|
declare const currentInheritBuff: {
|
||||||
|
[v in inheritBuffType]: number | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const inheritBuffHelpText: Record<
|
||||||
|
inheritBuffType,
|
||||||
|
{
|
||||||
|
title: string;
|
||||||
|
info: string;
|
||||||
|
}
|
||||||
|
> = {
|
||||||
|
warAvoidRatio: {
|
||||||
|
title: "회피 확률 증가",
|
||||||
|
info: "전투 시 회피 확률이 1%p ~ 5%p 증가합니다.",
|
||||||
|
},
|
||||||
|
warCriticalRatio: {
|
||||||
|
title: "필살 확률 증가",
|
||||||
|
info: "전투 시 필살 확률이 1%p ~ 5%p 증가합니다.",
|
||||||
|
},
|
||||||
|
warMagicTrialProb: {
|
||||||
|
title: "계략 시도 확률 증가",
|
||||||
|
info: "전투 시 계략을 시도할 확률이 1%p ~ 5%p 증가합니다. 무장도 계략을 시도합니다.",
|
||||||
|
},
|
||||||
|
warAvoidRatioOppose: {
|
||||||
|
title: "상대 회피 확률 감소",
|
||||||
|
info: "전투 시 상대의 회피 확률이 1%p ~ 5%p 감소합니다.",
|
||||||
|
},
|
||||||
|
warCriticalRatioOppose: {
|
||||||
|
title: "상대 필살 확률 감소",
|
||||||
|
info: "전투 시 상대의 필살 확률이 1%p ~ 5%p 감소합니다.",
|
||||||
|
},
|
||||||
|
warMagicTrialProbOppose: {
|
||||||
|
title: "상대 계략 시도 확률 감소",
|
||||||
|
info: "전투 시 상대의 계략 시도 확률이 1%p ~ 5%p 감소합니다.",
|
||||||
|
},
|
||||||
|
domesticSuccessProb: {
|
||||||
|
title: "내정 성공 확률 증가",
|
||||||
|
info: "민심, 인구, 농업, 상업, 치안, 수비, 성벽, 기술 내정의 성공 확률이 1%p ~ 5%p 증가합니다.",
|
||||||
|
},
|
||||||
|
domesticFailProb: {
|
||||||
|
title: "내정 실패 확률 감소",
|
||||||
|
info: "민심, 인구, 농업, 상업, 치안, 수비, 성벽, 기술 내정의 실패 확률이 1%p ~ 5%p 감소합니다.",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
declare const maxInheritBuff: number;
|
||||||
|
declare const inheritBuffCost: number[];
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "InheritPoint",
|
name: "InheritPoint",
|
||||||
data() {
|
data() {
|
||||||
|
const inheritBuff = {} as Record<inheritBuffType, number>;
|
||||||
|
for (const buffKey of Object.keys(
|
||||||
|
inheritBuffHelpText
|
||||||
|
) as inheritBuffType[]) {
|
||||||
|
inheritBuff[buffKey] = currentInheritBuff[buffKey] ?? 0;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
title: "유산 관리",
|
title: "유산 관리",
|
||||||
inheritanceViewText,
|
inheritanceViewText,
|
||||||
@@ -138,8 +256,70 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
})(),
|
})(),
|
||||||
|
inheritBuffHelpText,
|
||||||
|
inheritBuff,
|
||||||
|
prevInheritBuff: currentInheritBuff,
|
||||||
|
maxInheritBuff,
|
||||||
|
inheritBuffCost,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
async buyInheritBuff(buffKey: inheritBuffType) {
|
||||||
|
const level = this.inheritBuff[buffKey];
|
||||||
|
const prevLevel = this.prevInheritBuff[buffKey] ?? 0;
|
||||||
|
if (level == prevLevel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (level < prevLevel) {
|
||||||
|
alert("낮출 수 없습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const cost =
|
||||||
|
this.inheritBuffCost[level] - this.inheritBuffCost[prevLevel];
|
||||||
|
if (this.items.previous < cost) {
|
||||||
|
alert("유산 포인트가 부족합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = inheritBuffHelpText[buffKey].title;
|
||||||
|
|
||||||
|
if (
|
||||||
|
!confirm(
|
||||||
|
`${name}를 ${level}등급으로 올릴까요? ${cost} 포인트가 소모됩니다.`
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result: InvalidResponse;
|
||||||
|
try {
|
||||||
|
const response = await axios({
|
||||||
|
url: "api.php",
|
||||||
|
method: "post",
|
||||||
|
responseType: "json",
|
||||||
|
data: {
|
||||||
|
path: 'InheritAction/BuyHiddenBuff',
|
||||||
|
args: {
|
||||||
|
type: buffKey,
|
||||||
|
level,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
result = response.data;
|
||||||
|
if (!result.result) {
|
||||||
|
throw result.reason;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
alert(`실패했습니다: ${e}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
alert('성공했습니다.');
|
||||||
|
//TODO: 페이지 새로고침 필요없이 하도록
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
TopBackBar,
|
TopBackBar,
|
||||||
},
|
},
|
||||||
|
|||||||
+12
-1
@@ -19,6 +19,14 @@ $items = [];
|
|||||||
foreach (array_keys(General::INHERITANCE_KEY) as $key) {
|
foreach (array_keys(General::INHERITANCE_KEY) as $key) {
|
||||||
$items[$key] = $me->getInheritancePoint($key) ?? 0;
|
$items[$key] = $me->getInheritancePoint($key) ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$currentInheritBuff = [];
|
||||||
|
foreach ($me->getAuxVar('inheritBuff') as $buff=>$buffLevel){
|
||||||
|
if(!key_exists($buff,TriggerInheritBuff::BUFF_KEY_TEXT)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$currentInheritBuff[$buff] = $buffLevel;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -35,7 +43,10 @@ foreach (array_keys(General::INHERITANCE_KEY) as $key) {
|
|||||||
<?= WebUtil::printJS('dist_js/common_vue.js', true) ?>
|
<?= WebUtil::printJS('dist_js/common_vue.js', true) ?>
|
||||||
<?= WebUtil::printJS('dist_js/v_inheritPoint.js', true) ?>
|
<?= WebUtil::printJS('dist_js/v_inheritPoint.js', true) ?>
|
||||||
<?= WebUtil::printStaticValues([
|
<?= WebUtil::printStaticValues([
|
||||||
'items' => $items
|
'items' => $items,
|
||||||
|
'currentInheritBuff' => $currentInheritBuff,
|
||||||
|
'maxInheritBuff' => TriggerInheritBuff::MAX_STEP,
|
||||||
|
'inheritBuffCost' => GameConst::$inheritBuffPoints,
|
||||||
]) ?>
|
]) ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class APIHelper
|
|||||||
|
|
||||||
public static function launch(string $rootPath)
|
public static function launch(string $rootPath)
|
||||||
{
|
{
|
||||||
|
//TODO: path를 php://input에서 받는게 아니라 api.php?~~~~~ 로 받아오는것이 etag 캐시 측면에서 훨씬 나을 듯!
|
||||||
try {
|
try {
|
||||||
$rawInput = file_get_contents('php://input');
|
$rawInput = file_get_contents('php://input');
|
||||||
$input = Json::decode($rawInput);
|
$input = Json::decode($rawInput);
|
||||||
|
|||||||
Reference in New Issue
Block a user