From 12add9001dc3f62e3e5e77ce39fe826a6ab29881 Mon Sep 17 00:00:00 2001 From: xiangmy21 <90919434+xiangmy21@users.noreply.github.com> Date: Wed, 8 May 2024 02:42:50 +0800 Subject: [PATCH 1/4] Update run.sh --- dependency/shell/run.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dependency/shell/run.sh b/dependency/shell/run.sh index 89f35a3e..bb10d6d1 100644 --- a/dependency/shell/run.sh +++ b/dependency/shell/run.sh @@ -64,11 +64,11 @@ function retry_command { sleep $sleep_seconds if kill -0 $PID 2>/dev/null; then - echo "Connected to server successfully." - return 0 - else echo "Failed to connect to server. Retrying..." ((attempt_num++)) + else + echo "Connected to server successfully." + return 0 fi done @@ -106,6 +106,7 @@ if [ "$TERMINAL" = "SERVER" ]; then finish_payload='{"result": {"status": "Crashed", "scores": [0, 0]}}' curl $FINISH_URL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d "${finish_payload}" > $playback_dir/send.log 2>&1 else + echo "Game is started." ps -p $server_pid while [ $? -eq 0 ] do From c6566ea79d18395ce523e0b7ea54ff036dae60a4 Mon Sep 17 00:00:00 2001 From: xiangmy21 <90919434+xiangmy21@users.noreply.github.com> Date: Wed, 8 May 2024 03:26:23 +0800 Subject: [PATCH 2/4] Update HttpSender.cs --- logic/Server/HttpSender.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/logic/Server/HttpSender.cs b/logic/Server/HttpSender.cs index 728e627a..c9652b5d 100755 --- a/logic/Server/HttpSender.cs +++ b/logic/Server/HttpSender.cs @@ -58,9 +58,8 @@ public async Task GetLadderScore(double[] scores) var jsonString = await response.Content.ReadAsStringAsync(); // 解析 JSON 字符串 - var result = JsonConvert.DeserializeObject>(jsonString); - double[] org = (from r in result select (double)(r.score)).ToArray(); - return org; + var result = JsonConvert.DeserializeObject(jsonString); + return result.Scores.Select(score => (double)score).ToArray();; } catch (Exception e) { From 242999a28cca3bb464eecae7f5df9d297c11aa2e Mon Sep 17 00:00:00 2001 From: xiangmy21 <90919434+xiangmy21@users.noreply.github.com> Date: Wed, 8 May 2024 03:36:50 +0800 Subject: [PATCH 3/4] fix(http): ContestResult type --- logic/Server/GameServer.cs | 3 ++- logic/Server/HttpSender.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index acee6f86..35292541 100755 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -15,7 +15,8 @@ namespace Server { public class ContestResult { - public int score; + public string status; + public int[] scores; } partial class GameServer : ServerBase { diff --git a/logic/Server/HttpSender.cs b/logic/Server/HttpSender.cs index c9652b5d..8c3e6db1 100755 --- a/logic/Server/HttpSender.cs +++ b/logic/Server/HttpSender.cs @@ -58,8 +58,8 @@ public async Task GetLadderScore(double[] scores) var jsonString = await response.Content.ReadAsStringAsync(); // 解析 JSON 字符串 - var result = JsonConvert.DeserializeObject(jsonString); - return result.Scores.Select(score => (double)score).ToArray();; + var result = JsonConvert.DeserializeObject(jsonString); + return result.Scores.Select(score => (double)score).ToArray(); } catch (Exception e) { From 1fcce7df26b4c0ceff8efbecd420a6722155a046 Mon Sep 17 00:00:00 2001 From: xiangmy21 <90919434+xiangmy21@users.noreply.github.com> Date: Wed, 8 May 2024 03:48:28 +0800 Subject: [PATCH 4/4] fix: ContestResult type --- logic/Server/GameServer.cs | 2 +- logic/Server/HttpSender.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index 35292541..82aa7286 100755 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -16,7 +16,7 @@ namespace Server public class ContestResult { public string status; - public int[] scores; + public double[] scores; } partial class GameServer : ServerBase { diff --git a/logic/Server/HttpSender.cs b/logic/Server/HttpSender.cs index 8c3e6db1..a4d1eb24 100755 --- a/logic/Server/HttpSender.cs +++ b/logic/Server/HttpSender.cs @@ -59,7 +59,7 @@ public async Task GetLadderScore(double[] scores) // 解析 JSON 字符串 var result = JsonConvert.DeserializeObject(jsonString); - return result.Scores.Select(score => (double)score).ToArray(); + return result.scores.Select(score => (double)score).ToArray(); } catch (Exception e) {