enc_bin_gen = generator(
    encounter_py,
    arguments: [ '@INPUT@', '@OUTPUT@', ],
    output: '@BASENAME@.bin'
)

pl_enc_data_srcs = files(
    'encounters_canalave_city.json',
    'encounters_eterna_city.json',
    'encounters_pastoria_city.json',
    'encounters_sunyshore_city.json',
    'encounters_pokemon_league.json',
    'encounters_oreburgh_mine_b1f.json',
    'encounters_oreburgh_mine_b2f.json',
    'encounters_valley_windworks_outside.json',
    'encounters_eterna_forest.json',
    'encounters_fuego_ironworks_outside.json',
    'encounters_mt_coronet_1f_south.json',
    'encounters_mt_coronet_2f.json',
    'encounters_mt_coronet_3f.json',
    'encounters_mt_coronet_outside_north.json',
    'encounters_mt_coronet_outside_south.json',
    'encounters_mt_coronet_4f_rooms_1_and_2.json',
    'encounters_mt_coronet_4f_room_3.json',
    'encounters_mt_coronet_5f.json',
    'encounters_mt_coronet_6f.json',
    'encounters_mt_coronet_1f_tunnel_room.json',
    'encounters_mt_coronet_1f_north_room_2.json',
    'encounters_mt_coronet_1f_north_room_1.json',
    'encounters_mt_coronet_b1f.json',
    'encounters_great_marsh_1.json',
    'encounters_great_marsh_2.json',
    'encounters_great_marsh_3.json',
    'encounters_great_marsh_4.json',
    'encounters_great_marsh_5.json',
    'encounters_great_marsh_6.json',
    'encounters_solaceon_ruins_maniac_tunnel_room.json',
    'encounters_solaceon_ruins_room_2_northeast_dead_end.json',
    'encounters_solaceon_ruins_room_1_northwest_dead_end.json',
    'encounters_solaceon_ruins_room_2.json',
    'encounters_solaceon_ruins_room_1_southeast_dead_end.json',
    'encounters_solaceon_ruins_room_3.json',
    'encounters_solaceon_ruins_room_2_southeast_dead_end.json',
    'encounters_solaceon_ruins_room_6_southeast_dead_end.json',
    'encounters_solaceon_ruins_room_5_southwest_dead_end.json',
    'encounters_solaceon_ruins_room_3_northwest_dead_end.json',
    'encounters_solaceon_ruins_room_3_southwest_dead_end.json',
    'encounters_solaceon_ruins_room_4.json',
    'encounters_solaceon_ruins_room_6.json',
    'encounters_solaceon_ruins_room_5.json',
    'encounters_solaceon_ruins_room_7.json',
    'encounters_solaceon_ruins_room_4_southeast_dead_end.json',
    'encounters_solaceon_ruins_room_6_northwest_dead_end.json',
    'encounters_solaceon_ruins_room_5_southeast_deadend.json',
    'encounters_victory_road_1f.json',
    'encounters_victory_road_2f.json',
    'encounters_victory_road_b1f.json',
    'encounters_victory_road_1f_room_2.json',
    'encounters_victory_road_1f_room_1.json',
    'encounters_victory_road_1f_room_3.json',
    'encounters_ravaged_path.json',
    'encounters_oreburgh_gate_1f.json',
    'encounters_oreburgh_gate_b1f.json',
    'encounters_stark_mountain_outside.json',
    'encounters_stark_mountain_room_1.json',
    'encounters_stark_mountain_room_2.json',
    'encounters_sendoff_spring.json',
    'encounters_turnback_cave_entrance.json',
    'encounters_turnback_cave_pillar_room.json',
    'encounters_turnback_cave_giratina_room.json',
    'encounters_turnback_cave_pillar_1_room_1.json',
    'encounters_turnback_cave_pillar_1_room_2.json',
    'encounters_turnback_cave_pillar_1_room_3.json',
    'encounters_turnback_cave_pillar_1_room_4.json',
    'encounters_turnback_cave_pillar_1_room_5.json',
    'encounters_turnback_cave_pillar_1_room_6.json',
    'encounters_turnback_cave_pillar_2_room_1.json',
    'encounters_turnback_cave_pillar_2_room_2.json',
    'encounters_turnback_cave_pillar_2_room_3.json',
    'encounters_turnback_cave_pillar_2_room_4.json',
    'encounters_turnback_cave_pillar_2_room_5.json',
    'encounters_turnback_cave_pillar_2_room_6.json',
    'encounters_turnback_cave_pillar_3_room_1.json',
    'encounters_turnback_cave_pillar_3_room_2.json',
    'encounters_turnback_cave_pillar_3_room_3.json',
    'encounters_turnback_cave_pillar_3_room_4.json',
    'encounters_turnback_cave_pillar_3_room_5.json',
    'encounters_turnback_cave_pillar_3_room_6.json',
    'encounters_unknown_533.json',
    'encounters_unknown_534.json',
    'encounters_unknown_535.json',
    'encounters_unknown_536.json',
    'encounters_unknown_537.json',
    'encounters_unknown_538.json',
    'encounters_unknown_539.json',
    'encounters_unknown_540.json',
    'encounters_unknown_541.json',
    'encounters_unknown_542.json',
    'encounters_unknown_543.json',
    'encounters_unknown_544.json',
    'encounters_unknown_545.json',
    'encounters_unknown_546.json',
    'encounters_unknown_547.json',
    'encounters_unknown_548.json',
    'encounters_unknown_549.json',
    'encounters_unknown_550.json',
    'encounters_unknown_551.json',
    'encounters_unknown_552.json',
    'encounters_unknown_553.json',
    'encounters_unknown_554.json',
    'encounters_unknown_555.json',
    'encounters_unknown_556.json',
    'encounters_unknown_557.json',
    'encounters_snowpoint_temple_1f.json',
    'encounters_snowpoint_temple_b1f.json',
    'encounters_snowpoint_temple_b2f.json',
    'encounters_snowpoint_temple_b3f.json',
    'encounters_snowpoint_temple_b4f.json',
    'encounters_snowpoint_temple_b5f.json',
    'encounters_wayward_cave_1f.json',
    'encounters_wayward_cave_b1f.json',
    'encounters_ruin_maniac_cave_short.json',
    'encounters_ruin_maniac_cave_long.json',
    'encounters_maniac_tunnel.json',
    'encounters_trophy_garden.json',
    'encounters_iron_island.json',
    'encounters_iron_island_1f.json',
    'encounters_iron_island_b1f_left_room.json',
    'encounters_iron_island_b1f_right_room.json',
    'encounters_iron_island_b2f_right_room.json',
    'encounters_iron_island_b2f_left_room.json',
    'encounters_iron_island_b3f.json',
    'encounters_old_chateau.json',
    'encounters_old_chateau_dining_area.json',
    'encounters_old_chateau_side_rooms.json',
    'encounters_old_chateau_corridor.json',
    'encounters_old_chateau_back_west_room.json',
    'encounters_old_chateau_back_middle_west_room.json',
    'encounters_old_chateau_back_middle_room.json',
    'encounters_old_chateau_back_middle_east_room.json',
    'encounters_old_chateau_back_east_room.json',
    'encounters_lake_verity_low_water.json',
    'encounters_lake_verity.json',
    'encounters_lake_valor.json',
    'encounters_lake_acuity.json',
    'encounters_valor_lakefront.json',
    'encounters_acuity_lakefront.json',
    'encounters_route_201.json',
    'encounters_route_202.json',
    'encounters_route_203.json',
    'encounters_route_204_south.json',
    'encounters_route_204_north.json',
    'encounters_route_205_south.json',
    'encounters_route_205_north.json',
    'encounters_route_206.json',
    'encounters_route_207.json',
    'encounters_route_208.json',
    'encounters_route_209.json',
    'encounters_route_209_lost_tower_1f.json',
    'encounters_route_209_lost_tower_2f.json',
    'encounters_route_209_lost_tower_3f.json',
    'encounters_route_209_lost_tower_4f.json',
    'encounters_route_209_lost_tower_5f.json',
    'encounters_route_210_south.json',
    'encounters_route_210_north.json',
    'encounters_route_211_west.json',
    'encounters_route_211_east.json',
    'encounters_route_212_north.json',
    'encounters_route_212_south.json',
    'encounters_route_213.json',
    'encounters_route_214.json',
    'encounters_route_215.json',
    'encounters_route_216.json',
    'encounters_route_217.json',
    'encounters_route_218.json',
    'encounters_route_219.json',
    'encounters_route_221.json',
    'encounters_route_222.json',
    'encounters_route_224.json',
    'encounters_route_225.json',
    'encounters_route_227.json',
    'encounters_route_228.json',
    'encounters_route_229.json',
    'encounters_twinleaf_town.json',
    'encounters_celestic_town.json',
    'encounters_resort_area.json',
    'encounters_route_220.json',
    'encounters_route_223.json',
    'encounters_route_226.json',
    'encounters_route_230.json',
)

pl_enc_data_order = files('encounters.order')

pl_enc_tbl_narc = custom_target('pl_enc_data.narc',
    output: 'pl_enc_data.narc',
    input: [
        enc_bin_gen.process(pl_enc_data_srcs, env: json2bin_env),
        pl_enc_data_order
    ],
    depends: [ py_consts_generators ],
    command: [
        narc_exe, 'create',
        '--order', pl_enc_data_order,
        '--output', '@OUTPUT@',
        '@PRIVATE_DIR@',
    ]
)

enc_ex_er_bin_gen = generator(
    encdata_ex_elusive_rod_py,
    arguments: [ '@INPUT@', '@OUTPUT0@', '@OUTPUT1@', ],
    output: [
        '@BASENAME@_species.bin',
        '@BASENAME@_tiles.bin',
    ]
)
enc_ex_ht_bin_gen = generator(
    encdata_ex_honey_trees_py,
    arguments: [ '@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@', ],
    output: [
        '@BASENAME@_common.bin',
        '@BASENAME@_uncommon.bin',
        '@BASENAME@_rare.bin',
    ]
)
enc_ex_tg_bin_gen = generator(
    encdata_ex_trophy_garden_py,
    arguments: [ '@INPUT@', '@OUTPUT@', ],
    output: '@BASENAME@_dailies.bin'
)
enc_ex_gm_bin_gen = generator(
    encdata_ex_great_marsh_py,
    arguments: [ '@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@', ],
    output: [
        '@BASENAME@_natdex.bin',
        '@BASENAME@_local.bin',
        '@BASENAME@_coords.bin',
    ]
)

encdata_ex_elusive_rod_src = files('encounters_mt_coronet_b1f.json')
encdata_ex_honey_trees_src = files('encounters_honey_tree.json')
encdata_ex_trophy_garden_src = files('encounters_trophy_garden.json')
encdata_ex_great_marsh_src = files('encounters_great_marsh_lookout.json')

encdata_ex_order = files('encdata_ex.order')

encdata_ex_narc = custom_target('encdata_ex.narc',
    output: 'encdata_ex.narc',
    input: [
        enc_ex_er_bin_gen.process(encdata_ex_elusive_rod_src, env: json2bin_env),
        enc_ex_ht_bin_gen.process(encdata_ex_honey_trees_src, env: json2bin_env),
        enc_ex_tg_bin_gen.process(encdata_ex_trophy_garden_src, env: json2bin_env),
        enc_ex_gm_bin_gen.process(encdata_ex_great_marsh_src, env: json2bin_env),
        encdata_ex_order
    ],
    env: json2bin_env,
    depends: [ py_consts_generators ],
    command: [
        narc_exe, 'create',
        '--order', encdata_ex_order,
        '--output', '@OUTPUT@',
        '@PRIVATE_DIR@',
    ]
)

zukan_enc_platinum_srcs = encdata_ex_elusive_rod_src
zukan_enc_platinum_srcs += encdata_ex_honey_trees_src
zukan_enc_platinum_srcs += encdata_ex_trophy_garden_src
zukan_enc_platinum_srcs += encdata_ex_great_marsh_src
zukan_enc_platinum_srcs += pl_enc_data_srcs

pokedex_enc_platinum_narc = custom_target('zukan_enc_platinum.narc',
    output: 'zukan_enc_platinum.narc',
    input: zukan_enc_platinum_srcs,
    env: json2bin_env,
    depends: [ py_consts_generators ],
    command: [
        make_pokedex_enc_platinum_py,
        '--narc', narc_exe,
        '--source-dir', '@CURRENT_SOURCE_DIR@',
        '--private-dir', '@PRIVATE_DIR@',
        '--output-dir', '@OUTDIR@',
        '--coronet-file', '@INPUT0@',
        '--honey-file', '@INPUT1@',
        '--trophy-file', '@INPUT2@',
        '--marsh-file', '@INPUT3@',
        zukan_enc_platinum_srcs
    ]
)

nitrofs_files += pl_enc_tbl_narc
nitrofs_files += encdata_ex_narc
nitrofs_files += pokedex_enc_platinum_narc
