def build_locations(session: sqlalchemy.orm.Session, mhdata): for order_id, entry in enumerate(mhdata.location_map.values()): location_name = entry['name']['en'] for language in cfg.supported_languages: session.add( db.Location(id=entry.id, order_id=order_id, lang_id=language, name=entry.name(language))) for item_entry in entry['items']: item_lang = item_entry['item_lang'] item_name = item_entry['item'] item_id = mhdata.item_map.id_of(item_lang, item_name) session.add( db.LocationItem(location_id=entry.id, area=item_entry['area'], rank=item_entry['rank'], item_id=item_id, stack=item_entry['stack'], percentage=item_entry['percentage'], nodes=item_entry['nodes'])) print("Built locations")
def build_locations(session: sqlalchemy.orm.Session, mhdata): for location_id, entry in mhdata.location_map.items(): location_name = entry['name']['en'] for language in supported_languages: session.add( db.Location(id=location_id, lang_id=language, name=entry.name(language))) for item_entry in entry['items']: item_lang = item_entry['item_lang'] item_name = item_entry['item'] item_id = mhdata.item_map.id_of(item_lang, item_name) ensure( item_id, f"item {item_name} in monster {location_name} does not exist") session.add( db.LocationItem( location_id=location_id, rank=item_entry['rank'], item_id=item_id, stack=item_entry['stack'], percentage=item_entry['percentage'], )) print("Built locations")
def build_locations(session: sqlalchemy.orm.Session, mhdata, item_tracker: ItemTracker): for order_id, entry in enumerate(mhdata.location_map.values()): location_name = entry['name']['en'] for language in cfg.supported_languages: session.add( db.Location( id=entry.id, order_id=order_id, lang_id=language, name=get_translated(entry, 'name', language), )) for item_entry in entry['items']: item_lang = item_entry['item_lang'] item_name = item_entry['item'] item_id = mhdata.item_map.id_of(item_lang, item_name) item_tracker.mark_encountered_id(item_id) session.add( db.LocationItem(location_id=entry.id, area=item_entry['area'], rank=item_entry['rank'], item_id=item_id, stack=item_entry['stack'], percentage=item_entry['percentage'], nodes=item_entry['nodes'])) for camp in entry['camps']: for language in cfg.supported_languages: session.add( db.LocationCamp(location_id=entry.id, lang_id=language, name=get_translated( camp, 'name', language), area=camp['area'])) print("Built locations")