1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-21 21:17:49 +02:00

Complete parsing for new Artifacts. iconIndex needs to be handled.

Otherwise, they are ready for test.
This commit is contained in:
DjWarmonger 2012-12-13 14:27:33 +00:00
parent 23fcdd1a4a
commit 62a281a665
4 changed files with 22 additions and 9 deletions

@ -215,6 +215,14 @@ std::string CArtifact::nodeName() const
// // //boost::algorithm::replace_first(description, "[spell name]", VLC->spellh->spells[spellid].name);
// }
void CArtifact::addNewBonus(Bonus *b)
{
b->source = Bonus::ARTIFACT;
b->duration = Bonus::PERMANENT;
b->description = name;
CBonusSystemNode::addNewBonus(b);
}
void CArtifact::setName (std::string desc)
{
name = desc;
@ -462,7 +470,12 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
art->setDescription (text["description"].String());
art->setName (text["event"].String());
art->image = node["image"].String();
const JsonNode & graphics = graphics["text"];
art->iconIndex = graphics["iconIndex"].Float();
art->image = graphics["image"].String();
value = &graphics["large"];
if (!value->isNull())
art->large = value->String();
art->price = node["value"].Float();
@ -504,8 +517,7 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
BOOST_FOREACH (const JsonNode &bonus, node["bonuses"].Vector())
{
auto b = JsonUtils::parseBonus(bonus);
b->source = Bonus::ARTIFACT;
b->duration = Bonus::PERMANENT;
//TODO: bonus->sid = art->id;
art->addNewBonus(b);
}
@ -715,11 +727,7 @@ void CArtHandler::addBonuses()
BOOST_FOREACH (auto b, artifact["bonuses"].Vector())
{
auto bonus = JsonUtils::parseBonus (b);
//common properties
bonus->source = Bonus::ARTIFACT;
bonus->sid = ga->id;
bonus->duration = Bonus::PERMANENT;
bonus->description = ga->Name();
ga->addNewBonus (bonus);
}
if(artifact["type"].String() == "Creature")

@ -76,6 +76,8 @@ public:
enum EartClass {ART_SPECIAL=1, ART_TREASURE=2, ART_MINOR=4, ART_MAJOR=8, ART_RELIC=16}; //artifact classes
std::string image;
std::string large; // big image for cutom artifacts, used in drag & drop
si32 iconIndex; //TODO: handle automatically
const std::string &Name() const; //getter
const std::string &Description() const; //getter
@ -87,6 +89,7 @@ public:
int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
std::string nodeName() const OVERRIDE;
void addNewBonus(Bonus *b) OVERRIDE;
virtual void levelUpArtifact (CArtifactInstance * art){};
@ -100,7 +103,8 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CBonusSystemNode&>(*this);
h & name & description & eventText & image & price & possibleSlots & constituents & constituentOf & aClass & id;
h & name & description & eventText & image & large & iconIndex &
price & possibleSlots & constituents & constituentOf & aClass & id;
}
CArtifact();

@ -141,6 +141,7 @@ void CModHandler::loadActiveMods()
VLC->townh->load(JsonUtils::assembleFromFiles(config ["factions"].convertTo<std::vector<std::string> >()));
VLC->creh->load( JsonUtils::assembleFromFiles(config["creatures"].convertTo<std::vector<std::string> >()));
VLC->arth->load( JsonUtils::assembleFromFiles(config["artifacts"].convertTo<std::vector<std::string> >()));
}
VLC->creh->buildBonusTreeForTiers(); //do that after all new creatures are loaded

@ -601,7 +601,7 @@ public:
void attachTo(CBonusSystemNode *parent);
void detachFrom(CBonusSystemNode *parent);
void detachFromAll();
void addNewBonus(Bonus *b); //b will be deleted with destruction of node
virtual void addNewBonus(Bonus *b); //b will be deleted with destruction of node
void accumulateBonus(Bonus &b); //add value of bonus with same type/subtype or create new
void newChildAttached(CBonusSystemNode *child);