| 79 | // result in the plants not being usable for farming or even collectable at all). |
| 80 | |
| 81 | selectability selectablePlant(color_ostream& out, const df::plant_raw* plant, bool farming) { |
| 82 | TRACE(log, out).print("analyzing {}\n", plant->id); |
| 83 | const DFHack::MaterialInfo basic_mat = DFHack::MaterialInfo(plant->material_defs.type[plant_material_def::basic_mat], plant->material_defs.idx[plant_material_def::basic_mat]); |
| 84 | bool outOfSeason = false; |
| 85 | selectability result = selectability::Nonselectable; |
| 86 | |
| 87 | if (plant->flags.is_set(plant_raw_flags::TREE)) { |
| 88 | DEBUG(log, out).print("{} is a selectable tree\n", plant->id); |
| 89 | if (farming) { |
| 90 | return selectability::Nonselectable; |
| 91 | } |
| 92 | else { |
| 93 | return selectability::Selectable; |
| 94 | } |
| 95 | } |
| 96 | else if (plant->flags.is_set(plant_raw_flags::GRASS)) { |
| 97 | DEBUG(log, out).print("{} is a non selectable Grass\n", plant->id); |
| 98 | return selectability::Grass; |
| 99 | } |
| 100 | |
| 101 | if (farming && plant->material_defs.type[plant_material_def::seed] == -1) { |
| 102 | return selectability::Nonselectable; |
| 103 | } |
| 104 | |
| 105 | if (basic_mat.isValid() && |
| 106 | (basic_mat.material->flags.is_set(material_flags::EDIBLE_RAW) || |
| 107 | basic_mat.material->flags.is_set(material_flags::EDIBLE_COOKED))) |
| 108 | { |
| 109 | DEBUG(log, out).print("{} is edible\n", plant->id); |
| 110 | if (farming) { |
| 111 | if (basic_mat.material->flags.is_set(material_flags::EDIBLE_RAW)) { |
| 112 | result = selectability::Selectable; |
| 113 | } |
| 114 | } |
| 115 | else { |
| 116 | return selectability::Selectable; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | if (plant->flags.is_set(plant_raw_flags::THREAD) || |
| 121 | plant->flags.is_set(plant_raw_flags::MILL) || |
| 122 | plant->flags.is_set(plant_raw_flags::EXTRACT_VIAL) || |
| 123 | plant->flags.is_set(plant_raw_flags::EXTRACT_BARREL) || |
| 124 | plant->flags.is_set(plant_raw_flags::EXTRACT_STILL_VIAL)) { |
| 125 | DEBUG(log, out).print("{} is thread/mill/extract\n", plant->id); |
| 126 | if (farming) { |
| 127 | result = selectability::Selectable; |
| 128 | } |
| 129 | else { |
| 130 | return selectability::Selectable; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | if (basic_mat.isValid() && |
| 135 | (basic_mat.material->reaction_product.id.size() > 0 || |
| 136 | basic_mat.material->reaction_class.size() > 0)) |
| 137 | { |
| 138 | DEBUG(log, out).print("{} has a reaction\n", plant->id); |
no test coverage detected