Fixed visual glitch

This commit is contained in:
Robert 2020-04-13 23:12:21 +02:00
parent aa53dd4b30
commit 5eacd1a630
2 changed files with 25 additions and 10 deletions

View file

@ -7,7 +7,7 @@ It contains the definition of routes and views for the application.
import mysql.connector
import json
import os
from item import Item, production_names, to_json
from item import Item, production_names, to_json, units
from flask import Flask, render_template, request, session
app = Flask(__name__)
@ -31,7 +31,11 @@ def make_tree_view(item):
output += "<input type='submit' value='<' />"
output += "</form>"
output += f"{item.amount} {item.name}"
unit = item.made_in
if unit not in units:
unit = "default"
output += units[unit].format(item.name, item.amount)
if needs_form:
output += "<form method='POST' class='right'>"
@ -42,7 +46,7 @@ def make_tree_view(item):
output += "</span>"
if item.made_in != "natural":
if item.made_in in production_names:
output += "<ul><li><code>"
if production_names.get(item.made_in) != None:
output += f"{production_names[item.made_in]}"
@ -53,7 +57,8 @@ def make_tree_view(item):
output += " can be found naturally."
output += item.get_formatted()
if item.made_in != "natural":
print(item.get_formatted())
if item.made_in in production_names:
output += "</li></ul>"
output += "</li></ul>"

View file

@ -2,10 +2,16 @@ import mysql.connector
import json
import math
units = {
"default" : "{0} x{1}",
"fluid" : "{0} {1}mB"
}
production_names = {
"craftingtable" : "Crafting",
"furnace" : "Smelting",
"stonecutter" : "Stonecutting"
"filling" : "Filling",
"brewingstation" : "Brewing"
}
class Item(object):
@ -85,7 +91,7 @@ class Item(object):
recipe = self.possibilities[self.choice]
self.made_in = recipe["via"]
self.components = []
if self.made_in == "natural":
if self.made_in not in production_names:
return
self.creates = recipe["amount"]
@ -111,7 +117,11 @@ class Item(object):
output += "<input type='submit' value='<' />"
output += "</form>"
output += f"{component.amount} {component.name}"
unit = component.made_in
if component.made_in not in units:
unit = "default"
output += units[unit].format(component.name, component.amount)
if needs_form:
output += "<form method='POST' class='right'>"
@ -121,16 +131,16 @@ class Item(object):
output += "</form>"
output += "</span>"
if component.made_in != "natural":
if component.made_in in production_names:
output += "<ul><li><code>"
if production_names.get(component.made_in) != None:
if component.made_in in production_names:
output += f"{production_names[component.made_in]}"
else:
output += "???"
output += "</code>"
output += component.get_formatted()
if component.made_in != "natural":
if component.made_in in production_names:
output += "</li></ul>"
output += "</li>"
output += "</ul>"