From: Erik V. <eri...@hc...> - 2007-07-17 19:09:00
|
One problem I faced whilst implementing Undo/Redo was, that in some cases a player turn solely exists of answering a modal dialog. In such cases the player does not have a choice what action to take: the type of action is forced. A modal dialog, though, breaks the Undo chain in the sense, that it prohibits all actions but answering the dialog. So it also prohibits another Undo. I encountered this problem in two different cases, and for each case I have implemented a different solution (for good reasons, I think). The first case occurs when only one bid has been placed on the B&O private in the start round. In that case, buying is automatic, the player only must select the par price. This is done in a modal dialog. I have solved this problem by inserting an extra step before the par price setting dialog, in which the player must press "Buy" before the dialog is shown. The B&O private is preselected, no other actions are allowed. However, this extra step is only inserted after an Undo action. It is omitted in the normal forward course of actions and after Redo. The second case can occur when the first 4- or 5-train has been bought, and one or more companies exceed their train limit and must discard a train. In this case a modal dialog is shown where the player must select the train to discard. The solution I have chosen here is to link the discard actions to the preceding train buying action, in the sense that the whole lot is undone together, including the train buying action. Again, the Redo remains as it was: one action at a time. The second solution is far easier to use: just add one call to MoveSet.setLinkedToPrevious() following MoveSet.start(). But I don't think we should use this linkage in the B&O case, which is why I have implemented a more complex solution there. It is possible that buying the SVNRR triggers the whole start round to roll up, and it does not smell right to me to undo that as a whole when perhaps only a different B&O par price should be set. Erik Vos |