var mnfy; window.onload = function() { GroupBox("rwxl_panel", "人物修炼", 15, 5, 600, 85); GroupBox("xlxg_panel", "修炼效果", 15, 120, 240, 225); GroupBox("mnfy_panel", "模拟封印", 275, 120, 340, 225); RadioGroupTab("xlxg_type_option", "xlxg_type"); var tmp_radios = document.getElementsByName("xlxg_type_option"); for (var i = 0; i < tmp_radios.length; i++) { if (tmp_radios[i].attachEvent) tmp_radios[i].attachEvent( "onclick", function(){ document.getElementById("xlxg_basic_label").innerHTML = ("基本伤害|所受伤害".split("|"))[document.getElementById("xlxg_type").value-1]; } ); else if (tmp_radios[i].addEventListener) tmp_radios[i].addEventListener( "click", function(){ document.getElementById("xlxg_basic_label").innerHTML = ("基本伤害|所受伤害".split("|"))[this.value-1]; }, false ); } RadioGroupTab("xl_type_option", "rwxl_type"); // 计算人物修炼消耗 LLn_Control( [ {ids: ["rwxl_level_now", "rwxl_level_target"], min : 0, max : 25}, {ids: ["rwxl_exp_now"], min : 0, max : 9999999999}, {ids: ["rwxl_type"], min : 0, max : 9999999999} ], ["rwxl_level_need", "rwxl_contribution", "rwxl_property", "rwxl_money_need", "rwxl_exp_need"], function (v, o){ // 从0级0经验点到n级修炼,需要点(n^3 + 6n^2 + 38)/3下 var click_count = ((v[1] * v[1] + 6 * v[1] + 38) * v[1] - (v[0] * v[0] + 6 * v[0] + 38) * v[0]) / 3; click_count -= Math.floor(v[2] / 10); if (click_count < 0) click_count = 0; o[0].value = v[1] * 5 + 20; o[1].value = v[1] * 150; o[2].value = click_count * 5; o[3].value = click_count * v[3] + "万"; o[4].value = click_count * 10; } ); // 修炼效果 LLn_Control( [ {ids:["xlxg_type"], min:0, max:999999999}, {ids:["xlxg_basic"], min:0, max:99999999}, {ids:["xlxg_level"], min:0, max:25} ], ["xlxg_normal", "xlxg_plus", "xlxg_minus"], function (v, o) { var basic = Math.round( v[0] == 1 ? (v[1] + 250) * Math.pow(1.02, v[2]) - 250: (v[1] + 250) * Math.pow(0.98, v[2]) - 250 ); o[0].value = basic; o[1].value = Math.round(basic * 1.2); o[2].value = Math.round(basic * 0.8); } ); // 模拟封印 mnfy = new LLn_Control( [ {ids:["mnfy_mylevel"], min:0, max:160}, {ids:["mnfy_mypractice"], min:0, max:25}, {ids:["mnfy_hislevel"], min:0, max:155}, {ids:["mnfy_hispractice"], min:0, max:25} ], ["mnfy_hit_1", "mnfy_hit_2", "mnfy_success", "mnfy_fail", "mnfy_detail"], function (v, o) { var sgn = v[1] > v[3] ? 1 : v[1] < v[3] ? -1 : 0; var p = Math.pow(1 + 0.02 * sgn, Math.abs(v[1] - v[3])); var q = v[0] > v[2] ? 1 + 0.63375 * (1 - Math.pow(0.975, v[0] - v[2])) : Math.pow(0.9, Math.abs(v[0] - v[2])); var hit_rate = 0.6 * p * q, hit_rate_2 = 0.6 * q; if (hit_rate > 1) hit_rate = 1; if (hit_rate_2 > 1) hit_rate_2 = 1; o[0].value = (Math.round(hit_rate_2 * 100000) / 1000) + "%"; o[1].value = (Math.round(hit_rate * 100000) / 1000) + "%"; var detail_out = "", hit = 0, miss = 0; for (var i = 1; i <= 100; i++) { if (i > 1) detail_out += "\r\n"; detail_out += i + "."; if (Math.random() >= hit_rate) { miss++; detail_out += "失败"; } else { hit++; detail_out += "成功"; } } o[2].value = hit + "次"; o[3].value = miss + "次"; o[4].value = detail_out; } ); }