Update readme with URL
This commit is contained in:
parent
4916f77a1d
commit
2681090f5e
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# OrnaRPG Tools
|
||||
|
||||
Equipment combination toolkit
|
||||
https://orna.atr0phy.net
|
@ -1,70 +0,0 @@
|
||||
from flask import Flask, render_template, jsonify, request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/results', methods=['POST'])
|
||||
def results():
|
||||
combinations = calculate_combinations(request.get_json())
|
||||
return jsonify(combinations)
|
||||
|
||||
|
||||
# Data Methods
|
||||
def calculate_combinations(equipment, do_print=True):
|
||||
# name, defense, resistance
|
||||
eq_headware = equipment["head"]
|
||||
eq_chestware = equipment["chest"]
|
||||
eq_legwear = equipment["legs"]
|
||||
|
||||
# Create a list of all possible eq combinations
|
||||
results = []
|
||||
for hw in eq_headware:
|
||||
print('Headware: {}'.format(hw))
|
||||
for cw in eq_chestware:
|
||||
print('Chestware: {}'.format(cw))
|
||||
for lw in eq_legwear:
|
||||
print('legware: {}'.format(lw))
|
||||
result = {}
|
||||
result["eq"] = [hw[0], cw[0], lw[0]]
|
||||
result["def"] = hw[1] + cw[1] + lw[1]
|
||||
result["res"] = hw[2] + cw[2] + lw[2]
|
||||
results.append(result)
|
||||
|
||||
# Sort the combinations by combined total of def anf res
|
||||
results.sort(key=lambda i: i["def"] + i["res"])
|
||||
|
||||
if do_print:
|
||||
for result in results:
|
||||
print("{} ({} def {} res) -".format(result["def"] + result["res"], result["def"], result["res"]))
|
||||
for eq in result["eq"]:
|
||||
print("\t{}".format(eq))
|
||||
|
||||
return results
|
||||
|
||||
|
||||
"""
|
||||
eq_headware = [
|
||||
["Ljosalfar Hood", 98, 510],
|
||||
["Kobold Hood", 0, 614],
|
||||
["Northern Cowl", 584, 130],
|
||||
["High Fomorian Hood", 487, 112]
|
||||
]
|
||||
|
||||
eq_chestware = [
|
||||
["Ljosalfar Robe", 121, 528],
|
||||
["High Fomorian Garb", 544, 0],
|
||||
["Darkest Garb", 514, 169],
|
||||
["Northern Garb", 535, 119],
|
||||
["Northern Robe", 486, 108]
|
||||
]
|
||||
|
||||
eq_legwear = [
|
||||
["Northern Boots", 636, 142],
|
||||
["Terra Boots", 129, 369],
|
||||
["High Fomorian Boots", 516, 0],
|
||||
["Ljosalfar Boots", 280, 280]
|
||||
]
|
||||
"""
|
@ -24,13 +24,13 @@
|
||||
</nav>
|
||||
<div class="uk-container">
|
||||
<div id="help-container" class="uk-padding-large uk-text-center uk-text-muted uk-margin-large-left uk-margin-large-right">
|
||||
<div>Use the three tabs to input your options for each equipment slot (head/chest/leg). Click the calculate button to populate a table with possible combinations. Click on the column headers to sort results. Use the green + to input additional items.</div>
|
||||
<div>Use the three tabs to input your options for each equipment slot (head/chest/leg). Click the calculate button to populate a table with possible combinations. Click on the column headers to sort results.<br/><br/><strong>Ctrl+Enter</strong> adds a new row to existing table, or use the green <strong>+</strong> to input additional items.</div>
|
||||
</div>
|
||||
<div id="equipment-container" class="uk-padding-large">
|
||||
<ul class="uk-flex-center" uk-tab>
|
||||
<li class="uk-active"><a href="">Head</a></li>
|
||||
<li><a href="">Chest</a></li>
|
||||
<li><a href="">Leg</a></li>
|
||||
<li class="uk-active" tbl="head-table"><a href="">Head</a></li>
|
||||
<li tbl="chest-table"><a href="">Chest</a></li>
|
||||
<li tbl="leg-table"><a href="">Leg</a></li>
|
||||
</ul>
|
||||
<ul class="uk-switcher">
|
||||
{% for slot in ["Head", "Chest", "Leg"] %}
|
||||
@ -50,9 +50,9 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td><input type="text" class="uk-input"/></td>
|
||||
<td><input type="text" class="uk-input"/></td>
|
||||
<td><input type="text" class="uk-input"/></td>
|
||||
<td><input type="text" class="uk-input" autocomplete="off"/></td>
|
||||
<td><input type="text" class="uk-input" autocomplete="off"/></td>
|
||||
<td><input type="text" class="uk-input" autocomplete="off"/></td>
|
||||
<td><a class="uk-icon-button del-row-button" uk-icon="icon:minus-circle;ratio:1"></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -97,7 +97,7 @@
|
||||
</body>
|
||||
<script>
|
||||
// Support adding rows to the equipment tables
|
||||
function addEquipmentTableRow() {
|
||||
function addEquipmentTableRow(findByQuery=false) {
|
||||
let input_element = document.createElement("input");
|
||||
input_element.className="uk-input";
|
||||
input_element.type = "text";
|
||||
@ -108,7 +108,8 @@
|
||||
delete_button.setAttribute("uk-icon", "icon:minus-circle;ratio:1");
|
||||
delete_button.addEventListener("click", deleteEquipmentTableRow, false);
|
||||
|
||||
let tbody = this.parentElement.previousElementSibling.children[2];
|
||||
// If called manually, find specific table, otherwise determine based on event element
|
||||
let tbody = findByQuery ? document.querySelector(findByQuery) : this.parentElement.previousElementSibling.children[2];
|
||||
let new_row = tbody.insertRow(-1);
|
||||
|
||||
// Append all of the child cells needed
|
||||
@ -117,6 +118,11 @@
|
||||
new_row.insertCell(0).appendChild(input_element.cloneNode());
|
||||
new_row.insertCell(0).appendChild(input_element.cloneNode());
|
||||
new_row.insertCell(0).appendChild(document.createTextNode(tbody.children.length))
|
||||
|
||||
if(findByQuery) {
|
||||
// If this was a hotkey, then focus the new field
|
||||
new_row.children[1].firstChild.focus();
|
||||
}
|
||||
}
|
||||
|
||||
// Support deleting rows from the equipment table
|
||||
@ -224,6 +230,7 @@
|
||||
let input_element = document.createElement("input");
|
||||
input_element.className="uk-input";
|
||||
input_element.type = "text";
|
||||
input_element.autocomplete = "off";
|
||||
|
||||
// Create the delete button
|
||||
let delete_button = document.createElement("a");
|
||||
@ -271,6 +278,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
function listenForHotkeys(e) {
|
||||
if(e.ctrlKey && e.which == 13) {
|
||||
// Determine the active tab
|
||||
let tbl_id = "table#" + document.querySelector(".uk-active").getAttribute("tbl") + " > tbody";
|
||||
addEquipmentTableRow(tbl_id);
|
||||
}
|
||||
}
|
||||
|
||||
// Add event listeners to our table buttons
|
||||
const add_row_buttons = document.querySelectorAll("a.add-row-button");
|
||||
for(let button of add_row_buttons) {
|
||||
@ -288,6 +303,9 @@
|
||||
// Enable sorting for our results table
|
||||
var table_sort = new Tablesort(document.querySelector("table#results-table"), {descending: true});
|
||||
|
||||
// Configure keyboard hotkeys
|
||||
document.onkeyup = listenForHotkeys;
|
||||
|
||||
// Load any existing data from LocalStorage
|
||||
loadExistingData();
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user