Beispiel #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', '', '', '', '']])
Beispiel #2
0
 def testAddAction(self):
     action1 = Action('action1')
     action2 = Action('action2')
     overview = Overview('test')
     overview.addAction(action1)
     overview.addAction(action2)
     self.assertEqual(overview.actions, [action1, action2])
Beispiel #3
0
class ActionFormatterTestCase(OfficeTestCase):
    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)

    def testFormattingAction(self):
        formatter = ActionFormatter(self.overview, self.action)
        data = formatter.format()
        # name, hit, frames, phase, def, aa, bb, cc, notes 1, notes 2, notes 3
        result = [[
            'attack 1', '', '1', '0', 'x', 'x', '', '', 'note 1', 'note 2',
            'note 3'
        ],
                  [
                      'attack 1', 'x', '2', '1', 'x', '', 'x', '', 'note 1',
                      'note 2', 'note 3'
                  ]]
        self.assertEqual(data, result)
Beispiel #4
0
 def testFindAction(self):
     action1 = Action('action1')
     action2 = Action('action2')
     action3 = Action('action3')
     overview = Overview('test')
     overview.addAction(action1)
     overview.addAction(action2)
     overview.addAction(action3)
     self.assertTrue(action2.name == overview.findAction(action2).name)
     self.assertIsNone(overview.findAction(Action('cannot find')))
Beispiel #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', '', '', '']])
Beispiel #6
0
 def _rowGroupToAction(self, rowGroup):
     modifiers = {}
     notes = {}
     frames = {}
     kwargs = {
         'name': rowGroup[0][self.nameColumnIndex],
         'phases': len(rowGroup),
         'modifiers': modifiers,
         'notes': notes,
         'frames': frames
     }
     for phase, row in enumerate(rowGroup):
         if row[self.hitColumnIndex] != '':
             kwargs['hitPhase'] = phase
         if row[self.framesColumnIndex] != '':
             frames[str(phase)] = self._parseFrames(
                 row[self.framesColumnIndex])
         if row[self.defaultColumnIndex] != '':
             kwargs['default'] = True
         modInstances = self._modifiersFromRow(row)
         if modInstances:
             modifiers[phase] = modInstances
         noteInstances = self._notesFromRow(row)
         if noteInstances:
             notes[phase] = noteInstances
     return Action(**kwargs)
Beispiel #7
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)
Beispiel #8
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', '', '', '', '']])
Beispiel #9
0
 def _parseActions(self):
     actions = defaultdict(OrderedDict)
     for index, row in enumerate(self.dataRows):
         # Skip empty rows.
         if row[self.nameColumnIndex] != '':
             view = row[self.viewColumnIndex]
             kwargs = self._rowToKwargs(row)
             kwargs['color'] = self.actionColors[index]
             self._actionExist(actions, view, kwargs['name'])
             actions[view][kwargs['name']] = Action(**kwargs)
     return actions
Beispiel #10
0
 def createOverview(masterSheet, viewName):
     """
     Factory to build Overview class instance from Master sheet instance and
     from given view name. Modifiers from Modifier sheet will also be used.
     """
     modifiers = Modifiers(MODIFIER_LIST_SHEET_NAME)
     actions = masterSheet.getActions(viewName)
     overview = Overview(viewName)
     overview.modifiers = modifiers.getModifiers()
     for action in actions:
         overview.addAction(
             Action(action.name, color=action.color, phases=action.phases))
     return overview
Beispiel #11
0
 def setUp(self):
     super().setUp()
     self.action = Action('aaa', phases=1)
Beispiel #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')])
Beispiel #13
0
 def testIsValidDetailNotSuccess(self):
     action = Action('action')
     modifiers = [Modifier('Fail')]
     detail = Detail(action, modifiers=modifiers)
     self.assertFalse(self.modifier.isValidDetail(detail))
Beispiel #14
0
 def setUp(self):
     super().setUp()
     self.action1 = Action('aaa')
     self.action2 = Action('aaa')
     self.action3 = Action('bbb')