Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / item_family.cpp
blobd8ee8a25eb17f44f29ddf6433231381b9b71051a
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "stdpch.h"
21 // nel
22 #include "nel/misc/i18n.h"
23 #include "nel/misc/string_conversion.h"
25 #include "item_family.h"
27 using namespace std;
28 using namespace NLMISC;
30 namespace ITEMFAMILY
32 // The conversion table
33 const CStringConversion<EItemFamily>::CPair stringTable [] =
35 { "UNDEFINED", UNDEFINED },
36 { "SERVICE", SERVICE },
37 { "ARMOR", ARMOR },
38 { "MELEE_WEAPON", MELEE_WEAPON },
39 { "RANGE_WEAPON", RANGE_WEAPON },
40 { "AMMO", AMMO },
41 { "RAW_MATERIAL", RAW_MATERIAL },
42 { "SHIELD", SHIELD },
43 { "CRAFTING_TOOL", CRAFTING_TOOL },
44 { "HARVEST_TOOL", HARVEST_TOOL },
45 { "TAMING_TOOL", TAMING_TOOL },
46 { "TRAINING_TOOL", TRAINING_TOOL },
47 { "AI", AI },
48 { "BRICK", BRICK },
49 { "FOOD", FOOD },
50 { "JEWELRY", JEWELRY },
51 { "CORPSE", CORPSE },
52 { "CARRION", CARRION },
53 { "BAG", BAG },
54 { "STACK", STACK },
55 { "DEAD_SEED", DEAD_SEED },
56 { "TELEPORT", TELEPORT },
57 { "GUILD_FLAG", GUILD_FLAG },
58 { "LIVING_SEED", LIVING_SEED },
59 { "LITTLE_SEED", LITTLE_SEED },
60 { "MEDIUM_SEED", MEDIUM_SEED },
61 { "BIG_SEED", BIG_SEED },
62 { "VERY_BIG_SEED", VERY_BIG_SEED },
63 { "MISSION_ITEM", MISSION_ITEM },
64 { "CRYSTALLIZED_SPELL", CRYSTALLIZED_SPELL },
65 { "ITEM_SAP_RECHARGE", ITEM_SAP_RECHARGE },
66 { "PET_ANIMAL_TICKET", PET_ANIMAL_TICKET },
67 { "GUILD_OPTION", GUILD_OPTION },
68 { "COSMETIC", COSMETIC },
69 { "HANDLED_ITEM", HANDLED_ITEM },
70 { "CONSUMABLE", CONSUMABLE },
71 { "XP_CATALYSER", XP_CATALYSER },
72 { "SCROLL", SCROLL },
73 { "SCROLL_R2", SCROLL_R2 },
74 { "COMMAND_TICKET", COMMAND_TICKET },
75 { "GENERIC_ITEM", GENERIC_ITEM },
78 CStringConversion<EItemFamily> conversion(stringTable, sizeof(stringTable) / sizeof(stringTable[0]), UNDEFINED);
81 // convert item family id to item family name string
82 const std::string& toString( EItemFamily itemFamily )
84 return conversion.toString(itemFamily);
88 // convert item family name to item family enum value
89 EItemFamily stringToItemFamily( const std::string& str )
91 return conversion.fromString(str);
94 bool isSellableByPlayer( EItemFamily fam )
96 return fam!=FOOD;
99 bool isResellable( EItemFamily fam )
101 return
102 fam == ARMOR ||
103 fam == MELEE_WEAPON ||
104 fam == RANGE_WEAPON ||
105 fam == AMMO ||
106 fam == RAW_MATERIAL ||
107 fam == SHIELD ||
108 fam == JEWELRY ||
109 fam == CRYSTALLIZED_SPELL ||
110 fam == CONSUMABLE ||
111 fam == ITEM_SAP_RECHARGE;
115 bool isTextCustomizable( EItemFamily fam )
117 return
118 fam == ARMOR ||
119 fam == MELEE_WEAPON ||
120 fam == RANGE_WEAPON ||
121 fam == SHIELD ||
122 fam == JEWELRY ||
123 fam == SCROLL;
127 bool isUsable( EItemFamily fam )
129 return
130 fam == ITEM_SAP_RECHARGE ||
131 fam == CRYSTALLIZED_SPELL ||
132 fam == CONSUMABLE ||
133 fam == XP_CATALYSER;
138 * returns true if items of this family are destroyed when they are completely worned out
140 bool destroyedWhenWorned(EItemFamily family)
142 switch(family)
144 case ITEMFAMILY::MELEE_WEAPON:
145 case ITEMFAMILY::RANGE_WEAPON:
146 case ITEMFAMILY::ARMOR:
147 case ITEMFAMILY::SHIELD:
148 return true;
150 default:
151 return false;
156 }; // ITEMFAMILY