Esempio n. 1
0
def get_ko_data():
    item_keys = ["#", "Singular", "ItemUICategory"]
    items = csv_util.get_ko_table("Item", item_keys)

    tackle = {}
    fishes = {}
    for id, item in items.items():
        # no plurals
        if item["ItemUICategory"] == str(tackle_id):
            tackle[int(id)] = item["Singular"]
        elif item["ItemUICategory"] == str(seafood_id):
            fishes[int(id)] = item["Singular"]

    # Sorry, this is an unfortunate duplication of get_fish_data
    # xivapi has data in a different way than the csvs do.
    # This does mean that there are more keys here.
    place_keys = ["#", "Name"]
    place_names = csv_util.get_ko_table("PlaceName", place_keys)

    spot_keys = ["#", "PlaceName", "Item[0]"]
    spots = csv_util.get_ko_table("FishingSpot", spot_keys)

    places = {}
    for id, spot in spots.items():
        place_id = spot["PlaceName"]
        if place_id == "0":
            continue
        places[int(place_id)] = place_names[place_id]["Name"]

    return {"ko": places}, {"ko": fishes}, {"ko": tackle}
Esempio n. 2
0
import coinach
import csv
import csv_util
import os

_OUTPUT_FILE = "pet_names.ts"

if __name__ == "__main__":
    keys = ["Name"]

    tables = {}
    for lang in ["en", "fr", "de", "ja"]:
        reader = coinach.CoinachReader(verbose=True)
        tables[lang] = csv_util.make_map(reader.exd("Pet", lang=lang), keys)
    tables["cn"] = csv_util.get_cn_table("Pet", keys)
    tables["ko"] = csv_util.get_ko_table("Pet", keys)

    tables = {
        lang: [name for name in table.keys() if name]
        for lang, table in tables.items()
    }

    writer = coinach.CoinachWriter(verbose=True)
    header = """import { Lang } from '../types/global';

type PetData = {
  [name in Lang]: readonly string[];
};"""
    writer.writeTypeScript(
        filename=os.path.join("resources", _OUTPUT_FILE),
        scriptname=os.path.basename(os.path.abspath(__file__)),