cosmetix
[k8-i-v-a-n.git] / src / game / iloops.h
blob2d766ca4dd9f6f4c650ee6bfe8edebaf8988afd6
1 /*
3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
6 * Public License
8 * See LICENSING which should be included
9 * along with this file for more details
13 #ifndef __ILOOPS_H__
14 #define __ILOOPS_H__
16 #include "ivancommon.h"
18 #include "feloops.h"
19 #include "char.h"
22 struct combinebodypartpredicates : public combinepredicates<ccharacter, bodypart>
24 typedef combinepredicates<ccharacter, bodypart> base;
25 truth operator()(ccharacter* C, base::routine F, truth OrBit) const
27 return base::operator()(C, &character::GetBodyPart, F, C->GetBodyParts(), OrBit);
31 template <class param>
32 struct combinebodypartpredicateswithparam : public combinepredicateswithparam<ccharacter, bodypart, param>
34 typedef combinepredicateswithparam<ccharacter, bodypart, param> base;
35 truth operator()(ccharacter* C, typename base::routine F, param P, truth OrBit) const
37 return base::operator()(C, &character::GetBodyPart, F, P, C->GetBodyParts(), OrBit);
41 struct combineequipmentpredicates : public combinepredicates<ccharacter, item>
43 typedef combinepredicates<ccharacter, item> base;
44 truth operator()(ccharacter* C, base::routine F, truth OrBit) const
46 return base::operator()(C, &character::GetEquipment, F, C->GetEquipments(), OrBit);
50 template <class param>
51 struct combineequipmentpredicateswithparam : public combinepredicateswithparam<ccharacter, item, param>
53 typedef combinepredicateswithparam<ccharacter, item, param> base;
54 truth operator()(ccharacter* C, typename base::routine F, param P, truth OrBit) const
56 return base::operator()(C, &character::GetEquipment, F, P, C->GetEquipments(), OrBit);
60 struct doforbodyparts : public doforelements<ccharacter, bodypart>
62 typedef doforelements<ccharacter, bodypart> base;
63 void operator()(ccharacter* C, base::routine F) const
65 base::operator()(C, &character::GetBodyPart, F, C->GetBodyParts());
69 template <class param>
70 struct doforbodypartswithparam : public doforelementswithparam<ccharacter, bodypart, param>
72 typedef doforelementswithparam<ccharacter, bodypart, param> base;
73 void operator()(ccharacter* C, typename base::routine F, param P) const
75 base::operator()(C, &character::GetBodyPart, F, P, C->GetBodyParts());
79 struct doforequipments : public doforelements<ccharacter, item>
81 typedef doforelements<ccharacter, item> base;
82 void operator()(ccharacter* C, base::routine F) const
84 base::operator()(C, &character::GetEquipment, F, C->GetEquipments());
86 void operator()(ccharacter* C, void (item::*F)() const) const
88 base::operator()(C, &character::GetEquipment, base::routine(F), C->GetEquipments());
92 template <class param>
93 struct doforequipmentswithparam : public doforelementswithparam<ccharacter, item, param>
95 typedef doforelementswithparam<ccharacter, item, param> base;
96 void operator()(ccharacter* C, typename base::routine F, param P) const
98 base::operator()(C, &character::GetEquipment, F, P, C->GetEquipments());
100 void operator()(ccharacter* C, void (item::*F)(param) const, param P) const
102 base::operator()(C, &character::GetEquipment, (typename base::routine)(F), P, C->GetEquipments());
106 struct sumbodypartproperties : public sumproperties<ccharacter, bodypart>
108 typedef sumproperties<ccharacter, bodypart> base;
109 int operator()(ccharacter* C, base::routine F) const
111 return base::operator()(C, &character::GetBodyPart, F, C->GetBodyParts());
115 template <class param>
116 struct findequipment : public findelement<ccharacter, item, param>
118 typedef findelement<ccharacter, item, param> base;
119 item* operator()(ccharacter* C, typename base::routine F, param P) const
121 return base::operator()(C, &character::GetEquipment, F, P, C->GetEquipments());
125 #endif