#
#  $Id: CardPileUndo.pm,v 4.7 2002/07/21 06:49:52 kono Exp $
#
package CardPlay::CardPileUndo;

use strict;

use vars qw($VERSION @ISA @EXPORT @EXPORT_OK
);

require Exporter;
require AutoLoader;

@ISA = qw(Exporter AutoLoader);

@EXPORT = qw( );

$VERSION = "0.2";

use Tk;
use Carp;

# class method

sub new {
    my ($types) = shift;
    my $self;

    %{$self} = @_;
    bless $self;
}

sub undo {
    my ($self) = @_;
    $self->{'-from'}->merge($self->{'-to'}->split($self->{'-at'}));
}

sub redo {
    my ($self) = @_;
    $self->{'-to'}->merge($self->{'-from'}->split($self->{'-at'}));
}

sub print {
    my ($self) = @_;
    my ($card);
    print STDERR "undo from:";
    if ( defined ($card = $self->{'-from'}->first())) {
    print STDERR $card->{'-suit'}, $card->{'-number'};
    }
    print STDERR " to:";
    if ( defined ($card = $self->{'-to'}->first())) {
    print STDERR $card->{'-suit'}, $card->{'-number'};
    }
    print STDERR " at:",$self->{'-at'},"\n";
}

1;
# end