File indexing completed on 2024-05-12 04:04:48

0001 /*
0002  * Copyright (C) 1997 Rodolfo Borges <barrett@labma.ufrj.br>
0003  * Copyright (C) 1998-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 FREECELL_H
0038 #define FREECELL_H
0039 
0040 // own
0041 #include "dealer.h"
0042 #include "hint.h"
0043 
0044 class KSelectAction;
0045 
0046 class Freecell : public DealerScene
0047 {
0048     Q_OBJECT
0049 
0050 public:
0051     explicit Freecell(const DealerInfo *di);
0052     void initialize() override;
0053     void mapOldId(int id) override;
0054     int oldId() const override;
0055     QList<QAction *> configActions() const override;
0056 
0057 protected:
0058     bool checkAdd(const PatPile *pile, const QList<KCard *> &oldCards, const QList<KCard *> &newCards) const override;
0059     bool checkRemove(const PatPile *pile, const QList<KCard *> &cards) const override;
0060     void cardsDroppedOnPile(const QList<KCard *> &cards, KCardPile *pile) override;
0061     void restart(const QList<KCard *> &cards) override;
0062 
0063 private Q_SLOTS:
0064     void gameTypeChanged();
0065 
0066 protected Q_SLOTS:
0067     bool tryAutomaticMove(KCard *c) override;
0068 
0069 private:
0070     bool canPutStore(const KCardPile *pile, const QList<KCard *> &cards) const;
0071 
0072     void configOptions();
0073     void setOptions(int v);
0074     void getSavedOptions();
0075     void setSavedOptions();
0076     void matchVariant();
0077 
0078     virtual QString solverFormat() const;
0079     PatPile *store[12];
0080     PatPile *freecell[8];
0081     PatPile *target[12];
0082 
0083     KSelectAction *options;
0084     int m_variation;
0085 
0086     KSelectAction *m_emptyStackFillOption;
0087     int m_emptyStackFill;
0088 
0089     KSelectAction *m_sequenceBuiltByOption;
0090     int m_sequenceBuiltBy;
0091 
0092     KSelectAction *m_reservesOption;
0093     int m_reserves;
0094 
0095     KSelectAction *m_stacksOption;
0096     int m_stacks;
0097 
0098     KSelectAction *m_decksOption;
0099     int m_decks;
0100 
0101     friend class FreecellSolver;
0102 };
0103 
0104 #endif