~ampelbein/+junk/fix-granule-deb-701292

« back to all changes in this revision

Viewing changes to src/CardDeck.h

  • Committer: Bazaar Package Importer
  • Author(s): Eric Dorland
  • Date: 2008-03-06 23:21:27 UTC
  • mfrom: (1.2.2 upstream) (2.1.4 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080306232127-93bghuc4e7r8d3j3
Tags: 1.3.0-1
* New upstream release.
* debian/control: 
  - Add Homepage and Vcs-* headers.
  - Upgrade Standards Version to 3.7.3.
  - Build-Depend on the new libassa.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
//------------------------------------------------------------------------------
3
3
//                              CardDeck.h
4
4
//------------------------------------------------------------------------------
5
 
// $Id: CardDeck.h,v 1.20 2006/08/30 12:22:35 vlg Exp $
 
5
// $Id: CardDeck.h,v 1.24 2008/01/06 16:51:09 vlg Exp $
6
6
//
7
7
//  Copyright (c) 2004,2006 by Vladislav Grinchenko
8
8
//
22
22
 
23
23
class VCard;
24
24
 
25
 
/** To remove duplicates we compare Card References by the IDs of 
26
 
        the cards they point to. If two cards happen to have the same
27
 
        ID (case of reversed *sticky* duplicates), we arbitrarily
28
 
        nominate lefthand-side be smaller then righthand-side.
29
 
*/
30
 
class Compare_CardRefs {
 
25
/** @class Compare_CardRefs
 
26
 *
 
27
 * To remove duplicates we compare Card References by the IDs of 
 
28
 * the cards they point to. If two cards happen to have the same
 
29
 * ID (case of reversed *sticky* duplicates), we arbitrarily
 
30
 * nominate lefthand-side be smaller then righthand-side.
 
31
 */
 
32
class Compare_CardRefs 
 
33
{
31
34
public:
32
35
        int operator () (VCard* const& vc1_, VCard* const& vc2_)
33
36
        {
50
53
};
51
54
 
52
55
/** 
 
56
 * @class CardDeck
 
57
 *
53
58
 * CardDeck represents each of the Card Boxes on the left of the MainWindow.
54
59
 * Each CardDeck holds a list of virtual cards, CardRef, each of which points
55
60
 * to the real Card in a real Deck.
75
80
        virtual void push_back (VCard* card_);
76
81
 
77
82
        /** Erase card from the VCard list only. Calling this method leaves 
78
 
                the Deck intact.
79
 
        */
 
83
         *  the Deck intact.
 
84
         */
80
85
        virtual void erase (cardlist_iterator iter_);
81
86
 
82
87
        /** Erase card from the VCard list only. Calling this method leaves
83
 
                the Deck intact.
 
88
         *      the Deck intact.
84
89
         */
85
90
        virtual bool erase (VCard* card_);
86
91
                
89
94
        void clear ();
90
95
 
91
96
        /** Sort Card References based on their expiration time.
92
 
                Those with oldest expiration dates go to the front of the list.
93
 
        */
 
97
         *  Those with oldest expiration dates go to the front of the list.
 
98
         */
94
99
        void sort_by_expiration_time ();
95
100
 
96
 
        virtual SideSelection get_side_selection ()    { return m_side_selection; }
 
101
        virtual SideSelection get_side_selection () { return m_side_selection; }
97
102
        virtual void set_side_selection (SideSelection s_) { m_side_selection=s_; }
98
103
 
99
 
        virtual void play_card (VDeck::cardlist_iterator& iter_);
 
104
        virtual void play_card (SideSelection s_, VDeck::cardlist_iterator& iter_);
100
105
 
101
106
        virtual const string&  get_name () const { return m_cdname; }
 
107
        virtual int  get_index () const { return m_index; }
102
108
 
103
 
        virtual int  get_index      () const;
104
109
        virtual void get_progress   (float& pct_done_, std::string& msg_, int idx_);
105
110
        virtual void reset_progress ();
106
111
 
108
113
        void remove_duplicates (); 
109
114
 
110
115
        /** Shuffle all subsets with equal expiration 
111
 
                timestamp, preserving the general expiration order.
112
 
        */
 
116
         *  timestamp, preserving the general expiration order.
 
117
         */
113
118
        void shuffle_subsets ();
114
119
 
115
120
        /** Dump the content of the deck to file (for troubleshooting).
121
126
        void export_sound_bits (const std::string& path_);
122
127
 
123
128
private:
124
 
        string         m_cdname;        // Number of the card box this deck represents
 
129
    /// Number of the card box this deck represents
 
130
        string m_cdname;        
 
131
 
 
132
        /// CardDeck index 
 
133
        int m_index;
 
134
 
 
135
        /// A collection of cards
125
136
        cardlist_type  m_cards;
126
137
 
127
138
    /// The size at the moment when DeckPlayer started playing the Deck.
128
 
        u_int          m_init_size;     
 
139
        u_int m_init_size;      
129
140
 
130
141
        /// How many cards has been already played by the DeckPlayer so far.
131
 
        u_int          m_progress_idx;
 
142
        u_int m_progress_idx;
132
143
};
133
144
 
134
 
//------Inlines ---------------------------------------------------------------
 
145
/**-----------------------------------------------------------------------------
 
146
 * Inlined methods
 
147
 **-----------------------------------------------------------------------------
 
148
 */
135
149
inline
136
150
CardDeck::
137
151
CardDeck () 
138
152
        : 
139
 
        m_init_size      (0), 
140
 
        m_progress_idx   (0)
 
153
        m_index (0),
 
154
        m_init_size (0), 
 
155
        m_progress_idx (0)
141
156
{
142
157
        trace_with_mask("CardDeck::CardDeck",GUITRACE|DECK);
143
158
}
156
171
        m_cards.push_back (card_); 
157
172
}
158
173
 
159
 
inline void
160
 
CardDeck::
161
 
reset_progress () 
162
 
163
 
        trace_with_mask("CardDeck::reset_progress",GUITRACE|DECK);
164
 
        m_init_size = size ();
165
 
        m_progress_idx = 0;
166
 
}
167
 
 
168
174
inline void 
169
175
CardDeck::
170
176
erase (cardlist_iterator iter_)