Commits

zarka  committed 453f109

fixed rounding on tech calc
fixed boxcar XSS file

  • Participants
  • Parent commits 657cb6e

Comments (0)

Files changed (2)

File break_calc.html

 			$("#jets_ps").html(milOut(jets_ps,0,'.',','));
 		}
 		function zzz_weapCalcAtt() {
-			var t = zzz_calcWeap($("#att_weap_tech").val(), $("#att_land").val(), $("#att_gov").val());
+			var t = milOut(zzz_calcWeap($("#att_weap_tech").val(), $("#att_land").val(), $("#att_gov").val()), 2, '.', '');
 			$('#att_weapons').val(t);
 			$('#att_weapons').keyup();
 		}

File break_calc_boxcar.html

-<script>function milOut(n_i,c,d,t){var n=n_i,c=isNaN(c=Math.abs(c))?2:c,d=d==undefined?",":d,t=t==undefined?".":t,s=n<0?"-":"",i=parseInt(n=Math.abs(+n||0).toFixed(c))+"",j=(j=i.length)>3?j%3:0;return s+(j?i.substr(0,j)+t:"")+i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+t)+(c?d+Math.abs(n-i).toFixed(c).slice(2):"");};function zzz_readNumeric(jQsearch){var val=parseFloat($(jQsearch).val());if(isNaN(val)){val=0;}return val;}function zzz_readPercent(jQsearch){var val=$(jQsearch).val();val=parseInt(val);val=(val/100);if(isNaN(val)||val==0){val=1;}return val;}function zzz_govBonus(gov){if("rep"==gov){return 0.9;}else if("dict"==gov){return 1.25}return 1;}function zzz_milStr(pre,post,is_def){var troops=zzz_readNumeric("#"+pre+"troops"+post);var jets=zzz_readNumeric("#"+pre+(is_def?"turrets":"jets")+post);var tanks=zzz_readNumeric("#"+pre+"tanks"+post);return(troops/2)+jets+(tanks*2);}function zzz_calc(){var war_perc=$("#att_war").attr("checked")?1.1:1;var main_att=zzz_milStr("att_","",false);var a_weap=zzz_readPercent("#att_weapons"),a_gov=zzz_govBonus($("#att_gov").val());var break_cap=main_att*a_gov*a_weap*war_perc;var o_ally1=zzz_milStr("att_","_a1",false)/4;var o_ally2=zzz_milStr("att_","_a2",false)/4;var o_ally3=zzz_milStr("att_","_a3",false)/4;var o_ally_str=(o_ally1+o_ally2+o_ally3>break_cap?break_cap:o_ally1+o_ally2+o_ally3);$("#off_ally_str").html(milOut(o_ally_str,0,'.',','));break_cap+=o_ally_str;$("#max_break_cap").html(milOut(break_cap,0,'.',','));var def_str=zzz_milStr("def_","",true)*zzz_govBonus($("#def_gov").val())*zzz_readPercent("#def_weapons");var d_ally1=zzz_milStr("def_","_a1",true)/4;var d_ally2=zzz_milStr("def_","_a2",true)/4;var d_ally_str=(d_ally1+d_ally2>def_str?def_str:d_ally1+d_ally2);$("#def_ally_str").html(milOut(d_ally_str,0,'.',','));def_str+=d_ally_str;$("#def_str").html(milOut(def_str,0,'.',','));var def_to_break=(o_ally_str>(def_str/2)?def_str/2:def_str-o_ally_str);var jets_ss=def_to_break/a_weap/a_gov/war_perc*1.11;var jets_ps=jets_ss/1.5;$("#jets_ss").html(milOut(jets_ss,0,'.',','));$("#jets_ps").html(milOut(jets_ps,0,'.',','));}$(document).ready(function(){$(".attack").change(zzz_calc);$(".attack").keyup(zzz_calc);$(".defense").change(zzz_calc);$(".defense").keyup(zzz_calc);zzz_calc();});</script><div id=Container><table><tr><th colspan=2>Attacker</th><th>Off Ally 1</th><th>Off Ally 2</th><th>Off Ally 3</th><tr><th>Troops:</th><td><input name=att_troops id=att_troops class=attack value=0></td><td><input name=att_troops_a1 id=att_troops_a1 class=attack value=0></td><td><input name=att_troops_a2 id=att_troops_a2 class=attack value=0></td><td><input name=att_troops_a3 id=att_troops_a3 class=attack value=0></td><tr><th>Jets:</th><td><input name=att_jets id=att_jets class=attack value=0></td><td><input name=att_jets_a1 id=att_jets_a1 class=attack value=0></td><td><input name=att_jets_a2 id=att_jets_a2 class=attack value=0></td><td><input name=att_jets_a3 id=att_jets_a3 class=attack value=0></td><tr><th>Tanks:</th><td><input name=att_tanks id=att_tanks class=attack value=0></td><td><input name=att_tanks_a1 id=att_tanks_a1 class=attack value=0></td><td><input name=att_tanks_a2 id=att_tanks_a2 class=attack value=0></td><td><input name=att_tanks_a3 id=att_tanks_a3 class=attack value=0></td><tr><th>Goverment:<br></th><td><select name=att_gov id=att_gov class=attack><option value=other>Other<option value=rep>Republic<option value=dict>Dictatorship</select></td><td colspan=3>Total Ally str:&nbsp;<span id=off_ally_str></span></td><tr><th>Weapons:</th><td colspan=4><input name=att_weapons id=att_weapons class=attack value=0></td><tr><th>War Dec:</th><td colspan=4><input type=checkbox name=att_war id=att_war class=attack></td></table>Max Break capacity:&nbsp;<span id=max_break_cap>0</span><br>Jets SS:&nbsp;<span id=jets_ss></span>&nbsp;(99.7% success rate)<br>Jets PS:&nbsp;<span id=jets_ps></span>&nbsp;(99.7% success rate)<br><table><tr><th colspan=2>Defender</th><th>Def Ally 1</th><th>Def Ally 2</th><tr><th>Troops</th><td><input name=def_troops id=def_troops class=defense></td><td><input name=def_troops_a1 id=def_troops_a1 class=defense></td><td><input name=def_troops_a2 id=def_troops_a2 class=defense></td><tr><th>Turrets</th><td><input name=def_turrets id=def_turrets class=defense></td><td><input name=def_turrets_a1 id=def_turrets_a1 class=defense></td><td><input name=def_turrets_a2 id=def_turrets_a2 class=defense></td><tr><th>Tanks</th><td><input name=def_tanks id=def_tanks class=defense></td><td><input name=def_tanks_a1 id=def_tanks_a1 class=defense></td><td><input name=def_tanks_a2 id=def_tanks_a2 class=defense></td><tr><th>Goverment:<br></th><td><select name=def_gov id=def_gov class=defense><option value=other>Other<option value=rep>Republic<option value=dict>Dictatorship</select></td><td colspan=2>Total Ally str:&nbsp;<span id=def_ally_str></span></td><tr><th>Weapons:</th><td colspan=3><input name=def_weapons id=def_weapons class=defense value=0></td></table>Defensive Strength:&nbsp;<span id=def_str>0</span><br></div>
+<script>function milOut(n_i,c,d,t){var n=n_i,c=isNaN(c=Math.abs(c))?2:c,d=d==undefined?",":d,t=t==undefined?".":t,s=n<0?"-":"",i=parseInt(n=Math.abs(+n||0).toFixed(c))+"",j=(j=i.length)>3?j%3:0;return s+(j?i.substr(0,j)+t:"")+i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+t)+(c?d+Math.abs(n-i).toFixed(c).slice(2):"");}function zzz_readNumeric(jQsearch){var val=parseFloat($(jQsearch).val());if(isNaN(val)){val=0;}return val;}function zzz_readPercent(jQsearch){var val=$(jQsearch).val();val=parseInt(val);val=(val/100);if(isNaN(val)||val==0){val=1;}return val;}function zzz_govBonus(gov){if("rep"==gov){return 0.9;}else if("dict"==gov){return 1.25}return 1;}function zzz_milStr(pre,post,is_def){var troops=zzz_readNumeric("#"+pre+"troops"+post);var jets=zzz_readNumeric("#"+pre+(is_def?"turrets":"jets")+post);var tanks=zzz_readNumeric("#"+pre+"tanks"+post);return(troops/2)+jets+(tanks*2);}function zzz_calcWeap(tech,land,gov){var c1=192;var c2=6.795;var base_tech=100;var max_tech=150;var gvt_tech=1;var gvt_eff=1;if('theo'==gov){gvt_tech=0.65;}else if('demo'==gov){gvt_tech=1.1}else if('com'==gov){gvt_eff=1.2}var exp=Math.exp(-gvt_eff*tech/(c1+c2*land));var perc=base_tech+((max_tech-base_tech)*gvt_tech*(1-exp));return perc;}function zzz_calc(){var war_perc=$("#att_war").attr("checked")?1.1:1;var main_att=zzz_milStr("att_","",false);var a_weap=zzz_readPercent("#att_weapons");var a_gov=zzz_govBonus($("#att_gov").val());var break_cap=main_att*a_gov*a_weap*war_perc;var o_ally1=zzz_milStr("att_","_a1",false)/4;var o_ally2=zzz_milStr("att_","_a2",false)/4;var o_ally3=zzz_milStr("att_","_a3",false)/4;var o_ally_str=(o_ally1+o_ally2+o_ally3>break_cap?break_cap:o_ally1+o_ally2+o_ally3);$("#off_ally_str").html(milOut(o_ally_str,0,'.',','));break_cap+=o_ally_str;$("#max_break_cap").html(milOut(break_cap,0,'.',','));var def_weap=zzz_readPercent("#def_weapons");var def_str=zzz_milStr("def_","",true)*zzz_govBonus($("#def_gov").val())*def_weap;var d_ally1=zzz_milStr("def_","_a1",true)/4;var d_ally2=zzz_milStr("def_","_a2",true)/4;var d_ally_str=(d_ally1+d_ally2>def_str?def_str:d_ally1+d_ally2);$("#def_ally_str").html(milOut(d_ally_str,0,'.',','));def_str+=d_ally_str;$("#def_str").html(milOut(def_str,0,'.',','));var def_to_break=(o_ally_str>(def_str/2)?def_str/2:def_str-o_ally_str);var jets_ss=def_to_break/a_weap/a_gov/war_perc*1.11;var jets_ps=jets_ss/1.5;$("#jets_ss").html(milOut(jets_ss,0,'.',','));$("#jets_ps").html(milOut(jets_ps,0,'.',','));}function zzz_weapCalcAtt(){var t=milOut(zzz_calcWeap($("#att_weap_tech").val(),$("#att_land").val(),$("#att_gov").val()),2,'.','');$('#att_weapons').val(t);$('#att_weapons').keyup();}function zzz_weapCalcDef(){var t=milOut(zzz_calcWeap($("#def_weap_tech").val(),$("#def_land").val(),$("#def_gov").val()),2,'.','');$('#def_weapons').val(t);$('#def_weapons').change();}$(document).ready(function(){$(".attack").change(zzz_calc);$(".attack").keyup(zzz_calc);$(".defense").change(zzz_calc);$(".defense").keyup(zzz_calc);$("#att_gov").keyup(zzz_weapCalcAtt);$("#att_gov").change(zzz_weapCalcAtt);$(".att_tech_calc").change(zzz_weapCalcAtt);$(".att_tech_calc").keyup(zzz_weapCalcAtt);$("#def_gov").keyup(zzz_weapCalcDef);$("#def_gov").change(zzz_weapCalcDef);$(".def_tech_calc").change(zzz_weapCalcDef);$(".def_tech_calc").keyup(zzz_weapCalcDef);zzz_calc();});</script><div id=Container><table><tr><th colspan=2>Attacker</th><th>Off Ally 1</th><th>Off Ally 2</th><th>Off Ally 3</th><tr><th>Troops:</th><td><input name=att_troops id=att_troops class=attack value=0></td><td><input name=att_troops_a1 id=att_troops_a1 class=attack value=0></td><td><input name=att_troops_a2 id=att_troops_a2 class=attack value=0></td><td><input name=att_troops_a3 id=att_troops_a3 class=attack value=0></td><tr><th>Jets:</th><td><input name=att_jets id=att_jets class=attack value=0></td><td><input name=att_jets_a1 id=att_jets_a1 class=attack value=0></td><td><input name=att_jets_a2 id=att_jets_a2 class=attack value=0></td><td><input name=att_jets_a3 id=att_jets_a3 class=attack value=0></td><tr><th>Tanks:</th><td><input name=att_tanks id=att_tanks class=attack value=0></td><td><input name=att_tanks_a1 id=att_tanks_a1 class=attack value=0></td><td><input name=att_tanks_a2 id=att_tanks_a2 class=attack value=0></td><td><input name=att_tanks_a3 id=att_tanks_a3 class=attack value=0></td><tr><th>Goverment:<br></th><td><select name=att_gov id=att_gov class=attack><option value=other>Other<option value=rep>Republic<option value=com>Communism<option value=demo>Democracy<option value=dict>Dictatorship<option value=rep>Republic<option value=theo>Theocracy</select></td><td colspan=3>Total Ally str:&nbsp;<span id=off_ally_str></span></td><tr><th>Weapons:</th><td><input name=att_weapons id=att_weapons class=attack value=100></td><td colspan=3>Land:<input name=att_land id=att_land class=att_tech_calc value=0>Points:<input name=att_weap_tech id=att_weap_tech class=att_tech_calc value=0></td><tr><th>War Dec:</th><td colspan=4><input type=checkbox name=att_war id=att_war class=attack></td></table>Max Break capacity:&nbsp;<span id=max_break_cap>0</span><br>Jets SS:&nbsp;<span id=jets_ss></span>&nbsp;(99.7% success rate)<br>Jets PS:&nbsp;<span id=jets_ps></span>&nbsp;(99.7% success rate)<br><table><tr><th colspan=2>Defender</th><th>Def Ally 1</th><th>Def Ally 2</th><tr><th>Troops</th><td><input name=def_troops id=def_troops class=defense></td><td><input name=def_troops_a1 id=def_troops_a1 class=defense></td><td><input name=def_troops_a2 id=def_troops_a2 class=defense></td><tr><th>Turrets</th><td><input name=def_turrets id=def_turrets class=defense></td><td><input name=def_turrets_a1 id=def_turrets_a1 class=defense></td><td><input name=def_turrets_a2 id=def_turrets_a2 class=defense></td><tr><th>Tanks</th><td><input name=def_tanks id=def_tanks class=defense></td><td><input name=def_tanks_a1 id=def_tanks_a1 class=defense></td><td><input name=def_tanks_a2 id=def_tanks_a2 class=defense></td><tr><th>Goverment:<br></th><td><select name=def_gov id=def_gov class=defense><option value=other>Other<option value=com>Communism<option value=demo>Democracy<option value=dict>Dictatorship<option value=rep>Republic<option value=theo>Theocracy</select></td><td colspan=2>Total Ally str:&nbsp;<span id=def_ally_str></span></td><tr><th>Weapons:</th><td><input name=def_weapons id=def_weapons class=defense value=100></td><td colspan=2>Land:<input name=def_land id=def_land class=def_tech_calc value=0>Points:<input name=def_weap_tech id=def_weap_tech class=def_tech_calc value=0></td></table>Defensive Strength:&nbsp;<span id=def_str>0</span><br></div>