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

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 KLONDIKE_H
0038 #define KLONDIKE_H
0039 
0040 // own
0041 #include "dealer.h"
0042 
0043 class KlondikePile;
0044 
0045 class KSelectAction;
0046 
0047 class Klondike : public DealerScene
0048 {
0049     Q_OBJECT
0050 
0051 public:
0052     explicit Klondike(const DealerInfo *di);
0053     void initialize() override;
0054     void mapOldId(int id) override;
0055     int oldId() const override;
0056     QList<QAction *> configActions() const override;
0057 
0058 protected:
0059     void setGameState(const QString &state) override;
0060     QString getGameOptions() const override;
0061     void setGameOptions(const QString &options) override;
0062     bool checkAdd(const PatPile *pile, const QList<KCard *> &oldCards, const QList<KCard *> &newCards) const override;
0063     bool checkRemove(const PatPile *pile, const QList<KCard *> &cards) const override;
0064     void cardsMoved(const QList<KCard *> &cards, KCardPile *oldPile, KCardPile *newPile) override;
0065     void restart(const QList<KCard *> &cards) override;
0066 
0067 protected Q_SLOTS:
0068     bool drop() override;
0069     bool newCards() override;
0070 
0071 private Q_SLOTS:
0072     void gameTypeChanged();
0073 
0074 private:
0075     void setEasy(bool easy);
0076 
0077     bool easyRules;
0078 
0079     KSelectAction *options;
0080 
0081     PatPile *talon;
0082     PatPile *play[7];
0083     PatPile *target[4];
0084 
0085     KlondikePile *pile;
0086 
0087     friend class KlondikeSolver;
0088 };
0089 
0090 class KlondikePile : public PatPile
0091 {
0092 public:
0093     KlondikePile(DealerScene *scene, int index, const QString &objectName = QString());
0094     void setCardsToShow(int numCards);
0095     int cardsToShow() const;
0096     QList<QPointF> cardPositions() const override;
0097 
0098 private:
0099     int m_cardsToShow;
0100 };
0101 
0102 #endif