Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / brick_flags.cpp
blob062b04d888f9fe4085cd61cfe51100532444de73
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 #include "nel/misc/debug.h"
22 #include "nel/misc/string_conversion.h"
24 #include "brick_flags.h"
26 using namespace std;
27 using namespace NLMISC;
29 namespace BRICK_FLAGS
31 // The conversion table
32 NL_BEGIN_STRING_CONVERSION_TABLE (TBrickFlag)
33 NL_STRING_CONVERSION_TABLE_ENTRY (Miss)
34 NL_STRING_CONVERSION_TABLE_ENTRY (Fumble)
35 NL_STRING_CONVERSION_TABLE_ENTRY (Hit)
36 NL_STRING_CONVERSION_TABLE_ENTRY (CriticalHit)
37 NL_STRING_CONVERSION_TABLE_ENTRY (Parry)
38 NL_STRING_CONVERSION_TABLE_ENTRY (Dodge)
39 NL_STRING_CONVERSION_TABLE_ENTRY (ShieldUsed)
40 NL_STRING_CONVERSION_TABLE_ENTRY (Head)
41 NL_STRING_CONVERSION_TABLE_ENTRY (Chest)
42 NL_STRING_CONVERSION_TABLE_ENTRY (Arms)
43 NL_STRING_CONVERSION_TABLE_ENTRY (Hands)
44 NL_STRING_CONVERSION_TABLE_ENTRY (Legs)
45 NL_STRING_CONVERSION_TABLE_ENTRY (Feet)
47 NL_STRING_CONVERSION_TABLE_ENTRY (Feint)
49 NL_STRING_CONVERSION_TABLE_ENTRY (Stun)
50 NL_STRING_CONVERSION_TABLE_ENTRY (Bleed)
51 NL_STRING_CONVERSION_TABLE_ENTRY (SlowMove)
52 NL_STRING_CONVERSION_TABLE_ENTRY (SlowAttacks)
54 NL_STRING_CONVERSION_TABLE_ENTRY (Taunt)
55 NL_STRING_CONVERSION_TABLE_ENTRY (SpeedingUp)
56 NL_STRING_CONVERSION_TABLE_ENTRY (LifeConcentration)
57 NL_STRING_CONVERSION_TABLE_ENTRY (StaminaConcentration)
58 NL_STRING_CONVERSION_TABLE_ENTRY (SapConcentration)
59 NL_STRING_CONVERSION_TABLE_ENTRY (ConvertStamina)
60 NL_STRING_CONVERSION_TABLE_ENTRY (ConvertSap)
61 NL_STRING_CONVERSION_TABLE_ENTRY (Berserk)
62 NL_STRING_CONVERSION_TABLE_ENTRY (BalanceHp)
63 NL_STRING_CONVERSION_TABLE_ENTRY (Heal)
64 NL_STRING_CONVERSION_TABLE_ENTRY (Shielding)
65 NL_STRING_CONVERSION_TABLE_ENTRY (Invulnerability)
66 NL_STRING_CONVERSION_TABLE_ENTRY (EnchantWeapon)
67 NL_STRING_CONVERSION_TABLE_ENTRY (ChgCharac)
68 NL_STRING_CONVERSION_TABLE_ENTRY (ModDefense)
69 NL_STRING_CONVERSION_TABLE_ENTRY (ModMeleeSuccess)
70 NL_STRING_CONVERSION_TABLE_ENTRY (ModRangeSuccess)
71 NL_STRING_CONVERSION_TABLE_ENTRY (ModMagicSuccess)
72 NL_STRING_CONVERSION_TABLE_ENTRY (ModMeleeSuccess)
73 NL_STRING_CONVERSION_TABLE_ENTRY (ModRangeSuccess)
74 NL_STRING_CONVERSION_TABLE_ENTRY (ModMagicSuccess)
75 NL_STRING_CONVERSION_TABLE_ENTRY (ModForageSuccess)
76 NL_STRING_CONVERSION_TABLE_ENTRY (HealHpC)
77 NL_STRING_CONVERSION_TABLE_ENTRY (HealSapC)
78 NL_STRING_CONVERSION_TABLE_ENTRY (HealStaC)
79 NL_STRING_CONVERSION_TABLE_ENTRY (HealFocusC)
81 NL_STRING_CONVERSION_TABLE_ENTRY (Aura)
83 NL_STRING_CONVERSION_TABLE_ENTRY (UnknownFlag)
84 NL_END_STRING_CONVERSION_TABLE(TBrickFlag, FlagConversion, UnknownFlag)
87 const string &toString(TBrickFlag flag)
89 #if !FINAL_VERSION
90 nlassert( NbCombatFlags < 32);
91 nlassert( NbPowerFlags < 31);
92 #endif
93 return FlagConversion.toString(flag);
96 TBrickFlag toBrickFlag( const string &str)
98 #if !FINAL_VERSION
99 nlassert( NbCombatFlags < 32);
100 nlassert( NbPowerFlags < 31);
101 #endif
102 return FlagConversion.fromString(str);
105 TBrickFlag powerTypeToFlag( POWERS::TPowerType powerType )
107 if (powerType >= POWERS::BeginAuras && powerType <= POWERS::EndAuras)
109 return Aura;
112 if (powerType >= POWERS::BeginPower && powerType <= POWERS::EndPower)
114 return (TBrickFlag)(BeginPowerFlags + powerType - POWERS::BeginPower);
117 return UnknownFlag;
121 /// convert a slot to a combat flag
122 TBrickFlag slotToFlag( SLOT_EQUIPMENT::TSlotEquipment slot )
124 switch(slot)
126 case SLOT_EQUIPMENT::HEAD:
127 return Head;
128 case SLOT_EQUIPMENT::CHEST:
129 return Chest;
130 case SLOT_EQUIPMENT::ARMS:
131 return Arms;
132 case SLOT_EQUIPMENT::HANDS:
133 return Hands;
134 case SLOT_EQUIPMENT::LEGS:
135 return Legs;
136 case SLOT_EQUIPMENT::FEET:
137 return Feet;
138 default:
139 return UnknownFlag;
143 /// convert an effect family to a flag
144 TBrickFlag effectFamilyToFlag( EFFECT_FAMILIES::TEffectFamily family )
146 switch(family)
148 case EFFECT_FAMILIES::CombatBleed:
149 return Bleed;
150 case EFFECT_FAMILIES::CombatStun:
151 return Stun;
152 case EFFECT_FAMILIES::CombatMvtSlow:
153 return SlowMove;
154 case EFFECT_FAMILIES::CombatAttackSlow:
155 return SlowAttacks;
156 default:
157 return UnknownFlag;
161 }; // BRICK_FLAGS