From 058002f94071ff2fc043cdc1fece26cd430df4fa Mon Sep 17 00:00:00 2001 From: Joao Pedro Leal Date: Wed, 1 Mar 2023 14:54:18 -0300 Subject: [PATCH] feat(strategy/iron2023): implement ball get item dunder method --- entities/Ball.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/entities/Ball.py b/entities/Ball.py index 804c0b45..ad7b02f1 100644 --- a/entities/Ball.py +++ b/entities/Ball.py @@ -56,3 +56,12 @@ def _update_speeds(self): self.vx = speed(self._frames['x'], self.game.vision._fps) self.vy = speed(self._frames['y'], self.game.vision._fps) + + def __getitem__(self, item): + if item == 0: + return self.x + + if item == 1: + return self.y + + raise IndexError("Ball only has 2 coordinates")