issues with Feawn's evolution ability.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10559 c06c8d41-db1a-0410-9941-cceddc491573
XCGPG77ZJUVU6TH4Z4I3K677TAG7XTDEEWRP7IGVO7MG7GBVPOSQC
struct lesser_second
// Given a monster (well it should be a plant/fungus) see if evolve_flora can
// upgrade it, and set up a monster_conversion structure for it. Returns true
// (and fills in possible_monster) if input an be upgraded, and returns false
// otherwise.
bool _possible_evolution(monsters * input,
monster_conversion & possible_monster)
// Explicitly making this comparison unstable. I'm not clear on the
// complete implications of this but it should be ok for a heap.
if (left.second == right.second)
return coinflip();
case MONS_PLANT:
possible_monster.cost = plant_cost;
possible_monster.new_type = MONS_OKLOB_PLANT;
break;
case MONS_FUNGUS:
possible_monster.cost = fungus_cost;
possible_monster.new_type = MONS_WANDERING_MUSHROOM;
break;
int cost = 0;
switch (target->mons_species())
{
case MONS_PLANT:
cost = plant_cost;
break;
case MONS_FUNGUS:
cost = fungus_cost;
break;
case MONS_TOADSTOOL:
cost = toadstool_cost;
break;
};
if (cost != 0)
available_targets.push(std::pair<monsters *, int>(target, cost));
if (_possible_evolution(target, temp_conversion))
available_targets.push(temp_conversion);
// We can potentially upgrade toadstools a second time.
if (base_species == MONS_TOADSTOOL && rc != -1)
available_targets.push(monster_cost(&env.mons[rc], fungus_cost));
// Try to remove slowly dying in case we are upgrading a toadstool.
current_plant->del_ench(ENCH_SLOWLY_DYING);
// Maybe we can upgrade it again?
if (_possible_evolution(current_plant, temp_conversion)
&& temp_conversion.cost <= points)
{
available_targets.push(temp_conversion);
}