push 98438d20051787465e7a05f4aa66ab452afb1c14
[tagua/yd.git] / src / positioninfo.h
blobdb633b87721ea048a09357a879b2bb5dc08e9535
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 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 POSITIONINFO_H
12 #define POSITIONINFO_H
14 #include <vector>
15 #include <map>
16 #include <boost/shared_ptr.hpp>
17 #include <QRegExp>
19 #include <core/point.h>
20 #include <core/state_fwd.h>
21 #include <core/piece.h>
22 #include "icsapi_fwd.h"
23 #include "icsgamedata.h"
25 class PositionInfo {
26 public:
27 enum Relation {
28 MoveListStart = -4,
29 IsolatedPosition = -3,
30 ObservingExamined = -2,
31 NotMyMove = -1,
32 ObservingPlayed = 0,
33 MyMove = 1,
34 Examining = 2,
35 UnknownRelation = -255
38 class CaptureIndexes {
39 public:
40 enum {
41 ChessboardStart = 1,
42 Turn = 9,
43 EnPassant = 10,
44 WhiteKingCastle = 11,
45 WhiteQueenCastle = 12,
46 BlackKingCastle = 13,
47 BlackQueenCastle = 14,
48 ReversibleMoves = 15,
49 GameNumber = 16,
50 WhitePlayer = 17,
51 BlackPlayer = 18,
52 Relation = 19,
53 StartingTime = 20,
54 StartingIncrement = 21,
55 WhiteTime = 24,
56 BlackTime = 25,
57 MoveOrdinal = 26,
58 LastMoveVerbose = 27,
59 TimeUsed = 28,
60 LastMove = 29,
61 Flip = 30
65 class PositionRow {
66 public:
67 std::vector<Piece> row;
68 explicit PositionRow(const ICSAPIPtr& icsapi, const QString& str);
71 static QRegExp pattern;
73 bool valid;
74 PositionInfo();
76 /**
77 * Parse a style12 line filling the fields of this PositionInfo object.
78 * \param games Games we know about.
79 * \param style12 A style12 line.
80 * \return Whether the game is new.
82 bool load(std::map<int, ICSGameData>& games, const QString& style12);
84 int turn;
85 int moveIndex;
86 int index() const;
87 int gameNumber;
88 QString whitePlayer;
89 QString blackPlayer;
90 StatePtr position;
91 Point enPassantSquare;
93 Relation relation;
95 QString lastMoveSAN;
96 QString lastMove;
97 int whiteTime;
98 int blackTime;
101 #endif // POSITIONINFO_H