battle_damage_tooltip

Показывает урон всех вражеских стеков по одному своему. Выбор существа и стороны по кнопке. Урон не полностью корректен, так что нужно помнить про погрешность.

当前为 2023-04-10 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         battle_damage_tooltip
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Показывает урон всех вражеских стеков по одному своему. Выбор существа и стороны по кнопке. Урон не полностью корректен, так что нужно помнить про погрешность.
// @author       You
// @license        GNU GPLv3
// @match       https://www.heroeswm.ru/war*
// @match       https://my.lordswm.com/war*
// @match       https://www.lordswm.com/war*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
let chosen_one = "Высшие вампиры"

let chosen_side = 1
let outer_chat = document.getElementById("chat_format");//
outer_chat.innerHTML+= '<button id = "dmg_list_refresh" style="background-color: #3d3d29; color: white; padding: 5px 10px; border: none; border-radius: 4px; font-size: 10px; cursor: pointer">Открыть</button><select style = "display : none; background-color: #333; color: white; margin: 10px" id = "choose_cre"></select>'
outer_chat.innerHTML+= '<button id = "change_side" style="background-color: #6b6b47; color: white; padding: 5px 10px; border: none; border-radius: 4px; font-size: 10px; cursor: pointer; display: none">Сменить сторону</button>'
outer_chat.innerHTML+= '<button id = "collapse" style="background-color: #000000; color: white; padding: 5px 10px; border: none; border-radius: 4px; font-size: 10px; cursor: pointer; display: none; margin:10px">Свернуть</button>'

//outer_chat.innerHTML+= '<style>.tooltip{position:relative;display:inline-block;border-bottom:1px dotted #000}.tooltip .tooltiptext{visibility:hidden;width:120px;background-color:#555;color:#fff;text-align:center;border-radius:6px;padding:5px 0;position:absolute;z-index:1;bottom:125%;left:50%;margin-left:-60px;opacity:0;transition:opacity .3s}.tooltip .tooltiptext::after{content:"";position:absolute;top:100%;left:50%;margin-left:-5px;border-width:5px;border-style:solid;border-color:#555 transparent transparent transparent}.tooltip:hover .tooltiptext{visibility:visible;opacity:1}</style>'
//outer_chat.innerHTML+= '<button class="tooltip" id = "help" style="background-color: #555; color: white; padding: 5px 10px; border: none; border-radius: 4px; font-size: 10px; margin: 10px; display:none">?<span class="tooltiptext">tooltip</span></button>'
//let help_button = document.getElementById("help")
let chat = document.getElementById("chat_inside");
let select = document.getElementById("choose_cre")
let refresh_button = document.getElementById("dmg_list_refresh")
let side_button = document.getElementById("change_side")
let collapse_button = document.getElementById("collapse")
collapse_button.onclick = () =>{
    [...chat.children].forEach(child=>{
        if (child.tagName == "P") child.remove()
    })
    refresh_button.innerHTML = "Открыть"
    /*help_button.style.display = */select.style.display = side_button.style.display = collapse_button.style.display = "none"
}
refresh_button.onclick = refresh
side_button.onclick = ()=>{
    chosen_side = - chosen_side
    refresh()
}

function get_dmg_info(cre1_id, cre2_id){
    window.stage.pole.attackmonster(cre1_id, window.stage.pole.obj[cre1_id].x, window.stage.pole.obj[cre1_id].y, window.stage.pole.obj[cre2_id].x, window.stage.pole.obj[cre2_id].y, cre2_id)
    return {min: window.PhysicalDamage, max: window.PhysicalDamage2}
}
select.addEventListener('change', function() {
    chosen_one = select.value
    refresh()
});
let defender_obj_id = 0
let selected_id = 0
function refresh(){
    /*help_button.style.display = */select.style.display = side_button.style.display = collapse_button.style.display = "inline"
    refresh_button.innerHTML = "Обновить"
    let cre_list = Object.values(window.stage.pole.obj);
    cre_list.sort(function(a, b) {
        return a.obj_index - b.obj_index;
    });
    [...chat.children].forEach(child=>{
        if (child.tagName == "P") child.remove()
    })
    select.innerHTML = ""
    let found_defender = false
    cre_list.forEach(creature => {
        if (creature.nownumber!=0 && creature.nametxt!="" && creature.side == chosen_side && creature.hero == undefined){
            select.innerHTML+=`<option value = "${creature.nametxt}">${creature.nametxt} [${creature.nownumber}] </option>`
            if (!found_defender) {
                if (creature.nametxt == chosen_one){
                    defender_obj_id = creature.obj_index
                    selected_id = [...select.children].indexOf(select.lastChild)
                    found_defender = true
                }
                else {
                    defender_obj_id = creature.obj_index
                    selected_id = [...select.children].indexOf(select.lastChild)
                }
            }
        }
    })
    cre_list.forEach(creature => {
        if (creature.side == -chosen_side) {
            if (creature.nownumber == 0 || creature.nametxt == "") return
            let data = get_dmg_info(creature.obj_index, defender_obj_id)
            let hp = cre_list[defender_obj_id-1].maxhealth
            let row = `<p>${creature.nametxt} [${creature.nownumber}] --> ${cre_list[defender_obj_id-1].nametxt} [${cre_list[defender_obj_id-1].nownumber}] : <b>${Math.round(data.min/hp)}-${Math.round(data.max/hp)} существ</b> (${data.min}-${data.max})  </p>`;
            chat.innerHTML += row;
        }
    })
    select.options.item(selected_id).selected = true
}