=encoding euc-jp =head1 NAME =begin original Games::Cards::Undo -- undoing/redoing moves in Games::Cards games =end original Games::Cards::Undo -- Games::Cardsの移動操作に対する取り消しとやり直し =head1 概要 use Games::Cards::Undo; $Undo = new Games::Cards::Undo(100); # 100操作を記録するエンジンの作成 $Undo->undo; # 最後の操作を取り消す $Undo->redo; # 最後の取り消し操作をやり直す $Undo->end_move; # undoエンジンに一回の移動が終わったことを伝える =head1 説明 =begin original 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). =end original これは移動操作に対する取り消しとやり直しのためのメソッド用パッケージである。 GC::Undoオブジェクトはパブリックにアクセスできるフィールドを持ってはいない。 だが、今までの移動操作を配列に保持している。注意して欲しいのは、 移動操作(move)はいくつかの単操作(atoms)から成り立っているということだ (プライベートなクラスであるGC::Undo::Atomとそのサブクラスのオブジェクト)。 例えば、ソリティアでカードを一方の列から他方の列へと移動することは、一つ以上の Splice操作(Cardsetからカードを取り除いたり、つけ加えたりする)と、おそらく 一回のFace操作(カードをひっくり返す)を伴っている。 =begin original 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: =end original GC::Undoメソッドの多くは(そして全てのGC::Undo::Atomメソッドは)、他の Games::Cardsメソッドによって呼び出されるのであって、実際にゲームで呼び出す わけではない。パブリックにアクセス可能なメソッドは以下のとおり: =over 4 =item new(MOVES) =begin original Initialize the Undo engine. MOVES is the number of atoms to save. 0 (or no argument) allows infinite undo. =end original Undoエンジンの初期化。MOVESは記録しておく単操作の数。 0、もしくは引数無しだと無限にundo可能。 =begin original 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. =end original このメソッドはundo可能な操作が行われる前に呼び出されなければならない (これはつまり、手札が配られた後に呼び出すことが出来るということだ)。 このメソッドはまた、新しいゲームのためにエンジンを再初期化する。 =item end_move =begin original End the current move. Everything between the last call to end_move and now is considered one move. This tells undo how much to undo. =end original 現在の移動操作を終了する。最後にend_moveが呼び出されてから現在までの全操作を 一つの移動操作と考える。これはundoメソッドに対しundoのために何回必要かを教える。 =item undo =begin original Undo a move. =end original 一つの移動操作を取り消す。 =item redo =begin original Redo a move that had been undone with undo. =end original undoを使って取り消した移動操作をやり直す。 =back