| @@ -5,10 +5,10 @@ python_main_dir=/usr/local/PlayerCode/CAPI/python | |||||
| playback_dir=/usr/local/playback | playback_dir=/usr/local/playback | ||||
| if [ $EXPOSED -eq 1 ]; then | if [ $EXPOSED -eq 1 ]; then | ||||
| nice -10 ./Server --port 8888 --studentCount 4 --trickerCount 1 --resultFileName $playback_dir/result --gameTimeInSecond $TIME --mapResource $MAP --url $URL --token $TOKEN --fileName $playback_dir/video --startLockFile $playback_dir/start.lock > $playback_dir/server.log 2>&1 & | |||||
| nice -10 ./Server --port 8888 --studentCount 4 --trickerCount 1 --resultFileName $playback_dir/result --gameTimeInSecond $TIME --mode $MODE --mapResource $MAP --url $URL --token $TOKEN --fileName $playback_dir/video --startLockFile $playback_dir/start.lock > $playback_dir/server.log 2>&1 & | |||||
| server_pid=$! | server_pid=$! | ||||
| else | else | ||||
| nice -10 ./Server --port 8888 --studentCount 4 --trickerCount 1 --resultFileName $playback_dir/result --gameTimeInSecond $TIME --mapResource $MAP --notAllowSpectator --url $URL --token $TOKEN --fileName $playback_dir/video --startLockFile $playback_dir/start.lock > $playback_dir/server.log 2>&1 & | |||||
| nice -10 ./Server --port 8888 --studentCount 4 --trickerCount 1 --resultFileName $playback_dir/result --gameTimeInSecond $TIME --mode $MODE --mapResource $MAP --notAllowSpectator --url $URL --token $TOKEN --fileName $playback_dir/video --startLockFile $playback_dir/start.lock > $playback_dir/server.log 2>&1 & | |||||
| server_pid=$! | server_pid=$! | ||||
| fi | fi | ||||
| sleep 5 | sleep 5 | ||||
| @@ -74,5 +74,8 @@ namespace Server | |||||
| [Option("startLockFile", Required = false, HelpText = "Whether to create a file that identifies whether the game has started")] | [Option("startLockFile", Required = false, HelpText = "Whether to create a file that identifies whether the game has started")] | ||||
| public string StartLockFile { get; set; } = DefaultArgumentOptions.FileName; | public string StartLockFile { get; set; } = DefaultArgumentOptions.FileName; | ||||
| [Option("mode", Required = false, HelpText = "Whether to run final competition")] | |||||
| public int Mode { get; set; } = 0; | |||||
| } | } | ||||
| } | |||||
| } | |||||
| @@ -102,10 +102,9 @@ namespace Server | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| protected void SendGameResult() // 天梯的 Server 给网站发消息记录比赛结果 | |||||
| protected void SendGameResult(int[] scores, int mode) // 天梯的 Server 给网站发消息记录比赛结果 | |||||
| { | { | ||||
| int[] scores = GetScore(); | |||||
| httpSender?.SendHttpRequest(scores).Wait(); | |||||
| httpSender?.SendHttpRequest(scores, mode).Wait(); | |||||
| } | } | ||||
| private void OnGameEnd() | private void OnGameEnd() | ||||
| @@ -114,7 +113,8 @@ namespace Server | |||||
| mwr?.Flush(); | mwr?.Flush(); | ||||
| if (options.ResultFileName != DefaultArgumentOptions.FileName) | if (options.ResultFileName != DefaultArgumentOptions.FileName) | ||||
| SaveGameResult(options.ResultFileName.EndsWith(".json") ? options.ResultFileName : options.ResultFileName + ".json"); | SaveGameResult(options.ResultFileName.EndsWith(".json") ? options.ResultFileName : options.ResultFileName + ".json"); | ||||
| SendGameResult(); | |||||
| int[] scores = GetScore(); | |||||
| SendGameResult(scores, options.Mode); | |||||
| this.endGameSem.Release(); | this.endGameSem.Release(); | ||||
| } | } | ||||
| public void ReportGame(GameState gameState, bool requiredGaming = true) | public void ReportGame(GameState gameState, bool requiredGaming = true) | ||||
| @@ -20,7 +20,7 @@ namespace Server | |||||
| // { | // { | ||||
| // this.SendHttpRequest(new()).Wait(); | // this.SendHttpRequest(new()).Wait(); | ||||
| // } | // } | ||||
| public async Task SendHttpRequest(int[] scores) | |||||
| public async Task SendHttpRequest(int[] scores, int mode) | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -33,7 +33,7 @@ namespace Server | |||||
| new TeamScore() { team_id = 0, score = scores[0], }, | new TeamScore() { team_id = 0, score = scores[0], }, | ||||
| new TeamScore() { team_id = 1, score = scores[1], }, | new TeamScore() { team_id = 1, score = scores[1], }, | ||||
| }, | }, | ||||
| mode = 0 | |||||
| mode = mode | |||||
| }))) | }))) | ||||
| { | { | ||||
| Console.WriteLine("Send to web successfully!"); | Console.WriteLine("Send to web successfully!"); | ||||