Difference between revisions of "Mir4Test" - LOMCN Wiki

Mu online season 21 - grand opening
(Created page with "== AVA Mir 4 Map Database == This page provides a database of stages in the AVA Mir 4 game. === Search and Filter === <form method="get" action=""> {| class="wikitable" style...")
 
m
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== AVA Mir 4 Map Database ==
 
This page provides a database of stages in the AVA Mir 4 game.
 
  
=== Search and Filter ===
+
     <h1>Create Recipe</h1>
<form method="get" action="">
+
     <a href="../database.html" class="return-button">Return to Main Database</a>
{| class="wikitable" style="width:100%; margin-bottom:10px; background-color:#f9f9f9;"
 
|-
 
! style="text-align:left;" | Search:
 
| <input type="text" name="search" placeholder="Search by Stage Name or ID" value="{{#urlget:search|}}">
 
! style="text-align:left;" | Type:
 
| <select name="type" onchange="this.form.submit();">
 
     <option value="">All Types</option>
 
    <!-- Add options dynamically -->
 
     <option value="Custom" {{#ifeq:{{#urlget:type}}|Custom|selected}} >Custom</option>
 
    <option value="Field" {{#ifeq:{{#urlget:type}}|Field|selected}} >Field</option>
 
    <option value="Fight" {{#ifeq:{{#urlget:type}}|Fight|selected}} >Fight</option>
 
    <!-- Add remaining stage types as options -->
 
</select>
 
! style="text-align:left;" | Sort by:
 
| <select name="sort" onchange="this.form.submit();">
 
    <option value="id_asc" {{#ifeq:{{#urlget:sort}}|id_asc|selected}}>Stage ID (Low to High)</option>
 
    <option value="id_desc" {{#ifeq:{{#urlget:sort}}|id_desc|selected}}>Stage ID (High to Low)</option>
 
</select>
 
|}
 
<button type="submit">Apply Filters</button>
 
</form>
 
  
=== Stage List ===
+
    <div class="container">
{| class="wikitable sortable" style="width:100%;"
+
        <label>Recipe (Item Name):</label>
|-
+
        <select id="recipeTitle"></select>
! Stage ID
 
! Stage Name
 
! Type
 
|-
 
<!-- Example of dynamic rows -->
 
| 1
 
| Unnamed Stage
 
| Field
 
|-
 
| 2
 
| Siege Battle
 
| Siege
 
|-
 
| 3
 
| Dungeon Maze
 
| Labyrinth
 
|}
 
  
=== Pagination ===
+
        <label>Amount:</label>
<div style="text-align:center;">
+
        <input type="number" id="amount" value="1" min="1">
<!-- Pagination links -->
+
 
[{{fullurl:{{FULLPAGENAME}}|page=1}} 1] | [{{fullurl:{{FULLPAGENAME}}|page=2}} 2] | [{{fullurl:{{FULLPAGENAME}}|page=3}} 3]
+
        <label>Chance (%):</label>
</div>
+
        <input type="number" id="chance" value="100" min="1" max="100">
 +
 
 +
        <label>Gold Cost:</label>
 +
        <input type="number" id="goldCost" value="0" min="0">
 +
 
 +
        <!-- Tools Section -->
 +
        <div class="section">
 +
            <label>Tools:</label>
 +
            <div id="tools-container"></div>
 +
            <button type="button" onclick="addTool()">Add Tool</button>
 +
        </div>
 +
 
 +
        <!-- Ingredients Section -->
 +
        <div class="section">
 +
            <label>Ingredients:</label>
 +
            <div id="ingredients-container"></div>
 +
            <button type="button" onclick="addIngredient()">Add Ingredient</button>
 +
        </div>
 +
 
 +
        <!-- File Name -->
 +
        <label>File Name:</label>
 +
        <input type="text" id="fileName" placeholder="Enter file name (no extension)">
 +
 
 +
        <button onclick="generateRecipe()">Generate Recipe File</button>
 +
    </div>
 +
 
 +
    <script>
 +
        let itemDatabase = [];
 +
        async function loadItemDatabase() {
 +
            const response = await fetch('csv/ItemDatabase.csv');
 +
            const text = await response.text();
 +
            const rows = text.split(/\r?\n/).map(row => row.split(',').map(cell => cell.trim()));
 +
            const headers = rows.shift();
 +
            const nameIndex = headers.indexOf('ItemName');
 +
 
 +
            itemDatabase = rows.map(row => row[nameIndex]).filter(name => name);
 +
 
 +
            populateDropdowns();
 +
            addTool(); // Add the first tool input
 +
            addIngredient(); // Add the first ingredient input
 +
        }
 +
 
 +
        function populateDropdowns() {
 +
            const dropdowns = ['recipeTitle'];
 +
            dropdowns.forEach(id => {
 +
                const select = document.getElementById(id);
 +
                addNoneOption(select);
 +
                itemDatabase.forEach(name => {
 +
                    const option = document.createElement('option');
 +
                    option.value = name;
 +
                    option.textContent = name;
 +
                    select.appendChild(option);
 +
                });
 +
            });
 +
        }
 +
 
 +
        function addNoneOption(select) {
 +
            const noneOption = document.createElement('option');
 +
            noneOption.value = "";
 +
            noneOption.textContent = "None";
 +
            select.appendChild(noneOption);
 +
        }
 +
 
 +
        function addTool() {
 +
            const container = document.getElementById('tools-container');
 +
            const toolDiv = document.createElement('div');
 +
            toolDiv.innerHTML = `
 +
                <select>
 +
                    ${itemDatabase.map(name => `<option value="${name}">${name}</option>`).join('')}
 +
                    <option value="" selected>None</option>
 +
                </select>
 +
                <button type="button" onclick="removeElement(this)">Remove</button>
 +
            `;
 +
            container.appendChild(toolDiv);
 +
        }
 +
 
 +
        function addIngredient() {
 +
            const container = document.getElementById('ingredients-container');
 +
            const ingDiv = document.createElement('div');
 +
            ingDiv.innerHTML = `
 +
                <select>
 +
                    ${itemDatabase.map(name => `<option value="${name}">${name}</option>`).join('')}
 +
                    <option value="" selected>None</option>
 +
                </select>
 +
                <input type="number" placeholder="Quantity" min="1" value="1">
 +
                <input type="number" placeholder="Dura" min="0">
 +
                <button type="button" onclick="removeElement(this)">Remove</button>
 +
            `;
 +
            container.appendChild(ingDiv);
 +
        }
 +
 
 +
        function removeElement(button) {
 +
            button.parentElement.remove();
 +
        }
 +
 
 +
        function generateRecipe() {
 +
            const title = document.getElementById('recipeTitle').value || "Unknown";
 +
            const amount = document.getElementById('amount').value;
 +
            const chance = document.getElementById('chance').value;
 +
            const goldCost = document.getElementById('goldCost').value;
 +
 
 +
            // Tools
 +
            const tools = Array.from(document.querySelectorAll('#tools-container select'))
 +
                .map(select => select.value)
 +
                .filter(value => value);
 +
 
 +
            // Ingredients
 +
            const ingredients = Array.from(document.querySelectorAll('#ingredients-container div'))
 +
                .map(div => {
 +
                    const selects = div.querySelectorAll('select, input');
 +
                    const name = selects[0].value;
 +
                    const quantity = selects[1].value;
 +
                    const dura = selects[2].value;
 +
                    return name ? `${name} ${quantity}${dura ? ` ${dura}` : ''}` : null;
 +
                }).filter(item => item);
 +
 
 +
            // Build content
 +
            const content = `
 +
[Recipe]
 +
Amount ${amount}
 +
Chance ${chance}
 +
Gold ${goldCost}
 +
 
 +
[Tools]
 +
${tools.join('\n') || 'None'}
 +
 
 +
[Ingredients]
 +
${ingredients.join('\n') || 'None'}
 +
            `.trim();
 +
 
 +
            // Save to file
 +
            const fileName = document.getElementById('fileName').value || title;
 +
            const blob = new Blob([content], { type: 'text/plain' });
 +
            const link = document.createElement('a');
 +
            link.href = URL.createObjectURL(blob);
 +
            link.download = `${fileName}.txt`;
 +
            link.click();
 +
        }
 +
 
 +
        document.addEventListener('DOMContentLoaded', loadItemDatabase);
 +
    </script>

Latest revision as of 23:59, 23 February 2025

Create Recipe

   <a href="../database.html" class="return-button">Return to Main Database</a>
       <label>Recipe (Item Name):</label>
       <select id="recipeTitle"></select>
       <label>Amount:</label>
       <input type="number" id="amount" value="1" min="1">
       <label>Chance (%):</label>
       <input type="number" id="chance" value="100" min="1" max="100">
       <label>Gold Cost:</label>
       <input type="number" id="goldCost" value="0" min="0">
           <label>Tools:</label>
           <button type="button" onclick="addTool()">Add Tool</button>
           <label>Ingredients:</label>
           <button type="button" onclick="addIngredient()">Add Ingredient</button>
       <label>File Name:</label>
       <input type="text" id="fileName" placeholder="Enter file name (no extension)">
       <button onclick="generateRecipe()">Generate Recipe File</button>
   <script>
       let itemDatabase = [];
       async function loadItemDatabase() {
           const response = await fetch('csv/ItemDatabase.csv');
           const text = await response.text();
           const rows = text.split(/\r?\n/).map(row => row.split(',').map(cell => cell.trim()));
           const headers = rows.shift();
           const nameIndex = headers.indexOf('ItemName');
           itemDatabase = rows.map(row => row[nameIndex]).filter(name => name);
           populateDropdowns();
           addTool(); // Add the first tool input
           addIngredient(); // Add the first ingredient input
       }
       function populateDropdowns() {
           const dropdowns = ['recipeTitle'];
           dropdowns.forEach(id => {
               const select = document.getElementById(id);
               addNoneOption(select);
               itemDatabase.forEach(name => {
                   const option = document.createElement('option');
                   option.value = name;
                   option.textContent = name;
                   select.appendChild(option);
               });
           });
       }
       function addNoneOption(select) {
           const noneOption = document.createElement('option');
           noneOption.value = "";
           noneOption.textContent = "None";
           select.appendChild(noneOption);
       }
       function addTool() {
           const container = document.getElementById('tools-container');
           const toolDiv = document.createElement('div');
           toolDiv.innerHTML = `
               <select>
                   ${itemDatabase.map(name => `<option value="${name}">${name}</option>`).join()}
                   <option value="" selected>None</option>
               </select>
               <button type="button" onclick="removeElement(this)">Remove</button>
           `;
           container.appendChild(toolDiv);
       }
       function addIngredient() {
           const container = document.getElementById('ingredients-container');
           const ingDiv = document.createElement('div');
           ingDiv.innerHTML = `
               <select>
                   ${itemDatabase.map(name => `<option value="${name}">${name}</option>`).join()}
                   <option value="" selected>None</option>
               </select>
               <input type="number" placeholder="Quantity" min="1" value="1">
               <input type="number" placeholder="Dura" min="0">
               <button type="button" onclick="removeElement(this)">Remove</button>
           `;
           container.appendChild(ingDiv);
       }
       function removeElement(button) {
           button.parentElement.remove();
       }
       function generateRecipe() {
           const title = document.getElementById('recipeTitle').value || "Unknown";
           const amount = document.getElementById('amount').value;
           const chance = document.getElementById('chance').value;
           const goldCost = document.getElementById('goldCost').value;
           // Tools
           const tools = Array.from(document.querySelectorAll('#tools-container select'))
               .map(select => select.value)
               .filter(value => value);
           // Ingredients
           const ingredients = Array.from(document.querySelectorAll('#ingredients-container div'))
               .map(div => {
                   const selects = div.querySelectorAll('select, input');
                   const name = selects[0].value;
                   const quantity = selects[1].value;
                   const dura = selects[2].value;
                   return name ? `${name} ${quantity}${dura ? ` ${dura}` : }` : null;
               }).filter(item => item);
           // Build content
           const content = `

[Recipe] Amount ${amount} Chance ${chance} Gold ${goldCost}

[Tools] ${tools.join('\n') || 'None'}

[Ingredients] ${ingredients.join('\n') || 'None'}

           `.trim();
           // Save to file
           const fileName = document.getElementById('fileName').value || title;
           const blob = new Blob([content], { type: 'text/plain' });
           const link = document.createElement('a');
           link.href = URL.createObjectURL(blob);
           link.download = `${fileName}.txt`;
           link.click();
       }
       document.addEventListener('DOMContentLoaded', loadItemDatabase);
   </script>