fix(backend): handle None destination in plan_next_actions to prevent errors

Previously, the code assumed dest was always a valid tuple, potentially causing errors if dest was None. Added a check to guide to current position when dest is None, ensuring safe fallback behavior.
This commit is contained in:
2025-12-28 12:37:39 +08:00
parent 033979c663
commit 6cae6a2ad8

View File

@@ -265,7 +265,10 @@ def plan_next_actions(req):
protect_list.remove((f[0],f[1]))
else:
continue
player_moves[p["name"]] = myMap.guideance(p["posX"],p["posY"],dest[0],dest[1])
if dest is not None:
player_moves[p["name"]] = myMap.guideance(p["posX"],p["posY"],dest[0],dest[1])
else:
player_moves[p["name"]] = myMap.guideance(p["posX"],p["posY"],p["posX"],p["posY"])
return player_moves
def game_over(req):