diff --git a/MinecraftRecipeViewer/app.py b/MinecraftRecipeViewer/app.py index ea88067..205706a 100644 --- a/MinecraftRecipeViewer/app.py +++ b/MinecraftRecipeViewer/app.py @@ -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 += "" output += "" - 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 += "
" @@ -42,7 +46,7 @@ def make_tree_view(item): output += "" - if item.made_in != "natural": + if item.made_in in production_names: output += "" output += "" diff --git a/MinecraftRecipeViewer/item.py b/MinecraftRecipeViewer/item.py index aaec9bc..835a662 100644 --- a/MinecraftRecipeViewer/item.py +++ b/MinecraftRecipeViewer/item.py @@ -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 += "" output += "" - 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 += "
" @@ -121,16 +131,16 @@ class Item(object): output += "
" output += "" - if component.made_in != "natural": + if component.made_in in production_names: output += "" output += "" output += ""