Beispiel #1
0
class TestAACoordMapper(unittest.TestCase):
    def setUp(self):
        self.sut = AACoordMapper()
        
    def test_archetype_coords(self):
        self.assert_archetype_coord_maps_to([1, 0], [63, 15])
        self.assert_archetype_coord_maps_to([4, 1], [183, 92])
        self.assert_archetype_coord_maps_to([7, 2], [303, 157])
        self.assert_archetype_coord_maps_to([10, 3], [423, 222])
        self.assert_archetype_coord_maps_to([13, 4], [543, 287])
        self.assert_archetype_coord_maps_to([13, 5], [543, 352])
        self.assert_archetype_coord_maps_to([13, 6], [543, 417])
        
    def test_regular_coords(self):
        expected_x = {  0: 13, 
                       1: 29, 
                       2: 42, 
                       3: 55, 
                       5: 81, 
                       6: 94, 
                       7: 107, 
                       8: 120, 
                       9: 133, 
                       11: 159, 
                       12: 172, 
                       13: 185, 
                       14: 198, 
                       15: 211, 
                       17: 237, 
                       18: 250, 
                       19: 263, 
                       21: 289, 
                       22: 302, 
                       24: 328, 
                       25: 341, 
                       26: 354, 
                       28: 380, 
                       29: 393, 
                       30: 406, 
                       31: 419, 
                       33: 445, 
                       34: 458, 
                       35: 471, 
                       37: 497, 
                       38: 510, 
                       41: 549, 
                       42: 562}
        
        expected_y = {   0: 15,
                       1: 40, 
                       3: 82, 
                       4: 103, 
                       5: 124, 
                       6: 145, 
                       7: 166, 
                       8: 187, 
                       9: 208, 
                       11: 250, 
                       13: 292, 
                       14: 313, 
                       15: 334, 
                       16: 355, 
                       17: 376, 
                       19: 418}
        
        all_coords = [[x, y] for x in expected_x.keys() for y in expected_y.keys()]
        
        for x, y in iter(all_coords):
            aa = MagicMock()
            aa.coords = [x, y]
            self.sut.map_coords(aa, "AnyOtherTree")
            self.assertEqual(aa.coords[0], expected_x[x])
            self.assertEqual(aa.coords[1], expected_y[y])
        
    def assert_archetype_coord_maps_to(self, coords, expected_coords):
        aa = MagicMock()
        aa.coords = coords
        
        self.sut.map_coords(aa, "Archetype")
        
        self.assertEqual(aa.coords, expected_coords)
Beispiel #2
0
 def setUp(self):
     self.sut = AACoordMapper()
Beispiel #3
0
    def run(self):
        start_time = datetime.datetime.now()

        logger = ConsoleLogger()
        logger.log('Started')

        cache_dir_path = os.path.abspath('./soe/cached_data')
        logger.log('Cache path: ' + cache_dir_path)

        data_provider = CachedDataProvider(SonyDataProvider(UrlReader(logger)),
                                           FileDataCache(cache_dir_path))
        spell_effect_formatter = SpellEffectFormatter()
        coord_mapper = AACoordMapper()

        aa_factory = AAFactory(data_provider, spell_effect_formatter,
                               coord_mapper, logger)
        tree_factory = TreeFactory(data_provider, aa_factory, logger)
        point_pool_factory = PointPoolFactory()
        class_factory = EQ2ClassFactory(data_provider, tree_factory,
                                        point_pool_factory, logger)

        json_writer = JsonFileWriter(logger)

        build_dir = os.path.abspath('../../build')

        icon_output_path = os.path.join(build_dir, 'icons')
        self._ensure_dir_exists(icon_output_path)
        icon_downloader = IconDownloader(data_provider, icon_output_path,
                                         logger)

        image_manipulator = ImageManipulator()

        sprite_output_path = os.path.join(build_dir, 'sprites')
        self._ensure_dir_exists(sprite_output_path)
        sprite_image_generator = SpriteImageGenerator(image_manipulator,
                                                      icon_output_path,
                                                      sprite_output_path,
                                                      logger)

        classes = list(class_factory.create_classes())

        tree_output_dir = os.path.join('.', 'output')
        tree_minified_output_dir = os.path.join('.', 'output_min')

        icon_size = 42
        icon_padding = 1
        sprite_css_generator = SpriteCssGenerator()

        for c in classes:
            icon_downloader.download_all(c)
            sprite_image_generator.generate(c, icon_size, icon_padding)

            filename = c.name + '.json'
            json_writer.write(c.to_dict(),
                              os.path.join(tree_output_dir, filename),
                              indent=3)
            json_writer.write(c.to_dict(),
                              os.path.join(tree_minified_output_dir, filename))

            if c.name == 'Beastlord':
                beastlord_css = sprite_css_generator.generate_css(
                    c.trees, icon_size, icon_padding, '.Beastlord ')
                self._write_to_text_file(
                    os.path.join(sprite_output_path, "sprites-beastlord.css"),
                    beastlord_css)

        css = sprite_css_generator.generate_css(classes[0].trees, icon_size,
                                                icon_padding)
        self._write_to_text_file(
            os.path.join(sprite_output_path, "sprites.css"), css)

        end_time = datetime.datetime.now()
        logger.log('Done in {0}'.format(end_time - start_time))