-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext.h
46 lines (43 loc) · 966 Bytes
/
context.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
#pragma once
#include <string>
#include <vector>
#include <unordered_map>
#include "global.h"
#include "deck.h"
#include "condition.h"
#include <ostream>
namespace YGO
{
class Context
{
std::unordered_map<t_string, Condition*> m_context;
public:
Context() {}
void addCardNameCondition(const Card& card)
{
m_context[card.name()] = new CardNameCondition(card.name());
}
void addCondition(const t_string& key, Condition* cond)
{
m_context[key] = cond;
}
Condition* getCondition(const t_string& key);
void print(std::ostream& os) const
{
for (auto& [k, v] : m_context)
{
os << k << ": ";
v->print(os);
os << std::endl;
}
}
};
class Utils
{
public:
static Condition* parseSingle(const t_string& cond);
static Condition* parseSingle(Context& context, const t_string& cond);
static std::vector<t_string> strSplit(const t_string& s);
static Condition* parse(Context& context, const t_string& cond);
};
}