1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
21 #include "nel/misc/i18n.h"
22 #include "nel/misc/string_conversion.h"
24 #include "characteristics.h"
27 using namespace NLMISC
;
29 namespace CHARACTERISTICS
31 // The conversion table
32 const CStringConversion
<TCharacteristics
>::CPair stringTable
[] =
34 { "Constitution", constitution
}, //HP max
35 { "Metabolism", metabolism
}, //Hp Regen
36 { "Intelligence", intelligence
}, //Sap Max
37 { "Wisdom", wisdom
}, //Sap regen
38 { "Strength", strength
}, //Stamina Max
39 { "WellBalanced", well_balanced
}, //Stamina regen
40 { "Dexterity", dexterity
}, //Focus Max
41 { "Will", will
}, //Focus regen
43 { "Unknown", Unknown
},
46 CStringConversion
<TCharacteristics
> conversion(stringTable
, sizeof(stringTable
) / sizeof(stringTable
[0]), Unknown
);
50 * get the right characteristic enum from the input string
51 * \param str the input string
52 * \return the TCharacteristics associated to this string (unknown if the string cannot be interpreted)
54 TCharacteristics
toCharacteristic( const std::string
&str
)
56 return conversion
.fromString(str
);
60 * get the right characteristic string from the gived enum
61 * \param c is the enum number of characteristic
62 * \return the string associated to this enum number (Unknown if enum number not exist)
64 const std::string
& toString( TCharacteristics c
)
66 return conversion
.toString(c
);
68 const std::string
& toString( uint c
)
70 return conversion
.toString((TCharacteristics
)c
);
73 // The code conversion table
74 const CStringConversion
<TCharacteristics
>::CPair codeTable
[] =
76 { "c", constitution
},
78 { "i", intelligence
},
81 { "b", well_balanced
},
85 CStringConversion
<TCharacteristics
> codeCharac(codeTable
, sizeof(codeTable
) / sizeof(codeTable
[0]), Unknown
);
87 const std::string
&getCharacteristicCode( TCharacteristics c
)
89 return codeCharac
.toString(c
);
92 TCharacteristics
getCharacteristicFromCode( const std::string
&code
)
94 return codeCharac
.fromString(code
);