Difference between revisions of "User:Ivan/Mod format WIP"
From VCMI Project Wiki
(Sandbox, testing syntax highlight) |
m |
||
Line 6: | Line 6: | ||
[ | [ | ||
{ | { | ||
− | "id": 146, / | + | "id": 146, /* axe of smashing */ |
"bonusesPerLevel": | "bonusesPerLevel": | ||
[ | [ | ||
Line 42: | Line 42: | ||
int CHeroClass::chooseSecSkill(const std::set<int> & possibles) const //picks secondary skill out from given possibilities | int CHeroClass::chooseSecSkill(const std::set<int> & possibles) const //picks secondary skill out from given possibilities | ||
{ | { | ||
− | if(possibles.size()==1) | + | if(possibles.size()==1) /* picks secondary skill out from given */ |
return *possibles.begin(); | return *possibles.begin(); | ||
int totalProb = 0; | int totalProb = 0; |
Revision as of 13:50, 14 December 2012
Sandbox, testing syntax highlight
{
"artifacts":
[
{
"id": 146, /* axe of smashing */
"bonusesPerLevel":
[
{
"level": 6,
"bonus": ["PRIMARY_SKILL", 1, 0, 0]
}
]
},
{
"id": 147, //mithril mail
"bonusesPerLevel":
[
{
"level": 1,
"bonus": ["STACK_HEALTH", 1, 0, 0]
}
]
},
{
"id": 148, //sword of sharpness
"bonusesPerLevel":
[
{
"level": 1,
"bonus": ["CREATURE_DAMAGE", 1, 0, 0]
}
]
}
]
}
int CHeroClass::chooseSecSkill(const std::set<int> & possibles) const //picks secondary skill out from given possibilities
{
if(possibles.size()==1) /* picks secondary skill out from given */
return *possibles.begin();
int totalProb = 0;
for(std::set<int>::const_iterator i=possibles.begin(); i!=possibles.end(); i++)
{
totalProb += proSec[*i];
}
int ran = rand()%totalProb;
for(std::set<int>::const_iterator i=possibles.begin(); i!=possibles.end(); i++)
{
ran -= proSec[*i];
if(ran<0)
return *i;
}
throw std::runtime_error("Cannot pick secondary skill!");
}