|
|
|
@@ -199,7 +199,113 @@ namespace starter.viewmodel.settings |
|
|
|
{ |
|
|
|
if (Tencent_cos_download.CheckAlreadyDownload()) |
|
|
|
{ |
|
|
|
Process.Start(System.IO.Path.Combine(Data.FilePath, startName)); |
|
|
|
//Process.Start(System.IO.Path.Combine(Data.FilePath, startName)); |
|
|
|
switch (RunProgram.RunInfo.mode) |
|
|
|
{ |
|
|
|
case RunProgram.RunMode.ServerOnly: |
|
|
|
RunProgram.StartServer(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.ServerForDebugOnly: |
|
|
|
RunProgram.StartServerForDebug(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.GUIAttendGameOnly: |
|
|
|
RunProgram.RunGUIClient(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.characterID, |
|
|
|
false, RunProgram.RunInfo.occupation, RunProgram.RunInfo.type); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.GUIVisit: |
|
|
|
RunProgram.RunGUIClient(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, 0, true, 1, 1); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.GUIAndAICpp: |
|
|
|
RunProgram.StartServerForDebug(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
Task.Delay(100); |
|
|
|
RunProgram.RunCpp(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.saveDebugLog, RunProgram.RunInfo.showDebugLog, |
|
|
|
RunProgram.RunInfo.warningOnly, RunProgram.RunInfo.playerId, RunProgram.RunInfo.filePath); |
|
|
|
RunProgram.RunInfo.playerId = null; |
|
|
|
RunProgram.RunInfo.filePath = null; |
|
|
|
RunProgram.RunGUIClient(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.characterID, |
|
|
|
false, RunProgram.RunInfo.occupation, RunProgram.RunInfo.type); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.GUIAndAIPython: |
|
|
|
RunProgram.StartServerForDebug(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
Task.Delay(100); |
|
|
|
RunProgram.RunPython(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.saveDebugLog, RunProgram.RunInfo.showDebugLog, |
|
|
|
RunProgram.RunInfo.warningOnly, RunProgram.RunInfo.playerId, RunProgram.RunInfo.filePath); |
|
|
|
RunProgram.RunInfo.playerId = null; |
|
|
|
RunProgram.RunInfo.filePath = null; |
|
|
|
RunProgram.RunGUIClient(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.characterID, |
|
|
|
false, RunProgram.RunInfo.occupation, RunProgram.RunInfo.type); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.ServerAndCpp: |
|
|
|
RunProgram.StartServer(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
Task.Delay(100); |
|
|
|
RunProgram.RunCpp(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.saveDebugLog, RunProgram.RunInfo.showDebugLog, |
|
|
|
RunProgram.RunInfo.warningOnly, RunProgram.RunInfo.playerId, RunProgram.RunInfo.filePath); |
|
|
|
RunProgram.RunInfo.playerId = null; |
|
|
|
RunProgram.RunInfo.filePath = null; |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.ServerAndPython: |
|
|
|
RunProgram.StartServer(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
Task.Delay(100); |
|
|
|
RunProgram.RunPython(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.saveDebugLog, RunProgram.RunInfo.showDebugLog, |
|
|
|
RunProgram.RunInfo.warningOnly, RunProgram.RunInfo.playerId, RunProgram.RunInfo.filePath); |
|
|
|
RunProgram.RunInfo.playerId = null; |
|
|
|
RunProgram.RunInfo.filePath = null; |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.ServerAndCppVisit: |
|
|
|
RunProgram.StartServer(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
Task.Delay(100); |
|
|
|
RunProgram.RunCpp(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.saveDebugLog, RunProgram.RunInfo.showDebugLog, |
|
|
|
RunProgram.RunInfo.warningOnly, RunProgram.RunInfo.playerId, RunProgram.RunInfo.filePath); |
|
|
|
RunProgram.RunInfo.playerId = null; |
|
|
|
RunProgram.RunInfo.filePath = null; |
|
|
|
RunProgram.RunGUIClient(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.characterID, true, 0, 1); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.ServerAndPythonVisit: |
|
|
|
RunProgram.StartServer(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
Task.Delay(100); |
|
|
|
RunProgram.RunPython(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.saveDebugLog, RunProgram.RunInfo.showDebugLog, |
|
|
|
RunProgram.RunInfo.warningOnly, RunProgram.RunInfo.playerId, RunProgram.RunInfo.filePath); |
|
|
|
RunProgram.RunInfo.playerId = null; |
|
|
|
RunProgram.RunInfo.filePath = null; |
|
|
|
RunProgram.RunGUIClient(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.characterID, true, 0, 1); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.ServerDebugAndCppVisit: |
|
|
|
RunProgram.StartServerForDebug(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
Task.Delay(100); |
|
|
|
RunProgram.RunCpp(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.saveDebugLog, RunProgram.RunInfo.showDebugLog, |
|
|
|
RunProgram.RunInfo.warningOnly, RunProgram.RunInfo.playerId, RunProgram.RunInfo.filePath); |
|
|
|
RunProgram.RunInfo.playerId = null; |
|
|
|
RunProgram.RunInfo.filePath = null; |
|
|
|
RunProgram.RunGUIClient(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.characterID, true, 0, 1); |
|
|
|
break; |
|
|
|
case RunProgram.RunMode.ServerDebugAndPythonVisit: |
|
|
|
RunProgram.StartServerForDebug(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.gameTimeSec, RunProgram.RunInfo.playbackFileName); |
|
|
|
Task.Delay(100); |
|
|
|
RunProgram.RunPython(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.studentCount, |
|
|
|
RunProgram.RunInfo.trickerCount, RunProgram.RunInfo.saveDebugLog, RunProgram.RunInfo.showDebugLog, |
|
|
|
RunProgram.RunInfo.warningOnly, RunProgram.RunInfo.playerId, RunProgram.RunInfo.filePath); |
|
|
|
RunProgram.RunInfo.playerId = null; |
|
|
|
RunProgram.RunInfo.filePath = null; |
|
|
|
RunProgram.RunGUIClient(RunProgram.RunInfo.IP, RunProgram.RunInfo.port, RunProgram.RunInfo.characterID, true, 0, 1); |
|
|
|
break; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
else |
|
|
|
@@ -773,7 +879,7 @@ namespace Downloader |
|
|
|
// 读取 Interlocked.CompareExchange(ref newFile, 0, 0); |
|
|
|
|
|
|
|
int upcnt = updateFileName.Count; |
|
|
|
if(upcnt <= 20) |
|
|
|
if (upcnt <= 20) |
|
|
|
{ |
|
|
|
while (newFileName.TryDequeue(out var filename)) |
|
|
|
{ |
|
|
|
@@ -1449,24 +1555,292 @@ namespace Downloader |
|
|
|
|
|
|
|
public class RunProgram |
|
|
|
{ |
|
|
|
public static int StartServer() |
|
|
|
{ |
|
|
|
Console.WriteLine("Input port: "); |
|
|
|
string? port = Console.ReadLine(); |
|
|
|
if(port == null || port.Length == 0) |
|
|
|
{ |
|
|
|
return 1; |
|
|
|
} |
|
|
|
Process process_cmd = new Process(); |
|
|
|
process_cmd.StartInfo.FileName = "cmd.exe"; |
|
|
|
process_cmd.StartInfo.RedirectStandardInput = true;//是否可以输入 |
|
|
|
process_cmd.StartInfo.RedirectStandardOutput = true;//是否可以输出 |
|
|
|
process_cmd.StartInfo.CreateNoWindow = false;//不创建窗体 也就是隐藏窗体 |
|
|
|
process_cmd.StartInfo.UseShellExecute = true;//是否使用系统shell执行,否 |
|
|
|
process_cmd.Start(); |
|
|
|
string command = Data.FilePath + "\\THUAI6\\win" + "\\win64\\Server.exe --port 8888 --studentCount 1 --trickerCount 1 --gameTimeInSecond 600 --fileName video"; |
|
|
|
process_cmd.StandardInput.WriteLine("你要执行的命令"); |
|
|
|
return -1; |
|
|
|
public enum RunMode |
|
|
|
{ |
|
|
|
ServerOnly, //只启动Server |
|
|
|
ServerForDebugOnly, //只启动ServerForDebug |
|
|
|
GUIAttendGameOnly, //只用GUIClient参与游戏 |
|
|
|
GUIVisit, //只用GUIClient观战 |
|
|
|
GUIAndAICpp, //用GUI参与游戏并且让cpp的AI同时参与 |
|
|
|
GUIAndAIPython, //用GUI参与游戏并且让python的AI同时参与 |
|
|
|
ServerAndCpp, //只运行Server和cpp, |
|
|
|
ServerAndPython, //只运行Server和python |
|
|
|
ServerAndCppVisit, //运行Server和Cpp并用GUI观战 |
|
|
|
ServerAndPythonVisit, //运行Server和python并用GUI观战 |
|
|
|
ServerDebugAndCpp, //运行ServerForDebug... |
|
|
|
ServerDebugAndPython, |
|
|
|
ServerDebugAndCppVisit, |
|
|
|
ServerDebugAndPythonVisit, |
|
|
|
} |
|
|
|
|
|
|
|
public class RunInfo //UI需要在调用Launch函数前保证其中数据已经更新并有效 |
|
|
|
{ |
|
|
|
static public RunMode mode; |
|
|
|
static public string? IP; |
|
|
|
static public int port; |
|
|
|
static public int studentCount; |
|
|
|
static public int trickerCount; |
|
|
|
static public int gameTimeSec; |
|
|
|
static public string? playbackFileName; |
|
|
|
static public int characterID; |
|
|
|
static public int type; |
|
|
|
static public bool saveDebugLog; |
|
|
|
static public bool showDebugLog; |
|
|
|
static public bool warningOnly; |
|
|
|
static public bool visiting; |
|
|
|
static public int occupation; |
|
|
|
static public List<int>? playerId = new List<int>(); //两者长度必须与studentCount + trickerCount一致 |
|
|
|
static public List<string>? filePath = new List<string>(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 运行cmd命令 |
|
|
|
/// 会显示命令窗口 |
|
|
|
/// </summary> |
|
|
|
/// <param name="cmdExe">指定应用程序的完整路径</param> |
|
|
|
/// <param name="cmdStr">执行命令行参数</param> |
|
|
|
static bool RunCmd(string cmdExe, string cmdStr) |
|
|
|
{ |
|
|
|
bool result = false; |
|
|
|
try |
|
|
|
{ |
|
|
|
using (Process myPro = new Process()) |
|
|
|
{ |
|
|
|
//指定启动进程是调用的应用程序和命令行参数 |
|
|
|
ProcessStartInfo psi = new ProcessStartInfo(cmdExe, cmdStr); |
|
|
|
myPro.StartInfo = psi; |
|
|
|
myPro.Start(); |
|
|
|
//myPro.WaitForExitAsync(); |
|
|
|
result = true; |
|
|
|
} |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 启动Server |
|
|
|
/// 会显示命令窗口 |
|
|
|
/// </summary> |
|
|
|
/// <param name="IP">指定Server运行的IPV4地址</param> |
|
|
|
/// <param name="port">指定Server运行的端口</param> |
|
|
|
/// <param name="studentCount">指定学生人数</param> |
|
|
|
/// <param name="trickerCount">指定捣蛋鬼人数</param> |
|
|
|
/// <param name="gameTimeSec">指定游戏最大时长</param> |
|
|
|
/// <param name="playbackFileName">指定回放文件名称</param> |
|
|
|
public static int StartServer(string? IP, int port, int studentCount, int trickerCount, int gameTimeSec, string? playbackFileName) |
|
|
|
{ |
|
|
|
if (System.Diagnostics.Process.GetProcessesByName("Server").ToList().Count > 0) |
|
|
|
{ |
|
|
|
System.Diagnostics.Process.GetProcessesByName("Server")[0].Kill(); |
|
|
|
} |
|
|
|
string cmdExe = $"{Data.FilePath}\\THUAI6\\win\\win64\\Server.exe"; |
|
|
|
string cmdPara = $"--ip {IP} --port {port} --studentCount {studentCount} --trickerCount {trickerCount}" + |
|
|
|
$" --gameTimeInSecond {gameTimeSec} --fileName {playbackFileName}"; |
|
|
|
RunCmd(cmdExe, cmdPara); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 启动Debug用的Server |
|
|
|
/// 会显示命令窗口 |
|
|
|
/// </summary> |
|
|
|
/// <param name="IP">指定Server运行的IPV4地址</param> |
|
|
|
/// <param name="port">指定Server运行的端口</param> |
|
|
|
/// <param name="studentCount">指定学生人数</param> |
|
|
|
/// <param name="trickerCount">指定捣蛋鬼人数</param> |
|
|
|
/// <param name="gameTimeSec">指定游戏最大时长</param> |
|
|
|
/// <param name="playbackFileName">指定回放文件名称</param> |
|
|
|
public static int StartServerForDebug(string? IP, int port, int studentCount, int trickerCount, int gameTimeSec, string? playbackFileName) |
|
|
|
{ |
|
|
|
if (System.Diagnostics.Process.GetProcessesByName("Server").ToList().Count > 0) |
|
|
|
{ |
|
|
|
System.Diagnostics.Process.GetProcessesByName("Server")[0].Kill(); |
|
|
|
} |
|
|
|
string cmdExe = $"{Data.FilePath}\\THUAI6\\win\\win64\\Debug\\Server.exe"; |
|
|
|
string cmdPara = $"--ip {IP} --port {port} --studentCount {studentCount} --trickerCount {trickerCount} " + |
|
|
|
$"--gameTimeInSecond {gameTimeSec} --fileName {playbackFileName}"; |
|
|
|
RunCmd(cmdExe, cmdPara); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 启动cpp,在这之前要先启动Server,可能还需要一些延时 |
|
|
|
/// 会显示命令窗口 |
|
|
|
/// </summary> |
|
|
|
/// <param name="IP">指定Server运行的IPV4地址</param> |
|
|
|
/// <param name="port">指定Server运行的端口</param> |
|
|
|
/// <param name="studentCount">指定学生人数</param> |
|
|
|
/// <param name="trickerCount">指定捣蛋鬼人数</param> |
|
|
|
/// <param name="saveDebugLog">是否保存Debug日志文件</param> |
|
|
|
/// <param name="showDebugLog">是否将日志输出到屏幕上</param> |
|
|
|
/// <param name="warningOnly">在showDebugLog == true时,是否只输出警告或者报错(不影响日志保存)</param> |
|
|
|
/// <param name="playerIp">默认为空,如果不为空,playerIp将会按照顺序代替默认从0~3的IP</param> |
|
|
|
public static int RunCpp(string? IP, int port, int studentCount, int trickerCount, bool saveDebugLog, |
|
|
|
bool showDebugLog, bool warningOnly, List<int>? playerIp = null, List<string>? filePath = null) |
|
|
|
{ |
|
|
|
string cmdExe; |
|
|
|
string cmdBase = $"-I {IP} -P {port} "; |
|
|
|
for (int i = 0; i < studentCount; i++) |
|
|
|
{ |
|
|
|
string cmdPara; |
|
|
|
if (playerIp == null) |
|
|
|
{ |
|
|
|
cmdPara = cmdBase + $" -p {i}"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmdPara = cmdBase + $" -p {playerIp[i]}"; |
|
|
|
} |
|
|
|
if (saveDebugLog) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -d"; |
|
|
|
} |
|
|
|
if (showDebugLog) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -o"; |
|
|
|
} |
|
|
|
if (warningOnly) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -w"; |
|
|
|
} |
|
|
|
if (filePath == null) |
|
|
|
{ |
|
|
|
cmdExe = $"{Data.FilePath}\\THUAI6\\win\\CAPI\\cpp\\x64\\Debug\\API.exe"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmdExe = filePath[i]; |
|
|
|
} |
|
|
|
RunCmd(cmdExe, cmdPara); |
|
|
|
} |
|
|
|
|
|
|
|
if (trickerCount != 0) |
|
|
|
{ |
|
|
|
string cmdPara; |
|
|
|
cmdPara = cmdBase + " -p 4"; |
|
|
|
if (saveDebugLog) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -d"; |
|
|
|
} |
|
|
|
if (showDebugLog) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -o"; |
|
|
|
} |
|
|
|
if (warningOnly) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -w"; |
|
|
|
} |
|
|
|
if (filePath == null) |
|
|
|
{ |
|
|
|
cmdExe = $"{Data.FilePath}\\THUAI6\\win\\CAPI\\cpp\\x64\\Debug\\API.exe"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmdExe = filePath[studentCount]; |
|
|
|
} |
|
|
|
RunCmd(cmdExe, cmdPara); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 启动客户端 |
|
|
|
/// 会显示命令窗口 |
|
|
|
/// </summary> |
|
|
|
/// <param name="IP">指定Server运行的IPV4地址</param> |
|
|
|
/// <param name="port">指定Server运行的端口</param> |
|
|
|
/// <param name="characterID">进入游戏时的角色ID 0~4,0~3为学生,4为捣蛋鬼</param> |
|
|
|
/// <param name="visiting">是否观战,当值为true时,characterID无效</param> |
|
|
|
/// <param name="occupation">指定参加游戏时的角色职业,详情见说明文档</param> |
|
|
|
/// <param name="type">角色类别,type = 1 表示学生,type = 2 表示捣蛋鬼</param> |
|
|
|
public static int RunGUIClient(string? IP, int port, int characterID, bool visiting, int occupation = 1, int type = 1) |
|
|
|
{ |
|
|
|
string cmdExe = $"{Data.FilePath}\\THUAI6\\win\\win64\\Client.exe"; |
|
|
|
string cmdBase = $"--port {port} --ip {IP} --type {type} --occupation {occupation}"; |
|
|
|
if (visiting) |
|
|
|
{ |
|
|
|
cmdBase = cmdBase + " --characterID 200000"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmdBase = cmdBase + $" --characterID {characterID}"; |
|
|
|
} |
|
|
|
cmdBase = cmdBase + " --cl"; |
|
|
|
RunCmd(cmdExe, cmdBase); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
//启动python,参数同RunCpp |
|
|
|
public static int RunPython(string? IP, int port, int studentCount, int trickerCount, bool saveDebugLog, |
|
|
|
bool showDebugLog, bool warningOnly, List<int>? playerIp = null, List<string>? filePath = null) |
|
|
|
{ |
|
|
|
string cmdExe = $"python"; |
|
|
|
string cmdBase; |
|
|
|
for (int i = 0; i < studentCount; i++) |
|
|
|
{ |
|
|
|
string cmdPara; |
|
|
|
if (filePath == null) |
|
|
|
{ |
|
|
|
cmdBase = $" {Data.FilePath}\\THUAI6\\win\\CAPI\\python\\PyAPI\\main.py -I {IP} -P {port} "; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmdBase = " " + filePath[i] + $" -I {IP} -P {port} "; |
|
|
|
} |
|
|
|
if (playerIp == null) |
|
|
|
{ |
|
|
|
cmdPara = cmdBase + $" -p {i}"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmdPara = cmdBase + $" -p {playerIp[i]}"; |
|
|
|
} |
|
|
|
if (saveDebugLog) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -d"; |
|
|
|
} |
|
|
|
if (showDebugLog) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -o"; |
|
|
|
} |
|
|
|
if (warningOnly) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -w"; |
|
|
|
} |
|
|
|
RunCmd(cmdExe, cmdPara); |
|
|
|
} |
|
|
|
|
|
|
|
if (trickerCount != 0) |
|
|
|
{ |
|
|
|
string cmdPara; |
|
|
|
if (filePath == null) |
|
|
|
{ |
|
|
|
cmdBase = $" {Data.FilePath}\\THUAI6\\win\\CAPI\\python\\PyAPI\\main.py -I {IP} -P {port} "; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmdBase = " " + filePath[studentCount] + $" -I {IP} -P {port} "; |
|
|
|
} |
|
|
|
cmdPara = cmdBase + " -p 4"; |
|
|
|
if (saveDebugLog) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -d"; |
|
|
|
} |
|
|
|
if (showDebugLog) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -o"; |
|
|
|
} |
|
|
|
if (warningOnly) |
|
|
|
{ |
|
|
|
cmdPara = cmdPara + " -w"; |
|
|
|
} |
|
|
|
RunCmd(cmdExe, cmdPara); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|