hacky fix the indexerror

This commit is contained in:
Waylon Walker 2023-01-02 10:11:20 -06:00
parent 1e43a417af
commit 1c0766e985
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4

View file

@ -287,8 +287,12 @@ class Creeper(Game):
for i, tree in enumerate(copy(self.trees)):
if tree.health <= 0:
self.inventory["log"] = self.inventory.get("log", 0) + 10
del self.trees[i]
print(f"you have {self.inventory['log']} log")
try:
del self.trees[i]
except IndexError:
# get this one on the next pass
# killing two items in the same frame will error
...
def game(self):
creeper = next(self.creepers)