Skip to content

Commit

Permalink
added the missing "needs_drifting" field to the NavRoute class
Browse files Browse the repository at this point in the history
Ctri-The-Third committed Dec 5, 2023
1 parent 6b65ea9 commit 0e942a6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion straders_sdk/pathfinder/route.py
Original file line number Diff line number Diff line change
@@ -85,6 +85,7 @@ def __init__(
seconds_to_destination: int,
compilation_timestamp: datetime,
max_fuel: int,
needs_drifting: bool,
) -> None:
pass
self.start_waypoint: Waypoint = start_waypoint
@@ -95,6 +96,7 @@ def __init__(
self.seconds_to_destination: int = seconds_to_destination
self.compilation_timestamp: datetime = compilation_timestamp
self.max_fuel: int = max_fuel
self.needs_drifting: bool = needs_drifting

def to_json(self):
return {
@@ -108,12 +110,13 @@ def to_json(self):
"%Y-%m-%d %H:%M:%S"
),
"max_fuel": self.max_fuel,
"needs_drifting": self.needs_drifting,
}

def save_to_file(self, destination_folder: str):
try:
with open(
f"{destination_folder}{self.start_waypoint.symbol}-{self.end_waypoint.symbol}.json",
f"{destination_folder}{self.start_waypoint.symbol}-{self.end_waypoint.symbol}[{self.max_fuel}].json",
"w",
encoding="utf-8",
) as f:
@@ -136,5 +139,12 @@ def from_json(cls, json_data):
json_data["seconds_to_destination"],
datetime.fromisoformat(json_data["compilation_timestamp"]),
json_data["max_fuel"],
json_data["needs_drifting"],
)
return route

@classmethod
def from_file(cls, file_path: str):
with open(file_path, "r", encoding="utf-8") as f:
json_data = json.load(f)
return cls.from_json(json_data)

0 comments on commit 0e942a6

Please sign in to comment.