def calculate_items(adjusted_temperature, gender, intensity, conditions, time_of_day): """ Actually does the calculating""" clothing_config = ConfigManager.get_clothing_config_data() clothes = {} for bodyPart in clothing_config: #print("--" + bodyPart + "--") for item in clothing_config[bodyPart]: if item["min_temp"] <= adjusted_temperature <= item["max_temp"]: if "gender" in item: if item["gender"] == gender: #print(item["title"] + " added with special gender!") clothes[bodyPart] = item["title"] clothes[bodyPart + "_name"] = item["name"] break elif "intensity" in item: if item["intensity"].find(intensity) > -1: # print(item["title"] + " added with special intensity!") clothes[bodyPart] = item["title"] clothes[bodyPart + "_name"] = item["name"] break elif "conditions" in item: if item["conditions"].find(conditions) > -1: #print(item["title"] + " added with special conditions!") clothes[bodyPart] = item["title"] clothes[bodyPart + "_name"] = item["name"] break elif "special" in item: if item["special"] == "sunny": if conditions.find("Clear") > -1 and time_of_day == "day": # print(item["title"] + " added with special special sunny!") clothes[bodyPart] = item["title"] clothes[bodyPart + "_name"] = item["name"] break elif item["special"] == "not_rain": if conditions.find("Rain") == -1: # print(item["title"] + " added with special special not_rain!") clothes[bodyPart] = item["title"] clothes[bodyPart + "_name"] = item["name"] break elif item["special"] == "singlet": if intensity == "race": clothes[bodyPart] = item["title"] clothes[bodyPart + "_name"] = item["name"] break else: # print(item["title"] + " added normally!") clothes[bodyPart] = item["title"] clothes[bodyPart + "_name"] = item["name"] break return clothes
def get_bodyparts(): # returns list of body parts that have clothing associated data = {} ary = [] clothingConfig = ConfigManager.get_clothing_config_data() if "error" not in clothingConfig: for bodypart in clothingConfig: ary.append( bodypart) data["data"] = ary return data return {"error": "Error getting bodyparts"}, 500
def get_all_clothing(): # read config and return clothing titles # UI can use this to build stuff if it needs it clothingConfig = ConfigManager.get_clothing_config_data() if "error" not in clothingConfig: data = {} info = {} for bodypart in clothingConfig: for clothing in clothingConfig[bodypart]: info[clothing["name"]] = {} info[clothing["name"]]["bodypart"] = bodypart info[clothing["name"]]["title"] = clothing["title"] data["data"] = info return data return {"error": "Error getting all clothing"}, 500