item.h
2.46 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include <common.h>
#include <common_msg.pb.h>
class user_t;
typedef std::map<ITEM_ID, share_msg::item_t> ITEM_MAP;//key:item id
struct item_mgr_t
{
item_mgr_t();
user_t* user;
ITEM_MAP item_map;
//memory, db, notify client
void add(ITEM_ID id, ITEM_CNT cnt);
//ITEM_CNT game_add(ITEM_ID id, ITEM_CNT cnt);
//memory, db, notify client
void reduce(ITEM_ID id, ITEM_CNT cnt);
share_msg::item_t* find(ITEM_ID id);
ITEM_CNT get_item_cnt(ITEM_ID id);
bool is_has_all(ITEM_ID id, ITEM_CNT cnt);
//memory
void load_from_db(const share_msg::item_t& r);
void clothes_on(ITEM_ID item_id);
void clothes_off(uint32_t body_type);
void wall_on(ITEM_ID item_id);
private:
//memory, db, notify client
void update(ITEM_ID id, ITEM_CNT cnt);
//memory, db, notify client
void del(ITEM_ID id);
void notify_user(ITEM_ID id, ITEM_CNT cnt);
};
//////////////////////////////////////////////////////////////////////////
//item config
//////////////////////////////////////////////////////////////////////////
struct item_cfg_mgr_t
{
bool load_cfg();
void init();
std::map<ITEM_ID, common_msg::item_cfg_t> item_cfg_map;//key:item_id
std::map<uint32_t, common_msg::item_cfg_t*> pet_star_item_map;
common_msg::item_cfg_t* find(ITEM_ID id);
common_msg::item_cfg_t* find_key_by_star( uint32_t star );
common_msg::item_cfg_t* find_shuijing_by_star( uint32_t star );
bool is_wall(ITEM_ID id){
return 7 == id/100000;
}
bool is_clothes(ITEM_ID id){
return 8 == id/100000;
}
bool is_clothes_wing(ITEM_ID id){
return this->is_clothes(id) && 6 == id%10;
}
bool is_pet_eat(ITEM_ID id){
return 6 == id/100000;
}
bool is_pet_food(ITEM_ID id){
return 60 == id/10000;
}
bool is_pet_drink(ITEM_ID id){
return 61 == id/10000;
}
bool is_pet_medicine(ITEM_ID id){
return 62 == id/10000;
}
bool is_pet_key(ITEM_ID id){
return 2 == id/100000;
}
bool is_shuijing(ITEM_ID id){
return 3 == id/100000;
}
bool is_furniture(ITEM_ID id){
return 9 == id/100000;
}
// ¼¼ÄÜË®¾§ [2019/1/15 Administrator]
bool is_pet_skill_crystal(ITEM_ID id){
return 3 == id/100000;
}
};
extern item_cfg_mgr_t* g_item_cfg_mgr;
//////////////////////////////////////////////////////////////////////////
class furniture_mgr_t{
public:
furniture_mgr_t();
user_t* user;
share_msg::furniture_t* find(uint32_t furniture_id);
std::map<uint32_t, share_msg::furniture_t> furniture_map;
void update(share_msg::furniture_t* furniture);
void notify_user( ITEM_ID furniture_id );
protected:
private:
};