1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef RY_RM_FAMILY_H
23 #define RY_RM_FAMILY_H
25 #include "nel/misc/types_nl.h"
28 // Raw material faber type
29 namespace RM_FABER_TYPE
32 * WARNING: if you modify,remove or add some elements in this enum, you should:
33 * - search mpft* in wk.uxt (for localisation text)
34 * - search item_part_icon_* in all xml (for binding of item part to gfx icon)
35 * particulary in bot_chat_v4.xml, where you may have to reorganize the list of item_part filter
67 NUM_FABER_TYPE
= Unknown
70 extern std::string TypeToSheetEntry
[];
73 * get the right string from the given enum value
74 * \param faber_type the TRMFType value to convert
75 * \return the string associated to this enum number (UNKNOWN if the enum number not exist)
77 const std::string
& toString( TRMFType faber_type
);
80 * get the right TRMFamily from its string
81 * \param str the input string
82 * \return the TRMFamily associated to this string (unknown if the string cannot be interpreted)
84 TRMFType
toFaberType( const std::string
& str
);
86 /** From the enum, retrieve the entry field to read in Georges.
88 const std::string
&faberTypeToSheetEntry(TRMFType type
);
90 /// Get the Localized UCString
91 const std::string
& toLocalString( TRMFType e
);
93 /// For Client Interface, return the define name of the type (eg: "item_part_icon_MpL")
94 std::string
toIconDefineString( TRMFType e
);
99 // Raw material family
102 typedef uint32 TRMFamily
;
104 const TRMFamily Unknown
= 0;
106 /// Get the Localized UCString
107 const std::string
& toLocalString( TRMFamily e
);
110 inline std::string
toString( TRMFamily e
) { return NLMISC::toString(e
); }
112 /// Extract number from string
113 inline TRMFamily
toFamily( const std::string
& s
) { TRMFamily ret
; NLMISC::fromString(s
, ret
); return ret
; }
117 // Raw material group
120 typedef uint32 TRMGroup
;
122 const TRMGroup Unknown
= 0;
124 /// Get the Localized UCString
125 const std::string
& toLocalString( TRMGroup e
);
127 // Note: the group names are accessible on server by CMP::rmGroupToString()
130 inline std::string
toString( TRMGroup e
) { return NLMISC::toString(e
); }
132 /// Extract number from string
133 inline TRMGroup
toGroup( const std::string
& s
) { TRMGroup ret
; NLMISC::fromString(s
, ret
); return ret
; }
136 // Raw material property
137 namespace RM_FABER_PROPERTY
139 typedef uint32 TRMFProperty
;
141 const TRMFProperty Unknown
= 0;
143 /// Get the Localized UCString
144 const std::string
& toLocalString( TRMFProperty e
);
147 inline std::string
toString( TRMFProperty e
) { return NLMISC::toString(e
); }
149 /// Extract number from string
150 inline TRMFProperty
toFaberProperty( const std::string
& s
) { TRMFProperty ret
; NLMISC::fromString(s
, ret
); return ret
; }
155 // Raw material property depth
156 namespace RM_FABER_QUALITY
166 NUM_FABER_QUALITY
= Unknown
170 * get the right string from the given enum value
171 * \param fq the value to convert
172 * \return the string associated to this enum number (UNKNOWN if the enum number not exist)
174 const std::string
& toString( TFaberQuality v
);
177 * get the right TFaberQuality from its string
178 * \param str the input string
179 * \return the TFaberQuality associated to this string (unknown if the string cannot be interpreted)
181 TFaberQuality
toFaberQuality( const std::string
& str
);
183 /// Get the Localized UCString
184 const std::string
& toLocalString( TFaberQuality e
);
189 // Raw material color
194 /// true if valid color.
195 inline bool validColor( sint value
) {return value
>=0 && value
<NumColors
;}
198 * get the right string from the given uint value (stored as a uint in the sheet)
199 * \param family the TRMColor value to convert
200 * \return the string associated to this number (UNKNOWN if the enum number not exist)
202 const std::string
& toString( sint value
);
204 /// Get the Localized UCString
205 const std::string
& toLocalString( sint value
);
209 // Raw material stats
210 namespace RM_FABER_STAT_TYPE
222 AdversaryDodgeModifier
,
223 AdversaryParryModifier
,
225 MaxSlashingProtection
,
227 MaxPiercingProtection
,
234 ElectricityProtection
,
239 PrimaryRootResistance
,
240 ElementalCastingTimeFactor
,
241 ElementalPowerFactor
,
242 OffensiveAfflictionCastingTimeFactor
,
243 OffensiveAfflictionPowerFactor
,
244 DefensiveAfflictionCastingTimeFactor
,
245 DefensiveAfflictionPowerFactor
,
246 HealCastingTimeFactor
,
250 Unknown
= NumRMStatType
,
253 // get the georges identifier
254 const std::string
& toString( TRMStatType stats
);
256 /// Get the Localized UCString
257 const std::string
& toLocalString( TRMStatType stats
);
259 /// For each Raw material faber type, does this Stat is relevant?
260 bool isStatRelevant(RM_FABER_TYPE::TRMFType ft
, TRMStatType fs
);
262 /** For Craft. Common EGS and client Code: Stretch the Item Stats.
263 * \param array Stat array of float [0,1]
264 * \param statBitField, for each stat, a bit to say if used for the item crafted
265 * \param addBonusRule. must be true server side. add or not the bonus for "best stat +35"
267 void stretchItemStats(float array
[NumRMStatType
], uint64 statBitField
, bool addBonusRule
= true);
269 /** For Craft. Common EGS and client Code: get final stat validity (protection and resist: take 3 biggest values)
270 * \param array Stat array of float [0,1]
271 * \param statBitField, for each stat, a bit to say if used for the item crafted
272 * \return statBitField, with any magic prot or resist removed
274 uint64
getStatFinalValidity(const float array
[NumRMStatType
], uint64 statBitField
);
276 /** true if the stat is a Magic Resistance stat
278 bool isMagicResistStat(TRMStatType fs
);
280 /** true if the stat is a Magic Protection stat
282 bool isMagicProtectStat(TRMStatType fs
);
285 // raw material class
286 namespace RM_CLASS_TYPE
297 Unknown
= NumTRMClassType
300 enum TRMClassEnergyLimit
306 MinChoiceEnergy
= 36,
307 MaxChoiceEnergy
= 50,
308 MinExcellentEnergy
= 51,
309 MaxExcellentEnergy
= 65,
310 MinSupremeEnergy
= 66,
311 MaxSupremeEnergy
= 100
314 /// Get the Localized UCString
315 const std::string
& toLocalString( TRMClassType classType
);
317 /// return the item class for a given stat energy [0..100]
318 inline TRMClassType
getItemClass(uint32 energy
)
320 if( energy
<= RM_CLASS_TYPE::MaxBasicEnergy
)
321 return RM_CLASS_TYPE::Basic
;
322 if( energy
<= RM_CLASS_TYPE::MaxFineEnergy
)
323 return RM_CLASS_TYPE::Fine
;
324 if( energy
<= RM_CLASS_TYPE::MaxChoiceEnergy
)
325 return RM_CLASS_TYPE::Choice
;
326 if( energy
<= RM_CLASS_TYPE::MaxExcellentEnergy
)
327 return RM_CLASS_TYPE::Excellent
;
328 return RM_CLASS_TYPE::Supreme
;
334 #endif // RY_RM_FAMILY_H
335 /* End of rm_family.h */