-
Notifications
You must be signed in to change notification settings - Fork 0
/
deck.h
66 lines (60 loc) · 1.68 KB
/
deck.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include <string>
#include <vector>
#include <unordered_map>
#include <yaml-cpp/yaml.h>
#include <iostream>
#include "global.h"
namespace YGO {
struct Effect
{
t_string m_prog_attribute;
t_string m_valid_position;
t_string m_program;
bool exec_once_each_turn() const;
bool exec_at_beginning() const;
bool is_executable_at(t_string position) const;
};
class Card
{
t_string m_name;
int m_count = 1;
std::vector<t_string> m_attribute;
t_string m_description;
public:
Card() = default;
Card(const Card& other) = default;
Card(const t_string name, const YAML::Node& node);
Card& operator=(const Card &rhs) = default;
friend std::ostream& operator<<(std::ostream& os, const Card& card);
t_string name() const { return m_name; }
t_string effect_name(int idx) const;
t_string description() const { return m_description; }
t_string print_name() const {
return m_name + "(" + m_description + ")";
}
bool test_attribute(const t_string& attr) const;
bool test_attribute_wildcard(const t_string& pattern) const;
int count() const { return m_count; }
void set_count(int cnt) { m_count = cnt; }
bool exec_once_each_turn() const;
bool exec_at_beginning() const;
std::vector<Effect> m_effects;
};
std::ostream& operator<<(std::ostream& os, const Card& card);
class Deck
{
int m_size;
std::vector<Card> m_cards;
public:
friend std::ostream& operator<<(std::ostream& os, const Deck& deck);
Deck(const YAML::Node& node);
const std::vector<Card>& cards() const
{
return m_cards;
}
int size() const { return m_size; }
const std::vector<Card> generate() const;
};
std::ostream& operator<<(std::ostream& os, const Deck& deck);
}