[Engedélyezett] Sablon alapú nyersi bekérő érmézéshez

-Numlock-

Brit tudós
A reakció pontszáma
582
@Battle228 kérésére lett készítve
A script használható gépen és mobilon is

A Piac --> Nyersanyagok kérése oldalon futtatandó.

1602418379608.png

Beírjuk a nyersanyagokat, pontosabban 1db érmének az árát ami szükséges a veretéshez, maximális útidőt és a Beillesztésre gombra kattintunk. A script a kiválasztott falucsoport összes falvát, azokon belül a nyersiket megvizsgálja és beilleszteni a beállított sablonoknak megfelelően a maximális sablon adagok szállítható mennyiségét, figyelembe véve a kereskedők számát is. Az útidőn kívülre eső falvakat figyelmen kívül hagyja. Továbbá állítható hogy a küldő falvakban mennyi sablon adagnyi nyersinek kell maradnia.

A script segítségével elkerülhető a "nyersikifolyás" amikor érmézünk és egyes nyersanyagfajtákból túl sok jön a faluba, mindenből csak annyit illeszt be amennyi elverethető momentálisan a csomag beérkeztével.

Tipp: Ha egy érme árának a felét adjuk meg a sablonnak, akkor elégendő kereskedő esetén egy fél érme árával többet szálíthatunk egy körben, így egy idő elteltével több nyersanyag kerül importálásra mint ha egy teljes érme árával szálítgatnánk. További felezésekkel meg méginkább...

1602420292202.png

Kód beillesztése:
javascript:$.getScript('https://media.innogamescdn.com/com_DS_HU/scripts/res_sampl.js');void(0);
 

öreg

Well-Known Member
A reakció pontszáma
1.707
Sziasztok!

Erre ránézne valaki, hogy miért nem működik?
Kód beillesztése:
var storage_keys;

var woods = [], stones = [], irons = [], merchants = [], trev_times = [];

if(document.location.href.indexOf("screen=market") > -1 && document.location.href.indexOf("mode=call") > -1){
    getting_storage_keys();

    script_main_form();

    load_settings();
    ev_listeners();
}else{
    UI.ErrorMessage("Piac -->> Nyersanyagok kérése", 2000);
}
function get_available_res_data(){
    var vill_rows;
    if($("#mobileNav").length == 0){
        vill_rows = $("#village_list > tbody").find("tr");
        for(var x = 0; x < vill_rows.length; x++){//desktop
            var wood = $(vill_rows[x]).find("td").eq(2).attr("data-res");
            var stone = $(vill_rows[x]).find("td").eq(3).attr("data-res");
            var iron = $(vill_rows[x]).find("td").eq(4).attr("data-res");
            var merchant_s = $(vill_rows[x]).find(".traders").eq(0).text().match(/\d+/)[0];
            var trev_time = $(vill_rows[x]).children().eq(1).text().trim();
            
            woods.push(parseInt(wood));
            stones.push(parseInt(stone));
            irons.push(parseInt(iron));
            merchants.push(parseInt(merchant_s) * 1000);
            trev_times.push(trev_time);
        }
        
    }else{ //mobile
        vill_rows = $("#village_list").find("div[data-capacity]");
        for(var x = 0; x < vill_rows.length; x++){
            var wood = $(vill_rows[x]).find("div[class='wood']").eq(0).attr("data-res");
            var stone = $(vill_rows[x]).find("div[class='stone']").eq(0).attr("data-res");
            var iron = $(vill_rows[x]).find("div[class='iron']").eq(0).attr("data-res");
            var merchant_s = $(vill_rows[x]).find(".traders").eq(0).text().match(/\d+/)[0];
            var trev_time = $(vill_rows[x]).find("span[class='icon header time']").eq(0).parent().text().trim();
            
            woods.push(parseInt(wood));
            stones.push(parseInt(stone));
            irons.push(parseInt(iron));
            merchants.push(parseInt(merchant_s) * 1000);
            trev_times.push(trev_time);
        }
        
    }
    console.log(woods);
    console.log(stones);
    console.log(irons);
    console.log(merchants);
    console.log(trev_times);
    setTimeout(set_resources, 500);
}
function set_resources(){
    var vill_rows;
    if($("#mobileNav").length == 0){ //desktop
        vill_rows = $("#village_list > tbody").find("tr");
    }else{ //mobile
        vill_rows = $("#village_list").find("div[data-capacity]");
    }
    for(var x = 0; x < vill_rows.length; x++){
        if(travel_time_check(x, trev_times[x])){
            $(vill_rows[x]).find("[name='select-village']").click();
            //continue;
        }
        var maxSendCount = [];
        maxSendCount.push(parseInt(merchants[x] / (storage_keys.wood_samp + storage_keys.stone_samp + storage_keys.iron_samp)));
        maxSendCount.push(parseInt(woods[x] / storage_keys.wood_samp));
        maxSendCount.push(parseInt(stones[x] / storage_keys.stone_samp));
        maxSendCount.push(parseInt(irons[x] / storage_keys.iron_samp));
        var willbesent = Math.min(...maxSendCount);
        //keep behind part
        var ready_state = false;
        do{
            if(woods[x] - (willbesent * storage_keys.wood_samp) < storage_keys.keep_behind * storage_keys.wood_samp){
                willbesent--;
                continue;
            }
            if(stones[x] - (willbesent * storage_keys.stone_samp) < storage_keys.keep_behind * storage_keys.stone_samp){
                willbesent--;
                continue;
            }
            if(irons[x] - (willbesent * storage_keys.iron_samp) < storage_keys.keep_behind * storage_keys.iron_samp){
                willbesent--;
                continue;
            }
            ready_state = true;
        }while(!ready_state);
        //------
        
        console.log(willbesent);
        
        //SET
        if(willbesent <= 0){
            $(vill_rows[x]).find(".wood input").val(0).change();
            $(vill_rows[x]).find(".stone input").val(0).change();
            $(vill_rows[x]).find(".iron input").val(0).change();
        }else{
            $(vill_rows[x]).find(".wood input").val(willbesent * storage_keys.wood_samp).change();
            $(vill_rows[x]).find(".stone input").val(willbesent * storage_keys.stone_samp).change();
            $(vill_rows[x]).find(".iron input").val(willbesent * storage_keys.iron_samp).change();
        }
    }
    woods = [];
    stones = [];
    irons = [];
    merchants = [];
    trev_times = [];
}
function travel_time_check(eq, stringg){
    var max = storage_keys.max_trav_time.match(/\d+/g);
    var current = trev_times[eq].match(/\d+/g);
    max = (parseInt(max[0]) * 60 * 60) + (parseInt(max[1]) * 60) + parseInt(max[2]);
    current = (parseInt(current[0]) * 60 * 60) + (parseInt(current[1]) * 60) + parseInt(current[2]);
    if(max > current){
        return true;
    }else{
        return false;
    }
}
function ev_listeners(){
    $("#wood_samp").change(function(){
        if($(this).val() == ""){
            $(this).val("28000");
            UI.ErrorMessage("A famennyiséget üresen hagytad ezért alaphelyezetbe lett állítva", 4000);
        }
        if($(this).val() == "0"){
            $(this).val("28000");
            UI.ErrorMessage("Az érték nem lehet 0!", 4000);
        }
        if(isNaN(parseInt($(this).val()))){
            $(this).val("28000");
            UI.ErrorMessage("Hibás famennyiség! Az értéken alaphelyezetbe lett állítva", 4000);
        }
        storage_keys.wood_samp = parseInt($(this).val());
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
    $("#stone_samp").change(function(){
        if($(this).val() == ""){
            $(this).val("30000");
            UI.ErrorMessage("Az agyagmennyiséget üresen hagytad ezért alaphelyezetbe lett állítva", 4000);
        }
        if($(this).val() == "0"){
            $(this).val("30000");
            UI.ErrorMessage("Az érték nem lehet 0!", 4000);
        }
        if(isNaN(parseInt($(this).val()))){
            $(this).val("30000");
            UI.ErrorMessage("Hibás agyagmennyiség! Az érték alaphelyezetbe lett állítva", 4000);
        }
        storage_keys.stone_samp = parseInt($(this).val());
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
    $("#iron_samp").change(function(){
        if($(this).val() == ""){
            $(this).val("25000");
            UI.ErrorMessage("A vasmennyiséget üresen hagytad ezért alaphelyezetbe lett állítva", 4000);
        }
        if($(this).val() == "0"){
            $(this).val("25000");
            UI.ErrorMessage("Az érték nem lehet 0!", 4000);
        }
        if(isNaN(parseInt($(this).val()))){
            $(this).val("25000");
            UI.ErrorMessage("Hibás vasmennyiség! Az érték alaphelyezetbe lett állítva", 4000);
        }
        storage_keys.iron_samp = parseInt($(this).val());
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
    $("#max_trav_time").change(function(){
        if($(this).val() == ""){
            $(this).val("02:00:00");
            UI.ErrorMessage("Hibás menetidő, alaphelyezetbe állítva! Helyes: hh:mm:ss", 4000);
        }
        if(isNaN(parseInt($(this).val())) || $(this).val().match(/\d+:\d+:\d+/) == null){
            $(this).val("02:00:00");
            UI.ErrorMessage("Hibás menetidő, alaphelyezetbe állítva! Helyes: hh:mm:ss", 4000);
        }
        storage_keys.max_trav_time = $(this).val().match(/\d+:\d+:\d+/)[0];
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
    $("#keep_behind").change(function(){
        if($(this).val() == ""){
            $(this).val("0");
            UI.ErrorMessage("Üres mező, alapheyezetbe állítva!", 4000);
        }
        if(isNaN(parseInt($(this).val()))){
            $(this).val("0");
            UI.ErrorMessage("Hibás bevitel! Az érték alaphelyezetbe lett állítva", 4000);
        }
        storage_keys.keep_behind = parseInt($(this).val());
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
}
function load_settings(){
    $("#wood_samp").val(storage_keys.wood_samp);
    $("#stone_samp").val(storage_keys.stone_samp);
    $("#iron_samp").val(storage_keys.iron_samp);
    $("#max_trav_time").val(storage_keys.max_trav_time);
    $("#keep_behind").val(storage_keys.keep_behind);
}
function getting_storage_keys(){
    if(localStorage.getItem("res_coinner") != null){
        storage_keys = JSON.parse(localStorage.getItem("res_coinner"));
    }else{
        set_default_storage_keys();
        storage_keys = JSON.parse(localStorage.getItem("res_coinner"));
    }
}
function set_default_storage_keys(){
    localStorage.setItem("res_coinner", `{"version": 1.0,
                                                    "wood_samp": 28000,
                                                    "stone_samp": 30000,
                                                    "iron_samp": 25000,
                                                    "max_trav_time": "02:00:00",
                                                    "keep_behind": 0
                                                    }`);
}
function script_main_form(){
    $("#res_sum > tbody").append(`<tr>
                                <th colspan = "3" style = "text-align: center;">
                                    Bekérendő nyersi sablonadagok
                                </th>
                            </tr>
                            <tr><td style = "background-color: yellow;">
                                    <span class="res wood"></span>
                                    <input id = "wood_samp" type = "text" style = "width: 40px; margin: 0px 2px 0px 2px;">
                                </td>
                                <td style = "background-color: yellow;">
                                    <span class="res stone"></span>
                                    <input id = "stone_samp" type = "text" style = "width: 40px; margin: 0px 2px 0px 2px;">
                                </td>
                                <td style = "background-color: yellow;">
                                    <span class="res iron"></span>
                                    <input id = "iron_samp" type = "text" style = "width: 40px; margin: 0px 2px 0px 2px;">
                                </td>
                            <tr>
                                <td colspan = "3" style = "background-color: yellow;">
                                    <input id = "max_trav_time" type = "text" value = "02:00:00" style = "width: 45px; margin: 0px 2px 0px 2px;">
                                    max. utazási idő
                                </td>
                            </tr>
                            <tr>
                                <td colspan = "3" style = "background-color: yellow;">
                                    <input id = "keep_behind" type = "text" value = "0" style = "width: 20px; margin: 0px 2px 0px 2px;">
                                    adag benthagyása a falvakban
                                </td>
                            </tr>
                            <tr>
                                <td colspan = "3" style = "text-align: center; background-color: yellow;">
                                    <input class = "btn" type = "button" value = "Beillesztés" onclick = "get_available_res_data()">
                                </td>
                            </tr>
                        </tr>`);
}
 

-NooBLeadeR-

#igazajátékosnevem
A reakció pontszáma
8.319
Kód beillesztése:
var storage_keys;

var woods = [], stones = [], irons = [], merchants = [], trev_times = [];

if(document.location.href.indexOf("screen=market") > -1 && document.location.href.indexOf("mode=call") > -1){
    getting_storage_keys();

    script_main_form();

    load_settings();
    ev_listeners();
}else{
    UI.ErrorMessage("Piac -->> Nyersanyagok kérése", 2000);
}
function get_available_res_data(){
    var vill_rows;
    if($("#mobileNav").length == 0){
        vill_rows = $("#village_list > tbody").find("tr");
        for(var x = 0; x < vill_rows.length; x++){//desktop
            var wood = $(vill_rows[x]).find("td").eq(2).attr("data-res");
            var stone = $(vill_rows[x]).find("td").eq(3).attr("data-res");
            var iron = $(vill_rows[x]).find("td").eq(4).attr("data-res");
            var merchant_s = $(vill_rows[x]).find(".traders").eq(0).text().match(/\d+/)[0];
            var trev_time = $(vill_rows[x]).children().eq(1).text().trim();
          
            woods.push(parseInt(wood));
            stones.push(parseInt(stone));
            irons.push(parseInt(iron));
            merchants.push(parseInt(merchant_s) * 1000);
            trev_times.push(trev_time);
        }
      
    }else{ //mobile
        vill_rows = $("#village_list").find("div[data-capacity]");
        for(var x = 0; x < vill_rows.length; x++){
            var wood = $(vill_rows[x]).find("div[class='wood']").eq(0).attr("data-res");
            var stone = $(vill_rows[x]).find("div[class='stone']").eq(0).attr("data-res");
            var iron = $(vill_rows[x]).find("div[class='iron']").eq(0).attr("data-res");
            var merchant_s = $(vill_rows[x]).find(".traders").eq(0).text().match(/\d+/)[0];
            var trev_time = $(vill_rows[x]).find("span[class='icon header time']").eq(0).parent().text().trim();
          
            woods.push(parseInt(wood));
            stones.push(parseInt(stone));
            irons.push(parseInt(iron));
            merchants.push(parseInt(merchant_s) * 1000);
            trev_times.push(trev_time);
        }
      
    }
    console.log(woods);
    console.log(stones);
    console.log(irons);
    console.log(merchants);
    console.log(trev_times);
    setTimeout(set_resources, 500);
}
function set_resources(){
    var vill_rows;
    if($("#mobileNav").length == 0){ //desktop
        vill_rows = $("#village_list > tbody").find("tr");
    }else{ //mobile
        vill_rows = $("#village_list").find("div[data-capacity]");
    }
    for(var x = 0; x < vill_rows.length; x++){
        if(travel_time_check(x, trev_times[x])){
            $(vill_rows[x]).find("[name='select-village']").click();
            //continue;
        }
        var maxSendCount = [];
        maxSendCount.push(parseInt(merchants[x] / (storage_keys.wood_samp + storage_keys.stone_samp + storage_keys.iron_samp)));
        maxSendCount.push(parseInt(woods[x] / storage_keys.wood_samp));
        maxSendCount.push(parseInt(stones[x] / storage_keys.stone_samp));
        maxSendCount.push(parseInt(irons[x] / storage_keys.iron_samp));
        var willbesent = Math.min(...maxSendCount);
        //keep behind part
        var ready_state = false;
        do{
            if(woods[x] - (willbesent * storage_keys.wood_samp) < storage_keys.keep_behind * storage_keys.wood_samp){
                willbesent--;
                continue;
            }
            if(stones[x] - (willbesent * storage_keys.stone_samp) < storage_keys.keep_behind * storage_keys.stone_samp){
                willbesent--;
                continue;
            }
            if(irons[x] - (willbesent * storage_keys.iron_samp) < storage_keys.keep_behind * storage_keys.iron_samp){
                willbesent--;
                continue;
            }
            ready_state = true;
        }while(!ready_state);
        //------
      
        console.log(willbesent);
      
        //SET
        if(willbesent <= 0){
            $(vill_rows[x]).find(".wood input").val(0).change();
            $(vill_rows[x]).find(".stone input").val(0).change();
            $(vill_rows[x]).find(".iron input").val(0).change();
        }else{
            $(vill_rows[x]).find(".wood input").val(willbesent * storage_keys.wood_samp).change();
            $(vill_rows[x]).find(".stone input").val(willbesent * storage_keys.stone_samp).change();
            $(vill_rows[x]).find(".iron input").val(willbesent * storage_keys.iron_samp).change();
        }
    }
    woods = [];
    stones = [];
    irons = [];
    merchants = [];
    trev_times = [];
}
function travel_time_check(eq, stringg){
    var max = storage_keys.max_trav_time.match(/\d+/g);
    var current = trev_times[eq].match(/\d+/g);
    max = (parseInt(max[0]) * 60 * 60) + (parseInt(max[1]) * 60) + parseInt(max[2]);
    current = (parseInt(current[0]) * 60 * 60) + (parseInt(current[1]) * 60) + parseInt(current[2]);
    if(max > current){
        return true;
    }else{
        return false;
    }
}
function ev_listeners(){
    $("#wood_samp").change(function(){
        if($(this).val() == ""){
            $(this).val("28000");
            UI.ErrorMessage("A famennyiséget üresen hagytad ezért alaphelyezetbe lett állítva", 4000);
        }
        if($(this).val() == "0"){
            $(this).val("28000");
            UI.ErrorMessage("Az érték nem lehet 0!", 4000);
        }
        if(isNaN(parseInt($(this).val()))){
            $(this).val("28000");
            UI.ErrorMessage("Hibás famennyiség! Az értéken alaphelyezetbe lett állítva", 4000);
        }
        storage_keys.wood_samp = parseInt($(this).val());
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
    $("#stone_samp").change(function(){
        if($(this).val() == ""){
            $(this).val("30000");
            UI.ErrorMessage("Az agyagmennyiséget üresen hagytad ezért alaphelyezetbe lett állítva", 4000);
        }
        if($(this).val() == "0"){
            $(this).val("30000");
            UI.ErrorMessage("Az érték nem lehet 0!", 4000);
        }
        if(isNaN(parseInt($(this).val()))){
            $(this).val("30000");
            UI.ErrorMessage("Hibás agyagmennyiség! Az érték alaphelyezetbe lett állítva", 4000);
        }
        storage_keys.stone_samp = parseInt($(this).val());
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
    $("#iron_samp").change(function(){
        if($(this).val() == ""){
            $(this).val("25000");
            UI.ErrorMessage("A vasmennyiséget üresen hagytad ezért alaphelyezetbe lett állítva", 4000);
        }
        if($(this).val() == "0"){
            $(this).val("25000");
            UI.ErrorMessage("Az érték nem lehet 0!", 4000);
        }
        if(isNaN(parseInt($(this).val()))){
            $(this).val("25000");
            UI.ErrorMessage("Hibás vasmennyiség! Az érték alaphelyezetbe lett állítva", 4000);
        }
        storage_keys.iron_samp = parseInt($(this).val());
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
    $("#max_trav_time").change(function(){
        if($(this).val() == ""){
            $(this).val("02:00:00");
            UI.ErrorMessage("Hibás menetidő, alaphelyezetbe állítva! Helyes: hh:mm:ss", 4000);
        }
        if(isNaN(parseInt($(this).val())) || $(this).val().match(/\d+:\d+:\d+/) == null){
            $(this).val("02:00:00");
            UI.ErrorMessage("Hibás menetidő, alaphelyezetbe állítva! Helyes: hh:mm:ss", 4000);
        }
        storage_keys.max_trav_time = $(this).val().match(/\d+:\d+:\d+/)[0];
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
    $("#keep_behind").change(function(){
        if($(this).val() == ""){
            $(this).val("0");
            UI.ErrorMessage("Üres mező, alapheyezetbe állítva!", 4000);
        }
        if(isNaN(parseInt($(this).val()))){
            $(this).val("0");
            UI.ErrorMessage("Hibás bevitel! Az érték alaphelyezetbe lett állítva", 4000);
        }
        storage_keys.keep_behind = parseInt($(this).val());
        localStorage.setItem("res_coinner", JSON.stringify(storage_keys));
    });
}
function load_settings(){
    $("#wood_samp").val(storage_keys.wood_samp);
    $("#stone_samp").val(storage_keys.stone_samp);
    $("#iron_samp").val(storage_keys.iron_samp);
    $("#max_trav_time").val(storage_keys.max_trav_time);
    $("#keep_behind").val(storage_keys.keep_behind);
}
function getting_storage_keys(){
    if(localStorage.getItem("res_coinner") != null){
        storage_keys = JSON.parse(localStorage.getItem("res_coinner"));
    }else{
        set_default_storage_keys();
        storage_keys = JSON.parse(localStorage.getItem("res_coinner"));
    }
}
function set_default_storage_keys(){
    localStorage.setItem("res_coinner", `{"version": 1.0,
                                                    "wood_samp": 28000,
                                                    "stone_samp": 30000,
                                                    "iron_samp": 25000,
                                                    "max_trav_time": "02:00:00",
                                                    "keep_behind": 0
                                                    }`);
}
function script_main_form(){
    $("#res_sum > tbody").append(`<tr>
                                <th colspan = "3" style = "text-align: center;">
                                    Bekérendő nyersi sablonadagok
                                </th>
                            </tr>
                            <tr><td style = "background-color: yellow;">
                                    <span class="res wood"></span>
                                    <input id = "wood_samp" type = "text" style = "width: 40px; margin: 0px 2px 0px 2px;">
                                </td>
                                <td style = "background-color: yellow;">
                                    <span class="res stone"></span>
                                    <input id = "stone_samp" type = "text" style = "width: 40px; margin: 0px 2px 0px 2px;">
                                </td>
                                <td style = "background-color: yellow;">
                                    <span class="res iron"></span>
                                    <input id = "iron_samp" type = "text" style = "width: 40px; margin: 0px 2px 0px 2px;">
                                </td>
                            <tr>
                                <td colspan = "3" style = "background-color: yellow;">
                                    <input id = "max_trav_time" type = "text" value = "02:00:00" style = "width: 45px; margin: 0px 2px 0px 2px;">
                                    max. utazási idő
                                </td>
                            </tr>
                            <tr>
                                <td colspan = "3" style = "background-color: yellow;">
                                    <input id = "keep_behind" type = "text" value = "0" style = "width: 20px; margin: 0px 2px 0px 2px;">
                                    adag benthagyása a falvakban
                                </td>
                            </tr>
                            <tr>
                                <td colspan = "3" style = "text-align: center; background-color: yellow;">
                                    <input class = "btn" type = "button" value = "Beillesztés" onclick = "get_available_res_data()">
                                </td>
                            </tr>
                        </tr>`);
}

Pillanat és befrissítem a linket, és működni fog.

Szerk.: frissítés kész.
 

SzAtiSz

Member
A reakció pontszáma
75
Érdekes módon, nem mindenhova illeszti be a fának a mennyiségét, még tesztelgetem, ha van valami, még jelzek:

Screenshot 2023-03-15 131557.png
 
Fent