Crossfire Server, Trunk
Archetypes.h
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2020-2021 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #ifndef ARCHETYPES_H
14 #define ARCHETYPES_H
15 
16 #include <functional>
17 #include "AssetsCollection.h"
18 #include "global.h"
19 
23 class Archetypes : public AssetsCollection<archetype> {
24 
25 public:
27  typedef std::function<void(archetype*, archetype*)> updateListener;
28 
33  empty_archetype = get("empty_archetype");
34  }
35 
41  m_updateListener = fct;
42  }
43 
49  }
50 
59  archetype *findByObjectName(const char *name);
60 
72  archetype *findByObjectTypeName(int type, const char *name);
73 
83  archetype *findBySkillNameAndType(const char *skill, int type);
84 
100  archetype *findByTypeSubtype(int type, int subtype);
101 
111  static void recursive_update(object *item, archetype *updated);
112 
113 protected:
114  virtual void replace(archetype *existing, archetype *update) override;
115 
117 };
118 
119 #endif /* ARCHETYPES_H */
120 
global.h
Archetypes
Definition: Archetypes.h:23
AssetsCollection
Definition: AssetsCollection.h:55
Archetypes::recursive_update
static void recursive_update(object *item, archetype *updated)
Definition: Archetypes.cpp:31
AssetsCollection.h
Archetypes::findBySkillNameAndType
archetype * findBySkillNameAndType(const char *skill, int type)
Definition: Archetypes.cpp:109
archetype
Definition: object.h:483
AssetsCollection< archetype >::get
archetype * get(const std::string &name)
Definition: AssetsCollection.h:89
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
Archetypes::clearReplaceListener
void clearReplaceListener()
Definition: Archetypes.h:47
Archetypes::findByTypeSubtype
archetype * findByTypeSubtype(int type, int subtype)
Definition: Archetypes.cpp:121
item
Definition: item.py:1
Archetypes::Archetypes
Archetypes()
Definition: Archetypes.h:32
Archetypes::replace
virtual void replace(archetype *existing, archetype *update) override
Definition: Archetypes.cpp:62
Archetypes::updateListener
std::function< void(archetype *, archetype *)> updateListener
Definition: Archetypes.h:27
Archetypes::findByObjectName
archetype * findByObjectName(const char *name)
Definition: Archetypes.cpp:82
empty_archetype
archetype * empty_archetype
Definition: init.cpp:119
Archetypes::m_updateListener
updateListener m_updateListener
Definition: Archetypes.h:116
Archetypes::findByObjectTypeName
archetype * findByObjectTypeName(int type, const char *name)
Definition: Archetypes.cpp:97
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
Archetypes::setReplaceListener
void setReplaceListener(updateListener fct)
Definition: Archetypes.h:40
give.name
name
Definition: give.py:27