Skip to content
Snippets Groups Projects
Commit 34020a41 authored by David Bergström's avatar David Bergström
Browse files

Fill TechTree with data from TechTreeImproved

parent 69438514
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,8 @@ void define_tech_tree(py::module & m)
.def_readonly("warp_ability", &TypeData::warpAbility, "the ability that creates this item via warp-in")
.def_readonly("what_builds", &TypeData::whatBuilds, "any of these units can build the item")
.def_readonly("required_units", &TypeData::requiredUnits, "owning ONE of these is required to make")
.def_readonly("required_upgrades", &TypeData::requiredUpgrades, "having ALL of these is required to make");
.def_readonly("required_upgrades", &TypeData::requiredUpgrades, "having ALL of these is required to make")
.def_readonly("required_addons", &TypeData::requiredAddons, "a unit of this type must be present next to the producer");
py::class_<TechTree>(m, "TechTree")
.def("get_data", py::overload_cast<const UnitType &>(&TechTree::getData, py::const_))
......
......@@ -12,6 +12,39 @@ void TechTree::onStart()
{
initUnitTypeData();
initUpgradeData();
/* As it turns out, some of the hard-coded values are wrong. Instead of
going through each and checking, we fix them with information from a
(hopefully) up to date JSON-file. Sorry in advance, this was the best
solution at the time. Hopefully the JSON-files are still up to date. */
TechTreeImproved tree;
tree.LoadData();
for (std::pair<const UnitType, TypeData> & pair : m_unitTypeData)
{
TypeData & data = pair.second;
data.whatBuilds.clear();
data.requiredUnits.clear();
// TODO: Support for upgrades, is it possible via JSON? Is the hard coded information correct?
data.requiredUpgrades.clear();
const std::vector<BuildDescription> & howToBuild = tree.HowToBuild(pair.first.getAPIUnitType());
for (const BuildDescription & description : howToBuild)
{
data.whatBuilds.push_back(UnitType(description.producer_type, m_bot));
for (sc2::UNIT_TYPEID unit_typeid : description.buildings_needed)
{
data.requiredUnits.push_back(UnitType(unit_typeid, m_bot));
}
for (sc2::UNIT_TYPEID unit_typeid : description.addons_needed)
{
data.requiredAddons.push_back(UnitType(unit_typeid, m_bot));
}
}
}
}
......
......@@ -25,6 +25,7 @@ struct TypeData
std::vector<UnitType> whatBuilds; // any of these units can build the item
std::vector<UnitType> requiredUnits; // owning ONE of these is required to make
std::vector<CCUpgrade> requiredUpgrades; // having ALL of these is required to make
std::vector<UnitType> requiredAddons; // a unit of this type must be present next to the producer
};
class TechTree
......
......@@ -9,13 +9,6 @@
int main(int argc, char* argv[])
{
TechTreeImproved tree;
tree.LoadData();
std::vector<BuildDescription> alts = tree.HowToBuild(sc2::UNIT_TYPEID::TERRAN_GHOST);
return 0;
sc2::Coordinator coordinator;
if (!coordinator.LoadSettings(argc, argv))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment