diff --git a/orna_tools.py b/orna_tools.py new file mode 100644 index 0000000..5837b0e --- /dev/null +++ b/orna_tools.py @@ -0,0 +1,67 @@ +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=False): + # 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: + for cw in eq_chestware: + for lw in eq_legwear: + 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] +] +""" diff --git a/templates/index.html b/templates/index.html index 1080b80..40e486f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -19,10 +19,13 @@
+
+
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.
+
+
-
+ + + +
+ © by binaryatrocity +    |    + Created for the Legends of Palisma Kingdom +    |    + OrnaRPG +