| @@ -14,3 +14,22 @@ A: | |||
| python -m pip install --upgrade pip | |||
| (pip 版本最好为23.1) | |||
| Q: Windows找不到文件:\CAPI\cpp\x64\Debug\APl.exe? | |||
| A: | |||
| 解决办法:打开CAPI\cpp目录,在里面打开CAPI.sln,然后点击生成,对代码进行编译 | |||
| Q: 怎么开始游戏? | |||
| A: | |||
| 需要确保学生阵营和捣蛋鬼阵营的人数都达到Server.cmd中设定的值。现有代码只能保证一个Client对应一个阵营,如果想要两侧同时运行,有三种办法:对于C++,可以先对一个阵营编译,然后修改API.exe的文件名,然后再更改AI.cpp中指定的阵营,对另一个阵营编译,最后修改RunCpp.cmd中的目标文件;对于Python,可以将整个python接口复制一份(CAPI\python文件夹),在第二份代码中修改阵营,然后同样修改RunPython.cmd中的目标文件;也可以打开WPF,方法是参考问题4中的教程,修改RunGUIClient.cmd的参数,然后运行RunGUIClient.cmd,这样可以通过WPF运行部分客户端,来达到人数限制。 | |||
| Q: Mac怎么用? | |||
| A: | |||
| 解决办法:安装Windows虚拟机 | |||
| Q: 怎么修改.cmd参数? | |||
| A: | |||
| 见选手包中的使用文档部分 | |||
| @@ -39,7 +39,7 @@ | |||
| <TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="5" Name="RouteTxtBox" Text="{Binding Route}" Visibility="{Binding RouteBoxVis}"/> | |||
| <Button Grid.Row="3" Grid.Column="6" Name="GetRouteBtn" Content="选择文件夹" Command="{Binding ClickBrowseCommand}" Visibility="{Binding RouteBoxVis}" /> | |||
| <Button Grid.Row="3" Grid.Column="7" Name="SetBtm" Content="{Binding ConfirmBtnCont}" Command="{Binding ClickConfirmCommand}" Visibility="{Binding RouteBoxVis}"/> | |||
| <Button Grid.Row="4" Grid.Column="6" Grid.ColumnSpan="2" Name="ReadExsisted" Content="从所选文件夹直接读取" Command="{Binding ClickReadCommand}" Visibility="{Binding NewUserVis}"/> | |||
| <Button Grid.Row="4" Grid.Column="6" Grid.ColumnSpan="2" Name="ReadExsisted" Content="所选文件夹即为选手包" Command="{Binding ClickReadCommand}" Visibility="{Binding NewUserVis}"/> | |||
| <Button Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" Name="UpdateBtn" Content="{Binding UpdateBtnCont}" Command="{Binding ClickUpdateCommand}" Visibility="{Binding MenuVis}" /> | |||
| <TextBlock Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" FontSize="10" Text="{Binding UpdateInfo}" Visibility="{Binding UpdateInfoVis}" /> | |||
| @@ -88,7 +88,7 @@ | |||
| <TextBlock Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Text="你有已完成的比赛!" Visibility="{Binding MatchFinishedVis}"/> | |||
| <Button Grid.Row="3" Grid.Column="1" Name ="Upload" Content="{Binding UploadBtnCont}" Command="{Binding ClickUploadCommand}" Visibility="{Binding WebVis}"/> | |||
| <TextBlock Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding CodeName}" Visibility="{Binding UploadReadyVis}" /> | |||
| <Button Grid.Row="3" Grid.Column="2" Name="ReUpload" Content="放弃上传" Command="{Binding ClickReselectCommand}" Visibility="{Binding UploadReadyVis}" /> | |||
| <Button Grid.Row="3" Grid.Column="2" Name="ReUpload" Content="{Binding AbortOrSelLanguage}" Command="{Binding ClickAboutUploadCommand}" Visibility="{Binding WebVis}" /> | |||
| <Button Grid.Row="6" Grid.Column="3" Grid.ColumnSpan="2" Content="退出登录" Command="{Binding ClickBackCommand}" Visibility="{Binding WebVis}" /> | |||
| <StackPanel Grid.Row="5" Grid.Column="1" Grid.RowSpan="3" Grid.ColumnSpan="2"> | |||
| <Grid> | |||
| @@ -31,6 +31,8 @@ using WebConnect; | |||
| using System.IO.Compression; | |||
| using ICSharpCode.SharpZipLib.Tar; | |||
| using ICSharpCode.SharpZipLib.GZip; | |||
| using static System.Net.WebRequestMethods; | |||
| using File = System.IO.File; | |||
| namespace starter.viewmodel.settings | |||
| { | |||
| @@ -656,6 +658,7 @@ namespace Downloader | |||
| //Console.WriteLine(filename + "下载完毕!" + Environment.NewLine); | |||
| updateFile++; | |||
| } | |||
| UpdatePlanned = false; | |||
| } | |||
| catch (CosClientException clientEx) | |||
| { | |||
| @@ -808,6 +811,16 @@ namespace Downloader | |||
| sw.Write(JsonConvert.SerializeObject(dict)); | |||
| Check(); | |||
| Download(); | |||
| if (File.Exists(Data.FilePath + "/THUAI6/AI.cpp")) | |||
| { | |||
| FileInfo userCpp = new FileInfo((Data.FilePath + "/THUAI6/AI.cpp").Replace("/", "\\")); | |||
| userCpp.MoveTo(Data.FilePath + "/THUAI6/win/CAPI/cpp/API/src/AI.cpp", true); | |||
| } | |||
| if (File.Exists(Data.FilePath + "/THUAI6/AI.py")) | |||
| { | |||
| FileInfo userCpp = new FileInfo((Data.FilePath + "/THUAI6/AI.py").Replace("/", "\\")); | |||
| userCpp.MoveTo(Data.FilePath + "/THUAI6/win/CAPI/python/PyAPI/AI.cpp", true); | |||
| } | |||
| } | |||
| public static void Change_all_hash(string topDir, Dictionary<string, string> jsonDict) // 更改HASH | |||
| @@ -887,7 +900,7 @@ namespace Downloader | |||
| public static int DeleteAll() | |||
| { | |||
| DirectoryInfo di = new DirectoryInfo(Data.FilePath); | |||
| DirectoryInfo di = new DirectoryInfo(Data.FilePath + "/THUAI6"); | |||
| //DirectoryInfo player = new DirectoryInfo(System.IO.Path.GetFullPath(System.IO.Path.Combine(Data.FilePath, playerFolder))); | |||
| FileInfo[] allfile = di.GetFiles(); | |||
| try | |||
| @@ -902,10 +915,16 @@ namespace Downloader | |||
| //} | |||
| file.Delete(); | |||
| } | |||
| FileInfo userFileCpp = new FileInfo(Data.FilePath + "/THUAI6/win/CAPI/cpp/API/src/AI.cpp"); | |||
| FileInfo userFilePy = new FileInfo(Data.FilePath + "/THUAI6/win/CAPI/python/PyAPI/AI.py"); | |||
| userFileCpp.MoveTo(System.IO.Path.Combine(Data.FilePath + "/THUAI6", System.IO.Path.GetFileName(userFileCpp.FullName))); | |||
| userFilePy.MoveTo(System.IO.Path.Combine(Data.FilePath + "/THUAI6", System.IO.Path.GetFileName(userFilePy.FullName))); | |||
| foreach (DirectoryInfo subdi in di.GetDirectories()) | |||
| { | |||
| subdi.Delete(true); | |||
| } | |||
| FileInfo hashFile = new FileInfo(Data.FilePath + "/hash.json"); | |||
| hashFile.Delete(); | |||
| } | |||
| catch (UnauthorizedAccessException) | |||
| { | |||
| @@ -12,6 +12,7 @@ using System.ComponentModel; | |||
| using Installer; | |||
| using static System.Windows.Forms.VisualStyles.VisualStyleElement; | |||
| using System.IO; | |||
| using System.Windows.Automation.Provider; | |||
| namespace starter.viewmodel.settings | |||
| { | |||
| @@ -250,6 +251,20 @@ namespace starter.viewmodel.settings | |||
| } | |||
| } | |||
| } | |||
| public string AbortOrSelLanguage | |||
| { | |||
| get | |||
| { | |||
| string ans = ""; | |||
| if (obj.UploadReady) | |||
| ans = "放弃上传"; | |||
| else if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp) | |||
| ans = "语言:c++"; | |||
| else if (obj.launchLanguage == SettingsModel.LaunchLanguage.python) | |||
| ans = "语言:python"; | |||
| return ans; | |||
| } | |||
| } | |||
| public int PlayerNum | |||
| { | |||
| get | |||
| @@ -504,10 +519,18 @@ namespace starter.viewmodel.settings | |||
| } | |||
| else if (type == "File") | |||
| { | |||
| var openFileDialog = new Microsoft.Win32.OpenFileDialog() | |||
| var openFileDialog = new Microsoft.Win32.OpenFileDialog(); | |||
| if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp) | |||
| { | |||
| openFileDialog.InitialDirectory = (Route + "/THUAI6/win/CAPI/cpp/API/src/").Replace("/", "\\"); | |||
| openFileDialog.Filter = "c++ Source Files (.cpp)|*.cpp|c++ Header File (.h)|*.h|python Source File (.py)|*.py"; | |||
| } | |||
| else if (obj.launchLanguage == SettingsModel.LaunchLanguage.python) | |||
| { | |||
| Filter = "c++ Source Files (.cpp)|*.cpp|c++ Header File (.h)|*.h|python Source File (.py)|*.py" | |||
| }; | |||
| openFileDialog.InitialDirectory = (Route + "/THUAI6/win/CAPI/python/PyAPI/").Replace("/", "\\"); | |||
| openFileDialog.Filter = "python Source File (.py)|*.py|c++ Source Files (.cpp)|*.cpp|c++ Header File (.h)|*.h"; | |||
| } | |||
| var result = openFileDialog.ShowDialog(); | |||
| if (result == true) | |||
| { | |||
| @@ -658,7 +681,7 @@ namespace starter.viewmodel.settings | |||
| break; | |||
| case 0: | |||
| Status = SettingsModel.Status.newUser; | |||
| MessageBox.Show($"删除成功!player文件夹中的文件已经放在{Downloader.Program.ProgramName}的根目录下", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); | |||
| MessageBox.Show($"删除成功!player文件夹中的文件已经放在{Downloader.Program.Data.FilePath}/{Downloader.Program.ProgramName}的根目录下", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); | |||
| break; | |||
| default: | |||
| Status = SettingsModel.Status.error; | |||
| @@ -833,6 +856,7 @@ namespace starter.viewmodel.settings | |||
| this.RaisePropertyChanged("UploadBtnCont"); | |||
| this.RaisePropertyChanged("UploadReadyVis"); | |||
| this.RaisePropertyChanged("CoverVis"); | |||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||
| } | |||
| } | |||
| else | |||
| @@ -845,6 +869,7 @@ namespace starter.viewmodel.settings | |||
| this.RaisePropertyChanged("UploadReadyVis"); | |||
| this.RaisePropertyChanged("CodeName"); | |||
| this.RaisePropertyChanged("CoverVis"); | |||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||
| } | |||
| else | |||
| { | |||
| @@ -856,24 +881,38 @@ namespace starter.viewmodel.settings | |||
| return clickUploadCommand; | |||
| } | |||
| } | |||
| private BaseCommand clickReselectCommand; | |||
| public BaseCommand ClickReselectCommand | |||
| private BaseCommand clickAboutUploadCommand; | |||
| public BaseCommand ClickAboutUploadCommand | |||
| { | |||
| get | |||
| { | |||
| if (clickReselectCommand == null) | |||
| if (clickAboutUploadCommand == null) | |||
| { | |||
| clickReselectCommand = new BaseCommand(new Action<object>(o => | |||
| clickAboutUploadCommand = new BaseCommand(new Action<object>(o => | |||
| { | |||
| obj.CodeRoute = ""; | |||
| obj.UploadReady = false; | |||
| this.RaisePropertyChanged("UploadBtnCont"); | |||
| this.RaisePropertyChanged("UploadReadyVis"); | |||
| this.RaisePropertyChanged("CodeName"); | |||
| this.RaisePropertyChanged("CoverVis"); | |||
| if (obj.UploadReady) | |||
| { | |||
| obj.CodeRoute = ""; | |||
| obj.UploadReady = false; | |||
| this.RaisePropertyChanged("UploadBtnCont"); | |||
| this.RaisePropertyChanged("UploadReadyVis"); | |||
| this.RaisePropertyChanged("CodeName"); | |||
| this.RaisePropertyChanged("CoverVis"); | |||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||
| } | |||
| else | |||
| { | |||
| if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp) | |||
| obj.launchLanguage = SettingsModel.LaunchLanguage.python; | |||
| else | |||
| obj.launchLanguage = SettingsModel.LaunchLanguage.cpp; | |||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||
| this.RaisePropertyChanged("ShiftLanguageBtnCont"); | |||
| this.RaisePropertyChanged("LaunchBtnCont"); | |||
| } | |||
| })); | |||
| } | |||
| return clickReselectCommand; | |||
| return clickAboutUploadCommand; | |||
| } | |||
| } | |||
| private BaseCommand clickExitCommand; | |||
| @@ -906,6 +945,7 @@ namespace starter.viewmodel.settings | |||
| obj.launchLanguage = SettingsModel.LaunchLanguage.cpp; | |||
| this.RaisePropertyChanged("ShiftLanguageBtnCont"); | |||
| this.RaisePropertyChanged("LaunchBtnCont"); | |||
| this.RaisePropertyChanged("AbortOrSelLanguage"); | |||
| })); | |||
| } | |||
| return clickShiftLanguageCommand; | |||