InheritAction: UI 턴 초기화, 전투 특기 초기화, 랜덤 유니크
- 턴 초기화에 버그가 있는듯?
This commit is contained in:
@@ -45,7 +45,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, 'BuyRandomUnique']);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class BuySpecificUnique extends \sammo\BaseAPI
|
|||||||
|
|
||||||
$itemTrials[$itemKey] = $amount;
|
$itemTrials[$itemKey] = $amount;
|
||||||
$general->setAuxVar('inheritUniqueTrial', $itemTrials);
|
$general->setAuxVar('inheritUniqueTrial', $itemTrials);
|
||||||
$inheritStor->setValue('previous', $previousPoint - $amount);
|
$inheritStor->setValue('previous', [$previousPoint - $amount, ['BuySpecificUnique', $itemKey, $amount]]);
|
||||||
$trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]);
|
$trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class ResetSpecialWar 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 < $reqPoint) {
|
if ($previousPoint < $reqPoint) {
|
||||||
return '충분한 유산 포인트를 가지고 있지 않습니다.';
|
return '충분한 유산 포인트를 가지고 있지 않습니다.';
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,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, 'ResetSpecialWar']);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class ResetTurnTime 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 < $reqPoint) {
|
if ($previousPoint < $reqPoint) {
|
||||||
return '충분한 유산 포인트를 가지고 있지 않습니다.';
|
return '충분한 유산 포인트를 가지고 있지 않습니다.';
|
||||||
}
|
}
|
||||||
@@ -60,13 +60,13 @@ class ResetTurnTime extends \sammo\BaseAPI
|
|||||||
$afterTurn = Util::randRange($turnTerm * -60 / 2, $turnTerm * 60 / 2);
|
$afterTurn = Util::randRange($turnTerm * -60 / 2, $turnTerm * 60 / 2);
|
||||||
|
|
||||||
$turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($afterTurn));
|
$turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($afterTurn));
|
||||||
if($turnTime <= $serverTurnTimeObj){
|
if ($turnTime <= $serverTurnTimeObj) {
|
||||||
$turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($turnTerm * 60));
|
$turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($turnTerm * 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
$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, 'ResetTurnTime']);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI
|
|||||||
return '이미 그 특기를 예약하였습니다.';
|
return '이미 그 특기를 예약하였습니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($inheritSpecificSpecialWar !== null){
|
if ($inheritSpecificSpecialWar !== null) {
|
||||||
return '이미 예약한 특기가 있습니다.';
|
return '이미 예약한 특기가 있습니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +62,13 @@ class SetNextSpecialWar 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 '충분한 유산 포인트를 가지고 있지 않습니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$general->setAuxVar('inheritSpecificSpecialWar', $type);
|
$general->setAuxVar('inheritSpecificSpecialWar', $type);
|
||||||
$inheritStor->setValue('previous', $previousPoint - $reqAmount);
|
$inheritStor->setValue('previous', [$previousPoint - $reqAmount, ['SetNextSpecialWar', $type]]);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+140
-12
@@ -62,14 +62,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="text-align: right">
|
<div style="text-align: right">
|
||||||
<small class="form-text text-muted"
|
<small class="form-text text-muted"
|
||||||
>{{ info.info }}<br /><span style="color:white">필요 포인트:
|
>{{ info.info }}<br /><span style="color: white"
|
||||||
|
>필요 포인트:
|
||||||
{{
|
{{
|
||||||
inheritBuffCost[inheritBuff[buffKey]] -
|
inheritActionCost.buff[inheritBuff[buffKey]] -
|
||||||
inheritBuffCost[prevInheritBuff[buffKey] ?? 0]
|
inheritActionCost.buff[prevInheritBuff[buffKey] ?? 0]
|
||||||
}}</span></small
|
}}</span
|
||||||
|
></small
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="row px-4" style="margin-bottom:1em;">
|
<div class="row px-4" style="margin-bottom: 1em">
|
||||||
<b-button
|
<b-button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
@click="inheritBuff[buffKey] = prevInheritBuff[buffKey] ?? 0"
|
@click="inheritBuff[buffKey] = prevInheritBuff[buffKey] ?? 0"
|
||||||
@@ -84,7 +86,69 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row"></div>
|
<div class="row px-4" style="margin-top: 2em">
|
||||||
|
<div class="col col-md-4 col-sm-6 p-2">
|
||||||
|
<div class="row">
|
||||||
|
<div class="a-right col-6 align-self-center">랜덤 턴 초기화</div>
|
||||||
|
<b-button
|
||||||
|
class="col-6"
|
||||||
|
variant="primary"
|
||||||
|
@click="buySimple('ResetTurnTime')"
|
||||||
|
>구입</b-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="a-right">
|
||||||
|
<small class="form-text text-muted"
|
||||||
|
>다음 턴이 랜덤으로 바뀝니다.<br /><span style="color: white"
|
||||||
|
>필요 포인트: {{ inheritActionCost.resetTurnTime }}</span
|
||||||
|
></small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col col-md-4 col-sm-6 p-2">
|
||||||
|
<div class="row">
|
||||||
|
<div class="a-right col-6 align-self-center">랜덤 유니크 획득</div>
|
||||||
|
<b-button
|
||||||
|
class="col-6"
|
||||||
|
variant="primary"
|
||||||
|
@click="buySimple('BuyRandomUnique')"
|
||||||
|
>구입</b-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="a-right">
|
||||||
|
<small class="form-text text-muted"
|
||||||
|
>다음 턴에 랜덤 유니크를 얻습니다.<br /><span style="color: white"
|
||||||
|
>필요 포인트: {{ inheritActionCost.randomUnique }}</span
|
||||||
|
></small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col col-md-4 col-sm-6 p-2">
|
||||||
|
<div class="row">
|
||||||
|
<div class="a-right col-6 align-self-center">
|
||||||
|
즉시 전투 특기 초기화
|
||||||
|
</div>
|
||||||
|
<b-button
|
||||||
|
class="col-6"
|
||||||
|
variant="primary"
|
||||||
|
@click="buySimple('ResetSpecialWar')"
|
||||||
|
>구입</b-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="a-right">
|
||||||
|
<small class="form-text text-muted"
|
||||||
|
>즉시 전투 특기를 초기화합니다.<br /><span style="color: white"
|
||||||
|
>필요 포인트: {{ inheritActionCost.resetSpecialWar }}</span
|
||||||
|
></small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ResetTurnTime -->
|
||||||
|
<!-- BuyRandomUnique -->
|
||||||
|
<!-- ResetSpecialWar -->
|
||||||
|
<!-- SetNextSpecialWar, type -->
|
||||||
|
<!-- BuySpecificUnique, item, amount -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -231,7 +295,15 @@ const inheritBuffHelpText: Record<
|
|||||||
};
|
};
|
||||||
|
|
||||||
declare const maxInheritBuff: number;
|
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({
|
export default defineComponent({
|
||||||
name: "InheritPoint",
|
name: "InheritPoint",
|
||||||
@@ -260,7 +332,9 @@ export default defineComponent({
|
|||||||
inheritBuff,
|
inheritBuff,
|
||||||
prevInheritBuff: currentInheritBuff,
|
prevInheritBuff: currentInheritBuff,
|
||||||
maxInheritBuff,
|
maxInheritBuff,
|
||||||
inheritBuffCost,
|
inheritActionCost,
|
||||||
|
resetTurnTimeLevel,
|
||||||
|
resetSpecialWarLevel,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -275,7 +349,8 @@ export default defineComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cost =
|
const cost =
|
||||||
this.inheritBuffCost[level] - this.inheritBuffCost[prevLevel];
|
this.inheritActionCost.buff[level] -
|
||||||
|
this.inheritActionCost.buff[prevLevel];
|
||||||
if (this.items.previous < cost) {
|
if (this.items.previous < cost) {
|
||||||
alert("유산 포인트가 부족합니다.");
|
alert("유산 포인트가 부족합니다.");
|
||||||
return;
|
return;
|
||||||
@@ -298,11 +373,11 @@ export default defineComponent({
|
|||||||
method: "post",
|
method: "post",
|
||||||
responseType: "json",
|
responseType: "json",
|
||||||
data: {
|
data: {
|
||||||
path: 'InheritAction/BuyHiddenBuff',
|
path: "InheritAction/BuyHiddenBuff",
|
||||||
args: {
|
args: {
|
||||||
type: buffKey,
|
type: buffKey,
|
||||||
level,
|
level,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
result = response.data;
|
result = response.data;
|
||||||
@@ -315,7 +390,60 @@ export default defineComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
alert('성공했습니다.');
|
alert("성공했습니다.");
|
||||||
|
//TODO: 페이지 새로고침 필요없이 하도록
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
async buySimple(
|
||||||
|
type: "ResetTurnTime" | "BuyRandomUnique" | "ResetSpecialWar"
|
||||||
|
) {
|
||||||
|
const costMap: Record<typeof type, number> = {
|
||||||
|
ResetTurnTime: inheritActionCost.resetTurnTime,
|
||||||
|
ResetSpecialWar: inheritActionCost.resetSpecialWar,
|
||||||
|
BuyRandomUnique: inheritActionCost.randomUnique,
|
||||||
|
};
|
||||||
|
|
||||||
|
const cost = costMap[type];
|
||||||
|
if (cost === undefined) {
|
||||||
|
alert(`올바르지 않은 타입:${type}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const messageMap: Record<typeof type, string> = {
|
||||||
|
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: 페이지 새로고침 필요없이 하도록
|
//TODO: 페이지 새로고침 필요없이 하도록
|
||||||
location.reload();
|
location.reload();
|
||||||
},
|
},
|
||||||
|
|||||||
+23
-3
@@ -21,12 +21,25 @@ foreach (array_keys(General::INHERITANCE_KEY) as $key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$currentInheritBuff = [];
|
$currentInheritBuff = [];
|
||||||
foreach ($me->getAuxVar('inheritBuff') as $buff=>$buffLevel){
|
foreach ($me->getAuxVar('inheritBuff') as $buff => $buffLevel) {
|
||||||
if(!key_exists($buff,TriggerInheritBuff::BUFF_KEY_TEXT)){
|
if (!key_exists($buff, TriggerInheritBuff::BUFF_KEY_TEXT)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$currentInheritBuff[$buff] = $buffLevel;
|
$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;
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -46,7 +59,14 @@ foreach ($me->getAuxVar('inheritBuff') as $buff=>$buffLevel){
|
|||||||
'items' => $items,
|
'items' => $items,
|
||||||
'currentInheritBuff' => $currentInheritBuff,
|
'currentInheritBuff' => $currentInheritBuff,
|
||||||
'maxInheritBuff' => TriggerInheritBuff::MAX_STEP,
|
'maxInheritBuff' => TriggerInheritBuff::MAX_STEP,
|
||||||
'inheritBuffCost' => GameConst::$inheritBuffPoints,
|
'resetTurnTimeLevel' => $resetTurnTimeLevel,
|
||||||
|
'resetSpecialWarLevel' => $resetSpecialWarLevel,
|
||||||
|
'inheritActionCost' => [
|
||||||
|
'buff' => GameConst::$inheritBuffPoints,
|
||||||
|
'resetTurnTime' => calcResetAttrPoint($resetTurnTimeLevel),
|
||||||
|
'resetSpecialWar' => calcResetAttrPoint($resetSpecialWarLevel),
|
||||||
|
'randomUnique' => GameConst::$inheritItemRandomPoint,
|
||||||
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user