File indexing completed on 2024-05-12 08:00:36
0001 /* 0002 * Copyright (C) 2003 Josh Metzler <joshdeb@metzlers.org> 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 SPIDER_H 0038 #define SPIDER_H 0039 0040 // own 0041 #include "dealer.h" 0042 0043 class KSelectAction; 0044 0045 class Spider : public DealerScene 0046 { 0047 Q_OBJECT 0048 0049 public: 0050 explicit Spider(const DealerInfo *di); 0051 void initialize() override; 0052 void mapOldId(int id) override; 0053 int oldId() const override; 0054 QList<QAction *> configActions() const override; 0055 0056 // interface for the solver - avoiding friend classes 0057 PatPile *getStack(int i) const 0058 { 0059 return stack[i]; 0060 }; 0061 PatPile *getLeg(int i) const 0062 { 0063 return legs[i]; 0064 }; 0065 PatPile *getRedeal(int i) const 0066 { 0067 return redeals[i]; 0068 }; 0069 0070 protected: 0071 QString getGameState() const override; 0072 void setGameState(const QString &state) override; 0073 QString getGameOptions() const override; 0074 void setGameOptions(const QString &options) override; 0075 bool checkAdd(const PatPile *pile, const QList<KCard *> &oldCards, const QList<KCard *> &newCards) const override; 0076 bool checkRemove(const PatPile *pile, const QList<KCard *> &cards) const override; 0077 void cardsMoved(const QList<KCard *> &cards, KCardPile *oldPile, KCardPile *newPile) override; 0078 void restart(const QList<KCard *> &cards) override; 0079 0080 protected Q_SLOTS: 0081 bool newCards() override; 0082 void animationDone() override; 0083 0084 private Q_SLOTS: 0085 void gameTypeChanged(); 0086 0087 private: 0088 bool pileHasFullRun(KCardPile *pile); 0089 void moveFullRunToLeg(KCardPile *pile); 0090 void setSuits(int s); 0091 void createDeck(); 0092 QPointF randomPos(); 0093 0094 PatPile *stack[10]; 0095 PatPile *legs[8]; 0096 int m_leg; 0097 PatPile *redeals[5]; 0098 int m_redeal; 0099 int m_suits; 0100 QList<KCardPile *> m_pilesWithRuns; 0101 0102 KSelectAction *options; 0103 0104 KSelectAction *m_stackFaceupOption; 0105 int m_stackFaceup; 0106 0107 friend class SpiderSolver; 0108 }; 0109 0110 #endif