forked from elonafoobar/elonafoobar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautopick.hpp
72 lines (51 loc) · 1.17 KB
/
autopick.hpp
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
66
67
68
69
70
71
72
#pragma once
#include <string>
#include "filesystem.hpp"
#include "item.hpp"
#include "lib/noncopyable.hpp"
namespace elona
{
class autopick : public lib::noncopyable
{
public:
struct operation
{
enum class type_t
{
do_nothing = 0,
pick_up = 1,
save = 2,
no_drop = 4,
save_and_no_drop = save | no_drop,
destroy = 8,
open = 16,
};
explicit operation(type_t type = type_t::do_nothing)
: type(type)
{
}
type_t type = type_t::do_nothing;
bool show_prompt = false;
std::string sound;
};
static autopick& instance();
void load(const std::string& player_id);
operation get_operation(const item&);
private:
struct matcher
{
matcher(const std::string& text, const operation& op)
: text(text)
, op(op)
{
}
std::string text;
operation op;
bool matches(const item&) const;
};
std::vector<matcher> matchers;
autopick() = default;
void clear();
bool try_load(const fs::path&);
};
} // namespace elona