File indexing completed on 2024-05-12 08:00:33

0001 /*
0002  * Copyright (C) 1995 Paul Olav Tvete <paul@troll.no>
0003  * Copyright (C) 2000-2009 Stephan Kulow <coolo@kde.org>
0004  *
0005  * License of original code:
0006  * -------------------------------------------------------------------------
0007  *   Permission to use, copy, modify, and distribute this software and its
0008  *   documentation for any purpose and without fee is hereby granted,
0009  *   provided that the above copyright notice appear in all copies and that
0010  *   both that copyright notice and this permission notice appear in
0011  *   supporting documentation.
0012  *
0013  *   This file is provided AS IS with no warranties of any kind.  The author
0014  *   shall have no liability with respect to the infringement of copyrights,
0015  *   trade secrets or any patents by this file or any part thereof.  In no
0016  *   event will the author be liable for any lost revenue or profits or
0017  *   other special, indirect and consequential damages.
0018  * -------------------------------------------------------------------------
0019  *
0020  * License of modifications/additions made after 2009-01-01:
0021  * -------------------------------------------------------------------------
0022  *   This program is free software; you can redistribute it and/or
0023  *   modify it under the terms of the GNU General Public License as
0024  *   published by the Free Software Foundation; either version 2 of
0025  *   the License, or (at your option) any later version.
0026  *
0027  *   This program is distributed in the hope that it will be useful,
0028  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0029  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0030  *   GNU General Public License for more details.
0031  *
0032  *   You should have received a copy of the GNU General Public License
0033  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
0034  * -------------------------------------------------------------------------
0035  */
0036 
0037 #ifndef GAMESTATE_H
0038 #define GAMESTATE_H
0039 
0040 // own
0041 #include "patsolve/solverinterface.h"
0042 // Qt
0043 #include <QString>
0044 
0045 class KCard;
0046 class KCardPile;
0047 
0048 class CardState
0049 {
0050 public:
0051     KCardPile *pile;
0052     int index;
0053     bool faceUp;
0054     bool takenDown;
0055 
0056     CardState()
0057         : pile(nullptr)
0058         , index(-1)
0059         , faceUp(false)
0060         , takenDown(false)
0061     {
0062     }
0063 
0064     CardState(KCardPile *pile, int index, bool faceUp, bool takenDown)
0065         : pile(pile)
0066         , index(index)
0067         , faceUp(faceUp)
0068         , takenDown(takenDown)
0069     {
0070     }
0071 
0072     bool operator==(const CardState &rhs) const
0073     {
0074         return pile == rhs.pile && index == rhs.index && faceUp == rhs.faceUp && takenDown == rhs.takenDown;
0075     }
0076 
0077     bool operator!=(const CardState &rhs) const
0078     {
0079         return !operator==(rhs);
0080     }
0081 };
0082 
0083 class CardStateChange
0084 {
0085 public:
0086     CardState oldState;
0087     CardState newState;
0088     QList<KCard *> cards;
0089 
0090     CardStateChange(CardState oldState, CardState newState, const QList<KCard *> &cards)
0091         : oldState(oldState)
0092         , newState(newState)
0093         , cards(cards){};
0094 };
0095 
0096 class GameState
0097 {
0098 public:
0099     QList<CardStateChange> changes;
0100     QString stateData;
0101     SolverInterface::ExitStatus solvability;
0102     QList<MOVE> winningMoves;
0103 
0104     GameState(const QList<CardStateChange> &changes, const QString &stateData)
0105         : changes(changes)
0106         , stateData(stateData)
0107         , solvability(SolverInterface::SearchAborted)
0108     {
0109     }
0110 };
0111 
0112 #endif