Bonjour,
Voila je rencontre un petit problème avec mon code.
/* Coût des héros */
if ($.inArray("Héros", wgCategories) > -1) {
$(function () {
var herostimeline = "0|0.5|1|1.5|2|2.5|3|3.5|4|4.5|5|5.5|6|6.5|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7";
var kingcostline = "10000|12500|15000|17500|20000|22500|25000|30000|35000|40000|45000|50000|55000|60000|65000|70000|75000|80000|85000|90000|95000|100000|105000|110000|115000|120000|125000|130000|135000|140000|145000|150000|155000|160000|165000|170000|175000|180000|185000|190000";
var queencostline = "40000|22500|25000|27500|30000|32500|35000|40000|45000|50000|55000|60000|65000|70000|75000|80000|85000|90000|95000|100000|105000|110000|115000|120000|125000|130000|135000|140000|145000|150000|155000|160000|165000|170000|175000|180000|185000|190000|195000|200000";
$('.heroscost').html('Coût cumulatif pour le héros du niveau <input type="number" style="width:10%" min="1" max="40" value="1"> au niveau <input style="width:10%" type="number" min="1" max="40" value="40"><div class="button">Calculer le coût</div> <span>0</span>');
$('.heroscost div.button').click(function () {
$('.heroscost input[type="number"]').each(function () {
if (!$.isNumeric($(this).val())) {
alert('Enter a valid value !');
return;
}
});
if (Math.floor($('.heroscost input[type="number"]:eq(0)').val()) > Math.floor($('.heroscost input[type="number"]:eq(1)').val())) {
alert('Et non ! Ca n\'existe pas les coûts cumulatifs négatifs ;)');
return;
}
var total = 0;
var totaltime = 0;
var herostime = herostimeline.split('|');
if (wgPageName == "Roi_des_barbares") {
var kingcost = kingcostline.split('|');
for (i = $('.heroscost input[type="number"]:eq(0)').val() - 1; i < $('.heroscost input[type="number"]:eq(1)').val(); i++) {
total += Math.floor(kingcost[i]);
totaltime += Math.floor(herostime[i] * 10) / 10;
}
} else if (wgPageName == "Reine_des_archers") {
var queencost = queencostline.split('|');
for (i = $('.heroscost input[type="number"]:eq(0)').val() - 1; i < $('.heroscost input[type="number"]:eq(1)').val(); i++) {
total += Math.floor(queencost[i]);
totaltime += Math.floor(herostime[i] * 10) / 10;
}
}
var spantime;
if (totaltime == Math.floor(totaltime)) {
spantime = totaltime + 'j';
} else {
spantime = Math.floor(totaltime) + 'j 12h';
}
$('.heroscost span').html(numberWithCommas(total) + " élixir noir et " + spantime);
});
});
}
Je souhaiterais ajouter une troupe, alors au niveau de : / Coût des héros / je voudrais que si:
$('.heroscost span').html(numberWithCommas(total) + " élixir noir et " + spantime);
Est égal à GrandWarden je puisse avoir: " élixir et "
Et me dire ce que je dois écrire pour ajouter un héros comme par exemple: kingcostline. Le problème c'est que je ne sait pas du tout comment m'y prendre...
Merci d'avance pour votre aide.