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

0001 /*
0002  *   Copyright 2021 Michael Lang <criticaltemp@protonmail.com>
0003  *
0004  *   This program is free software; you can redistribute it and/or
0005  *   modify it under the terms of the GNU General Public License as
0006  *   published by the Free Software Foundation; either version 2 of
0007  *   the License, or (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details.
0013  *
0014  *   You should have received a copy of the GNU General Public License
0015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef CASTLE_H
0019 #define CASTLE_H
0020 
0021 // own
0022 #include "dealer.h"
0023 #include "hint.h"
0024 
0025 class KSelectAction;
0026 
0027 class Castle : public DealerScene
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     explicit Castle(const DealerInfo *di);
0033     void initialize() override;
0034     void mapOldId(int id) override;
0035     int oldId() const override;
0036     QList<QAction *> configActions() const override;
0037 
0038 protected:
0039     bool checkAdd(const PatPile *pile, const QList<KCard *> &oldCards, const QList<KCard *> &newCards) const override;
0040     bool checkRemove(const PatPile *pile, const QList<KCard *> &cards) const override;
0041     void cardsDroppedOnPile(const QList<KCard *> &cards, KCardPile *pile) override;
0042     void restart(const QList<KCard *> &cards) override;
0043 
0044 private Q_SLOTS:
0045     void gameTypeChanged();
0046 
0047 protected Q_SLOTS:
0048     bool tryAutomaticMove(KCard *c) override;
0049 
0050 private:
0051     bool canPutStore(const KCardPile *pile, const QList<KCard *> &cards) const;
0052 
0053     void configOptions();
0054     void setOptions(int v);
0055     void getSavedOptions();
0056     void setSavedOptions();
0057     void matchVariant();
0058 
0059     virtual QString solverFormat() const;
0060     PatPile *store[10];
0061     PatPile *freecell[4];
0062     PatPile *target[8];
0063 
0064     KSelectAction *options;
0065     int m_variation;
0066 
0067     KSelectAction *m_emptyStackFillOption;
0068     int m_emptyStackFill;
0069 
0070     KSelectAction *m_sequenceBuiltByOption;
0071     int m_sequenceBuiltBy;
0072 
0073     KSelectAction *m_reservesOption;
0074     int m_reserves;
0075 
0076     KSelectAction *m_stacksOption;
0077     int m_stacks;
0078 
0079     KSelectAction *m_stackFaceupOption;
0080     int m_stackFaceup;
0081 
0082     KSelectAction *m_decksOption;
0083     int m_decks;
0084 
0085     KSelectAction *m_foundationOption;
0086     int m_foundation;
0087 
0088     KSelectAction *m_layoutOption;
0089     int m_layout;
0090 
0091     friend class CastleSolver;
0092 };
0093 
0094 #endif