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

0001 /*
0002  * Copyright (C) 1995 Paul Olav Tvete <paul@troll.no>
0003  * Copyright (C) 2000-2009 Stephan Kulow <coolo@kde.org>
0004  * Copyright (C) 2009 Parker Coates <coates@kde.org>
0005  *
0006  * License of original code:
0007  * -------------------------------------------------------------------------
0008  *   Permission to use, copy, modify, and distribute this software and its
0009  *   documentation for any purpose and without fee is hereby granted,
0010  *   provided that the above copyright notice appear in all copies and that
0011  *   both that copyright notice and this permission notice appear in
0012  *   supporting documentation.
0013  *
0014  *   This file is provided AS IS with no warranties of any kind.  The author
0015  *   shall have no liability with respect to the infringement of copyrights,
0016  *   trade secrets or any patents by this file or any part thereof.  In no
0017  *   event will the author be liable for any lost revenue or profits or
0018  *   other special, indirect and consequential damages.
0019  * -------------------------------------------------------------------------
0020  *
0021  * License of modifications/additions made after 2009-01-01:
0022  * -------------------------------------------------------------------------
0023  *   This program is free software; you can redistribute it and/or
0024  *   modify it under the terms of the GNU General Public License as
0025  *   published by the Free Software Foundation; either version 2 of
0026  *   the License, or (at your option) any later version.
0027  *
0028  *   This program is distributed in the hope that it will be useful,
0029  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0030  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0031  *   GNU General Public License for more details.
0032  *
0033  *   You should have received a copy of the GNU General Public License
0034  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
0035  * -------------------------------------------------------------------------
0036  */
0037 
0038 #ifndef DEALERINFO_H
0039 #define DEALERINFO_H
0040 
0041 // Qt
0042 #include <KLazyLocalizedString>
0043 #include <QByteArray>
0044 #include <QList>
0045 #include <QMap>
0046 #include <QString>
0047 #include <QXmlStreamReader>
0048 class DealerInfoList;
0049 class DealerScene;
0050 
0051 class DealerInfo
0052 {
0053 public:
0054     enum GameIds {
0055         KlondikeDrawOneId = 0,
0056         GrandfatherId = 1,
0057         AcesUpId = 2,
0058         FreecellGeneralId = 3,
0059         CastleGeneralId = 4,
0060         Mod3Id = 5,
0061         GypsyId = 7,
0062         FortyAndEightId = 8,
0063         SimpleSimonId = 9,
0064         YukonId = 10,
0065         GrandfathersClockId = 11,
0066         GolfId = 12,
0067         KlondikeDrawThreeId = 13,
0068         SpiderOneSuitId = 14,
0069         SpiderTwoSuitId = 15,
0070         SpiderFourSuitId = 16,
0071         SpiderGeneralId = 17,
0072         KlondikeGeneralId = 18,
0073         BakersDozenGeneralId = 19,
0074         BakersDozenId = 20,
0075         BakersDozenSpanishId = 21,
0076         BakersDozenCastlesId = 22,
0077         BakersDozenPortugueseId = 23,
0078         BakersDozenCustomId = 24,
0079         FreecellId = 30,
0080         FreecellBakersId = 31,
0081         FreecellEightOffId = 32,
0082         FreecellForeId = 33,
0083         FreecellSeahavenId = 34,
0084         FreecellCustomId = 39,
0085         CastleBeleagueredId = 40,
0086         CastleCitadelId = 41,
0087         CastleExiledKingsId = 42,
0088         CastleStreetAlleyId = 43,
0089         CastleSiegecraftId = 44,
0090         CastleStrongholdId = 45,
0091         CastleCustomId = 49,
0092         SpiderThreeSuitId = 50
0093     };
0094 
0095     DealerInfo(const KLazyLocalizedString &untranslatedBaseName, int baseId);
0096     virtual ~DealerInfo();
0097 
0098     QString baseName() const;
0099     KLazyLocalizedString untranslatedBaseName() const;
0100     QString baseIdString() const;
0101     int baseId() const;
0102 
0103     void addSubtype(int id, const KLazyLocalizedString &untranslatedName);
0104     QList<int> subtypeIds() const;
0105 
0106     QList<int> distinctIds() const;
0107     bool providesId(int id) const;
0108     QString nameForId(int id) const;
0109 
0110     virtual DealerScene *createGame() const = 0;
0111 
0112 protected:
0113     KLazyLocalizedString m_baseName;
0114     QString m_baseIdString;
0115     int m_baseId;
0116 
0117     QMap<int, KLazyLocalizedString> m_subtypes;
0118 };
0119 
0120 class DealerInfoList
0121 {
0122 private:
0123     friend class DealerInfoListPrivate;
0124     explicit DealerInfoList();
0125     virtual ~DealerInfoList();
0126 
0127 public:
0128     static DealerInfoList *self();
0129     void add(DealerInfo *di);
0130     const QList<DealerInfo *> games() const;
0131     int gameIdForFile(QXmlStreamReader &xml) const;
0132 
0133 private:
0134     QList<DealerInfo *> m_list;
0135 };
0136 
0137 #endif