예제 #1
0
class TestPointPoolFactory(unittest.TestCase):
    def setUp(self):
        self.sut = PointPoolFactory()
        
    def test_ordered_point_pools(self):
        trees = list(self._create_trees_of_type(["Archetype", "Tradeskill", "Prestige", "TradeskillPrestige", "Warder"]))
        
        points, ordered_point_pools = self.sut.create(trees)
        
        self.assertEqual(ordered_point_pools, ["AA", "Prestige", "Tradeskill", "TradeskillPrestige", "Warder"])
        
    def test_points_has_name_and_max_points(self):
        trees = list(self._create_trees([("Archetype", 20), ("Prestige", 30), ("Tradeskill", 40), ("TradeskillPrestige", 50)]))
        
        points, ordered_point_pools = self.sut.create(trees)
        
        self.assertEqual(points["AA"], { "name": "AA", "max": 350 })
        self.assertEqual(points["Prestige"], { "name": "Prestige", "max": 30 })
        self.assertEqual(points["Tradeskill"], { "name": "Tradeskill", "max": 40 })
        self.assertEqual(points["TradeskillPrestige"], { "name": "Tradeskill Prestige", "max": 50 })
        
    def test_points_warder_has_child_pools(self):
        trees = list(self._create_warder_trees([("War Boar", 20), ("Avian", 30), ("Aquatic", 40)]))
        
        points, ordered_point_pools = self.sut.create(trees)
        
        expected_child_pools = {'Aquatic': {'max': 40, 'name': 'Aquatic'},
                                'Avian': {'max': 30, 'name': 'Avian'},
                                'WarBoar': {'max': 20, 'name': 'War Boar'}}
        
        self.assertEqual(points["Warder"], { "name": "Warder", "child_pools": expected_child_pools })
        
        
    def _create_trees_of_type(self, types):
        for t in types:
            obj = MagicMock()
            obj.type = t
            yield obj
            
    def _create_trees(self, tuples):
        for t in tuples:
            obj = MagicMock()
            obj.name = t[0]
            obj.type = t[0]
            obj.max_points = t[1]
            
            yield obj
            
    def _create_warder_trees(self, tuples):
        for t in tuples:
            obj = MagicMock()
            obj.name = t[0]
            obj.type = "Warder"
            obj.max_points = t[1]
            
            yield obj
예제 #2
0
 def setUp(self):
     self.sut = PointPoolFactory()
예제 #3
0
class TestPointPoolFactory(unittest.TestCase):
    def setUp(self):
        self.sut = PointPoolFactory()

    def test_ordered_point_pools(self):
        trees = list(
            self._create_trees_of_type([
                "Archetype", "Tradeskill", "Prestige", "TradeskillPrestige",
                "Warder"
            ]))

        points, ordered_point_pools = self.sut.create(trees)

        self.assertEqual(
            ordered_point_pools,
            ["AA", "Prestige", "Tradeskill", "TradeskillPrestige", "Warder"])

    def test_points_has_name_and_max_points(self):
        trees = list(
            self._create_trees([("Archetype", 20), ("Prestige", 30),
                                ("Tradeskill", 40),
                                ("TradeskillPrestige", 50)]))

        points, ordered_point_pools = self.sut.create(trees)

        self.assertEqual(points["AA"], {"name": "AA", "max": 350})
        self.assertEqual(points["Prestige"], {"name": "Prestige", "max": 30})
        self.assertEqual(points["Tradeskill"], {
            "name": "Tradeskill",
            "max": 40
        })
        self.assertEqual(points["TradeskillPrestige"], {
            "name": "Tradeskill Prestige",
            "max": 50
        })

    def test_points_warder_has_child_pools(self):
        trees = list(
            self._create_warder_trees([("War Boar", 20), ("Avian", 30),
                                       ("Aquatic", 40)]))

        points, ordered_point_pools = self.sut.create(trees)

        expected_child_pools = {
            'Aquatic': {
                'max': 40,
                'name': 'Aquatic'
            },
            'Avian': {
                'max': 30,
                'name': 'Avian'
            },
            'WarBoar': {
                'max': 20,
                'name': 'War Boar'
            }
        }

        self.assertEqual(points["Warder"], {
            "name": "Warder",
            "child_pools": expected_child_pools
        })

    def _create_trees_of_type(self, types):
        for t in types:
            obj = MagicMock()
            obj.type = t
            yield obj

    def _create_trees(self, tuples):
        for t in tuples:
            obj = MagicMock()
            obj.name = t[0]
            obj.type = t[0]
            obj.max_points = t[1]

            yield obj

    def _create_warder_trees(self, tuples):
        for t in tuples:
            obj = MagicMock()
            obj.name = t[0]
            obj.type = "Warder"
            obj.max_points = t[1]

            yield obj
예제 #4
0
 def setUp(self):
     self.sut = PointPoolFactory()
예제 #5
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))