//// Constants var scoringFactor = 10 ; // Bumps first decimal place of score (e.g. 1.5 score becomes 15 points) var roundingFigure = 0.5 ; // So that 0.5 counts as 1 instead of 0 when rounding var kills = new Array() ; function addToKills() { var numKills = document.getElementById("numKills").value ; if ( numKills < 1 ) return false ; numKills = parseInt(numKills) ; var killValue = parseInt(document.getElementById("killValue").value) ; if ( killValue <= 0 ) return false ; var el = 0 ; var totalKills = numKills ; document.getElementById("kill-score").innerHTML = "" ; for ( i in kills ) { if ( kills[i].value == killValue ) { totalKills = kills[i].count + numKills ; kills[i].count = totalKills ; el = kills[i].el ; break ; } } if ( !el ) { el = document.createElement("li") ; document.getElementById("kill-list").appendChild(el) ; kills.push( { "count":numKills, "value":killValue, "el":el }) ; } el.innerText = totalKills + " of " + killValue ; return true ; } // Return the value of a check box if it is checked function scoreCheck(name) { var el = document.getElementById(name) ; if ( !el || !el.checked || !el.value ) return 0 ; return parseFloat(el.value) ; } function calculate() { var rtbModifier = parseFloat(document.getElementById("rtb").value) ; var myValue = parseInt(document.getElementById("myValue").value) ; if ( myValue <= 0 ) { alert("Vehicle with value of "+myValue+" only proves you ARE a retard") ; return false ; } var killScore = 0 ; for ( i in kills ) { var relativeValue = kills[i].value / myValue ; if ( relativeValue > 4 ) relativeValue = 4 ; killScore = killScore + (relativeValue * kills[i].count) ; } document.getElementById("kill-score").innerHTML = "Kill Score: " + killScore + "" ; // Multi-bonus scores var mspScore = parseInt(document.getElementById("mspawns").value) * 0.1 ; var aisScore = parseInt(document.getElementById("numais").value) * 0.25 ; var capScore = parseInt(document.getElementById("numcaptures").value) * 1.0 ; // Single bonus scores var aboScore = scoreCheck("abobridge") ; var dboScore = scoreCheck("dbobridge") ; var facScore = scoreCheck("factory") ; var fbsScore = scoreCheck("dfb") ; // Total up bonuses var bonusScore = mspScore + aisScore + capScore + aboScore + dboScore + facScore + fbsScore ; document.getElementById("bonus-score").innerHTML = "Bonus Score: " + killScore + "" ; var score = ( killScore + bonusScore ) * scoringFactor * rtbModifier ; var points = parseInt( score + roundingFigure ) ; document.getElementById("results").innerHTML = "" + "(" + killScore + " + " + bonusScore + ") x " + scoringFactor + " x " + rtbModifier + " = " + points + " points" + "" ; }