Browse Source

Update battle.vue

dev
许孟阳 2 months ago
parent
commit
98774e20dc
  1. 12
      src/views/dungeon/battle.vue

12
src/views/dungeon/battle.vue

@ -104,25 +104,25 @@ const playerMove = (monsterIdx?, playerIdx?) => {
const battleWithMonster = (monster) => { const battleWithMonster = (monster) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const player = state.playerAttribute.attribute; const player = state.playerAttribute.attribute;
const result = callBattleResult(player, monster);
const battleTime = Math.round(player_battle_time * 100 / (100 + state.rebornAttribute.battleSpeed)) const battleTime = Math.round(player_battle_time * 100 / (100 + state.rebornAttribute.battleSpeed))
const getMsg = (i18nName) => { const getMsg = (i18nName, takeDmg) => {
return t(i18nName).replace('${lv}', monster.lv).replace('${name}', t('difficulty.' + props.dungeon?.difficulty) + t(monster.type)).replace('${dmg}', result.takeDmg + ''); return t(i18nName).replace('${lv}', monster.lv).replace('${name}', t('difficulty.' + props.dungeon?.difficulty) + t(monster.type)).replace('${dmg}', takeDmg + '');
}; };
commit("set_sys_info", { msg: getMsg('battle'), type: 'battle' }); commit("set_sys_info", { msg: getMsg('battle', 0), type: 'battle' });
battle.value.timeOut = setTimeout(() => { battle.value.timeOut = setTimeout(() => {
const result = callBattleResult(player, monster);
nextTick(() => { nextTick(() => {
commit('add_player_curhp', -1 * result.takeDmg); commit('add_player_curhp', -1 * result.takeDmg);
}) })
if (result.win) { if (result.win) {
commit("set_sys_info", { msg: getMsg('killMonster'), type: 'battle', bouts: result.bouts }); commit("set_sys_info", { msg: getMsg('killMonster', result.takeDmg), type: 'battle', bouts: result.bouts });
// //
const equips = randonBootyEquip(monster); const equips = randonBootyEquip(monster);
commit('add_bootys', { equips: equips, coins: monster.coins }); commit('add_bootys', { equips: equips, coins: monster.coins });
resolve(true); resolve(true);
} else { } else {
commit("set_sys_info", { msg: getMsg('beKilled'), type: 'warning', bouts: result.bouts }); commit("set_sys_info", { msg: getMsg('beKilled', result.takeDmg), type: 'warning', bouts: result.bouts });
battle.value.battleShow = false; battle.value.battleShow = false;
dispatch('play_music', 'backgound'); dispatch('play_music', 'backgound');
} }

Loading…
Cancel
Save