From e054bded546409d19928484583103f13d47a30f1 Mon Sep 17 00:00:00 2001 From: Nickolas Gupton Date: Tue, 23 Jan 2024 07:28:33 -0600 Subject: [PATCH] dotnet format --- BaldersGait/BaldersGaitModule.cs | 2 +- .../State/BarberShop/BarberShopChair.cs | 4 ++-- BaldersGait/Models/State/BarberShopState.cs | 16 ++++++------- BaldersGait/Services/EnvironmentService.cs | 2 +- .../Services/Interface/IStateService.cs | 4 ++-- BaldersGait/Services/StateService.cs | 16 ++++++------- BaldersGait/ViewModels/MainWindowViewModel.cs | 4 ++-- .../BarberShop/BarberShopChairViewModel.cs | 12 +++++----- .../BarberShop/BarberShopTopViewModel.cs | 24 +++++++++---------- .../Panels/GameStatePanelViewModel.cs | 6 ++--- .../Panels/KnownIssuesPanelViewModel.cs | 2 +- .../Panels/PlannedChangesPanelViewModel.cs | 2 +- .../Sidebar/SidebarButtonViewModel.cs | 2 +- .../ViewModels/Sidebar/SidebarViewModel.cs | 6 ++--- BaldersGait/ViewModels/ViewModelBase.cs | 2 +- BaldersGait/Views/MainWindow.axaml.cs | 2 +- 16 files changed, 53 insertions(+), 53 deletions(-) diff --git a/BaldersGait/BaldersGaitModule.cs b/BaldersGait/BaldersGaitModule.cs index acbb9ce..d5f6011 100644 --- a/BaldersGait/BaldersGaitModule.cs +++ b/BaldersGait/BaldersGaitModule.cs @@ -13,7 +13,7 @@ protected override void Load(ContainerBuilder builder) // Services builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); - + //builder.RegisterType().As().SingleInstance(); // View Models diff --git a/BaldersGait/Models/State/BarberShop/BarberShopChair.cs b/BaldersGait/Models/State/BarberShop/BarberShopChair.cs index fe001ca..0d9fa72 100644 --- a/BaldersGait/Models/State/BarberShop/BarberShopChair.cs +++ b/BaldersGait/Models/State/BarberShop/BarberShopChair.cs @@ -19,7 +19,7 @@ public class BarberShopChair [JsonIgnore] public bool ReadyToCollect => HairLength >= GetMaxHairLength(); - + public double GetHairGrowthWithScalingFactor(double baseHairGrowthPerTick) { return Math.Round(baseHairGrowthPerTick * HairGrowthScalingFactor, 3); @@ -29,7 +29,7 @@ public bool IsProductionTooHigh(double baseHairGrowthPerTick) { return GetHairGrowthWithScalingFactor(baseHairGrowthPerTick) > GetMaxHairLength(); } - + public double GetMaxHairLength() { // TODO: Add upgrades for this diff --git a/BaldersGait/Models/State/BarberShopState.cs b/BaldersGait/Models/State/BarberShopState.cs index 5bffc0a..f58af67 100644 --- a/BaldersGait/Models/State/BarberShopState.cs +++ b/BaldersGait/Models/State/BarberShopState.cs @@ -49,17 +49,17 @@ public class BarberShopState ]; public int HairGrowthUpgrades { get; set; } = 0; - + public int ChairScalingFactorUpgrades { get; set; } = 0; - + public double HairCollected { get; set; } = 0; - + public bool ClippersPurchased { get; set; } = false; - - [JsonIgnore] + + [JsonIgnore] public double BaseHairPerTick => Math.Round(0.01 * (HairGrowthUpgrades + 1), 3); - + public void TickMe() { Parallel.ForEach(Chairs.Where(x => x.Unlocked), seat => @@ -80,7 +80,7 @@ public void TickMe() return; } - + // If we are full if (seat.HairLength >= maxHairLength) { @@ -95,7 +95,7 @@ public void TickMe() } return; } - + // Else we can add it to the seats hair length seat.HairLength = Math.Round(seat.HairLength + hairGrowth, 3); }); diff --git a/BaldersGait/Services/EnvironmentService.cs b/BaldersGait/Services/EnvironmentService.cs index b8d67ca..43b844d 100644 --- a/BaldersGait/Services/EnvironmentService.cs +++ b/BaldersGait/Services/EnvironmentService.cs @@ -27,7 +27,7 @@ public EnvironmentService() } _userdataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BaldersGait"); - + if (!Directory.Exists(_userdataDirectory)) { Directory.CreateDirectory(_userdataDirectory); diff --git a/BaldersGait/Services/Interface/IStateService.cs b/BaldersGait/Services/Interface/IStateService.cs index 8084248..c75e956 100644 --- a/BaldersGait/Services/Interface/IStateService.cs +++ b/BaldersGait/Services/Interface/IStateService.cs @@ -7,8 +7,8 @@ public interface IStateService public BarberShopState GetBarberShopState(); public bool LoadState(bool resetState = false); - + public bool SaveState(); - + public void TickState(); } \ No newline at end of file diff --git a/BaldersGait/Services/StateService.cs b/BaldersGait/Services/StateService.cs index 0b70224..3389350 100644 --- a/BaldersGait/Services/StateService.cs +++ b/BaldersGait/Services/StateService.cs @@ -11,10 +11,10 @@ namespace BaldersGait.Services; public class StateService : IStateService { private GameState GameState { get; set; } = new(); - + private const string SaveFileName = "GameState.1"; private string SaveFilePath => Path.Combine(_environmentService.GetUserdataDirectory(), SaveFileName); - + private const string BackupFileName = "GameState.2"; private string BackupFilePath => Path.Combine(_environmentService.GetUserdataDirectory(), BackupFileName); @@ -23,10 +23,10 @@ public class StateService : IStateService public StateService(IEnvironmentService environmentService) { _environmentService = environmentService; - + LoadState(); } - + public BarberShopState GetBarberShopState() { return GameState.BarberShopState; @@ -62,10 +62,10 @@ public bool LoadState(bool resetState = false) } } } - + Log.Information($"Creating new save."); GameState = new(); - + return false; } @@ -77,7 +77,7 @@ public bool SaveState() { File.Move(SaveFilePath, BackupFilePath, overwrite: true); } - + File.WriteAllText(SaveFilePath, JsonSerializer.Serialize(GameState)); return true; } @@ -85,7 +85,7 @@ public bool SaveState() { Log.Error($"Error writing save."); } - + return false; } diff --git a/BaldersGait/ViewModels/MainWindowViewModel.cs b/BaldersGait/ViewModels/MainWindowViewModel.cs index cc09fb4..d11d734 100644 --- a/BaldersGait/ViewModels/MainWindowViewModel.cs +++ b/BaldersGait/ViewModels/MainWindowViewModel.cs @@ -35,7 +35,7 @@ public PanelBase CurrentPanel this.RaiseAndSetIfChanged(ref _currentPanel, value); } } - + public MainWindowViewModel(SidebarViewModel sidebar, IStateService stateService) { if (Current != null) @@ -50,7 +50,7 @@ public MainWindowViewModel(SidebarViewModel sidebar, IStateService stateService) SidebarButtonViewModel button = _sidebar.Buttons.First(); _currentPanel = button.PanelToOpen; Log.Information($"Starting panel: {_currentPanel.PanelName}"); - + RxApp.TaskpoolScheduler.SchedulePeriodic(TimeSpan.FromMilliseconds(10), stateService.TickState); } diff --git a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopChairViewModel.cs b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopChairViewModel.cs index c8a215e..78b312f 100644 --- a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopChairViewModel.cs +++ b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopChairViewModel.cs @@ -18,9 +18,9 @@ public class BarberShopChairViewModel(IStateService stateService, ChairNumbers c public double MaxHair => ChairState.GetMaxHairLength(); public string HairGrowthLabel => $"Hair Growth:\n{stateService.GetBarberShopState().BaseHairPerTick * 60:F2}\" / second"; - + public string ScalingFactorLabel => $"Scaling factor:\nx{ChairState.HairGrowthScalingFactor}"; - + public string TotalGrowthLabel => $"Total Growth:\n{ChairState.GetHairGrowthWithScalingFactor(stateService.GetBarberShopState().BaseHairPerTick) * 60:F2}\" / second"; public string CurrentHairLabel => $"Current hair:\n{HairLength:F2}\" / {MaxHair:F2}\""; @@ -38,19 +38,19 @@ public bool CutHair() return true; } - + protected override void RefreshUIFromState() { this.RaisePropertyChanged(nameof(IsChairUnlocked)); - + this.RaisePropertyChanged(nameof(HairLength)); this.RaisePropertyChanged(nameof(MaxHair)); - + this.RaisePropertyChanged(nameof(HairGrowthLabel)); this.RaisePropertyChanged(nameof(ScalingFactorLabel)); this.RaisePropertyChanged(nameof(TotalGrowthLabel)); this.RaisePropertyChanged(nameof(CurrentHairLabel)); - + this.RaisePropertyChanged(nameof(ReadyToCollect)); this.RaisePropertyChanged(nameof(ProductionTooHigh)); } diff --git a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopTopViewModel.cs b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopTopViewModel.cs index 4ebcd4b..4370cc4 100644 --- a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopTopViewModel.cs +++ b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopTopViewModel.cs @@ -8,13 +8,13 @@ namespace BaldersGait.ViewModels.Panels.BarberShop; public class BarberShopTopViewModel(IStateService stateService) : ViewModelBase { - - public string PurchaseClippersButtonLabel => stateService.GetBarberShopState().ClippersPurchased ? "Clippers (purchased)" : "Purchase Clippers (500 Hair)" ; - + + public string PurchaseClippersButtonLabel => stateService.GetBarberShopState().ClippersPurchased ? "Clippers (purchased)" : "Purchase Clippers (500 Hair)"; + public string IncreaseScalingFactorButtonLabel => $"[{stateService.GetBarberShopState().ChairScalingFactorUpgrades}] Increase Scaling Factor ({IncreaseScalingFactorCost} Hair)"; - public string UnlockSeatButtonLabel => ChairsUnlocked == 8 ? "All Chairs Unlocked" : $"Unlock Chair {(ChairNumbers) ChairsUnlocked} ({UnlockChairCost} hair)"; + public string UnlockSeatButtonLabel => ChairsUnlocked == 8 ? "All Chairs Unlocked" : $"Unlock Chair {(ChairNumbers)ChairsUnlocked} ({UnlockChairCost} hair)"; public string IncreaseGrowthButtonLabel => $"[{stateService.GetBarberShopState().HairGrowthUpgrades}] Increase Growth ({IncreaseGrowthCost} Hair)"; - + private int ChairsUnlocked => stateService.GetBarberShopState().Chairs.Count(s => s.Unlocked) + 1; private int IncreaseScalingFactorCost => 500 * (stateService.GetBarberShopState().ChairScalingFactorUpgrades + 1); private int UnlockChairCost => 200 * (ChairsUnlocked - 1); @@ -32,17 +32,17 @@ public bool PurchaseClippers_Click() return false; } - + public bool IncreaseScalingFactor_Click() { if (stateService.GetBarberShopState().HairCollected < IncreaseScalingFactorCost) { return false; } - + stateService.GetBarberShopState().HairCollected = Math.Round(stateService.GetBarberShopState().HairCollected - IncreaseScalingFactorCost, 3); stateService.GetBarberShopState().ChairScalingFactorUpgrades++; - + return true; } @@ -52,7 +52,7 @@ public bool UnlockChair_Click() { return false; } - + for (int i = stateService.GetBarberShopState().Chairs.Count(seat => seat.Unlocked); i < stateService.GetBarberShopState().Chairs.Count; i++) { if (!stateService.GetBarberShopState().Chairs[i].Unlocked) @@ -65,7 +65,7 @@ public bool UnlockChair_Click() return false; } - + public bool IncreaseGrowth_Click() { if (stateService.GetBarberShopState().HairCollected < IncreaseGrowthCost) @@ -79,11 +79,11 @@ public bool IncreaseGrowth_Click() return true; } #endregion - + protected override void RefreshUIFromState() { this.RaisePropertyChanged(nameof(PurchaseClippersButtonLabel)); - + this.RaisePropertyChanged(nameof(IncreaseScalingFactorButtonLabel)); this.RaisePropertyChanged(nameof(UnlockSeatButtonLabel)); this.RaisePropertyChanged(nameof(IncreaseGrowthButtonLabel)); diff --git a/BaldersGait/ViewModels/Panels/GameStatePanelViewModel.cs b/BaldersGait/ViewModels/Panels/GameStatePanelViewModel.cs index a3bee3f..3cd2d5f 100644 --- a/BaldersGait/ViewModels/Panels/GameStatePanelViewModel.cs +++ b/BaldersGait/ViewModels/Panels/GameStatePanelViewModel.cs @@ -15,20 +15,20 @@ public bool SaveState_Click() stateService.SaveState(); return true; } - + public bool LoadState_Click() { stateService.LoadState(); return true; } - + public bool ResetState_Click() { stateService.LoadState(resetState: true); return true; } #endregion - + protected override void RefreshUIFromState() { // Nothing to do diff --git a/BaldersGait/ViewModels/Panels/KnownIssuesPanelViewModel.cs b/BaldersGait/ViewModels/Panels/KnownIssuesPanelViewModel.cs index af3c587..70e4e97 100644 --- a/BaldersGait/ViewModels/Panels/KnownIssuesPanelViewModel.cs +++ b/BaldersGait/ViewModels/Panels/KnownIssuesPanelViewModel.cs @@ -6,7 +6,7 @@ public class KnownIssuesPanelViewModel : PanelBase { public override string PanelName => "Known Issues"; public override IBrush PanelButtonBackgroundColor { get; } = Brushes.SlateGray; - + protected override void RefreshUIFromState() { // Nothing to do diff --git a/BaldersGait/ViewModels/Panels/PlannedChangesPanelViewModel.cs b/BaldersGait/ViewModels/Panels/PlannedChangesPanelViewModel.cs index c7aef7d..dc26052 100644 --- a/BaldersGait/ViewModels/Panels/PlannedChangesPanelViewModel.cs +++ b/BaldersGait/ViewModels/Panels/PlannedChangesPanelViewModel.cs @@ -6,7 +6,7 @@ public class PlannedChangesPanelViewModel : PanelBase { public override string PanelName => "Planned Changes"; public override IBrush PanelButtonBackgroundColor { get; } = Brushes.SlateGray; - + protected override void RefreshUIFromState() { // Nothing to do diff --git a/BaldersGait/ViewModels/Sidebar/SidebarButtonViewModel.cs b/BaldersGait/ViewModels/Sidebar/SidebarButtonViewModel.cs index 9e70fd8..d79cb33 100644 --- a/BaldersGait/ViewModels/Sidebar/SidebarButtonViewModel.cs +++ b/BaldersGait/ViewModels/Sidebar/SidebarButtonViewModel.cs @@ -24,7 +24,7 @@ public bool OnClick() Log.Information($"Opened panel: {PanelToOpen.PanelName}"); return true; } - + protected override void RefreshUIFromState() { this.RaisePropertyChanged(nameof(BackgroundColor)); diff --git a/BaldersGait/ViewModels/Sidebar/SidebarViewModel.cs b/BaldersGait/ViewModels/Sidebar/SidebarViewModel.cs index 30b442b..4251375 100644 --- a/BaldersGait/ViewModels/Sidebar/SidebarViewModel.cs +++ b/BaldersGait/ViewModels/Sidebar/SidebarViewModel.cs @@ -5,13 +5,13 @@ namespace BaldersGait.ViewModels.Sidebar; -public class SidebarViewModel(BarberShopPanelViewModel barberShopPanel, GameStatePanelViewModel gameStatePanel, +public class SidebarViewModel(BarberShopPanelViewModel barberShopPanel, GameStatePanelViewModel gameStatePanel, PlannedChangesPanelViewModel plannedChangesPanel, KnownIssuesPanelViewModel knownIssuesPanel, IStateService stateService) : ViewModelBase { public string HairCollectedLabel => $"Hair collected:\n{stateService.GetBarberShopState().HairCollected:F2}"; - + public List Buttons { get; } = [ new(barberShopPanel), @@ -19,7 +19,7 @@ public class SidebarViewModel(BarberShopPanelViewModel barberShopPanel, GameStat new(plannedChangesPanel), new(knownIssuesPanel) ]; - + protected override void RefreshUIFromState() { this.RaisePropertyChanged(nameof(HairCollectedLabel)); diff --git a/BaldersGait/ViewModels/ViewModelBase.cs b/BaldersGait/ViewModels/ViewModelBase.cs index afded02..8aff6ea 100644 --- a/BaldersGait/ViewModels/ViewModelBase.cs +++ b/BaldersGait/ViewModels/ViewModelBase.cs @@ -8,7 +8,7 @@ public abstract class ViewModelBase : ReactiveObject { // Roughly 60 frames per second private readonly TimeSpan _uiRefreshTimeSpan = TimeSpan.FromMilliseconds(16.66); - + protected ViewModelBase() { RxApp.MainThreadScheduler.SchedulePeriodic(_uiRefreshTimeSpan, RefreshUIFromState); diff --git a/BaldersGait/Views/MainWindow.axaml.cs b/BaldersGait/Views/MainWindow.axaml.cs index 8e4d263..92072d8 100644 --- a/BaldersGait/Views/MainWindow.axaml.cs +++ b/BaldersGait/Views/MainWindow.axaml.cs @@ -6,7 +6,7 @@ public partial class MainWindow : Window { private const int SetHeight = 750; private const int SetWidth = 1400; - + public MainWindow() { Width = SetHeight;