diff --git a/src/assets/icons/tips.png b/src/assets/icons/tips.png deleted file mode 100644 index b7b74bd..0000000 Binary files a/src/assets/icons/tips.png and /dev/null differ diff --git a/src/components/tooltip.vue b/src/components/tooltip.vue index 7ccde01..b8f37fc 100644 --- a/src/components/tooltip.vue +++ b/src/components/tooltip.vue @@ -4,6 +4,7 @@
+

* {{ info }}

@@ -18,7 +19,9 @@ import { useI18n } from "vue3-i18n"; const { t } = useI18n(); const { state, commit, dispatch } = useStore(); const tipsShow = ref(false); -const tipsStyle = ref({}); +const tipsStyle = ref({ + transform: '' +}); const prop = defineProps({ placement: { @@ -31,16 +34,25 @@ const prop = defineProps({ width: { type: String, default: '16rem' + }, + showIcon: { + type: Boolean, + default: true + }, + x: { + type: String, + default: null } }) const showTips = (e) => { const x = e.pageX, y = e.pageY, maxH = window.innerHeight, maxW = window.innerWidth; - const xt = x < 100 ? '15%' : y < maxH - 100 ? '0%' : '-40%'; - const yt = y < maxH - 200 ? '100%' : '-50%'; - tipsStyle.value = { - transform: 'translate(' + xt + ', ' + yt + ')' + let xt = x < 100 ? '15%' : y < maxH - 100 ? '0%' : '-40%'; + if (prop.x) { + xt = prop.x; } + const yt = y < maxH / 2 ? '100%' : '-50%'; + tipsStyle.value.transform = 'translate(' + xt + ', ' + yt + ')'; tipsShow.value = true } const closeTips = () => { @@ -66,28 +78,27 @@ onMounted(() => { }); border-radius: 4px; padding: 1.2rem; background: #111111; - padding-top: 3.6rem; + // padding-top: 3.6rem; font-size: 0.86rem; font-weight: normal; z-index: 9999; box-shadow: 0 0 3px 3px rgba($color: #000000, $alpha: 1.0); - .info { - font-weight: normal; - margin-top: 0.4rem; - } - - &::after { - position: absolute; - top: 0.4rem; - left: 50%; + .tip-icons { + // position: absolute; + margin-left: 50%; transform: translateX(-50%); display: flex; width: 3.2rem; height: 3.2rem; - background-image: url(@/assets/icons/tips.png); background-size: cover; } + + .info { + font-weight: normal; + margin-top: 0.4rem; + } + } .top { diff --git a/src/config/i18n/zh.ts b/src/config/i18n/zh.ts index 36c1d57..3a7553a 100644 --- a/src/config/i18n/zh.ts +++ b/src/config/i18n/zh.ts @@ -2,6 +2,7 @@ export default class Zh { title = '挂机放置游戏'; welcome = ['欢迎你勇士,点击地图上的副本开始战斗。', '界面左上角菜单可以打开世界副本地图。']; + sys = '系统'; loadEmpty = '未读取到存档!'; loadError = '存档坏了!'; @@ -146,6 +147,7 @@ export default class Zh { eliteMonster = '无尽模式精英怪'; startDungeon = '你已进入'; battle = '你遭遇了(lv${lv}${name}),正在战斗中...'; + bouts = ['点击查看战斗过程', '回合', '触发了暴击', '你造成了${dmg}点伤害', '受到${dmg}点伤害', '战斗结束', '你获胜', '你战败']; killMonster = '你击杀了(lv${lv}${name}),共受到了${dmg}点伤害'; beKilled = '你被(lv${lv}${name})击败,共受到了${dmg}点伤害'; getCoins = '获得金币:'; diff --git a/src/tool/caller.ts b/src/tool/caller.ts index f0464fd..91fabb7 100644 --- a/src/tool/caller.ts +++ b/src/tool/caller.ts @@ -63,9 +63,9 @@ export const callPlayerAttribute = (playerAttribute: any, rA: any) => { critdmg = attribute.critDmg / 100; attribute.dps = Math.ceil((1 - crit + crit * critdmg) * atk); //计算减伤比例 -// attribute.def = 500; + // attribute.def = 500; attribute.reducPercent = (0.5 * attribute.def) / (35 + 0.55 * attribute.def) + (0.09 * attribute.def) / (attribute.def + 200); -// attribute.reducPercent = (0.5 * attribute.def) / (200 + 0.502 * attribute.def); + // attribute.reducPercent = (0.5 * attribute.def) / (200 + 0.502 * attribute.def); return attribute; }; @@ -127,3 +127,31 @@ export const getPointsOfReborn = (playerAttribute) => { return Math.round(points * 1.2); }; + +export const callBattleResult = (player, monster) => { + const tmp = player.curHp, + crit = player.crit / 100, + critdmg = player.critDmg / 100, + atk = player.atk; + let monsterDmg = Math.ceil(monster.atk * (1 - player.reducPercent) - player.bloc); + monsterDmg < 1 && (monsterDmg = 1); + let curHp = player.curHp, + mHp = monster.hp; + const bouts: any = []; + while (true) { + const bout: any = {}; + bouts.push(bout); + if (Math.random() < crit) { + bout.crit = true; + bout.dmg = Math.ceil(atk * critdmg); + } else { + bout.dmg = atk; + } + mHp -= bout.dmg; + if (mHp < 0) break; + bout.takeDmg = monsterDmg; + curHp -= monsterDmg; + if (curHp < 0) break; + } + return { win: curHp > 0, bouts: bouts, takeDmg: tmp - curHp }; +}; diff --git a/src/views/dungeon/battle.vue b/src/views/dungeon/battle.vue index 3e6b62c..4019a8f 100644 --- a/src/views/dungeon/battle.vue +++ b/src/views/dungeon/battle.vue @@ -16,7 +16,7 @@ import { useStore } from "vuex"; import { computed, nextTick, onMounted, ref } from "vue"; import { useI18n } from "vue3-i18n"; import { dungeon_icon, player_move_time, player_battle_time } from "@/config"; -import { randonBootyEquip } from "@/tool"; +import { randonBootyEquip, callBattleResult } from "@/tool"; const { t } = useI18n(); const { state, commit, dispatch } = useStore(); @@ -103,30 +103,31 @@ const playerMove = (monsterIdx?, playerIdx?) => { const battleWithMonster = (monster) => { return new Promise((resolve, reject) => { const player = state.playerAttribute.attribute; - let monsterDmg = Math.ceil(monster.atk * (1 - player.reducPercent) - player.bloc); - monsterDmg < 1 && (monsterDmg = 1); + const result = callBattleResult(player, monster); + // let monsterDmg = Math.ceil(monster.atk * (1 - player.reducPercent) - player.bloc); + // monsterDmg < 1 && (monsterDmg = 1); - const playerDeadTime = Math.ceil(player.curHp / monsterDmg); - const monsterDeadTime = Math.ceil(monster.hp / player.dps); - const takeDmg = monsterDeadTime * monsterDmg; + // const playerDeadTime = Math.ceil(player.curHp / monsterDmg); + // const monsterDeadTime = Math.ceil(monster.hp / player.dps); + // const takeDmg = monsterDeadTime * monsterDmg; const battleTime = Math.round(player_battle_time * 100 / (100 + state.rebornAttribute.battleSpeed)) const getMsg = (i18nName) => { - return t(i18nName).replace('${lv}', monster.lv).replace('${name}', t('difficulty.' + props.dungeon?.difficulty) + t(monster.type)).replace('${dmg}', takeDmg + ''); + return t(i18nName).replace('${lv}', monster.lv).replace('${name}', t('difficulty.' + props.dungeon?.difficulty) + t(monster.type)).replace('${dmg}', result.takeDmg + ''); }; commit("set_sys_info", { msg: getMsg('battle'), type: 'battle' }); battle.value.timeOut = setTimeout(() => { nextTick(() => { - commit('add_player_curhp', -1 * takeDmg); + commit('add_player_curhp', -1 * result.takeDmg); }) - if (monsterDeadTime < playerDeadTime) { - commit("set_sys_info", { msg: getMsg('killMonster'), type: 'battle' }); + if (result.win) { + commit("set_sys_info", { msg: getMsg('killMonster'), type: 'battle', bouts: result.bouts }); //随机获取装备战利品 const equips = randonBootyEquip(monster); commit('add_bootys', { equips: equips, coins: monster.coins }); resolve(true); } else { - commit("set_sys_info", { msg: getMsg('beKilled'), type: 'warning' }); + commit("set_sys_info", { msg: getMsg('beKilled'), type: 'warning', bouts: result.bouts }); battle.value.battleShow = false; dispatch('play_music', 'backgound'); } diff --git a/src/views/message/bouts.vue b/src/views/message/bouts.vue new file mode 100644 index 0000000..e2c5356 --- /dev/null +++ b/src/views/message/bouts.vue @@ -0,0 +1,51 @@ + + + + \ No newline at end of file diff --git a/src/views/message/sys-info.vue b/src/views/message/sys-info.vue index aa722c3..61a99e1 100644 --- a/src/views/message/sys-info.vue +++ b/src/views/message/sys-info.vue @@ -1,9 +1,17 @@