### File Upload and Data Conversion (JavaScript) Source: https://github.com/anonymouswms/zzz-beta-zs/blob/main/beta/index.html This asynchronous JavaScript function, 'run()', is responsible for handling file uploads and converting the uploaded file's content. It calls an 'uploadButton()' function (presumably to get file content) and then processes it using 'FormatConversion()', storing the result in a global variable 'window.now' and logging it to the console. ```javascript async function run() { try { // 等待文件读取完成 const fileContent = await uploadButton(); // 转换 formattedContent = FormatConversion(fileContent); // 保存到全局变量 window.now = formattedContent; console.log("Formatted content:", formattedContent); console.log("Formatted content saved to window.now"); } catch (error) { console.error("Error:", error); } const regex = /\.entrance_id\s*=\s*(1|9),\s*\.zone_id\s*=\s*(\d+)/g; let match; let temp = {}; // 临时对象 while ((match = regex.exec(formattedContent)) !== null) { temp[`entrance_${match[1]}`] = Number(match[2]); } // 用解构赋值直接生成常量 const { entrance_1, entrance_9 } = temp; etn1Radios.value = entrance_1.toString().slice(-2); etn9Radios.value = entrance_9.toString().slice(-2); const numPart1 = parseInt((entrance_1), 10).toString().slice(3); // 提取 "620" 之后的部分 const num1 = parseInt(numPart1, 10); // 3. 检查数字是否在 1-21 范围内 if (num1 >= 1 && num1 <= 32) { // 普通格式 ent_sec1_1.checked = true; ent1_1.value = num1; // 更新输入框的值 } else { ent_sec1_2.checked = true; ent1_2.value = num1; // 更新下拉框的值 // 特殊格式 } const numPart2 = parseInt((entrance_9), 10).toString().slice(3); // 提取 "620" 之后的部分 const num2 = parseInt(n ``` -------------------------------- ### Main Stat Base Values Source: https://github.com/anonymouswms/zzz-beta-zs/blob/main/beta/gm_tool_avatar_overrides.html Stores the base numerical values for main statistics across different properties. These values are used as a starting point for calculations and are adjusted based on game mechanics. ```javascript const mainStatValues = { "HP": 550, "HP%": 750, "ATK": 79, "ATK%": 750, "DEF": 46, "DEF%": 1200, "PEN%": 600, "AM": 750, "AP": 23, "CD": 1200, "CR": 600, "ER": 1500, "I": 450, "El": 750, "Et": 750, "Fi": 750, "Ic": 750, "Ph": 750 }; ``` -------------------------------- ### Build and Run Orphie-ZS Server Source: https://github.com/anonymouswms/zzz-beta-zs/blob/main/beta/orphie-zs-windows/README.md Instructions for cloning the Orphie-ZS repository, building the project using Zig, and running the dispatch and game server services. ```sh git clone https://git.xeondev.com/orphie-zs/orphie-zs.git cd orphie-zs zig build run-orphie-dispatch zig build run-orphie-gameserver ``` -------------------------------- ### Game Data Saving and Formatting Logic (JavaScript) Source: https://github.com/anonymouswms/zzz-beta-zs/blob/main/beta/index.html This JavaScript function, 'save()', handles the logic for collecting user-selected game settings (like Cataclysm Nodes and Crisis Assault Battles) and formatting them into a specific string structure. It then creates a Blob object from this string and initiates a file download for 'gameplay_settings.default.zon'. ```javascript function save() { let selectedEtn1Value; for (const radio of etn1Radios) { if (radio.checked) { selectedEtn1Value = radio.value; break; } } let selectedEtn9Value; for (const radio of etn9Radios) { if (radio.checked) { selectedEtn9Value = radio.value; break; } } let entrance_id1 = 0 let entrance_id9 = 0 if (parseInt(selectedEtn1Value, 10) === 1) { //普通的逻辑 let ent_1 = parseInt(document.getElementById('ent1-1').value, 10); if (ent_1 < 10) { //如果小于10,前面补0 ent_1 = `0${ent_1}`; } entrance_id1 = `620${ent_1}`; } else if (parseInt(selectedEtn1Value, 10) === 2) { //特殊的逻辑 ent_1 = document.getElementById('ent1-2').value; } else { return alert('请选择剧变节点格式'); } if (parseInt(selectedEtn9Value, 10) === 1) { //普通的逻辑 let ent_9 = parseInt(selectedEtn1Value, 10); if (ent_9 < 10) { //如果小于10,前面补0 ent_9 = `0${ent_9}`; } entrance_id9 = `690${ent_9}`; } else if (parseInt(selectedEtn9Value, 10) === 2) { //特殊的逻辑 let ent_9 = document.getElementById('ent9-2').value; entrance_id9 = `690${ent_9}`; } else { return alert('请选择危局强袭战格式'); } const text = `. { .hadal_entrance_list = .{ //稳定节点不能修改! .{ .entrance_id = 2, .zone_id = 61001 }, //纷争节点不能修改! .{ .entrance_id = 3, .zone_id = 61002 }, //剧变节点! .{ .entrance_id = 1, .zone_id = ${entrance_id1} }, //危局强袭战! .{ .entrance_id = 9, .zone_id = ${entrance_id9} }, }, .avatar_overrides = .{ }, .weapons = .{ }, .equipment = .{ }, `; const blob = new Blob([text], { type: 'text/plain' }); const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = 'gameplay_settings.default.zon'; // 设置默认文件名 // 触发下载 link.click(); } ``` -------------------------------- ### Copy Configuration Preview to Clipboard Source: https://github.com/anonymouswms/zzz-beta-zs/blob/main/beta/gm_tool_avatar_overrides.html Selects the text in the output preview element and attempts to copy it to the clipboard using the asynchronous Clipboard API. If the Clipboard API fails, it falls back to the older document.execCommand('copy'). Alerts the user upon successful copy or if an error occurs. ```javascript function copyPreview() { const output = document.getElementById("outputPreview"); output.select(); try { navigator.clipboard.writeText(output.value).then(() => { alert('配置已复制到剪贴板!'); }).catch(err => { console.error('无法自动复制:', err); const range = document.createRange(); range.selectNodeContents(output); const selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range); document.execCommand('copy'); alert('配置已复制到剪贴板!'); }); } catch (err) { console.error('无法自动复制:', err); } } ``` -------------------------------- ### Dynamic UI Element Creation and Management (JavaScript) Source: https://github.com/anonymouswms/zzz-beta-zs/blob/main/beta/index.html This JavaScript code handles the dynamic creation of UI elements based on templates. It includes event listeners for 'create' buttons to add new sections and 'delete' buttons to remove them, facilitating user-driven content generation within the application. ```javascript let formattedContent = ""; const etn1Radios = document.getElementsByName('1etn'); const etn9Radios = document.getElementsByName('9etn'); const ent1_1 = document.getElementById('ent1-1'); const ent1_2 = document.getElementById('ent1-1'); const ent9_1 = document.getElementById('ent9-1'); const ent9_2 = document.getElementById('ent9-2'); const ent_sec1_1 = document.getElementById('ent_sec1-1'); const ent_sec1_2 = document.getElementById('ent_sec1-2'); const ent_sec9_1 = document.getElementById('ent_sec9-1'); const ent_sec9_2 = document.getElementById('ent_sec9-2'); document.getElementById('createBtn').addEventListener('click', function () { const template = document.getElementById('inputTemplate'); const clone = template.content.cloneNode(true); // 为删除按钮添加事件 clone.querySelector('.deleteBtn').addEventListener('click', function () { this.parentElement.remove(); }); document.getElementById('container').appendChild(clone); }); document.getElementById('createBtn1').addEventListener('click', function () { const template = document.getElementById('inputTemplate1'); const clone = template.content.cloneNode(true); // 为删除按钮添加事件 clone.querySelector('.deleteBtn1').addEventListener('click', function () { this.parentElement.remove(); }); document.getElementById('container1').appendChild(clone); }); document.getElementById('createBtn2').addEventListener('click', function () { const template = document.getElementById('inputTemplate2'); const clone = template.content.cloneNode(true); // 为删除按钮添加事件 clone.querySelector('.deleteBtn2').addEventListener('click', function () { this.parentElement.remove(); }); document.getElementById('container2').appendChild(clone); }); ```