1 | /* |
2 | * Copyright (C) 1995 Paul Olav Tvete <paul@troll.no> |
3 | * Copyright (C) 2000-2009 Stephan Kulow <coolo@kde.org> |
4 | * |
5 | * License of original code: |
6 | * ------------------------------------------------------------------------- |
7 | * Permission to use, copy, modify, and distribute this software and its |
8 | * documentation for any purpose and without fee is hereby granted, |
9 | * provided that the above copyright notice appear in all copies and that |
10 | * both that copyright notice and this permission notice appear in |
11 | * supporting documentation. |
12 | * |
13 | * This file is provided AS IS with no warranties of any kind. The author |
14 | * shall have no liability with respect to the infringement of copyrights, |
15 | * trade secrets or any patents by this file or any part thereof. In no |
16 | * event will the author be liable for any lost revenue or profits or |
17 | * other special, indirect and consequential damages. |
18 | * ------------------------------------------------------------------------- |
19 | * |
20 | * License of modifications/additions made after 2009-01-01: |
21 | * ------------------------------------------------------------------------- |
22 | * This program is free software; you can redistribute it and/or |
23 | * modify it under the terms of the GNU General Public License as |
24 | * published by the Free Software Foundation; either version 2 of |
25 | * the License, or (at your option) any later version. |
26 | * |
27 | * This program is distributed in the hope that it will be useful, |
28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
30 | * GNU General Public License for more details. |
31 | * |
32 | * You should have received a copy of the GNU General Public License |
33 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
34 | * ------------------------------------------------------------------------- |
35 | */ |
36 | |
37 | #ifndef GAMESTATE_H |
38 | #define GAMESTATE_H |
39 | |
40 | #include "patsolve/patsolve.h" |
41 | |
42 | class KCard; |
43 | class KCardPile; |
44 | |
45 | #include <QtCore/QSet> |
46 | #include <QtCore/QString> |
47 | |
48 | |
49 | class CardState |
50 | { |
51 | public: |
52 | KCardPile * pile; |
53 | int index; |
54 | bool faceUp; |
55 | bool takenDown; |
56 | |
57 | CardState() |
58 | : pile( 0 ), |
59 | index( -1 ), |
60 | faceUp( false ), |
61 | takenDown( false ) |
62 | { |
63 | } |
64 | |
65 | CardState( KCardPile * pile, int index, bool faceUp, bool takenDown ) |
66 | : pile( pile ), |
67 | index( index ), |
68 | faceUp( faceUp ), |
69 | takenDown( takenDown ) |
70 | { |
71 | } |
72 | |
73 | bool operator==( const CardState & rhs ) const |
74 | { |
75 | return pile == rhs.pile |
76 | && index == rhs.index |
77 | && faceUp == rhs.faceUp |
78 | && takenDown == rhs.takenDown; |
79 | } |
80 | |
81 | bool operator!=( const CardState & rhs ) const |
82 | { |
83 | return !operator==( rhs ); |
84 | } |
85 | }; |
86 | |
87 | |
88 | class CardStateChange |
89 | { |
90 | public: |
91 | CardState oldState; |
92 | CardState newState; |
93 | QList<KCard*> cards; |
94 | |
95 | CardStateChange( CardState oldState, CardState newState, QList<KCard*> cards ) |
96 | : oldState( oldState ), |
97 | newState( newState ), |
98 | cards( cards ) |
99 | { |
100 | }; |
101 | }; |
102 | |
103 | class GameState |
104 | { |
105 | public: |
106 | QList<CardStateChange> changes; |
107 | QString stateData; |
108 | Solver::ExitStatus solvability; |
109 | QList<MOVE> winningMoves; |
110 | |
111 | GameState( QList<CardStateChange> changes, QString stateData ) |
112 | : changes ( changes ), |
113 | stateData( stateData ), |
114 | solvability( Solver::SearchAborted ) |
115 | { |
116 | } |
117 | }; |
118 | |
119 | |
120 | #endif |
121 | |