2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #include "icsverbose.h"
17 QRegExp
ICSVerbose::pattern("([PRNBKQ])/([a-zA-Z]\\d+|@@)-([a-zA-Z]\\d+)(=([PRNBKQ]))?");
18 QRegExp
ICSVerbose::kingCastlingPattern("[oO0]-[oO0]");
19 QRegExp
ICSVerbose::queenCastlingPattern("[oO0]-[oO0]-[oO0]");
20 QRegExp
ICSVerbose::nonePattern("none");
22 ICSVerbose::ICSVerbose()
23 : from(Point::invalid())
24 , to(Point::invalid())
26 , castling(SAN::NoCastling
) { }
29 void ICSVerbose::load(const QString
& str
, int ysize
) {
30 if (nonePattern
.indexIn(str
) == 0) {
31 from
= Point::invalid();
32 to
= Point::invalid();
34 else if (pattern
.indexIn(str
) == 0) {
35 if (pattern
.cap(2) == "@@")
36 from
= Point::invalid();
38 from
= Point(pattern
.cap(2), ysize
);
40 to
= Point(pattern
.cap(3), ysize
);
42 type
= SAN::getType(pattern
.cap(1));
43 if (!pattern
.cap(5).isEmpty())
44 promotion
= SAN::getType(pattern
.cap(6));
47 castling
= SAN::NoCastling
;
49 else if (queenCastlingPattern
.indexIn(str
) == 0)
50 castling
= SAN::QueenSide
;
51 else if (kingCastlingPattern
.indexIn(str
) == 0)
52 castling
= SAN::KingSide
;
54 from
= Point::invalid();
55 to
= Point::invalid();
56 castling
= SAN::NoCastling
;
60 } // namespace HLVariant