zone: added filters to search for creatures who can be trained for war/hunting

develop
Robert Heinrich 2012-04-15 17:40:39 +02:00
parent be580592ce
commit 8bbd43f2c9
2 changed files with 65 additions and 21 deletions

@ -830,6 +830,8 @@ Filters:
:tamed: Creature is tame. :tamed: Creature is tame.
:trained: Creature is trained. :trained: Creature is trained.
:untrained: Creature is untrained. :untrained: Creature is untrained.
:trainablewar: Creature can be trained for war (and is not already trained for war/hunt).
:trainablehunt: Creature can be trained for hunting (and is not already trained for war/hunt).
:male: Creature is male. :male: Creature is male.
:female: Creature is female. :female: Creature is female.
:egglayer: Race lays eggs. :egglayer: Race lays eggs.

@ -116,6 +116,8 @@ const string zone_help_filters =
" (could have weird effects during trading, be careful)\n" " (could have weird effects during trading, be careful)\n"
" trained - obvious\n" " trained - obvious\n"
" untrained - obvious\n" " untrained - obvious\n"
" trainablewar - can be trained for war (and is not already trained)\n"
" trainablehunt- can be trained for hunting (and is not already trained)\n"
" male - obvious\n" " male - obvious\n"
" female - obvious\n" " female - obvious\n"
" egglayer - race lays eggs (use together with 'female')\n" " egglayer - race lays eggs (use together with 'female')\n"
@ -563,6 +565,32 @@ bool isMilkable(df::unit* unit)
return false; return false;
} }
bool isTrainableWar(df::unit* unit)
{
df::creature_raw *raw = df::global::world->raws.creatures.all[unit->race];
size_t sizecas = raw->caste.size();
for (size_t j = 0; j < sizecas;j++)
{
df::caste_raw *caste = raw->caste[j];
if(caste->flags.is_set(caste_raw_flags::TRAINABLE_WAR))
return true;
}
return false;
}
bool isTrainableHunting(df::unit* unit)
{
df::creature_raw *raw = df::global::world->raws.creatures.all[unit->race];
size_t sizecas = raw->caste.size();
for (size_t j = 0; j < sizecas;j++)
{
df::caste_raw *caste = raw->caste[j];
if(caste->flags.is_set(caste_raw_flags::TRAINABLE_HUNTING))
return true;
}
return false;
}
bool isMale(df::unit* unit) bool isMale(df::unit* unit)
{ {
return unit->sex == 1; return unit->sex == 1;
@ -1459,6 +1487,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
bool find_uncaged = false; bool find_uncaged = false;
bool find_foreign = false; bool find_foreign = false;
bool find_untrained = false; bool find_untrained = false;
bool find_trainable_war = false;
bool find_trainable_hunting = false;
//bool find_trained = false; //bool find_trained = false;
bool find_war = false; bool find_war = false;
bool find_own = false; bool find_own = false;
@ -1593,6 +1623,16 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
out << "Filter by 'untrained'." << endl; out << "Filter by 'untrained'." << endl;
find_untrained = true; find_untrained = true;
} }
else if(p == "trainablewar")
{
out << "Filter by 'trainable for war'." << endl;
find_trainable_war = true;
}
else if(p == "trainablehunt")
{
out << "Filter by 'trainable for hunting'." << endl;
find_trainable_hunting = true;
}
else if(p == "war") else if(p == "war")
{ {
out << "Filter by 'trained war creature'." << endl; out << "Filter by 'trained war creature'." << endl;
@ -1896,6 +1936,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
|| (find_male && !isMale(unit)) || (find_male && !isMale(unit))
|| (find_female && !isFemale(unit)) || (find_female && !isFemale(unit))
|| (find_named && !unit->name.has_name) || (find_named && !unit->name.has_name)
|| (find_trainable_war && (isWar(unit) || isHunter(unit) || !isTrainableWar(unit)))
|| (find_trainable_hunting && (isWar(unit) || isHunter(unit) || !isTrainableHunting(unit)))
) )
continue; continue;