Voila j'ai un leger problème avec ce script:
- Code: Tout sélectionner
<script language="JavaScript" type="text/javascript">
function calc(calcform) {
var defender;
var attacker;
var defense;
var offense;
var defbonus;
var offbonus;
var offsoldier = new Array("0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "1", "0", "0", "0", "0");
var defsoldier = new Array("0", "1", "0", "1", "0", "0", "1", "0", "1", "0", "1", "0", "0", "0", "0");
var offoffspec = new Array("7", "7", "3", "2", "4", "6", "7", "2", "3", "3", "25", "1", "2", "6", "2");
var defoffspec = new Array("2", "0", "0", "0", "0", "0", "1", "0", "1", "0", "0", "0", "0", "0", "0");
var offdefspec = new Array("0", "0", "0", "0", "0", "0", "0", "0", "2", "0", "0", "0", "0", "0", "2");
var defdefspec = new Array("6", "7", "4", "4", "4", "6", "4", "4", "4", "5", "32", "4", "2", "3", "7");
var offelite = new Array("16", "4", "4", "3", "0", "3", "4", "3", "8", "5", "50", "2", "9", "6", "6");
var defelite = new Array("1", "1", "5", "7", "9", "3", "6", "2", "6", "5", "15", "8", "9", "8", "3");
var offthief = new Array("0", "0", "6", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
var defthief = new Array("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
defense = 0;
offense = 0;
defender = calcform.defender.value;
attacker = calcform.attacker.value;
defense += calcform.def_soldiers.value * defsoldier[defender];
defense += calcform.def_attspec.value * defoffspec[defender];
defense += calcform.def_defspec.value * defdefspec[defender];
defense += calcform.def_elites.value * defelite[defender];
defbonus = (calcform.walls.value/100)*defense;
defbonus += defense * Math.round(calcform.def_science.value) / 100;
if (calcform.def_spell.checked) {
defbonus += defense * 0.1;
}
else {}
if (calcform.attack.value == '2') {
defbonus += defense * 0.15;
}
else {}
defense += defbonus;
calcform.defense.value = Math.round(defense);
offense += calcform.off_soldiers.value * offsoldier[attacker];
offense += calcform.off_attspec.value * offoffspec[attacker];
offense += calcform.off_defspec.value * offdefspec[attacker];
offense += calcform.off_elites.value * offelite[attacker];
offense += calcform.off_thief.value * offthief[attacker];
offbonus = (calcform.weapons.value/100)*offense;
offbonus += offense * Math.round(calcform.off_science.value) / 100;
if (calcform.off_spell.checked) {
offbonus += offense * 0.15;
}
else {}
if (calcform.attacker.value <= 2 && calcform.off_roar.checked) {
offbonus += offense * 0.1;
}
else {}
if (calcform.attacker.value >= 6 && calcform.attacker.value <= 8 && calcform.off_mortality.checked) {
offbonus += offense * 0.05;
}
else {}
offense += offbonus;
calcform.offense.value = Math.round(offense);
if (defense == 0) {
calcform.percent.value = '';
}
else {
calcform.percent.value = Math.round(offense/defense*1000) / 10;
}
}
</script>
en particulier avce cette partie:
- Code: Tout sélectionner
offense += calcform.off_soldiers.value * offsoldier[attacker];
offense += calcform.off_attspec.value * offoffspec[attacker];
offense += calcform.off_defspec.value * offdefspec[attacker];
offense += calcform.off_elites.value * offelite[attacker];
offense += calcform.off_thief.value * offthief[attacker];
si j'enleve la dernière ligne tout fonctionne, mais si elle est preésente dans le script la valeur "offense" n'est pas calculée.
Je met un lien vers la page pour donner une idée de ce qu'il est censé faire.
Si quelqu'un pouvait etre assez aimable pour y jeter un oeil et me dire ce qui ne va pas je le remercie d'avance.