Crossfire Server, Trunk
ArtifactWrapper.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 "ArtifactWrapper.h"
14 #include "ResourcesManager.h"
15 #include "CREPixmap.h"
16 #include "faces/FaceWrapper.h"
17 #include "ArtifactListWrapper.h"
18 
20  : AssetTWrapper(parent, "Artifact", art), myResourcesManager(resourcesManager), mySpecificItem(nullptr)
21 {
22 }
23 
25  QString name(myWrappedItem->item->name);
26  if (mySpecificItem) {
27  int n, d;
29  name = tr("%1 (%2%, %3 chances on %4)")
30  .arg(name)
31  .arg(qRound(100. * n / d))
32  .arg(n)
33  .arg(d);
34  } else {
36  if (list && list->total_chance != 0) {
37  name = tr("%1 (%2%, %3 chances on %4)")
38  .arg(name)
39  .arg(qRound((float)100 * myWrappedItem->chance / list->total_chance))
40  .arg(myWrappedItem->chance)
41  .arg(list->total_chance);
42  }
43  }
44 
45  return name;
46 }
47 
50 }
51 
52 QString ArtifactWrapper::name() const {
53  return myWrappedItem->item->name;
54 }
55 
56 QObject* ArtifactWrapper::item() {
57  return myResourcesManager->wrap(myWrappedItem->item, this);
58 }
59 
60 int ArtifactWrapper::chance() const {
61  return myWrappedItem->chance;
62 }
63 
64 void ArtifactWrapper::setChance(int chance) {
65  if (myWrappedItem->chance != chance) {
68  }
69 }
70 
71 int ArtifactWrapper::difficulty() const {
72  return myWrappedItem->difficulty;
73 }
74 
75 QStringList ArtifactWrapper::allowed() const {
76  QStringList allowed;
77  for (const auto a : myWrappedItem->allowed)
78  allowed.append(a);
79  return allowed;
80 }
81 
82 AssetWrapper::PossibleUse ArtifactWrapper::uses(const AssetWrapper *asset, std::string &) const {
83  auto face = dynamic_cast<const FaceWrapper *>(asset);
84  if (face) {
85  return myWrappedItem->item->face == face->wrappedItem() ? Uses : DoesntUse;
86  }
87  auto anim = dynamic_cast<const AnimationWrapper *>(asset);
88  if (anim) {
89  return myWrappedItem->item->animation == anim->wrappedItem() ? Uses : DoesntUse;
90  }
91  return DoesntUse;
92 }
ArtifactWrapper::displayIcon
virtual QIcon displayIcon() const override
Definition: ArtifactWrapper.cpp:48
n
based on the size of the this randomly makes land number of spaces randomly lower or higher The default is Note that this is run also based on the the altitude amount will likely be less So if you do something like l and n
Definition: land.6.txt:25
AssetWrapper::markModified
void markModified(ChangeType change, int extra=0)
Definition: AssetWrapper.h:55
guildoracle.list
list
Definition: guildoracle.py:87
artifact::item
object * item
Definition: artifact.h:15
artifact::allowed
std::vector< sstring > allowed
Definition: artifact.h:18
AssetTWrapper< artifact >::myWrappedItem
artifact * myWrappedItem
Definition: AssetWrapper.h:104
AssetWrapper
Definition: AssetWrapper.h:25
ArtifactWrapper::allowed
QStringList allowed
Definition: ArtifactWrapper.h:31
FaceWrapper
Definition: FaceWrapper.h:24
FaceWrapper.h
AssetWrapper::AssetUpdated
@ AssetUpdated
Definition: AssetWrapper.h:33
ResourcesManager::wrap
ArchetypeWrapper * wrap(archetype *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:131
object::face
const Face * face
Definition: object.h:341
AssetTWrapper
Definition: AssetWrapper.h:94
ResourcesManager
Definition: ResourcesManager.h:80
AnimationWrapper
Definition: AnimationWrapper.h:24
object::type
uint8_t type
Definition: object.h:348
ArtifactWrapper::displayName
virtual QString displayName() const override
Definition: ArtifactWrapper.cpp:24
animate.anim
string anim
Definition: animate.py:20
object::animation
const Animations * animation
Definition: object.h:426
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
d
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for d
Definition: INSTALL_WIN32.txt:13
artifact_compute_chance_for_item
void artifact_compute_chance_for_item(const object *op, const artifact *art, int *numerator, int *denominator)
Definition: artifact.cpp:133
ArtifactWrapper::ArtifactWrapper
ArtifactWrapper(AssetWrapper *parent, artifact *art, ResourcesManager *resourcesManager)
Definition: ArtifactWrapper.cpp:19
ArtifactListWrapper.h
AssetWrapper::Uses
@ Uses
Definition: AssetWrapper.h:32
ResourcesManager.h
ArtifactWrapper::difficulty
int difficulty
Definition: ArtifactWrapper.h:30
object::name
sstring name
Definition: object.h:319
CREPixmap.h
ArtifactWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: ArtifactWrapper.h:51
artifact::chance
uint16_t chance
Definition: artifact.h:16
artifact_get_face
uint16_t artifact_get_face(const artifact *art)
Definition: artifact.cpp:638
ArtifactWrapper::name
QString name
Definition: ArtifactWrapper.h:27
ArtifactWrapper.h
artifact::difficulty
uint8_t difficulty
Definition: artifact.h:17
ArtifactWrapper::item
QObject item
Definition: ArtifactWrapper.h:28
a
Magical Runes Runes are magical inscriptions on the dungeon which cast a spell or detonate when something steps on them Flying objects don t detonate runes Beware ! Runes are invisible most of the time They are only visible occasionally ! There are several runes which are there are some special runes which may only be called with the invoke and people may apply it to read it Maybe useful for mazes ! This rune will not nor is it ordinarily invisible Partial Visibility of they ll be visible only part of the time They have a(your level/2) chance of being visible in any given round
ArtifactWrapper::mySpecificItem
const object * mySpecificItem
Definition: ArtifactWrapper.h:52
ArtifactWrapper::setChance
void setChance(int chance)
Definition: ArtifactWrapper.cpp:64
artifact
Definition: artifact.h:14
AssetWrapper::DoesntUse
@ DoesntUse
Definition: AssetWrapper.h:32
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:65
find_artifactlist
artifactlist * find_artifactlist(int type)
Definition: artifact.cpp:574
ArtifactWrapper::chance
int chance
Definition: ArtifactWrapper.h:29
ArtifactWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: ArtifactWrapper.cpp:82