Crossfire Server, Trunk
ArtifactListWrapper.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 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 #include "ArtifactListWrapper.h"
14 #include "ResourcesManager.h"
15 #include "CREPixmap.h"
16 #include "faces/FaceWrapper.h"
17 
19  : AssetTWrapper(parent, "ArtifactList", list), myResourcesManager(resourcesManager) {
20 }
21 
23  return myWrappedItem->items.size();
24 }
25 
27  if (index < 0 || index >= static_cast<int>(myWrappedItem->items.size())) {
28  return nullptr;
29  }
31 }
32 
34  int index = 0;
35  for (auto item : myWrappedItem->items) {
36  if (myResourcesManager->wrap(item, this) == child) {
37  return index;
38  }
39  index++;
40  }
41  return -1;
42 }
43 
45  if (dynamic_cast<const FaceWrapper *>(asset) || dynamic_cast<const AnimationWrapper *>(asset)) {
46  return ChildrenMayUse;
47  }
48  return DoesntUse;
49 }
50 
52  if (childIndex(asset) != -1 && type == AssetUpdated) {
54  for (auto item : myWrappedItem->items) {
55  myWrappedItem->total_chance += item->chance;
56  }
58  return;
59  }
60  AssetWrapper::wasModified(asset, type, extra);
61 }
AssetTWrapper< artifactlist >::myWrappedItem
artifactlist * myWrappedItem
Definition: AssetWrapper.h:104
ArtifactListWrapper.h
AssetWrapper::AssetUpdated
@ AssetUpdated
Definition: AssetWrapper.h:33
ResourcesManager
Definition: ResourcesManager.h:80
AnimationWrapper
Definition: AnimationWrapper.h:24
ResourcesManager::wrap
ArchetypeWrapper * wrap(archetype *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:132
artifactlist::items
std::vector< artifact * > items
Definition: artifact.h:28
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
guildoracle.list
list
Definition: guildoracle.py:87
ArtifactListWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: ArtifactListWrapper.h:44
AssetWrapper::ChildrenMayUse
@ ChildrenMayUse
Definition: AssetWrapper.h:32
FaceWrapper
Definition: FaceWrapper.h:24
AssetWrapper
Definition: AssetWrapper.h:25
ArtifactListWrapper::childrenCount
virtual int childrenCount() const override
Definition: ArtifactListWrapper.cpp:22
ArtifactListWrapper::wasModified
virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra) override
Definition: ArtifactListWrapper.cpp:51
AssetWrapper::ChangeType
ChangeType
Definition: AssetWrapper.h:33
artifactlist
Definition: artifact.h:24
FaceWrapper.h
ArtifactListWrapper::ArtifactListWrapper
ArtifactListWrapper(AssetWrapper *parent, artifactlist *list, ResourcesManager *resourcesManager)
Definition: ArtifactListWrapper.cpp:18
ResourcesManager.h
item
Definition: item.py:1
ArtifactListWrapper::child
virtual AssetWrapper * child(int) override
Definition: ArtifactListWrapper.cpp:26
AssetWrapper::wasModified
virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra)
Definition: AssetWrapper.h:78
artifactlist::total_chance
uint16_t total_chance
Definition: artifact.h:26
npc_dialog.index
int index
Definition: npc_dialog.py:102
AssetWrapper::markModified
void markModified(ChangeType change, int extra=0)
Definition: AssetWrapper.h:55
ArtifactListWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: ArtifactListWrapper.cpp:44
ArtifactListWrapper::childIndex
virtual int childIndex(AssetWrapper *) override
Definition: ArtifactListWrapper.cpp:33
AssetWrapper::DoesntUse
@ DoesntUse
Definition: AssetWrapper.h:32
CREPixmap.h
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
AssetTWrapper
Definition: AssetWrapper.h:94