This commit is contained in:
Putoo
2026-07-05 18:51:01 +08:00
parent fdb16f5d91
commit a1dbce8a96
15 changed files with 468 additions and 47 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div class="content">
<div class="common">
<Abutton>{{ autoFight == 0 ? "开启自动攻击" : "关闭自动攻击" }}</Abutton>
<Abutton @click="AutoAtk">{{ autoFight == 0 ? "开启自动攻击" : "关闭自动攻击" }}</Abutton>
</div>
<div class="common">
你向{{ otAttr.name }}发起了攻击!
@@ -72,6 +72,7 @@ const coolTime = ref(0);
let coolLock = false;//冷却锁
const coolTimer = ref(0);//冷却定时器
let dataLock = false;//数据锁
const autoAtkTimer = ref(0);//冷却定时器
onMounted(async () => {
try {
@@ -83,7 +84,8 @@ onMounted(async () => {
})
onUnmounted(() => {
clearTimeout(coolTimer.value)
clearTimeout(coolTimer.value);
clearTimeout(autoAtkTimer.value);
})
/**加载方法 */
@@ -98,7 +100,7 @@ const BindData = async (data: string): Promise<void> => {
coolTime.value = result.data.cool;
dataLock = false;
myHarm.value = result.data.myHarm;
otHarm.value = result.data.otHarm;
otHarm.value = result.data.otHarm;
}
else if (result.code == 100) {
PageExtend.RedirectTo("/fight/result?f=" + fightId);
@@ -149,8 +151,8 @@ const UseFightDrug = async (drugId: string) => {
const FightAtk = async () => {
if (coolLock == false && dataLock == false) {
StartCool();
let result = FightTool.FightHandle(myAttr.value, otAttr.value);
let data = JSON.stringify(result);
let result = FightTool.FightHandle(myAttr.value, otAttr.value);
let data = JSON.stringify(result);
await BindData(data);
}
}
@@ -162,4 +164,19 @@ const StartCool = () => {
coolLock = false;
}, coolTime.value)
}
/**自动攻击 */
const AutoAtk = () => {
if (autoFight.value == 0) {
autoFight.value = 1;
autoAtkTimer.value = setInterval(async () => {
await FightAtk()
}, coolTime.value)
}
else {
autoFight.value = 0;
clearTimeout(autoAtkTimer.value)
}
}
</script>