1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

changed indentation from spaces to tabs

This commit is contained in:
Henning Koehler 2017-08-30 16:23:03 +12:00
parent aadb5d93f7
commit 36d671b093
4 changed files with 925 additions and 925 deletions

View File

@ -1,48 +1,48 @@
{
"type":"object",
"$schema": "http://json-schema.org/draft-04/schema",
"type" : "object",
"$schema" : "http://json-schema.org/draft-04/schema",
"title" : "VCMI skill format",
"description" : "Format used to replace bonuses provided by secondary skills in VCMI",
"definitions" : {
"skillBonus":{
"type": "object",
"description": "Set of bonuses provided by skill at given level",
"required" : ["effects"],
"properties": {
"description": {
"type": "string",
"description": "localizable description"
},
"effects": {
"type": "object",
"additionalProperties" : {
"$ref" : "vcmi:bonus"
}
}
}
},
"skillBonus" : {
"type" : "object",
"description" : "Set of bonuses provided by skill at given level",
"required" : ["effects"],
"properties" : {
"description" : {
"type" : "string",
"description" : "localizable description"
},
"effects" : {
"type" : "object",
"additionalProperties" : {
"$ref" : "vcmi:bonus"
}
}
}
},
"required" : ["basic", "advanced", "expert"],
"required" : ["basic", "advanced", "expert"],
"properties": {
"base":{
"type": "object",
"description": "will be merged with all levels",
"additionalProperties": true
},
"basic":{
"$ref" : "#/definitions/skillBonus"
},
"advanced":{
"$ref" : "#/definitions/skillBonus"
},
"expert":{
"$ref" : "#/definitions/skillBonus"
}
}
"properties" : {
"base" : {
"type" : "object",
"description" : "will be merged with all levels",
"additionalProperties" : true
},
"basic" : {
"$ref" : "#/definitions/skillBonus"
},
"advanced" : {
"$ref" : "#/definitions/skillBonus"
},
"expert" : {
"$ref" : "#/definitions/skillBonus"
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -37,14 +37,14 @@ CSkill::LevelInfo::~LevelInfo()
CSkill::CSkill(SecondarySkill id) : id(id)
{
if(id == SecondarySkill::DEFAULT)
identifier = "default";
else
identifier = NSecondarySkill::names[id];
// init levels
LevelInfo emptyLevel;
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
levels.push_back(emptyLevel);
if(id == SecondarySkill::DEFAULT)
identifier = "default";
else
identifier = NSecondarySkill::names[id];
// init levels
LevelInfo emptyLevel;
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
levels.push_back(emptyLevel);
}
CSkill::~CSkill()
@ -53,42 +53,42 @@ CSkill::~CSkill()
void CSkill::addNewBonus(const std::shared_ptr<Bonus>& b, int level)
{
b->source = Bonus::SECONDARY_SKILL;
b->source = Bonus::SECONDARY_SKILL;
b->sid = id;
b->duration = Bonus::PERMANENT;
b->description = identifier;
levels[level-1].effects.push_back(b);
b->duration = Bonus::PERMANENT;
b->description = identifier;
levels[level-1].effects.push_back(b);
}
void CSkill::setDescription(const std::string & desc, int level)
{
levels[level-1].description = desc;
levels[level-1].description = desc;
}
const std::vector<std::shared_ptr<Bonus>> & CSkill::getBonus(int level) const
{
return levels[level-1].effects;
return levels[level-1].effects;
}
const std::string & CSkill::getDescription(int level) const
{
return levels[level-1].description;
return levels[level-1].description;
}
DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill::LevelInfo &info)
{
out << "(\"" << info.description << "\", [";
for(int i=0; i < info.effects.size(); i++)
out << (i ? "," : "") << info.effects[i]->Description();
return out << "])";
out << "(\"" << info.description << "\", [";
for(int i=0; i < info.effects.size(); i++)
out << (i ? "," : "") << info.effects[i]->Description();
return out << "])";
}
DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill &skill)
{
out << "Skill(" << (int)skill.id << "," << skill.identifier << "): [";
for(int i=0; i < skill.levels.size(); i++)
out << (i ? "," : "") << skill.levels[i];
return out << "]";
out << "Skill(" << (int)skill.id << "," << skill.identifier << "): [";
for(int i=0; i < skill.levels.size(); i++)
out << (i ? "," : "") << skill.levels[i];
return out << "]";
}
std::string CSkill::toString() const
@ -101,14 +101,14 @@ std::string CSkill::toString() const
///CSkillHandler
CSkillHandler::CSkillHandler()
{
for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++)
{
CSkill * skill = new CSkill(SecondarySkill(id));
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++)
{
CSkill * skill = new CSkill(SecondarySkill(id));
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
for (auto bonus : defaultBonus(SecondarySkill(id), level))
skill->addNewBonus(bonus, level);
objects.push_back(skill);
}
objects.push_back(skill);
}
}
std::vector<JsonNode> CSkillHandler::loadLegacyData(size_t dataSize)
@ -141,42 +141,42 @@ const std::string CSkillHandler::getTypeName() const
CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string & identifier)
{
CSkill * skill = NULL;
CSkill * skill = NULL;
for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++)
{
if(NSecondarySkill::names[id].compare(identifier) == 0)
{
skill = new CSkill(SecondarySkill(id));
break;
}
}
for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++)
{
if(NSecondarySkill::names[id].compare(identifier) == 0)
{
skill = new CSkill(SecondarySkill(id));
break;
}
}
if(!skill)
{
logGlobal->error("unknown secondary skill %s", identifier);
throw std::runtime_error("invalid skill");
}
if(!skill)
{
logGlobal->error("unknown secondary skill %s", identifier);
throw std::runtime_error("invalid skill");
}
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
{
const std::string & levelName = NSecondarySkill::levels[level]; // basic, advanced, expert
const JsonNode & levelNode = json[levelName];
// parse bonus effects
for(int level = 1; level < NSecondarySkill::levels.size(); level++)
{
const std::string & levelName = NSecondarySkill::levels[level]; // basic, advanced, expert
const JsonNode & levelNode = json[levelName];
// parse bonus effects
for(auto b : levelNode["effects"].Struct())
{
{
auto bonus = JsonUtils::parseBonus(b.second);
bonus->sid = skill->id;
skill->addNewBonus(bonus, level);
}
// parse skill description - tracked separately
if(vstd::contains(levelNode.Struct(), "description") && !levelNode["description"].isNull())
skill->setDescription(levelNode["description"].String(), level);
}
logMod->debug("loaded secondary skill %s(%d)", identifier, (int)skill->id);
logMod->trace("%s", skill->toString());
bonus->sid = skill->id;
skill->addNewBonus(bonus, level);
}
// parse skill description - tracked separately
if(vstd::contains(levelNode.Struct(), "description") && !levelNode["description"].isNull())
skill->setDescription(levelNode["description"].String(), level);
}
logMod->debug("loaded secondary skill %s(%d)", identifier, (int)skill->id);
logMod->trace("%s", skill->toString());
return skill;
return skill;
}
void CSkillHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
@ -231,8 +231,8 @@ CSkillHandler::~CSkillHandler()
std::vector<bool> CSkillHandler::getDefaultAllowed() const
{
std::vector<bool> allowedSkills(objects.size(), true);
return allowedSkills;
std::vector<bool> allowedSkills(objects.size(), true);
return allowedSkills;
}
// HMM3 default bonus provided by secondary skill

View File

@ -38,51 +38,51 @@ protected:
std::vector<LevelInfo> levels; // bonuses provided by basic, advanced and expert level
public:
CSkill(SecondarySkill id = SecondarySkill::DEFAULT);
~CSkill();
CSkill(SecondarySkill id = SecondarySkill::DEFAULT);
~CSkill();
void addNewBonus(const std::shared_ptr<Bonus>& b, int level);
void setDescription(const std::string & desc, int level);
const std::vector<std::shared_ptr<Bonus>> & getBonus(int level) const;
const std::string & getDescription(int level) const;
std::string toString() const;
void addNewBonus(const std::shared_ptr<Bonus>& b, int level);
void setDescription(const std::string & desc, int level);
const std::vector<std::shared_ptr<Bonus>> & getBonus(int level) const;
const std::string & getDescription(int level) const;
std::string toString() const;
SecondarySkill id;
std::string identifier;
SecondarySkill id;
std::string identifier;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & id & identifier;
h & levels;
}
template <typename Handler> void serialize(Handler &h, const int version)
{
h & id & identifier;
h & levels;
}
friend class CSkillHandler;
friend std::ostream & operator<<(std::ostream &out, const CSkill &skill);
friend std::ostream & operator<<(std::ostream &out, const CSkill::LevelInfo &info);
friend class CSkillHandler;
friend std::ostream & operator<<(std::ostream &out, const CSkill &skill);
friend std::ostream & operator<<(std::ostream &out, const CSkill::LevelInfo &info);
};
class DLL_LINKAGE CSkillHandler: public CHandlerBase<SecondarySkill, CSkill>
{
public:
CSkillHandler();
virtual ~CSkillHandler();
CSkillHandler();
virtual ~CSkillHandler();
///IHandler base
std::vector<JsonNode> loadLegacyData(size_t dataSize) override;
void afterLoadFinalization() override;
void beforeValidate(JsonNode & object) override;
///IHandler base
std::vector<JsonNode> loadLegacyData(size_t dataSize) override;
void afterLoadFinalization() override;
void beforeValidate(JsonNode & object) override;
std::vector<bool> getDefaultAllowed() const override;
const std::string getTypeName() const override;
void loadObject(std::string scope, std::string name, const JsonNode & data) override;
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
std::vector<bool> getDefaultAllowed() const override;
const std::string getTypeName() const override;
void loadObject(std::string scope, std::string name, const JsonNode & data) override;
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & objects ;
}
template <typename Handler> void serialize(Handler &h, const int version)
{
h & objects ;
}
protected:
CSkill * loadFromJson(const JsonNode & json, const std::string & identifier) override;
CSkill * loadFromJson(const JsonNode & json, const std::string & identifier) override;
std::vector<std::shared_ptr<Bonus>> defaultBonus(SecondarySkill skill, int level) const;
};