Browse Source

Merge pull request #637 from eesast/TCL606-patch-1

chore: add mode
tags/v0.1.0
Changli Tang GitHub 2 years ago
parent
commit
1a49c9e237
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 9 deletions
  1. +2
    -2
      dependency/shell/run.sh
  2. +4
    -1
      logic/Server/ArgumentOption.cs
  3. +4
    -4
      logic/Server/GameServer.cs
  4. +2
    -2
      logic/Server/HttpSender.cs

+ 2
- 2
dependency/shell/run.sh View File

@@ -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


+ 4
- 1
logic/Server/ArgumentOption.cs View File

@@ -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;
} }
}
}

+ 4
- 4
logic/Server/GameServer.cs View File

@@ -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)


+ 2
- 2
logic/Server/HttpSender.cs View File

@@ -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!");


Loading…
Cancel
Save