Undo
We will add an Undo capability to our game. A new button will be added to the LaserGame morph control panel. That button will undo any previous cell operations. For now, we'll assume that there's no upper bound to the size of the undo stack. To keep the game statistics interesting, performing an undo will not remove any counts from the total number of moves the player makes.
We begin by designing another decision hierarchy. This one needs to provide answers for reverse actions related to cells. That means we need to provide undo responses for push north, push east, push south, push west, rotate clockwise and rotate counter-clockwise. The fire laser button will not have undo actions.
On the "Laser-Game-Model" system category, add new classes.
Object subclass: #ReverseLaserGameAction
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Laser-Game-Model'
ReverseLaserGameAction subclass: #ReversePushCellEastLaserGameAction
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Laser-Game-Model'
ReverseLaserGameAction subclass: #ReversePushCellNorthLaserGameAction
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Laser-Game-Model'
ReverseLaserGameAction subclass: #ReversePushCellSouthLaserGameAction
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Laser-Game-Model'
ReverseLaserGameAction subclass: #ReversePushCellWestLaserGameAction
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Laser-Game-Model'
ReverseLaserGameAction subclass: #ReverseRotateClockwiseLaserGameAction
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Laser-Game-Model'
ReverseLaserGameAction subclass: #ReverseRotateCounterClockwiseLaserGameAction
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Laser-Game-Model'