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

Merge branch 'master' into 'master'

feat: add is_carrying_minerals field for Unit class

See merge request starcraft-ai-course/pycommandcenter!5
parents a63b0516 ec132ddd
No related branches found
No related tags found
No related merge requests found
...@@ -73,6 +73,9 @@ Unit ...@@ -73,6 +73,9 @@ Unit
.. autoattribute:: tile_position .. autoattribute:: tile_position
.. autoattribute:: unit_type .. autoattribute:: unit_type
.. autoattribute:: weapon_cooldown .. autoattribute:: weapon_cooldown
.. autoattribute:: is_carrying_minerals
Returns if this unit is currently holding minerals
.. attribute:: Unit.target .. attribute:: Unit.target
......
...@@ -34,6 +34,7 @@ void define_unit(py::module & m) ...@@ -34,6 +34,7 @@ void define_unit(py::module & m)
.def_property_readonly("current_ability_id", &Unit::getCurrentAbilityID, "The AbilityID of currently used ability") .def_property_readonly("current_ability_id", &Unit::getCurrentAbilityID, "The AbilityID of currently used ability")
.def_property_readonly("facing", &Unit::getFacing) .def_property_readonly("facing", &Unit::getFacing)
.def_property_readonly("radius", &Unit::getRadius) .def_property_readonly("radius", &Unit::getRadius)
.def_property_readonly("is_carrying_minerals", &Unit::isCarryingMinerals)
.def("hold_position", &Unit::holdPosition) .def("hold_position", &Unit::holdPosition)
.def("patrol", py::overload_cast<const CCPosition &>(&Unit::patrol, py::const_)) .def("patrol", py::overload_cast<const CCPosition &>(&Unit::patrol, py::const_))
.def("stop_dance", &Unit::stopDance) .def("stop_dance", &Unit::stopDance)
......
...@@ -425,3 +425,17 @@ void Unit::stopDance() const ...@@ -425,3 +425,17 @@ void Unit::stopDance() const
BOT_ASSERT(isValid(), "Unit is not valid"); BOT_ASSERT(isValid(), "Unit is not valid");
m_bot->Actions()->UnitCommand(m_unit, sc2::ABILITY_ID::STOP_DANCE); m_bot->Actions()->UnitCommand(m_unit, sc2::ABILITY_ID::STOP_DANCE);
} }
bool Unit::isCarryingMinerals() const
{
BOT_ASSERT(isValid(), "Unit is not valid");
std::vector<CCBuff> buffs = m_unit->buffs;
for (auto & b : buffs)
{
if (b.to_string() == "271" or b.to_string() == "272")
{
return true;
}
}
return false;
}
...@@ -47,6 +47,7 @@ public: ...@@ -47,6 +47,7 @@ public:
bool isValid() const; bool isValid() const;
bool isTraining() const; bool isTraining() const;
bool isConstructing(const UnitType & type) const; bool isConstructing(const UnitType & type) const;
bool isCarryingMinerals() const;
bool isBlip() const; bool isBlip() const;
bool hasTarget() const; bool hasTarget() const;
......
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