111
This commit is contained in:
@@ -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>
|
||||
@@ -1 +1,89 @@
|
||||
<template></template>
|
||||
<template>
|
||||
<div class="content" v-if="isWin != -1">
|
||||
<div class="common">
|
||||
<span v-if="isWin == 1">战胜了{{ otName }}!</span>
|
||||
<span v-if="isWin == 0">你被{{ otName }}击杀!</span>
|
||||
<span v-if="isWin == 2">被{{ otName }}击杀!</span>
|
||||
</div>
|
||||
<div class="common">
|
||||
<Abar href="/map">继续</Abar>
|
||||
</div>
|
||||
<div class="common">
|
||||
你体力:{{ blood }}/{{ upBlood }}
|
||||
</div>
|
||||
<div class="common" v-if="isWin == 1">
|
||||
<div class="item" v-if="fight.exp > 0">
|
||||
经验:+{{ fight.exp }}
|
||||
</div>
|
||||
<div class="item" v-if="fight.copper > 0">
|
||||
铜贝:+{{ fight.copper }}
|
||||
</div>
|
||||
<div class="item" v-if="fight.petExp > 0">
|
||||
宠物经验:+{{ fight.petExp }}
|
||||
</div>
|
||||
<div class="item" v-if="fight.award != ''" v-html="AwardTips">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
layout: layout.default,
|
||||
middleware: 'page-loading'
|
||||
})
|
||||
|
||||
const isWin = ref(-1);
|
||||
const otName = ref('');
|
||||
const blood = ref(0);
|
||||
const upBlood = ref(0);
|
||||
const fight = ref<any>({});
|
||||
const AwardTips = ref('');
|
||||
let fightId = PageExtend.QueryString("f");
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await BindData();
|
||||
}
|
||||
finally {
|
||||
PageLoading.Close();
|
||||
}
|
||||
})
|
||||
|
||||
const BindData = async (): Promise<void> => {
|
||||
let result = await FightService.GetFightMsg(fightId);
|
||||
if (result.code == 0) {
|
||||
isWin.value = result.data.isWin;
|
||||
otName.value = result.data.otName;
|
||||
blood.value = result.data.blood;
|
||||
upBlood.value = result.data.upBlood;
|
||||
fight.value = result.data.fight;
|
||||
if (fight.value.award != '') {
|
||||
AwardTips.value = awardTipsStr(JSON.parse(fight.value.award))
|
||||
}
|
||||
}
|
||||
else if (result.code == 100) {
|
||||
PageExtend.RedirectTo("/fight?f=" + fightId);
|
||||
}
|
||||
else {
|
||||
|
||||
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
|
||||
PageExtend.RedirectTo("/map");
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
const awardTipsStr = (data: any) => {
|
||||
let result = '';
|
||||
if (data.code == 'Default') {
|
||||
result += "<span>掉落物品:</span><br>"
|
||||
let awData: Array<any> = data.award;
|
||||
awData.forEach(it => {
|
||||
result += `${it.name}×${it.count}、`;
|
||||
})
|
||||
return StringExtend.trimEnd(result, '、');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -7,7 +7,7 @@
|
||||
等级:{{ monster.lev }}<br>
|
||||
说明:{{ monster.remark }}<br>
|
||||
体力:{{ monster.blood }}<br>
|
||||
攻击:{{ monster.minAtk }}/{{ monster.maxAtk }}<br>
|
||||
攻击:{{ monster.minAtk }}-{{ monster.maxAtk }}<br>
|
||||
防御:{{ monster.defense }}<br>
|
||||
敏捷:{{ monster.agility }}<br>
|
||||
</div>
|
||||
|
||||
@@ -35,4 +35,12 @@ export class FightService {
|
||||
static async UseFightDrug(fightId: string, drugId: string) {
|
||||
return await ApiService.Request("get", "/Fight/UseFightDrug", { fightId, drugId });
|
||||
}
|
||||
|
||||
/**
|
||||
* 战斗信息
|
||||
* GET /Fight/GetFightMsg
|
||||
*/
|
||||
static async GetFightMsg(fightId: string) {
|
||||
return await ApiService.Request("get", "/Fight/GetFightMsg", { fightId });
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,6 @@ export class FightTool {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//士气处理
|
||||
if (atkUser.upMorale > 0) {
|
||||
atkUser.minAtk = atkUser.minAtk * (1.0 + (atkUser.morale / atkUser.upMorale) * 0.3);
|
||||
@@ -75,7 +74,6 @@ export class FightTool {
|
||||
else {
|
||||
defHarm = -1;
|
||||
}
|
||||
|
||||
//暴击处理
|
||||
if (atkUser.crit > 0) {
|
||||
if (this.randomTrigger(atkUser.crit)) {
|
||||
|
||||
Reference in New Issue
Block a user