From bfef365d9a9932c78a17daadde57a2d436fbca25 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 16 Jun 2014 00:37:14 +0200 Subject: [PATCH] Small refactoring. --- remoteglot.pl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/remoteglot.pl b/remoteglot.pl index a4f4ff4..d9ddd76 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -343,12 +343,7 @@ sub prettyprint_pv { } my $pv = shift @pvs; - my $from_col = col_letter_to_num(substr($pv, 0, 1)); - my $from_row = row_letter_to_num(substr($pv, 1, 1)); - my $to_col = col_letter_to_num(substr($pv, 2, 1)); - my $to_row = row_letter_to_num(substr($pv, 3, 1)); - my $promo = substr($pv, 4, 1); - + my ($from_col, $from_row, $to_col, $to_row, $promo) = parse_uci_move($pv); my ($pretty, $nb) = $board->prettyprint_move($from_row, $from_col, $to_row, $to_col, $promo); return ($pretty, prettyprint_pv($nb, @pvs)); } @@ -744,3 +739,12 @@ sub row_letter_to_num { return 7 - (ord(shift) - ord('1')); } +sub parse_uci_move { + my $move = shift; + my $from_col = col_letter_to_num(substr($move, 0, 1)); + my $from_row = row_letter_to_num(substr($move, 1, 1)); + my $to_col = col_letter_to_num(substr($move, 2, 1)); + my $to_row = row_letter_to_num(substr($move, 3, 1)); + my $promo = substr($move, 4, 1); + return ($from_col, $from_row, $to_col, $to_row, $promo); +} -- 2.39.2