| Chess-GameClock-GameClock documentation | Contained in the Chess-GameClock-GameClock distribution. |
Create object of GameClock
Set the parameters of the GclkCounter with or without GUI.
Embedded &GclkDisplay::display
GameClock - Chess and Go clock
Version 1.2
use strict ;
use Tk ;
use Chess::GameClock::GclkDisplay qw(display);
use Chess::GameClock::GameClock ;
#Three Modes for settings counters:
#With Gui to set the time (no parameters):
my ($whites,$blacks)=$clock->set ;
# or from the GUI like menu
# here the set is Blitz,Usuel, 10mn (indice 1)
my ($whites,$blacks)=$clock->set("Blitz Usuel 1") ;
# or a direct cadence with the following
#array of hashes
# first cadence 15 mn/25 moves then 15 mn dead time
our ($whites,$blacks)=$clock->set( [{qw/ct 15*60 mv 25 b 0 f 0 byo 1/},
{qw/ct 15*60 mv 0 b 0 f 0 byo 1/}] ) ;
# example of japonese byo-yomi
# main time 7s, then 3s per move and five byo-yomi time periods
#my ($whites,$blacks)=$clock->set( # [{qw/ct 7 mv 0 b 0 f 0 byo 0/}, # {qw/ct 3*5 mv 1 b 3 f 0 byo
# display the counters
&GclkDisplay::display($whites,$blacks,0.75) ;
# and at last the Perl/Tk necessary statement
MainLoop ;
The module Chess::GameClock do the job of a Chess or Go electronic clock. You can set any types of cadences like Fisher, Bronstein, Byo-yomi selecting preset cadences or by manual interface. The left and right mouse buttons are the clock buttons for whites & blacks. The keyboard is also divided into two zones right and left who emulates the actions of the mouse, as an extended facility (letter h, at the keyboard center has been excluded). The time counters are large on the screen and move counters are also displayed. The window could be adjusted with the "$scaling" parameter, that is a floating number generally between 0.5 and 2.0 . The counter display has three commands only accessed by keyboard keys: Control-q , forces application to quit. Control-h , make counters to toggle between the counting and halt (pause) mode. Start accessed by Control-Shift-0, Start or Restart the counters from the beginning. You can also toggling the display between the elapsed or remaining time with Alt-c.
Note: The window "Perl Chess Clock" must have the focus for that commands could be effective.
Charles Minc, <charles.minc\ at wanadoo.fr>
Please report any bugs or feature requests to
bug-gameclock at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=GameClock.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc GameClock
You can also look for information at:
Copyright 2006 Charles Minc, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Chess-GameClock-GameClock documentation | Contained in the Chess-GameClock-GameClock distribution. |
#!/usr/bin/perl -w ####----------------------------------- ### File : GameClock.pm ### Author : Ch.Minc ### Purpose : Main Package for GameClock ### Version : 1.2 2007/12/23 ### copyright GNU license ####----------------------------------- package GameClock ; our $VERSION = '1.2' ; use warnings; use strict; use Chess::GameClock::GclkData qw(:tout) ; use Chess::GameClock::GclkSettings qw(&menu ®lage) ; use Chess::GameClock::GclkCounter ; use Chess::GameClock::GclkDisplay qw(display); # Aliases modif 2007/1/8 #my %cad=%Chess::GameClock::GclkData::cad ; #my %sous_menu=%Chess::GameClock::GclkData::sous_menu ; my %cad=%GclkData::cad ; my %sous_menu=%GclkData::sous_menu ;
sub new { my ($class,@args)=@_ ; my $self={} ; # a surveiller return bless ($self,$class) ; }
sub set { my ($self,$cadence)=@_ ; # build counters my $whites=GclkCounter->new ; my $blacks=GclkCounter->new ; # build menu # if $cadence is a string that defines a cadence: # $type in (@menu),$cad in $sous-menus ,Array subscripts ex "Blitz Usuel 0" # if cadence is empty call reglage right away if(!defined($cadence)) {&GclkSettings::menu($whites,$blacks,"") ; &GclkSettings::reglage($whites,$blacks,"") ; return($whites,$blacks) ; } # if cadence is compatible with data array elsif ( ref($cadence) =~ /ARRAY/ ) { print "$cadence\n"; for my $i (0..$#{$cadence} ){ my $cadname="Cadence" . ($i+1) ; print " $cadname \n" ; for my $k (keys %{$cadence->[$i]}) { $cad{ReglagesManuels}{$cadname}[0]{$k}=$cadence->[$i]{$k}; print "\n $k $cadence->[$i]{$k} " ; } #®lage($whites,$blacks,$cadname) ; } $whites->init("ReglagesManuels Cadence" . @{$cadence} . " 0",'blancs') ; $blacks->init("ReglagesManuels Cadence" . @{$cadence} . " 0",'noirs') ; return($whites,$blacks) ; } else{ my ($type,$cad,$i)=split(' ',$cadence) ; if ( defined($sous_menu{$type}) ){ &GclkSettings::reglage($whites,$blacks,$cadence) ; return($whites,$blacks) ; } } }
sub display{ my ($self,$whites,$blacks,$scaling)=@_ ; &GclkDisplay::display($whites,$blacks,$scaling) ; }
1; # End of GameClock