Les Gardiens d'Asgard
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

Les Gardiens d'Asgard

Alliance Ikariam - serveur Epsilon
 
AccueilDernières imagesRechercherS'enregistrerConnexion
Le Deal du moment : -45%
PC Portable LG Gram 17″ Intel Evo Core i7 32 Go ...
Voir le deal
1099.99 €

 

 Shipment times

Aller en bas 
2 participants
AuteurMessage
willoo

willoo


Messages : 896
Date d'inscription : 31/01/2010

Shipment times Empty
MessageSujet: Shipment times   Shipment times Icon_minitimeDim 22 Aoû - 19:30

Bonjour à tous,

Ce script calcul le temps de trajet des bateaux en y incluant les temps de chargement.
Lien de téléchargement: Shipment times

Shipment times Shipme10

Attention, ce script comporte un bug. Il faut l'éditer et remplacer le code par celui-ci:

Code:
// ==UserScript==
// @name            Shipment Times v 0.2.5
// @namespace      http://ikariamlibrary.com/
// @description    A script for Ikariam that shows loading times for each shipment
// @include        http://s*.ikariam.*/*
// @exclude        http://board.ikariam.*/*
// ==/UserScript==

/*****************************************Modifications:************************************
- Modifications de phile                                                                                       
 lignes 33 a 48, le script fonctionne a condition de ne pas afficher les coordonees dans la liste deroulante des villes
- Modifications de Yog-Sothoth                                                                                       
ligne 40 pour que cela fonctionne avec les coordonnees, remplace "2" par "7" car l'espace est note   soit 5 caracteres de plus
Ligne 207 car sinon le nom de la ville pour l'update du fichier config de firefox ne tenait pas compte de la fonction getcityname modifiee et l'update se faisait avec l'ancien script .
Reste a voir: le script plante si on change de ville quand on est sur la page de chargement, mais si on passe par le port tout va bien :)
 ******************************************************************************************/

var SERVER_SPEED = 1;

Array.prototype.last = function()
{
    return this[this.length - 1]
}

/**
 *    Returns the name of the city
 */
/*function getCityName()
{
    var city_raw = document.getElementById('citySelect')[document.getElementById('citySelect').selectedIndex].innerHTML.split(" ");
    return city_raw[city_raw.length-1];
}*/
function getCityName()
{
    var city_raw = document.getElementById('citySelect')[document.getElementById('citySelect').selectedIndex].innerHTML;
    // Is the player showing cords?
    if (city_raw.indexOf(":") != -1)
    {
        // Showing cords
        var cordsEnd = city_raw.indexOf("]") + 7;
        return city_raw.substring(cordsEnd, city_raw.length);
    }
    else
    {
        // Not showing cords
        return city_raw;
    }
}

/**
 *    Returns wether the argument is an integer or not
 */
window.isInteger = function(s){
    return (s.toString().search(/^-?[0-9]+$/) == 0);
}

/**
 *    Gets the resource number for the given field. If it's null return 0 (happens when the field is empty)
 */
function getResource(field)
{
    if ((document.getElementById(field)) == null)
    {
        return 0;
    }
    else
    {
        return parseInt(document.getElementById(field).value);
    }
}
 
/**
 *    Adjusts the loadingtime each time the number of resources is changed
 */
window.adjustLoadingTime = function(port_lvl)
{
try
{
    var total_res;
    var marble_res = getResource('textfield_marble');
    var crystal_res = getResource('textfield_glass');
    // some server it's sulfur, some its sulphur. just add the together. can't happend twice and if the other doens't exists it returns 0
    var sulphur_res = getResource('textfield_sulphur') +  getResource('textfield_sulfur');
    var wine_res = getResource('textfield_wine');
    var wood_res = getResource('textfield_wood');
   
    // Get total ammount of resources that will be sent
    total_res = wood_res + wine_res + sulphur_res + marble_res + crystal_res;
    if (!isInteger(total_res))
        total_res = 0;
             
    // Get the transport time
    var divTime, time, restTime, travelHour, travelMin, travelSec, loadHour, loadMin, loadSec, loadSpeed, hour, min, sec;
    divTime = document.getElementById('missionSummary').childNodes[1].childNodes[3].innerHTML;
    restTime = divTime.split(" = ")[0].split(" + ");

    // Parse time, depending on how big it is
    timeAr = restTime[1].split(' ');
    travelHour = 0;
    travelMin = 0;
    travelSec = 0;
    if (timeAr.length == 3)
    {
        travelHour = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
        travelMin = parseInt(timeAr[1].substring(0,timeAr[1].length-1));
        travelSec = parseInt(timeAr[2].substring(0,timeAr[2].length-1));
    }
    else if (timeAr.length == 2)
    {
        if (timeAr[0].search('h') != -1)
            travelHour = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
        if (timeAr[1].search('h') != -1)
            travelHour = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
        if (timeAr[0].search('m') != -1)
            travelMin = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
        if (timeAr[1].search('m') != -1)
            travelMin = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
        if (timeAr[0].search('s') != -1)
            travelSec = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
        if (timeAr[1].search('s') != -1)
            travelSec = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
    }
    else if (timeAr.length == 1)
    {
        if (timeAr[0].search('h') != -1)
            travelHour = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
        if (timeAr[0].search('m') != -1)
            travelMin = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
        if (timeAr[0].search('s') != -1)
            travelSec = parseInt(timeAr[0].substring(0,timeAr[0].length-1));
    }

    // Calculate loading times
    loadingSpeeds = new Array(3, // 0
    30,
    60,
    93,
    129,
    169, //5
    213,
    261,
    315,
    373,
    437, //10
    508,
    586,
    672,
    766,
    869, //15
    983,
    1108,
    1246,
    1398,
    1565, // 20
    1748,
    1950,
    2172,
    2416);
    loadingSpeed = (loadingSpeeds[port_lvl]) * SERVER_SPEED;
    loadSec = Math.round(60*total_res / loadingSpeed);
    loadHour = Math.floor(loadSec / 60 / 60);
    loadSec -= loadHour * 60 * 60;
    loadMin = Math.floor(loadSec / 60);
    loadSec -= loadMin * 60;
   
    // Calculate total
    sec = Math.round(60*total_res / loadingSpeed) + travelSec + travelMin*60 + travelHour*60*60;
    hour = Math.floor(sec / 60 / 60);
    sec -= hour * 60 * 60;
    min = Math.floor(sec / 60);
    sec -= min * 60;
     
    document.getElementById('missionSummary').childNodes[1].childNodes[3].innerHTML =
        "<span class='textLabel'>Duration of journey: </span>"+      loadHour+"h "+loadMin+"m "+loadSec + "s + " +
                                                                    travelHour+"h "+travelMin+"m "+travelSec + "s = " + "<strong>" +
                                                                    hour+"h "+min+"m "+sec + "s" + "</strong>";
}
catch(er) {alert(er);}
}

window.addEventListener('load',  function()
{
try
{
    // Check if you are at the transport page
    if (document.getElementById('transport') != null)
    {
        var sliders = unsafeWindow.sliders;
        var city = getCityName();
        var port_lvl = GM_getValue(city+"_port_lvl",0);
        // Make sure the adjust functions is called when the ammount of resources changes
        if (unsafeWindow.swood) { unsafeWindow.swood.subscribe(    "change", function() {adjustLoadingTime(port_lvl);}); }
        if (unsafeWindow.smarble) { unsafeWindow.smarble.subscribe(    "change", function() {adjustLoadingTime(port_lvl);}); }
        if (unsafeWindow.swine) { unsafeWindow.swine.subscribe(    "change", function() {adjustLoadingTime(port_lvl);}); }
        if (unsafeWindow.ssulfur) { unsafeWindow.ssulfur.subscribe(    "change", function() {adjustLoadingTime(port_lvl);}); }
        if (unsafeWindow.sglass) { unsafeWindow.sglass.subscribe("change", function() {adjustLoadingTime(port_lvl);}); }

        // Add loading time to duration time
        var html = document.getElementById('missionSummary').childNodes[1].childNodes[3].innerHTML.split("</span>");
        document.getElementById('missionSummary').childNodes[1].childNodes[3].innerHTML = html[0] + "</span> 0h 0m 0s + " + html[1] + " = <strong>" + html[1] + "</strong>";
  }
 
    // Check if the city page is loaded, and if so, update the portsize
    if (document.getElementById('city') != null)
    {
   
        var city = getCityName();

        var positions = document.getElementById('locations');
        for (var i = 0; i < positions.childNodes.length; i++)
        {
            if (positions.childNodes[i].className == "port")
            {
                var aPortLevel = (positions.childNodes[i].childNodes[3].title.split(" "));
                GM_setValue(city+'_port_lvl', parseInt(aPortLevel.last()));
            }
        }
    }
}
catch(er){
    alert("Shipment Times has encountered an error\nPlease post a message on the Ikariam Library forums quoting the error below and which page it was received on\n" + er);
}
},
    true);

(N'hésitez pas à venir me voir si vous avez besoin d'aide...)

A bientôt,
Taz.


Dernière édition par willoo le Dim 29 Aoû - 13:47, édité 1 fois
Revenir en haut Aller en bas
-matleouf-

-matleouf-


Messages : 620
Date d'inscription : 13/02/2010

Shipment times Empty
MessageSujet: Re: Shipment times   Shipment times Icon_minitimeDim 22 Aoû - 23:43

Par tout ça?
Revenir en haut Aller en bas
willoo

willoo


Messages : 896
Date d'inscription : 31/01/2010

Shipment times Empty
MessageSujet: Re: Shipment times   Shipment times Icon_minitimeLun 23 Aoû - 13:59

Ben faut croire... lol
c'est une copie du message de Taz
Revenir en haut Aller en bas
-matleouf-

-matleouf-


Messages : 620
Date d'inscription : 13/02/2010

Shipment times Empty
MessageSujet: Re: Shipment times   Shipment times Icon_minitimeJeu 26 Aoû - 19:26

C'est géant^^
Revenir en haut Aller en bas
Contenu sponsorisé





Shipment times Empty
MessageSujet: Re: Shipment times   Shipment times Icon_minitime

Revenir en haut Aller en bas
 
Shipment times
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Shipment times
» Shipment times‏

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Les Gardiens d'Asgard :: Discussions Générales :: Scripts et Tutoriaux-
Sauter vers: