Skip to content

Commit

Permalink
Merge branch 'eesast:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamEnderKing authored May 5, 2024
2 parents 18f6605 + 4f9f793 commit 56e1bc5
Show file tree
Hide file tree
Showing 21 changed files with 960 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CAPI/cpp/API/include/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct State
std::shared_ptr<THUAI7::GameMap> mapInfo;
std::shared_ptr<THUAI7::GameInfo> gameInfo;
std::vector<int64_t> guids;
std::vector<int64_t> guids_all;
std::vector<int64_t> allGuids;
};

#endif
9 changes: 5 additions & 4 deletions CAPI/cpp/API/src/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ bool Logic::EndAllAction()

bool Logic::WaitThread()
{
Update();
if (asynchronous)
Wait();
return true;
}

Expand Down Expand Up @@ -821,14 +822,14 @@ void Logic::LoadBuffer(const protobuf::MessageToClient& message)
bufferState->enemyShips.clear();
bufferState->bullets.clear();
bufferState->guids.clear();
bufferState->guids_all.clear();
bufferState->allGuids.clear();
logger->info("Buffer cleared!");
// 读取新的信息
for (const auto& obj : message.obj_message())
if (Proto2THUAI7::messageOfObjDict[obj.message_of_obj_case()] == THUAI7::MessageOfObj::ShipMessage)
{
bufferState->guids_all.push_back(obj.ship_message().guid());
if (obj.obj.ship_message().team_id() == teamID)
bufferState->allGuids.push_back(obj.ship_message().guid());
if (obj.ship_message().team_id() == teamID)
bufferState->guids.push_back(obj.ship_message().guid());
}
bufferState->gameInfo = Proto2THUAI7::Protobuf2THUAI7GameInfo(message.all_message());
Expand Down
4 changes: 2 additions & 2 deletions CAPI/python/PyAPI/State.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self) -> None:
self.mapInfo = THUAI7.GameMap()
self.gameInfo = THUAI7.GameInfo()
self.guids = []
self.guids_all = []
self.allGuids = []

teamScore: int
self: Union[THUAI7.Ship, THUAI7.Team]
Expand All @@ -32,4 +32,4 @@ def __init__(self) -> None:
gameInfo: THUAI7.GameInfo

guids: List[int]
guids_all: List[int]
allGuids: List[int]
13 changes: 7 additions & 6 deletions CAPI/python/PyAPI/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def GetMessage(self) -> Tuple[int, Union[str, bytes]]:
return self.__messageQueue.get()

def WaitThread(self) -> bool:
self.__Update()
if Setting.Asynchronous():
self.__Wait()
return True

def GetCounter(self) -> int:
Expand Down Expand Up @@ -183,7 +184,7 @@ def GetHomeHp(self) -> int:
self.__logger.debug("Called GetHomeHp")
return copy.deepcopy(
self.__currentState.gameInfo.redHomeHp
if self.__teamID == 1
if self.__teamID == 0
else self.__currentState.gameInfo.blueHomeHp
)

Expand All @@ -192,7 +193,7 @@ def GetEnergy(self) -> int:
self.__logger.debug("Called GetEnergy")
return copy.deepcopy(
self.__currentState.gameInfo.redEnergy
if self.__teamID == 1
if self.__teamID == 0
else self.__currentState.gameInfo.blueEnergy
)

Expand All @@ -201,7 +202,7 @@ def GetScore(self) -> int:
self.__logger.debug("Called GetScore")
return copy.deepcopy(
self.__currentState.gameInfo.redScore
if self.__teamID == 1
if self.__teamID == 0
else self.__currentState.gameInfo.blueScore
)

Expand Down Expand Up @@ -314,12 +315,12 @@ def __LoadBuffer(self, message: Message2Clients.MessageToClient) -> None:
self.__bufferState.bullets.clear()
self.__bufferState.bombedBullets.clear()
self.__bufferState.guids.clear()
self.__bufferState.guids_all.clear()
self.__bufferState.allGuids.clear()
self.__logger.debug("Buffer cleared")

for obj in message.obj_message:
if obj.WhichOneof("message_of_obj") == "ship_message":
self.__bufferState.guids_all.append(obj.ship_message.guid)
self.__bufferState.allGuids.append(obj.ship_message.guid)
if obj.ship_message.team_id == self.__teamID:
self.__bufferState.guids.append(obj.ship_message.guid)

Expand Down
4 changes: 4 additions & 0 deletions CAPI/python/PyAPI/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ def Protobuf2THUAI7GameInfo(
gameInfo.gameTime = allMsg.game_time
gameInfo.redScore = allMsg.red_team_score
gameInfo.blueScore = allMsg.blue_team_score
gameInfo.redEnergy = allMsg.red_team_energy
gameInfo.blueEnergy = allMsg.blue_team_energy
gameInfo.redHomeHp = allMsg.red_home_hp
gameInfo.blueHomeHp = allMsg.blue_home_hp
return gameInfo


Expand Down
2 changes: 1 addition & 1 deletion CAPI/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
grpcio==1.62.2
grpcio==1.63.0
grpcio-tools==1.62.2
numpy
2 changes: 1 addition & 1 deletion CAPI/python_exp/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
grpcio==1.62.2
grpcio==1.63.0
grpcio-tools==1.62.2
numpy
2 changes: 1 addition & 1 deletion dependency/proto/Protos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Google.Protobuf.Tools" Version="3.26.1" />
<PackageReference Include="Grpc" Version="2.46.6" />
<PackageReference Include="Grpc.Core" Version="2.46.6" />
<PackageReference Include="Grpc.Tools" Version="2.62.0">
<PackageReference Include="Grpc.Tools" Version="2.63.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion dependency/shell/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ else
fi

if [ $flag -eq 1 ]; then
curl $URL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"Success"}' > $output/$base_name.curl.log
curl $URL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"Completed"}' > $output/$base_name.curl.log
else
curl $URL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"compile_status":"Failed"}' > $output/$base_name.curl.log
fi
2 changes: 1 addition & 1 deletion logic/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<PackageReference Include="FrameRateTask" Version="1.2.0" />
<PackageReference Include="Google.Protobuf" Version="3.26.1" />
<PackageReference Include="Grpc" Version="2.46.6" />
<PackageReference Include="Grpc.Tools" Version="2.62.0">
<PackageReference Include="Grpc.Tools" Version="2.63.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion logic/Client/Protos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="Google.Protobuf.Tools" Version="3.26.1" />
<PackageReference Include="Grpc" Version="2.46.6" />
<PackageReference Include="Grpc.Core" Version="2.46.6" />
<PackageReference Include="Grpc.Tools" Version="2.62.0">
<PackageReference Include="Grpc.Tools" Version="2.63.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 56e1bc5

Please sign in to comment.