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"
14 QRegExp
ICSVerbose::pattern("([PRNBKQ])/([a-zA-Z]\\d+|@@)-([a-zA-Z]\\d+)(=([PRNBKQ]))?");
15 QRegExp
ICSVerbose::kingCastlingPattern("[oO0]-[oO0]");
16 QRegExp
ICSVerbose::queenCastlingPattern("[oO0]-[oO0]-[oO0]");
17 QRegExp
ICSVerbose::nonePattern("none");
19 ICSVerbose::ICSVerbose()
20 : src(Point::invalid())
21 , dst(Point::invalid())
23 , castling(SAN::NoCastling
) { }
26 void ICSVerbose::load(const QString
& str
, int ysize
) {
27 if (nonePattern
.indexIn(str
) == 0) {
28 src
= Point::invalid();
29 dst
= Point::invalid();
31 else if (pattern
.indexIn(str
) == 0) {
32 if (pattern
.cap(2) == "@@")
33 src
= Point::invalid();
35 src
= Point(pattern
.cap(2), ysize
);
37 dst
= Point(pattern
.cap(3), ysize
);
39 type
= SAN::getType(pattern
.cap(1));
40 if (!pattern
.cap(5).isEmpty())
41 promotion
= SAN::getType(pattern
.cap(6));
44 castling
= SAN::NoCastling
;
46 else if (queenCastlingPattern
.indexIn(str
) == 0)
47 castling
= SAN::QueenSide
;
48 else if (kingCastlingPattern
.indexIn(str
) == 0)
49 castling
= SAN::KingSide
;
51 src
= Point::invalid();
52 dst
= Point::invalid();
53 castling
= SAN::NoCastling
;