diff --git a/installer/Installer/AssemblyInfo.cs b/installer/Installer/AssemblyInfo.cs index 87c30a8..746c6a3 100644 --- a/installer/Installer/AssemblyInfo.cs +++ b/installer/Installer/AssemblyInfo.cs @@ -1,6 +1,6 @@ using System.Windows; -[assembly:ThemeInfo( +[assembly: ThemeInfo( ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located //(used if a resource is not found in the page, // or application resource dictionaries) diff --git a/installer/Installer/Model.cs b/installer/Installer/Model.cs index 03ffad1..3982b69 100644 --- a/installer/Installer/Model.cs +++ b/installer/Installer/Model.cs @@ -26,15 +26,21 @@ namespace starter.viewmodel.settings /// /// Route of files /// - public string Route { - get; set; } + public string Route + { + get; set; + } /// /// if the route was set or is under editing /// - public bool HaveRoute { - get; set; } - public bool EditingRoute { - get; set; } + public bool HaveRoute + { + get; set; + } + public bool EditingRoute + { + get; set; + } /// /// downloader function /// @@ -144,7 +150,8 @@ namespace Downloader GetObjectRequest request = new GetObjectRequest(bucket, key, localDir, localFileName); Dictionary test = request.GetRequestHeaders(); - request.SetCosProgressCallback(delegate(long completed, long total) { + request.SetCosProgressCallback(delegate (long completed, long total) + { Console.WriteLine(String.Format("progress = {0:##.##}%", completed * 100.0 / total)); }); // 执行请求 diff --git a/installer/Installer/ViewModel.cs b/installer/Installer/ViewModel.cs index 291dbac..12c9842 100644 --- a/installer/Installer/ViewModel.cs +++ b/installer/Installer/ViewModel.cs @@ -22,10 +22,12 @@ namespace starter.viewmodel.settings public string Route { - get { + get + { return obj.Route; } - set { + set + { obj.Route = value; this.RaisePropertyChanged("Route"); } @@ -33,10 +35,12 @@ namespace starter.viewmodel.settings public bool CanEditRoute // if the user can still edit install route { - get { + get + { return !obj.HaveRoute; } - set { + set + { obj.HaveRoute = !value; obj.EditingRoute = value; this.RaisePropertyChanged("CanEditRoute"); @@ -46,7 +50,8 @@ namespace starter.viewmodel.settings private BaseCommand clickBrowseCommand; public BaseCommand ClickBrowseCommand { - get { + get + { if (clickBrowseCommand == null) { clickBrowseCommand = new BaseCommand(new Action(o => @@ -54,28 +59,29 @@ namespace starter.viewmodel.settings using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { _ = dialog.ShowDialog(); - if (dialog.SelectedPath != String.Empty) - Route = dialog.SelectedPath; + if (dialog.SelectedPath != String.Empty) + Route = dialog.SelectedPath; + } + })); } - })); - } - return clickBrowseCommand; - } -} -private BaseCommand clickConfirmCommand; -public BaseCommand ClickConfirmCommand -{ - get { - if (clickConfirmCommand == null) + return clickBrowseCommand; + } + } + private BaseCommand clickConfirmCommand; + public BaseCommand ClickConfirmCommand { + get + { + if (clickConfirmCommand == null) + { clickConfirmCommand = new BaseCommand(new Action(o => { CanEditRoute = false; - obj.install(); - })); - } + obj.install(); + })); + } return clickConfirmCommand; } - } - } - } \ No newline at end of file + } + } +} \ No newline at end of file diff --git a/launcher/Launcher/AssemblyInfo.cs b/launcher/Launcher/AssemblyInfo.cs index 87c30a8..746c6a3 100644 --- a/launcher/Launcher/AssemblyInfo.cs +++ b/launcher/Launcher/AssemblyInfo.cs @@ -1,6 +1,6 @@ using System.Windows; -[assembly:ThemeInfo( +[assembly: ThemeInfo( ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located //(used if a resource is not found in the page, // or application resource dictionaries) diff --git a/logic/Server/Game.cs b/logic/Server/Game.cs index 9eef516..22d8ac7 100644 --- a/logic/Server/Game.cs +++ b/logic/Server/Game.cs @@ -18,7 +18,7 @@ namespace Server public bool IsGaming { get => Interlocked.CompareExchange(ref isGaming, 0, 0) != 0; - set => Interlocked.Exchange(ref isGaming, value? 1: 0); + set => Interlocked.Exchange(ref isGaming, value ? 1 : 0); } public MessageToClient GetCopiedGameInfo() @@ -36,14 +36,16 @@ namespace Server return; if (player.PlayerType == PlayerType.HumanPlayer) { - gameInfo.HumanMessage.Add(new MessageOfHuman() { + gameInfo.HumanMessage.Add(new MessageOfHuman() + { PlayerId = player.PlayerId }); return; } if (player.PlayerType == PlayerType.ButcherPlayer) { - gameInfo.ButcherMessage.Add(new MessageOfButcher() { + gameInfo.ButcherMessage.Add(new MessageOfButcher() + { PlayerID = player.PlayerId }); return; @@ -65,39 +67,39 @@ namespace Server () => IsGaming, () => { - lock (gameInfo) - { - for (int i = 0; i < gameInfo.HumanMessage.Count; i++) - { - if (gameInfo.HumanMessage[i] != null) - { - gameInfo.HumanMessage[i].X++; - gameInfo.HumanMessage[i].Y--; - } - } - for (int i = 0; i < gameInfo.ButcherMessage.Count; i++) - { - if (gameInfo.ButcherMessage[i] != null) - { - gameInfo.ButcherMessage[i].X--; - gameInfo.ButcherMessage[i].Y++; - } - } - } + lock (gameInfo) + { + for (int i = 0; i < gameInfo.HumanMessage.Count; i++) + { + if (gameInfo.HumanMessage[i] != null) + { + gameInfo.HumanMessage[i].X++; + gameInfo.HumanMessage[i].Y--; + } + } + for (int i = 0; i < gameInfo.ButcherMessage.Count; i++) + { + if (gameInfo.ButcherMessage[i] != null) + { + gameInfo.ButcherMessage[i].X--; + gameInfo.ButcherMessage[i].Y++; + } + } + } }, 100, () => { - IsGaming = false; - waitHandle.Release(); - return 0; + IsGaming = false; + waitHandle.Release(); + return 0; }, gameTime ).Start(); - } + } ) { IsBackground = true }.Start(); return waitHandle; + } } } -} diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index f97a06f..fa80c96 100644 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -79,42 +79,42 @@ namespace Server 1000, () => { - ReportGame(); // 最后发一次消息,唤醒发消息的线程,防止发消息的线程由于有概率处在 Wait 状态而卡住 - return 0; + ReportGame(); // 最后发一次消息,唤醒发消息的线程,防止发消息的线程由于有概率处在 Wait 状态而卡住 + return 0; } ).Start(); - }) + }) { IsBackground = true }.Start(); new Thread(() => { waitHandle.Wait(); - this.endGameSem.Release(); - }) + this.endGameSem.Release(); + }) { IsBackground = true }.Start(); -} -public void WaitForEnd() -{ - this.endGameSem.Wait(); -} + } + public void WaitForEnd() + { + this.endGameSem.Wait(); + } -public void ReportGame() -{ - currentGameInfo = game.GetCopiedGameInfo(); + public void ReportGame() + { + currentGameInfo = game.GetCopiedGameInfo(); - foreach (var kvp in semaDict) - { - kvp.Value.Item1.Release(); - } + foreach (var kvp in semaDict) + { + kvp.Value.Item1.Release(); + } - foreach (var kvp in semaDict) - { - kvp.Value.Item2.Wait(); - } -} + foreach (var kvp in semaDict) + { + kvp.Value.Item2.Wait(); + } + } -public GameServer() -{ -} -} + public GameServer() + { + } + } } \ No newline at end of file diff --git a/logic/Server/Program.cs b/logic/Server/Program.cs index 080ac4d..155a97b 100644 --- a/logic/Server/Program.cs +++ b/logic/Server/Program.cs @@ -14,7 +14,8 @@ namespace Server try { GameServer gameServer = new(); - Grpc.Core.Server server = new Grpc.Core.Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) { + Grpc.Core.Server server = new Grpc.Core.Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) + { Services = { AvailableService.BindService(gameServer) }, Ports = { new ServerPort("0.0.0.0", 8888, ServerCredentials.Insecure) } };