push 98438d20051787465e7a05f4aa66ab452afb1c14
[tagua/yd.git] / src / variants / chess / san.h
blobcb6ece9a4caed2a726324fa185a880a2ff2733a5
1 /*
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.
9 */
11 #ifndef CHESS__SAN_H
12 #define CHESS__SAN_H
14 #include <QDebug>
15 #include <QRegExp>
17 #include "export.h"
18 #include <core/point.h>
20 class IType;
22 class TAGUA_EXPORT SAN {
23 friend QDebug operator<<(QDebug os, const SAN& move);
25 static QRegExp pattern;
26 static QRegExp kingCastlingPattern;
27 static QRegExp queenCastlingPattern;
28 static QRegExp nonePattern;
30 public:
31 enum CastlingType {
32 NoCastling,
33 KingSide,
34 QueenSide
37 SAN();
39 static const IType* getType(const QString& letter);
41 void load(const QString&, int& offset, int ysize);
42 void load(const QString&, int ysize);
44 Point src, dst;
45 const IType* type;
46 const IType* promotion;
47 CastlingType castling;
48 bool drop;
50 inline bool invalid() const { return (dst == Point::invalid()) && (castling == NoCastling); }
51 inline bool valid() const { return !invalid(); }
54 #endif // CHESS__SAN_H