1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

get rid of few magic numbers (obj types)

This commit is contained in:
alexvins 2012-12-24 10:18:30 +00:00
parent 399fbb4dfa
commit 889031a95a
2 changed files with 52 additions and 34 deletions

View File

@ -519,31 +519,31 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
{
switch(obj->ID)
{
case 65:
return std::pair<int,int>(5, VLC->arth->getRandomArt (CArtifact::ART_TREASURE | CArtifact::ART_MINOR | CArtifact::ART_MAJOR | CArtifact::ART_RELIC));
case 66: //random treasure artifact
return std::pair<int,int>(5, VLC->arth->getRandomArt (CArtifact::ART_TREASURE));
case 67: //random minor artifact
return std::pair<int,int>(5, VLC->arth->getRandomArt (CArtifact::ART_MINOR));
case 68: //random major artifact
return std::pair<int,int>(5, VLC->arth->getRandomArt (CArtifact::ART_MAJOR));
case 69: //random relic artifact
return std::pair<int,int>(5, VLC->arth->getRandomArt (CArtifact::ART_RELIC));
case 70: //random hero
return std::pair<int,int>(Obj::HERO,pickHero(obj->tempOwner));
case 71: //random monster
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran)));
case 72: //random monster lvl1
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran), 1));
case 73: //random monster lvl2
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran), 2));
case 74: //random monster lvl3
return std::pair<int,int>(54,VLC->creh->pickRandomMonster(boost::ref(ran), 3));
case 75: //random monster lvl4
return std::pair<int,int>(54, VLC->creh->pickRandomMonster(boost::ref(ran), 4));
case 76: //random resource
return std::pair<int,int>(79,ran()%7); //now it's OH3 style, use %8 for mithril
case 77: //random town
case Obj::RANDOM_ART:
return std::pair<int,int>(Obj::ARTIFACT, VLC->arth->getRandomArt (CArtifact::ART_TREASURE | CArtifact::ART_MINOR | CArtifact::ART_MAJOR | CArtifact::ART_RELIC));
case Obj::RANDOM_TREASURE_ART:
return std::pair<int,int>(Obj::ARTIFACT, VLC->arth->getRandomArt (CArtifact::ART_TREASURE));
case Obj::RANDOM_MINOR_ART:
return std::pair<int,int>(Obj::ARTIFACT, VLC->arth->getRandomArt (CArtifact::ART_MINOR));
case Obj::RANDOM_MAJOR_ART:
return std::pair<int,int>(Obj::ARTIFACT, VLC->arth->getRandomArt (CArtifact::ART_MAJOR));
case Obj::RANDOM_RELIC_ART:
return std::pair<int,int>(Obj::ARTIFACT, VLC->arth->getRandomArt (CArtifact::ART_RELIC));
case Obj::RANDOM_HERO:
return std::pair<int,int>(Obj::HERO, pickHero(obj->tempOwner));
case Obj::RANDOM_MONSTER:
return std::pair<int,int>(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran)));
case Obj::RANDOM_MONSTER_L1:
return std::pair<int,int>(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 1));
case Obj::RANDOM_MONSTER_L2:
return std::pair<int,int>(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 2));
case Obj::RANDOM_MONSTER_L3:
return std::pair<int,int>(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 3));
case Obj::RANDOM_MONSTER_L4:
return std::pair<int,int>(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 4));
case Obj::RANDOM_RESOURCE:
return std::pair<int,int>(Obj::RESOURCE,ran()%7); //now it's OH3 style, use %8 for mithril
case Obj::RANDOM_TOWN:
{
int align = (static_cast<CGTownInstance*>(obj))->alignment,
f;
@ -566,15 +566,15 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
}
return std::pair<int,int>(Obj::TOWN,f);
}
case 162: //random monster lvl5
return std::pair<int,int>(54, VLC->creh->pickRandomMonster(boost::ref(ran), 5));
case 163: //random monster lvl6
return std::pair<int,int>(54, VLC->creh->pickRandomMonster(boost::ref(ran), 6));
case 164: //random monster lvl7
return std::pair<int,int>(54, VLC->creh->pickRandomMonster(boost::ref(ran), 7));
case 216: //random dwellings
case 217:
case 218:
case Obj::RANDOM_MONSTER_L5:
return std::pair<int,int>(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 5));
case Obj::RANDOM_MONSTER_L6:
return std::pair<int,int>(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 6));
case Obj::RANDOM_MONSTER_L7:
return std::pair<int,int>(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 7));
case Obj::RANDOM_DWELLING:
case Obj::RANDOM_DWELLING_LVL:
case Obj::RANDOM_DWELLING_FACTION:
{
CGDwelling * dwl = static_cast<CGDwelling*>(obj);
int faction;

View File

@ -311,6 +311,18 @@ namespace Obj
PRISON = 62,
PYRAMID = 63,
RALLY_FLAG = 64,
RANDOM_ART = 65,
RANDOM_TREASURE_ART = 66,
RANDOM_MINOR_ART = 67,
RANDOM_MAJOR_ART = 68,
RANDOM_RELIC_ART = 69,
RANDOM_HERO = 70,
RANDOM_MONSTER = 71,
RANDOM_MONSTER_L1 = 72,
RANDOM_MONSTER_L2 = 73,
RANDOM_MONSTER_L3 = 74,
RANDOM_MONSTER_L4 = 75,
RANDOM_RESOURCE = 76,
RANDOM_TOWN = 77,
REFUGEE_CAMP = 78,
RESOURCE = 79,
@ -344,10 +356,16 @@ namespace Obj
WHIRLPOOL = 111,
WINDMILL = 112,
HOLE = 124,
RANDOM_MONSTER_L5 = 162,
RANDOM_MONSTER_L6 = 163,
RANDOM_MONSTER_L7 = 164,
BORDER_GATE = 212,
FREELANCERS_GUILD = 213,
HERO_PLACEHOLDER = 214,
QUEST_GUARD = 215,
RANDOM_DWELLING = 216,
RANDOM_DWELLING_LVL = 217, //subtype = creature level
RANDOM_DWELLING_FACTION = 218, //subtype = faction
GARRISON2 = 219,
ABANDONED_MINE = 220,
TRADING_POST_SNOW = 221,