BurnySc2 / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
509 stars 157 forks source link

Make _prepare_step async and add Unit.abilities #163

Open BurnySc2 opened 1 year ago

BurnySc2 commented 1 year ago

Fixes https://github.com/BurnySc2/python-sc2/issues/157

This PR adds the Unit.abilities property which returns a set of AbilityId for all own units. Returns an empty set and a warning for neutral and enemy units. This is useful so you don't have to handle querying abilities yourself, to check if tech requirement is met or if an ability is on cooldown (e.g. blink). However this sends one query to the API on each iteration before on_step is called.

codecov-commenter commented 1 year ago

Codecov Report

Merging #163 (2ee5387) into develop (731c12c) will decrease coverage by 0.00%. The diff coverage is 65.00%.

@@             Coverage Diff             @@
##           develop     #163      +/-   ##
===========================================
- Coverage    60.16%   60.15%   -0.01%     
===========================================
  Files          107      107              
  Lines        13974    14011      +37     
===========================================
+ Hits          8408     8429      +21     
- Misses        5566     5582      +16     
Impacted Files Coverage Δ
sc2/main.py 15.54% <0.00%> (ø)
test/autotest_bot.py 0.00% <0.00%> (ø)
test/benchmark_bot_ai_init.py 0.00% <0.00%> (ø)
test/benchmark_prepare_units.py 0.00% <0.00%> (ø)
sc2/unit.py 79.94% <33.33%> (-0.42%) :arrow_down:
sc2/bot_ai_internal.py 60.07% <80.00%> (+0.07%) :arrow_up:
sc2/constants.py 98.64% <100.00%> (+0.01%) :arrow_up:
test/test_pickled_data.py 99.40% <100.00%> (+<0.01%) :arrow_up:
test/test_pickled_ramp.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.