Esempio n. 1
0
 def test_koe(self):
     bits = Bits()
     map_dir = bits.gas_dir.get_subdir('world').get_subdir(
         'maps').get_subdir('map_world')
     m = Map(map_dir, bits)
     self.assertIsInstance(m, Map)
     self.assertEqual(map_dir, m.gas_dir)
     self.assertEqual('"Kingdom of Ehb"', m.get_data().screen_name)
     self.assertEqual(81, len(m.get_regions()))
Esempio n. 2
0
def check_map_vs_map(m1: Map, m2: Map):
    node_ids1 = set(m1.get_all_node_ids())
    node_ids2 = set(m2.get_all_node_ids())
    common_node_ids = node_ids1.intersection(node_ids2)
    for node_id in common_node_ids:
        print(node_id)
    assert len(
        common_node_ids
    ) == 0, f'{m1.get_name()} contains {len(common_node_ids)} common node ids with {m2.get_name()}!'
Esempio n. 3
0
def create_map(name, screen_name):
    bits = Bits()
    assert name not in bits.maps
    m = bits.maps[name] = Map(
        GasDir(os.path.join(bits.gas_dir.path, 'world', 'maps', name)), bits)
    data = Map.Data(name, screen_name)
    data.dev_only = False
    data.timeofday = '0h0m'
    data.use_node_mesh_index = True
    data.use_player_journal = False
    data.camera.azimuth = 70.0
    data.camera.distance = 13.0
    data.camera.position = '0,0,0,0x0'
    m.data = data
    m.save()
Esempio n. 4
0
 def test_init_new(self):
     bits = Bits()
     map_dir_path = os.path.join(bits.gas_dir.path, 'world', 'maps',
                                 'gaspy-unit-test-map')
     self.assertFalse(os.path.exists(map_dir_path))
     m = Map(GasDir(map_dir_path), bits)
     self.assertIsInstance(m, Map)
Esempio n. 5
0
def check_conflicting_region_ids(m: Map, region_data: Region.Data):
    for region in m.get_regions().values():
        assert region.get_data(
        ).id != region_data.id, f'Region GUID {region_data.id} already exists in map'
        # assert region.get_data().mesh_range != region_data.mesh_range, f'Region mesh range {region_data.mesh_range} already exists in map'  # doesn't matter
        assert region.get_data(
        ).scid_range != region_data.scid_range, f'Region scid range {region_data.scid_range} already exists in map'
Esempio n. 6
0
def copy_region(old_region: Region, to_map: Map) -> Region:
    src = old_region.gas_dir.path
    dst = os.path.join(to_map.gas_dir.path, 'regions',
                       old_region.gas_dir.dir_name)
    shutil.copytree(src, dst)
    time.sleep(0.1)  # shutil...
    to_map.gas_dir.clear_cache()
    return to_map.get_region(old_region.get_name())
Esempio n. 7
0
def check_map_vs_region(m1: Map, r2: Region):
    node_ids1 = set(m1.get_all_node_ids())
    node_ids2 = set(r2.get_node_ids())
    common_node_ids = node_ids1.intersection(node_ids2)
    for node_id in common_node_ids:
        print(node_id)
    assert len(
        common_node_ids
    ) == 0, f'{m1.get_name()} contains {len(common_node_ids)} common node ids with {r2.map.get_name()}.{r2.get_name()}!'
Esempio n. 8
0
def handle_multi_world_levels(from_map: Map, to_map: Map, new_region: Region):
    if not to_map.is_multi_world():
        if not from_map.is_multi_world():
            pass  # easy
        else:
            print(
                f'Note: Imported region is multi-world but target map is not. Removing world levels.'
            )
            rem_region_world_levels(new_region)
    else:
        if not from_map.is_multi_world():
            print(
                f'Warning: Target map is multi-world but imported region is not! Please add manually.'
            )  # add_region_world_levels is not really working
        else:
            if are_world_levels_compatible(from_map.get_data().worlds,
                                           to_map.get_data().worlds):
                pass  # phew
            else:
                print(
                    f'Warning: Both maps are multi-world, but their world levels differ! Good luck sorting that out.'
                )
Esempio n. 9
0
 def test_save_and_delete(self):
     bits = Bits()
     map_dir_path = os.path.join(bits.gas_dir.path, 'world', 'maps',
                                 'gaspy-unit-test-map')
     self.assertFalse(os.path.exists(map_dir_path))
     m = Map(
         GasDir(map_dir_path), bits,
         Map.Data(name='gaspy-unit-test-map',
                  screen_name='GasPy UnitTest Map!'))
     m.save()
     self.assertTrue(os.path.exists(map_dir_path))
     self.assertTrue(os.path.exists(os.path.join(map_dir_path, 'main.gas')))
     m.delete()
     self.assertFalse(os.path.exists(map_dir_path))
Esempio n. 10
0
def check_map(m: Map):
    node_ids = m.get_all_node_ids()
    dupes = dupes_in_list(node_ids)
    for node_id in dupes:
        print(node_id)
    assert len(dupes) == 0, f'{m.get_name()} contains duplicate node ids!'
Esempio n. 11
0
def add_map_world_levels(_map: Map):
    for region_name, region in _map.get_regions().items():
        print(region_name)
        add_region_world_levels(region)
Esempio n. 12
0
def convert_map(m: Map):
    if not m.get_data().use_node_mesh_index:
        m.get_data().use_node_mesh_index = True
        m.save()
        print(f'Converted map {m.get_data().screen_name} to NMI')