|
Games::Cards::Undo -- undoing/redoing moves in Games::Cards games |
Games::Cards::Undo -- undoing/redoing moves in Games::Cards games
use Games::Cards::Undo;
$Undo = new Games::Cards::Undo(100); # Make undo engine to save 100 moves
$Undo->undo; # undo last move
$Undo->redo; # redo last undone move
$Undo->end_move; # tell undo engine we're done with a move
This is the package for methods to undo & redo moves. The GC::Undo object has
no publicly accessible fields. But it stores an array of the
preceding moves. Note that a ``move'' is made up of several ``atoms'' (objects of
the private class GC::Undo::Atom and its subclassess). For example, moving a
card from one column to another in solitaire involves one or more Splice atoms
(removing or adding card(s) to a CardSet) and possibly a Face atom (turning a
card over).
Many of the GC::Undo methods (and all of the GC::Undo::Atom methods) will be called by other Games::Cards methods, but not by the actual games. Here are the publicly accesssible methods:
new(MOVES)This method must be called before any undo-able moves are made (i.e., it can be called after the hands are dealt). This method will also re-initialize the engine for a new game.
|
Games::Cards::Undo -- undoing/redoing moves in Games::Cards games |