aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/pile.h
blob: d86ea3739d605dd04ad18267cb2f645dff0e859b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Created by thecharlesblake on 10/28/17.
//

#ifndef SOLVITAIRE_PILE_H
#define SOLVITAIRE_PILE_H

#include <vector>
#include <iterator>

#include "sol_rules.h"
#include "card.h"

class pile {
    friend class hasher;
    friend class game_state;
    friend class cached_game_state;
public:
    typedef uint8_t size_type;
    const static size_type max_size_type;

    pile() = default;
    pile(std::vector<card>);
    pile(std::initializer_list<card>);

    // Inspect
    card top_card() const;
    bool empty() const;
    size_type size() const;

    // Indexes the vector, with the top card as index 0
    card& operator[] (size_type);
    card operator[] (size_type) const;

    friend bool operator==(const pile&, const pile&);
    friend bool operator!=(const pile&, const pile&);
    friend bool operator<(const pile&, const pile&);
    friend bool operator>(const pile&, const pile&);
    friend bool operator<=(const pile&, const pile&);
    friend bool operator>=(const pile&, const pile&);

    // Modify
    void place(card);
    card take();

private:
    // Underlying vector
    std::vector<card> pile_vec;
};


#endif //SOLVITAIRE_PILE_H