def get_productions_of_city(cursor, cityname): productions = sourcesDict.copy() for sourceType in productions: productions[sourceType] = CRUD.get_column(cursor, "CityProductions", "cityname", cityname, sourceType) return productions
def get_city_source_limits(cursor, cityname): limit = sourcesDict.copy() for sourceType in limit: limit[sourceType] = CRUD.get_column(cursor, "CityLimits", "cityname", cityname, sourceType) return limit
def get_base_building_increment(cursor, buildingname): baseincrement = sourcesDict.copy() for sourceType in baseincrement: baseincrement[sourceType] = CRUD.get_column(cursor, "BuildingIncrementEffects", "buildingname", buildingname, sourceType) return baseincrement
def get_base_building_limits(cursor, buildingname): baselimits = sourcesDict.copy() print("baselimits", baselimits) for sourceType in baselimits: baselimits[sourceType] = CRUD.get_column(cursor, "BuildingLimitEffects", "buildingname", buildingname, sourceType) print("returning limits", baselimits) return baselimits
def get_base_building_productions(cursor, buildingname): cursor.execute("""select stype, value from public.BuildingEffects where buildingname=%s and etype='inc'""", (buildingname,)) baseproductions = cursor.fetchall() baseproductionsDict = sourcesDict.copy() for (stype, value) in baseproductions: baseproductionsDict[stype] = value return baseproductionsDict
def get_sources_of_user(cursor, username): cursor.execute("""select stype,value from public.sources where username=%s""", (username,)) sourcesUser = cursor.fetchall() sourcesD = sourcesDict.copy() for (stype, value) in sourcesUser: sourcesD[stype] += value return sourcesD
def get_user_source_limits(cursor, username): cursor.execute("""select stype,value from public.limits where username=%s""", (username,)) limitsUser = cursor.fetchall() # print("limit user", limitsUser) limitsDict = sourcesDict.copy() for (stype, value) in limitsUser: limitsDict[stype] += value # print("limit return", limitsDict) return limitsDict
def update_all_city_productions(cursor): all_cities = get_all_cities(cursor) for cityname in all_cities: baseproductions = sourcesDict.copy() for sourceType in baseproductions: baseproductions[sourceType] = CRUD.get_column(cursor, "CityBaseProductions", "cityname", cityname, sourceType) buildings = get_buildings_of_city(cursor, cityname) productions = baseproductions for building in buildings: prods = get_building_productions(cursor, building) for prod in prods: productions[prod] += prods[prod] #endfor #endfor update_city_productions(cursor, cityname, productions)
def get_sources_of_city(cursor, cityname): sources = sourcesDict.copy() for source in sources: sources[source] = CRUD.get_column(cursor, "citysources", "cityname", cityname, source) return sources