全站通知:

Widget:战斗模拟器

来自凡人传说WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <style> .rotate-down {transform: rotate(90deg);} .input-group-addon { background-color:#EFCB84; } .sValue { height:33px; background-color:#f9f6d3; } .select_style { background-color:#f9f6d3; height:33px;border:1px solid #ccc; } .btn { border: 1px solid #ccc; padding:6px;box-sizing: border-box; text-align:middle; background-color:#EFCB84; } .sValue:disabled { height:33px; border: 1px solid #ccc; background-color: #EFE7CE; } </style>

        <button class="btn col-xs-12" id="button_board_show" style="text-align:left;">
        >
      属 性 输 入</button>

        <button class="btn col-xs-12" id="button_tool_show" style="text-align:left;">
        >
      道 具 配 置</button>

        <button class="btn col-xs-12" id="button_set_show" style="text-align:left;">
        >
      战 斗 设 置</button>

        <button class="btn col-xs-12" id="button_monster_show" style="text-align:left;">
        >
      出 战 妖 宠</button>

        <button class="btn col-xs-12" id="button_outcome_show" style="text-align:left;">
        >
      计 算 结 果</button>
<script>
$(document).ready(function () {
//localStorage.clear();
$('#button_outcome_show').click(function(){$('#container_outcome').slideToggle('fast', function(){$('#icon_outcome_show').toggleClass('rotate-down');}); });
$('#button_monster_show').click(function(){$('#container_monster').slideToggle('fast', function(){$('#icon_monster_show').toggleClass('rotate-down');}); });
$('#button_board_show').click(function(){$('#container_board').slideToggle('fast', function(){$('#icon_board_show').toggleClass('rotate-down');}); });
$('#button_tool_show').click(function(){$('#container_tool').slideToggle('fast', function(){$('#icon_tool_show').toggleClass('rotate-down');}); });
$('#button_set_show').click(function(){$('#container_set').slideToggle('fast', function(){$('#icon_set_show').toggleClass('rotate-down');}); });
$("input").bind("input propertychange", function () { Main(); })
$("select").bind("change", function(){ Main(); })
var 模块集 = [
    "大境界下拉框","小境界下拉框","攻击文本框","防御文本框","生命文本框","闪避文本框","速度文本框","暴击文本框",
    "金抗文本框","木抗文本框","水抗文本框","火抗文本框","土抗文本框","雷抗文本框",
    "道具选择下拉框","道具名称文本框","道具形制下拉框","道具五行下拉框","触发次数文本框","触发概率文本框",
    "伤害系数文本框","伤害常数文本框","伤害提升文本框","特效类型下拉框","特效参数文本框","提示信息文本框"
];
var 道具 = [];
Load();
function Main() {
    Clear();
    Save();
}
$("#保存按钮").click(function(){
    var index = M("道具选择下拉框").selectedIndex - 1;
    if (index == -1) {
        var new_tool = [];
        new_tool.push(M("道具名称文本框").value); for (var i=0;i<10;i++)new_tool.push("");
        for (var i=0;i<道具.length;i++){ if (道具[i][0] == new_tool[0]){ Print(M("提示信息文本框"), "不能新建相同名称的道具"); return; }}
        道具.push(new_tool); 
        Save(); Print(M("提示信息文本框"), "新增: " + new_tool[0]);
    }
    else {
        道具[index][0] = M("道具名称文本框").value;
        Save(); Print(M("提示信息文本框"), "保存成功");
    }
})
$("#删除按钮").click(function(){
    if (M("道具选择下拉框").selectedIndex == 0) Print(M("提示信息文本框"), "未选择道具");
    else {
        for (var i=道具.length-1;i>=0;i--) { if (道具[i][0] === M("道具选择下拉框").value) { 道具.splice(i, 1); } }
        M("道具选择下拉框").selectedIndex = 0;
        Save(); Print(M("提示信息文本框"), "已删除");
    }
})
function 加载道具信息(){ 
    for (var i=0;i<道具.size();i++){
        if (道具[i][0]==M("道具选择下拉框").value){
            M("道具名称文本框").value = 道具[i][0];
            M("道具形制下拉框").value = 道具[i][1]; M("道具五行下拉框").value = 道具[i][2]; M("触发次数文本框").value = 道具[i][3];
            M("触发概率文本框").value = 道具[i][4]; M("伤害系数文本框").value = 道具[i][5]; M("伤害常数文本框").value = 道具[i][6];
            M("伤害提升文本框").value = 道具[i][7]; M("特效类型下拉框").value = 道具[i][8]; M("特效参数文本框").value = 道具[i][9];
        }
    }
})
function Load() {
    //加载用户账户的信息
    道具 = Read("道具_存储", []);
    RevealChoices();
    //加载当前输入的内容
    for (var i=0;i<模块集.length;i++){
        if (Mtype(模块集[i])=="文本框") { M(模块集[i]).value = Read(Mname(模块集[i]) + "_存储", ""); }
        else if (Mtype(模块集[i])=="下拉框") { M(模块集[i]).value = Read(Mname(模块集[i]) + "_存储", "未选择"); }
        else {}
    }
}
function Save() {
    //保存当前输入的内容
    for (var i=0;i<模块集.length;i++) Write(Mname(模块集[i]) + "_存储", M(模块集[i]).value);
    //保存用户账户的信息
    Write("道具_存储", 道具);
    Load();
}
function RevealChoices() {
    //设置下拉框的选项
    SetChoices (M("大境界下拉框"),[ 
        "练气","筑基","金丹","元婴","出窍","分神","合体",
        "洞虚","大乘","洞真","散仙","游仙","地仙","天仙","金仙",
        "大罗金仙","玄仙","仙君","仙尊","准帝仙","帝仙" ]);
    SetChoices (M("小境界下拉框"), [ "1阶","2阶","3阶","4阶","5阶","6阶","7阶","8阶","9阶","10阶" ]);
    var 道具选择选项 = []; for (var i=0; i<道具.length; i++) { 道具选择选项.push(道具[i][0]); }
    SetChoices (M("道具选择下拉框"), 道具选择选项);
};
function SetChoices(selector, list) {
    var selectedValue = selector.value;
    selector.innerHTML = ""; 
    selector.appendChild(new Option("未选择"));
    for (var i = 0; i < list.length; i++) {selector.appendChild(new Option(list[i])); }
    if (list.includes(selectedValue)) { selector.value = selectedValue; }
};
function Write(place, content) { localStorage.setItem(place, JSON.stringify(content)); }
function Read(place, notexist) { var content = JSON.parse(localStorage.getItem(place)); if (content == null) content = notexist; return content; }
function M(id) { return document.getElementById(id); }
function Mtype(str) {
    if (str.endsWith("文本框")) { return "文本框"; } 
    else if (str.endsWith("下拉框")) { return "下拉框"; } 
    else { return ""; }
}
function Mname(str) {
    let suffix = Mtype(str);
    if (suffix) { return str.slice(0, -suffix.length); }
    return str;
}
function Print(place, content) { place.value = content; }
function Clear(){
    //将所有输出文本框内容清空
    M("提示信息文本框").value = "";
}
});
</script>