python-sc2
python-sc2 copied to clipboard
make already_pending_upgrade safe for all UpgradeId
In case of iteration over UpgradeId to poll current upgrades
Can you give me an example of in which situation it currently fails?
Edit: It seems in the context of
pending_upgrades = [upgrade for upgrade in UpgradeId if self.already_pending_upgrade(upgrade) != 0]
it fails. But in my opinion this is bad practice because it loops over upgrades that are no in the game. So a better solution would be to pre-filter UpgradeIds that are not in the game at all. If you want to iterate over UpgradeIds like that, I'd suggest using the dict in https://github.com/BurnySc2/python-sc2/blob/develop/sc2/dicts/upgrade_researched_from.py
From a conversation I had in discord, it seems this PR aims to return 0
whenever an UpgradeId was given as argument, that is not in the game (but in the enum list). However this seems like a rare use case to me and seems bad practice in general.
Closing the PR because of this