| 9 | |
| 10 | |
| 11 | class CalcRemoveLocalFighterCommand(wx.Command): |
| 12 | |
| 13 | def __init__(self, fitID, position): |
| 14 | wx.Command.__init__(self, True, 'Remove Fighter') |
| 15 | self.fitID = fitID |
| 16 | self.position = position |
| 17 | self.savedFighterInfo = None |
| 18 | |
| 19 | def Do(self): |
| 20 | pyfalog.debug('Doing removal of fighter at position {} from fit {}'.format(self.position, self.fitID)) |
| 21 | fit = Fit.getInstance().getFit(self.fitID) |
| 22 | fighter = fit.fighters[self.position] |
| 23 | self.savedFighterInfo = FighterInfo.fromFighter(fighter) |
| 24 | fit.fighters.remove(fighter) |
| 25 | return True |
| 26 | |
| 27 | def Undo(self): |
| 28 | pyfalog.debug('Undoing removal of fighter at position {} from fit {}'.format(self.position, self.fitID)) |
| 29 | from .localAdd import CalcAddLocalFighterCommand |
| 30 | cmd = CalcAddLocalFighterCommand( |
| 31 | fitID=self.fitID, |
| 32 | fighterInfo=self.savedFighterInfo, |
| 33 | position=self.position, |
| 34 | ignoreRestrictions=True) |
| 35 | return cmd.Do() |