From bb01183a446771663f15c53ca9c3e9d5623f0045 Mon Sep 17 00:00:00 2001 From: LeKeno <33626494+lekeno@users.noreply.github.com> Date: Mon, 10 Aug 2020 19:50:38 +0900 Subject: [PATCH] checks See issue #333 --- edr/edrracingcircuit.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/edr/edrracingcircuit.py b/edr/edrracingcircuit.py index 0e0db6ed..54345bff 100644 --- a/edr/edrracingcircuit.py +++ b/edr/edrracingcircuit.py @@ -25,8 +25,26 @@ def reset(self): def current_waypoint(self): if self._is_finished(): return None + waypoint = self.waypoints[self._current_wp] + if "radius" not in waypoint: + waypoint["radius"] = self.radius + if "max_altitude" not in waypoint: + waypoint["max_altitude"] = self.max_altitude return self.waypoints[self._current_wp] + # TODO decide if distance calculation should be done here instead of the client, would need planet's radius + def wp_cleared(self, distance, altitude): + wp = self.current_waypoint() + if not wp: + return False + return distance <= wp["radius"] and altitude <= wp["max_altitude"] + + def disqualified(self, attitude): + wp = self.current_waypoint() + if not wp: + return altitude > self.max_altitude + return altitude > wp["max_altitude"] + def advance(self): now = EDTime.py_epoch_now() if not self.waypoints: