feat: 포인트 초기화 추가

- 급하니까 일단 땜빵
This commit is contained in:
2024-07-10 18:11:10 +00:00
parent 7c9d5d34f6
commit d8870caf29
5 changed files with 129 additions and 9 deletions
+9 -6
View File
@@ -67,24 +67,24 @@ class ResetStat extends \sammo\BaseAPI
$intel = $this->args['intel'];
$inheritBonusStat = $this->args['inheritBonusStat'] ?? null;
if ($leadership + $strength + $intel > GameConst::$defaultStatTotal) {
return "능력치 " . GameConst::$defaultStatTotal . "을 넘어섰습니다. 다시 입해주세요!";
if ($leadership + $strength + $intel != GameConst::$defaultStatTotal) {
return "능력치 총합이 " . GameConst::$defaultStatTotal . "이 아닙니다. 다시 입해주세요!";
}
if ($inheritBonusStat) {
if (count($inheritBonusStat) != 3) {
return "보너스 능력치가 잘못 지정되었습니다. 다시 입해주세요!";
return "보너스 능력치가 잘못 지정되었습니다. 다시 입해주세요!";
}
foreach ($inheritBonusStat as $stat) {
if ($stat < 0) {
return "보너스 능력치가 음수입니다. 다시 입해주세요!";
return "보너스 능력치가 음수입니다. 다시 입해주세요!";
}
}
$sum = array_sum($inheritBonusStat);
if ($sum == 0) {
$inheritBonusStat = null;
} else if ($sum < 3 || $sum > 5) {
return "보너스 능력치 합이 잘못 지정되었습니다. 다시 입해주세요!";
return "보너스 능력치 합이 잘못 지정되었습니다. 다시 입해주세요!";
}
}
@@ -131,7 +131,7 @@ class ResetStat extends \sammo\BaseAPI
$pleadership = $inheritBonusStat[0] ?? 0;
$pstrength = $inheritBonusStat[1] ?? 0;
$pintel = $inheritBonusStat[2] ?? 0;
$userLogger->push("통솔 {$pleadership}, 무력 {$pstrength}, 지력 {$pintel} 보너스 능력치 적용", "inheritPoint");
$userLogger->push("{$reqAmount}통솔 {$pleadership}, 무력 {$pstrength}, 지력 {$pintel} 보너스 능력치 적용", "inheritPoint");
} else {
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
UniqueConst::$hiddenSeed,
@@ -161,6 +161,8 @@ class ResetStat extends \sammo\BaseAPI
$strength += $pstrength;
$intel += $pintel;
$lastUserStatReset[] = $gameSeason;
$general->setVar('leadership', $leadership);
$general->setVar('strength', $strength);
@@ -169,6 +171,7 @@ class ResetStat extends \sammo\BaseAPI
$userLogger->flush();
$inheritStor->setValue('previous', [$previousPoint - $reqAmount, null]);
$userStor->setValue('last_stat_reset', $lastUserStatReset);
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $reqAmount);
$general->applyDB($db);
return null;
+103 -2
View File
@@ -172,6 +172,56 @@
<BButton class="col-6 offset-6" variant="primary" @click="checkOwner"> 소유자 찾기 </BButton>
</div>
</div>
<div class="col col-lg-4 col-sm-6 col-12 py-2">
<div class="row px-4">
<div class="a-right col-6 align-self-center">능력치 초기화</div>
<div class="col-6">
<div class="row">기본 능력치</div>
<div class="row">
<div class="col col-2 center align-self-center"></div>
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.leadership" type="number"
:min="currentStat.statMin" :max="currentStat.statMax" /></div>
</div>
<div class="row">
<div class="col col-2 center align-self-center"></div>
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.strength" type="number"
:min="currentStat.statMin" :max="currentStat.statMax" /></div>
</div>
<div class="row">
<div class="col col-2 center align-self-center"></div>
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.intel" type="number"
:min="currentStat.statMin" :max="currentStat.statMax" /></div>
</div>
<div class="row">추가 능력치</div>
<div class="row">
<div class="col col-2 center align-self-center"></div>
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.inheritBonusStat[0]" type="number"
min="0" max="5" /></div>
</div>
<div class="row">
<div class="col col-2 center align-self-center"></div>
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.inheritBonusStat[1]" type="number"
min="0" max="5" />
</div>
</div>
<div class="row">
<div class="col col-2 center align-self-center"></div>
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.inheritBonusStat[2]" type="number"
min="0" max="5" />
</div>
</div>
</div>
</div>
<div class="a-right">
<small class="form-text text-muted">시즌 1회에 능력치를 초기화합니다. <br />
</small>
<span style="color: white">필요 포인트: {{ requiredResetStatPoint }}</span>
</div>
<div class="row px-4">
<BButton class="col-6 offset-6" variant="primary" @click="resetStat"> 능력치 초기화</BButton>
</div>
</div>
</div>
<div class="row">
<div class="col">
@@ -224,6 +274,7 @@ declare const staticValues: {
nextSpecial: number;
minSpecificUnique: number;
checkOwner: number;
bornStatPoint: number;
};
resetTurnTimeLevel: number;
resetSpecialWarLevel: number;
@@ -246,16 +297,23 @@ declare const staticValues: {
}
>;
availableTargetGeneral: Record<number, string>;
currentStat: {
leadership: number;
strength: number;
intel: number;
statMax: number;
statMin: number;
};
};
</script>
<script lang="ts" setup>
import { reactive, ref } from "vue";
import { reactive, ref, watch } from "vue";
import "@scss/game_bg.scss";
import TopBackBar from "@/components/TopBackBar.vue";
import _ from "lodash-es";
import NumberInputWithInfo from "@/components/NumberInputWithInfo.vue";
import { SammoAPI } from "./SammoAPI";
import type { inheritBuffType, InheritPointLogItem } from "./defs/API/InheritAction";
import { InheritResetStat, type inheritBuffType, type InheritPointLogItem } from "./defs/API/InheritAction";
import * as JosaUtil from "@/util/JosaUtil";
import { BButton } from "bootstrap-vue-next";
import { unwrap } from "./util/unwrap";
@@ -389,12 +447,20 @@ const {
availableSpecialWar,
availableUnique,
availableTargetGeneral,
currentStat
} = staticValues;
const nextSpecialWar = ref(Object.keys(availableSpecialWar)[0]);
const specificUnique = ref<string | null>(null);
const specificUniqueAmount = ref(inheritActionCost.minSpecificUnique);
const resetStatArgs = reactive<Required<Pick<InheritResetStat, 'inheritBonusStat'>> & InheritResetStat>({
leadership: currentStat.leadership,
strength: currentStat.strength,
intel: currentStat.intel,
inheritBonusStat: [0, 0, 0]
});
const lastLogID = ref(Math.min(...staticValues.lastInheritPointLogs.map((v) => v.id)));
const inheritPointLogs = ref(
(() => {
@@ -608,6 +674,41 @@ async function checkOwner(): Promise<void> {
}
const requiredResetStatPoint = ref(0);
watch(resetStatArgs, (value) => {
const bonusStat = value.inheritBonusStat.reduce((acc, v) => acc + v, 0);
requiredResetStatPoint.value = bonusStat > 0 ? inheritActionCost.bornStatPoint : 0;
})
async function resetStat(): Promise<void> {
const statArg: InheritResetStat = {
leadership: resetStatArgs.leadership,
strength: resetStatArgs.strength,
intel: resetStatArgs.intel,
};
if (resetStatArgs.inheritBonusStat.some(v => v > 0)) {
statArg.inheritBonusStat = resetStatArgs.inheritBonusStat;
}
if (!confirm(`능력치를 초기화 하시겠습니까? 시즌마다 한번만 가능합니다. 필요 포인트: ${requiredResetStatPoint.value}`)) {
return;
}
try {
const result = await SammoAPI.InheritAction.ResetStat(statArg);
alert('초기화 되었습니다.');
location.reload();
} catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
}
async function getMoreLog(): Promise<void> {
try {
const result = await SammoAPI.InheritAction.GetMoreLog({
+2 -1
View File
@@ -17,7 +17,7 @@ import { APIPathGen, NumVar, StrVar } from "./util/APIPathGen.js";
import type { BettingDetailResponse, BettingListResponse } from "./defs/API/Betting";
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 { inheritBuffType, InheritLogResponse, InheritResetStat } from "./defs/API/InheritAction";
import type { SetBlockWarResponse, GeneralListResponse as NationGeneralListResponse, NationInfoResponse } from "./defs/API/Nation";
import type { UploadImageResponse } from "./defs/API/Misc";
import type { GeneralLogType, GetGeneralLogResponse, JoinArgs } from "./defs/API/General";
@@ -183,6 +183,7 @@ const apiRealPath = {
CheckOwner: PUT as APICallT<{
destGeneralID: number;
}>,
ResetStat: PUT as APICallT<InheritResetStat>,
},
Message: {
DeleteMessage: PATCH as APICallT<{
+7
View File
@@ -22,3 +22,10 @@ export type InheritPointLogItem = {
export type InheritLogResponse = ValidResponse & {
log: InheritPointLogItem[];
};
export type InheritResetStat = {
leadership: number;
strength: number;
intel: number;
inheritBonusStat?: [number, number, number];
};
+8
View File
@@ -99,11 +99,19 @@ $lastInheritPointLogs = $db->query('SELECT id, server_id, year, month, date, tex
'nextSpecial' => GameConst::$inheritSpecificSpecialPoint,
'minSpecificUnique' => GameConst::$inheritItemUniqueMinPoint,
'checkOwner' => GameConst::$inheritCheckOwnerPoint,
'bornStatPoint' => GameConst::$inheritBornStatPoint,
],
'availableSpecialWar' => $avilableSpecialWar,
'availableUnique' => $availableUnique,
'lastInheritPointLogs' => $lastInheritPointLogs,
'availableTargetGeneral' => $availableTargetGeneral,
'currentStat' => [
'leadership' => Util::clamp($me->getVar('leadership'), GameConst::$defaultStatMin, GameConst::$defaultStatMax),
'strength' => Util::clamp($me->getVar('strength'), GameConst::$defaultStatMin, GameConst::$defaultStatMax),
'intel' => Util::clamp($me->getVar('intel'), GameConst::$defaultStatMin, GameConst::$defaultStatMax),
'statMin' => GameConst::$defaultStatMin,
'statMax' => GameConst::$defaultStatMax,
]
]
]) ?>
</head>