Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(PyAPI): 🐛 fix mismatch with proto #162

Merged
merged 2 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CAPI/python/PyAPI/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, logic: ILogic) -> None:
self.__pool = ThreadPoolExecutor(20)

def Move(self, timeInMilliseconds: int, angle: float) -> Future[bool]:
return self.__pool.submit(self.__logic.move, timeInMilliseconds, angle)
return self.__pool.submit(self.__logic.Move, timeInMilliseconds, angle)

def MoveRight(self, timeInMilliseconds: int) -> Future[bool]:
return self.Move(timeInMilliseconds, pi * 0.5)
Expand Down
138 changes: 69 additions & 69 deletions CAPI/python/PyAPI/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,120 +407,120 @@ def __LoadBufferCase(self, item: Message2Clients.MessageOfObj) -> None:
)
self.__logger.debug("Load Bullet!")

elif item.WhichOneof("message_of_obj") == "recycleBank_message":
if item.recycleBank_message.team_id == self.__teamID:
elif item.WhichOneof("message_of_obj") == "recyclebank_message":
if item.recyclebank_message.team_id == self.__teamID:
pos = (
AssistFunction.GridToCell(item.recycleBank_message.x),
AssistFunction.GridToCell(item.recycleBank_message.y),
AssistFunction.GridToCell(item.recyclebank_message.x),
AssistFunction.GridToCell(item.recyclebank_message.y),
)
if pos not in self.__bufferState.mapInfo.recycleBankState:
self.__bufferState.mapInfo.recycleBankState[pos] = (
item.recycleBank_message.hp
item.recyclebank_message.hp
)
self.__logger.debug("New RecycleBank")
else:
self.__bufferState.mapInfo.recycleBankState[pos] = (
item.recycleBank_message.hp
item.recyclebank_message.hp
)
self.__logger.debug("Update RecycleBank")
elif AssistFunction.HaveView(
self.__bufferState.self.viewRange,
self.__bufferState.self.x,
self.__bufferState.self.y,
item.recycleBank_message.x,
item.recycleBank_message.y,
item.recyclebank_message.x,
item.recyclebank_message.y,
self.__bufferState.gameMap,
):
pos = (
AssistFunction.GridToCell(item.recycleBank_message.x),
AssistFunction.GridToCell(item.recycleBank_message.y),
AssistFunction.GridToCell(item.recyclebank_message.x),
AssistFunction.GridToCell(item.recyclebank_message.y),
)
if pos not in self.__bufferState.mapInfo.recycleBankState:
self.__bufferState.mapInfo.recycleBankState[pos] = (
item.recycleBank_message.hp
item.recyclebank_message.hp
)
self.__logger.debug("New RecycleBank")
else:
self.__bufferState.mapInfo.recycleBankState[pos] = (
item.recycleBank_message.hp
item.recyclebank_message.hp
)
self.__logger.debug("Update RecycleBank")

elif item.WhichOneof("message_of_obj") == "chargeStation_message":
if item.chargeStation_message.team_id == self.__teamID:
elif item.WhichOneof("message_of_obj") == "chargestation_message":
if item.chargestation_message.team_id == self.__teamID:
pos = (
AssistFunction.GridToCell(item.chargeStation_message.x),
AssistFunction.GridToCell(item.chargeStation_message.y),
AssistFunction.GridToCell(item.chargestation_message.x),
AssistFunction.GridToCell(item.chargestation_message.y),
)
if pos not in self.__bufferState.mapInfo.chargeStationState:
self.__bufferState.mapInfo.chargeStationState[pos] = (
item.chargeStation_message.hp
item.chargestation_message.hp
)
self.__logger.debug("New ChargeStation")
else:
self.__bufferState.mapInfo.chargeStationState[pos] = (
item.chargeStation_message.hp
item.chargestation_message.hp
)
self.__logger.debug("Update ChargeStation")
elif AssistFunction.HaveView(
self.__bufferState.self.viewRange,
self.__bufferState.self.x,
self.__bufferState.self.y,
item.chargeStation_message.x,
item.chargeStation_message.y,
item.chargestation_message.x,
item.chargestation_message.y,
self.__bufferState.gameMap,
):
pos = (
AssistFunction.GridToCell(item.chargeStation_message.x),
AssistFunction.GridToCell(item.chargeStation_message.y),
AssistFunction.GridToCell(item.chargestation_message.x),
AssistFunction.GridToCell(item.chargestation_message.y),
)
if pos not in self.__bufferState.mapInfo.chargeStationState:
self.__bufferState.mapInfo.chargeStationState[pos] = (
item.chargeStation_message.hp
item.chargestation_message.hp
)
self.__logger.debug("New ChargeStation")
else:
self.__bufferState.mapInfo.chargeStationState[pos] = (
item.chargeStation_message.hp
item.chargestation_message.hp
)
self.__logger.debug("Update ChargeStation")

elif item.WhichOneof("message_of_obj") == "signalTower_message":
if item.signalTower_message.team_id == self.__teamID:
elif item.WhichOneof("message_of_obj") == "signaltower_message":
if item.signaltower_message.team_id == self.__teamID:
pos = (
AssistFunction.GridToCell(item.signalTower_message.x),
AssistFunction.GridToCell(item.signalTower_message.y),
AssistFunction.GridToCell(item.signaltower_message.x),
AssistFunction.GridToCell(item.signaltower_message.y),
)
if pos not in self.__bufferState.mapInfo.signalTowerState:
self.__bufferState.mapInfo.signalTowerState[pos] = (
item.signalTower_message.hp
item.signaltower_message.hp
)
self.__logger.debug("New SignalTower")
else:
self.__bufferState.mapInfo.signalTowerState[pos] = (
item.signalTower_message.hp
item.signaltower_message.hp
)
self.__logger.debug("Update SignalTower")
elif AssistFunction.HaveView(
self.__bufferState.self.viewRange,
self.__bufferState.self.x,
self.__bufferState.self.y,
item.signalTower_message.x,
item.signalTower_message.y,
item.signaltower_message.x,
item.signaltower_message.y,
self.__bufferState.gameMap,
):
pos = (
AssistFunction.GridToCell(item.signalTower_message.x),
AssistFunction.GridToCell(item.signalTower_message.y),
AssistFunction.GridToCell(item.signaltower_message.x),
AssistFunction.GridToCell(item.signaltower_message.y),
)
if pos not in self.__bufferState.mapInfo.signalTowerState:
self.__bufferState.mapInfo.signalTowerState[pos] = (
item.signalTower_message.hp
item.signaltower_message.hp
)
self.__logger.debug("New SignalTower")
else:
self.__bufferState.mapInfo.signalTowerState[pos] = (
item.signalTower_message.hp
item.signaltower_message.hp
)
self.__logger.debug("Update SignalTower")

Expand Down Expand Up @@ -634,105 +634,105 @@ def HaveOverView(targetX: int, targetY: int):
)
self.__logger.debug("Load enemy sweeper")

elif item.WhichOneof("message_of_obj") == "recycleBank_message":
if item.recycleBank_message.team_id == self.__teamID:
elif item.WhichOneof("message_of_obj") == "recyclebank_message":
if item.recyclebank_message.team_id == self.__teamID:
pos = (
AssistFunction.GridToCell(item.recycleBank_message.x),
AssistFunction.GridToCell(item.recycleBank_message.y),
AssistFunction.GridToCell(item.recyclebank_message.x),
AssistFunction.GridToCell(item.recyclebank_message.y),
)
if pos not in self.__bufferState.mapInfo.recycleBankState:
self.__bufferState.mapInfo.recycleBankState[pos] = (
item.recycleBank_message.hp
item.recyclebank_message.hp
)
self.__logger.debug("New RecycleBank")
else:
self.__bufferState.mapInfo.recycleBankState[pos] = (
item.recycleBank_message.hp
item.recyclebank_message.hp
)
self.__logger.debug("Update RecycleBank")
elif HaveOverView(
item.recycleBank_message.x, item.recycleBank_message.y
item.recyclebank_message.x, item.recyclebank_message.y
):
pos = (
AssistFunction.GridToCell(item.recycleBank_message.x),
AssistFunction.GridToCell(item.recycleBank_message.y),
AssistFunction.GridToCell(item.recyclebank_message.x),
AssistFunction.GridToCell(item.recyclebank_message.y),
)
if pos not in self.__bufferState.mapInfo.recycleBankState:
self.__bufferState.mapInfo.recycleBankState[pos] = (
item.recycleBank_message.hp
item.recyclebank_message.hp
)
self.__logger.debug("New RecycleBank")
else:
self.__bufferState.mapInfo.recycleBankState[pos] = (
item.recycleBank_message.hp
item.recyclebank_message.hp
)
self.__logger.debug("Update RecycleBank")

elif item.WhichOneof("message_of_obj") == "chargeStation_message":
if item.chargeStation_message.team_id == self.__teamID:
elif item.WhichOneof("message_of_obj") == "chargestation_message":
if item.chargestation_message.team_id == self.__teamID:
pos = (
AssistFunction.GridToCell(item.chargeStation_message.x),
AssistFunction.GridToCell(item.chargeStation_message.y),
AssistFunction.GridToCell(item.chargestation_message.x),
AssistFunction.GridToCell(item.chargestation_message.y),
)
if pos not in self.__bufferState.mapInfo.chargeStationState:
self.__bufferState.mapInfo.chargeStationState[pos] = (
item.chargeStation_message.hp
item.chargestation_message.hp
)
self.__logger.debug("New ChargeStation")
else:
self.__bufferState.mapInfo.chargeStationState[pos] = (
item.chargeStation_message.hp
item.chargestation_message.hp
)
self.__logger.debug("Update ChargeStation")
elif HaveOverView(
item.chargeStation_message.x, item.chargeStation_message.y
item.chargestation_message.x, item.chargestation_message.y
):
pos = (
AssistFunction.GridToCell(item.chargeStation_message.x),
AssistFunction.GridToCell(item.chargeStation_message.y),
AssistFunction.GridToCell(item.chargestation_message.x),
AssistFunction.GridToCell(item.chargestation_message.y),
)
if pos not in self.__bufferState.mapInfo.chargeStationState:
self.__bufferState.mapInfo.chargeStationState[pos] = (
item.chargeStation_message.hp
item.chargestation_message.hp
)
self.__logger.debug("New ChargeStation")
else:
self.__bufferState.mapInfo.chargeStationState[pos] = (
item.chargeStation_message.hp
item.chargestation_message.hp
)
self.__logger.debug("Update ChargeStation")

elif item.WhichOneof("message_of_obj") == "signalTower_message":
if item.signalTower_message.team_id == self.__teamID:
elif item.WhichOneof("message_of_obj") == "signaltower_message":
if item.signaltower_message.team_id == self.__teamID:
pos = (
AssistFunction.GridToCell(item.signalTower_message.x),
AssistFunction.GridToCell(item.signalTower_message.y),
AssistFunction.GridToCell(item.signaltower_message.x),
AssistFunction.GridToCell(item.signaltower_message.y),
)
if pos not in self.__bufferState.mapInfo.signalTowerState:
self.__bufferState.mapInfo.signalTowerState[pos] = (
item.signalTower_message.hp
item.signaltower_message.hp
)
self.__logger.debug("New SignalTower")
else:
self.__bufferState.mapInfo.signalTowerState[pos] = (
item.signalTower_message.hp
item.signaltower_message.hp
)
self.__logger.debug("Update SignalTower")
elif HaveOverView(
item.signalTower_message.x, item.signalTower_message.y
item.signaltower_message.x, item.signaltower_message.y
):
pos = (
AssistFunction.GridToCell(item.signalTower_message.x),
AssistFunction.GridToCell(item.signalTower_message.y),
AssistFunction.GridToCell(item.signaltower_message.x),
AssistFunction.GridToCell(item.signaltower_message.y),
)
if pos not in self.__bufferState.mapInfo.signalTowerState:
self.__bufferState.mapInfo.signalTowerState[pos] = (
item.signalTower_message.hp
item.signaltower_message.hp
)
self.__logger.debug("New SignalTower")
else:
self.__bufferState.mapInfo.signalTowerState[pos] = (
item.signalTower_message.hp
item.signaltower_message.hp
)
self.__logger.debug("Update SignalTower")

Expand Down
Loading