Пример #1
0
    def testGenerate(self):
        """
        Test generating new Overview-sheet from template, then assert that the
        sheet really exists and has generated content in it.
        """
        modifier1 = Modifier('aa')
        modifier2 = Modifier('bb')
        modifier3 = Modifier('cc')
        self.overview.modifiers = [modifier1, modifier2, modifier3]

        modAct1 = Action('attack 1', phases=2, hitPhase=1, default=True)
        modAct1.addModifier(0, Modifier('aa'))
        modAct1.addModifier(1, Modifier('bb'))
        self.overview.addAction(modAct1)

        formatter = OverviewFormatter(self.overview)
        formatter.generate(1)

        sheet = Sheet.getByName(names.getOverviewName(self.sheetName))
        data = cursor.getSheetContent(sheet)
        self.assertEqual(
            data, [['', '', '', '', '', '', '', '', '', '', ''],
                   [
                       'Action Name', 'Hit', 'Frames', 'Phase', 'DEF', 'aa',
                       'bb', 'cc', 'Notes 1', 'Notes 2', 'Notes 3'
                   ], ['attack 1', '', '', '0', 'x', 'x', '', '', '', '', ''],
                   ['attack 1', 'x', '', '1', 'x', '', 'x', '', '', '', '']])
Пример #2
0
 def testAddModifier(self):
     modifier1 = Modifier('mods1')
     modifier2 = Modifier('mods2')
     overview = Overview('test')
     overview.addModifier(modifier1)
     overview.addModifier(modifier2)
     self.assertEqual(overview.modifiers, [modifier1, modifier2])
Пример #3
0
 def testFormatHeader(self):
     self.overview.modifiers = [Modifier('aa'), Modifier('bb')]
     formatter = OverviewFormatter(self.overview)
     data = formatter.formatHeader()
     self.assertEqual(data, [
         'Action Name', 'Hit', 'Frames', 'Phase', 'DEF', 'aa', 'bb',
         'Notes 1', 'Notes 2', 'Notes 3'
     ])
Пример #4
0
 def testFilteringDetails(self):
     """
     Test that filtered first detail includes all possible modifier combinations.
     """
     filteredDetails = filter(
         lambda detail: detail.action.name == self.names[0],
         DetailsIterator(self.actions))
     filteredDetails = list(filteredDetails)
     self.assertEqual(len(filteredDetails), 3)
     self.assertEqual(filteredDetails[0].modifiers, (Modifier('WPN1'), ))
     self.assertEqual(filteredDetails[1].modifiers, (Modifier('WPN2'), ))
     self.assertEqual(filteredDetails[2].modifiers,
                      (Modifier('WPN1'), Modifier('WPN2')))
Пример #5
0
    def testFormatModifiers(self):
        modifier1 = Modifier('aa')
        modifier2 = Modifier('bb')
        self.overview.modifiers = [modifier1, modifier2]

        modAct1 = Action('attack 1', phases=2, hitPhase=1, default=True)
        modAct1.addModifier(0, Modifier('aa'))
        modAct1.addModifier(1, Modifier('bb'))
        self.overview.addAction(modAct1)

        formatter = OverviewFormatter(self.overview)
        data = formatter.formatActions()
        self.assertEqual(
            data, [['attack 1', '', '', '0', 'x', 'x', '', '', '', ''],
                   ['attack 1', 'x', '', '1', 'x', '', 'x', '', '', '']])
Пример #6
0
 def setUp(self):
     super().setUp()
     self.overview = Overview('test sheet')
     self.overview.modifiers = [
         Modifier('aa'), Modifier('bb'),
         Modifier('cc')
     ]
     self.action = Action('attack 1', phases=2, hitPhase=1, default=True)
     self.action.addModifier(0, Modifier('aa'))
     self.action.addModifier(1, Modifier('bb'))
     self.action.addNote(0, "note 1")
     self.action.addNote(0, "note 2")
     self.action.addNote(0, "note 3")
     self.action.setNotes(1, ["note 1", "note 2", "note 3"])
     self.action.setPhaseFrames(0, 1)
     self.action.setPhaseFrames(1, 2)
     self.overview.addAction(self.action)
Пример #7
0
 def _modifiersFromRow(self, row):
     mods = row[self.modifierStartColumn:self.modifierEndColumn]
     modifierNames = self.dataHeader[self.modifierStartColumn:self.
                                     modifierEndColumn]
     modifiers = []
     for index, value in enumerate(mods):
         if value != '':
             modifiers.append(Modifier(modifierNames[index]))
     return modifiers
Пример #8
0
 def _parseModifiers(self, modifierCell):
     """
     Parse string of modifier names to list of Modifier instances.
     For example 'WPN1 WPN2' will be two Modifier instances.
     """
     modifiers = []
     pattern = re.compile(r'\b\w+\b')
     for name in re.findall(pattern, modifierCell):
         modifiers.append(Modifier(name))
     return modifiers
Пример #9
0
    def testFormat(self):
        modifier1 = Modifier('aa')
        modifier2 = Modifier('bb')
        modifier3 = Modifier('cc')
        self.overview.modifiers = [modifier1, modifier2, modifier3]

        modAct1 = Action('attack 1', phases=2, hitPhase=1, default=True)
        modAct1.addModifier(0, Modifier('aa'))
        modAct1.addModifier(1, Modifier('bb'))
        self.overview.addAction(modAct1)

        formatter = OverviewFormatter(self.overview)
        data = formatter.format()
        self.assertEqual(
            data, [['', '', '', '', '', '', '', '', '', '', ''],
                   [
                       'Action Name', 'Hit', 'Frames', 'Phase', 'DEF', 'aa',
                       'bb', 'cc', 'Notes 1', 'Notes 2', 'Notes 3'
                   ], ['attack 1', '', '', '0', 'x', 'x', '', '', '', '', ''],
                   ['attack 1', 'x', '', '1', 'x', '', 'x', '', '', '', '']])
Пример #10
0
 def setUp(self):
     super().setUp()
     self.modifier1 = Modifier('aaa')
     self.modifier2 = Modifier('aaa')
     self.modifier3 = Modifier('bbb')
Пример #11
0
 def _readModifiers(self):
     modifiers = []
     mods = self.dataHeader[self.modifierStartColumn:self.modifierEndColumn]
     for mod in mods:
         modifiers.append(Modifier(mod))
     return modifiers
Пример #12
0
 def setUp(self):
     super().setUp()
     self.names = ['test1', 'test2', 'test3']
     self.actions = [Action(name) for name in self.names]
     self.actions[1].default = True
     self.actions[0].setModifiers(0, [Modifier('WPN1'), Modifier('WPN2')])
Пример #13
0
 def testIsValidDetailNotSuccess(self):
     action = Action('action')
     modifiers = [Modifier('Fail')]
     detail = Detail(action, modifiers=modifiers)
     self.assertFalse(self.modifier.isValidDetail(detail))