mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-09 13:14:02 +02:00
vcmi: rework CArtHandler
This commit is contained in:
parent
54eb550eb9
commit
a1e8d95028
@ -740,9 +740,21 @@ void CArtHandler::erasePickedArt(const ArtifactID & id)
|
|||||||
{
|
{
|
||||||
CArtifact *art = objects[id];
|
CArtifact *art = objects[id];
|
||||||
|
|
||||||
if(auto artl = listFromClass(art->aClass))
|
if(!(art->aClass & CArtifact::ART_SPECIAL))
|
||||||
{
|
{
|
||||||
auto & artifactList = artl->get();
|
auto & artifactList = treasures;
|
||||||
|
switch(art->aClass)
|
||||||
|
{
|
||||||
|
case CArtifact::ART_MINOR:
|
||||||
|
artifactList = minors;
|
||||||
|
break;
|
||||||
|
case CArtifact::ART_MAJOR:
|
||||||
|
artifactList = majors;
|
||||||
|
break;
|
||||||
|
case CArtifact::ART_RELIC:
|
||||||
|
artifactList = relics;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if(artifactList.empty())
|
if(artifactList.empty())
|
||||||
fillList(artifactList, art->aClass);
|
fillList(artifactList, art->aClass);
|
||||||
|
|
||||||
@ -759,23 +771,6 @@ void CArtHandler::erasePickedArt(const ArtifactID & id)
|
|||||||
logMod->warn("Problem: cannot find list for artifact %s, strange class. (special?)", art->getNameTranslated());
|
logMod->warn("Problem: cannot find list for artifact %s, strange class. (special?)", art->getNameTranslated());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::reference_wrapper<std::vector<CArtifact *>>> CArtHandler::listFromClass(CArtifact::EartClass artifactClass)
|
|
||||||
{
|
|
||||||
switch(artifactClass)
|
|
||||||
{
|
|
||||||
case CArtifact::ART_TREASURE:
|
|
||||||
return {std::ref(treasures)};
|
|
||||||
case CArtifact::ART_MINOR:
|
|
||||||
return {std::ref(minors)};
|
|
||||||
case CArtifact::ART_MAJOR:
|
|
||||||
return {std::ref(majors)};
|
|
||||||
case CArtifact::ART_RELIC:
|
|
||||||
return {std::ref(relics)};
|
|
||||||
default: //special artifacts should not be erased
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CArtHandler::fillList( std::vector<CArtifact*> &listToBeFilled, CArtifact::EartClass artifactClass )
|
void CArtHandler::fillList( std::vector<CArtifact*> &listToBeFilled, CArtifact::EartClass artifactClass )
|
||||||
{
|
{
|
||||||
assert(listToBeFilled.empty());
|
assert(listToBeFilled.empty());
|
||||||
|
@ -244,8 +244,6 @@ public:
|
|||||||
|
|
||||||
void fillList(std::vector<CArtifact*> &listToBeFilled, CArtifact::EartClass artifactClass); //fills given empty list with allowed artifacts of given class. No side effects
|
void fillList(std::vector<CArtifact*> &listToBeFilled, CArtifact::EartClass artifactClass); //fills given empty list with allowed artifacts of given class. No side effects
|
||||||
|
|
||||||
std::optional<std::reference_wrapper<std::vector<CArtifact *>>> listFromClass(CArtifact::EartClass artifactClass);
|
|
||||||
|
|
||||||
static CArtifact::EartClass stringToClass(const std::string & className); //TODO: rework EartClass to make this a constructor
|
static CArtifact::EartClass stringToClass(const std::string & className); //TODO: rework EartClass to make this a constructor
|
||||||
|
|
||||||
/// Gets a artifact ID randomly and removes the selected artifact from this handler.
|
/// Gets a artifact ID randomly and removes the selected artifact from this handler.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user