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 "AssetsCollection.h"
17 
18 extern "C" {
19 #include "global.h"
20 }
21 
22 #include <functional>
23 
27 class Archetypes : public AssetsCollection<archetype> {
28 
29 public:
31  typedef std::function<void(archetype*, archetype*)> updateListener;
32 
37  empty_archetype = get("empty_archetype");
38  }
39 
45  m_updateListener = fct;
46  }
47 
53  }
54 
63  archetype *findByObjectName(const char *name);
64 
76  archetype *findByObjectTypeName(int type, const char *name);
77 
87  archetype *findBySkillNameAndType(const char *skill, int type);
88 
104  archetype *findByTypeSubtype(int type, int subtype);
105 
115  static void recursive_update(object *item, archetype *updated);
116 
117 protected:
118  virtual archetype *create(const std::string& name);
119  virtual void destroy(archetype *item);
120  virtual void replace(archetype *existing, archetype *update);
121 
123 };
124 
125 #endif /* ARCHETYPES_H */
126 
empty_archetype
EXTERN archetype * empty_archetype
Definition: global.h:142
global.h
Archetypes
Definition: Archetypes.h:27
Archetypes::create
virtual archetype * create(const std::string &name)
Definition: Archetypes.cpp:17
Archetypes::destroy
virtual void destroy(archetype *item)
Definition: Archetypes.cpp:24
archt
Definition: object.h:468
AssetsCollection
Definition: AssetsCollection.h:39
Archetypes::recursive_update
static void recursive_update(object *item, archetype *updated)
Definition: Archetypes.cpp:29
AssetsCollection.h
Archetypes::findBySkillNameAndType
archetype * findBySkillNameAndType(const char *skill, int type)
Definition: Archetypes.cpp:107
AssetsCollection< archetype >::get
archetype * get(const std::string &name)
Definition: AssetsCollection.h:66
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
Archetypes::clearReplaceListener
void clearReplaceListener()
Definition: Archetypes.h:51
Archetypes::findByTypeSubtype
archetype * findByTypeSubtype(int type, int subtype)
Definition: Archetypes.cpp:119
item
Definition: item.py:1
Archetypes::Archetypes
Archetypes()
Definition: Archetypes.h:36
Archetypes::replace
virtual void replace(archetype *existing, archetype *update)
Definition: Archetypes.cpp:60
Archetypes::updateListener
std::function< void(archetype *, archetype *)> updateListener
Definition: Archetypes.h:31
Archetypes::findByObjectName
archetype * findByObjectName(const char *name)
Definition: Archetypes.cpp:80
Archetypes::m_updateListener
updateListener m_updateListener
Definition: Archetypes.h:122
Archetypes::findByObjectTypeName
archetype * findByObjectTypeName(int type, const char *name)
Definition: Archetypes.cpp:95
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
Archetypes::setReplaceListener
void setReplaceListener(updateListener fct)
Definition: Archetypes.h:44
give.name
name
Definition: give.py:27