Skip to content

Commit

Permalink
Merge pull request #301 from WoWs-Builder-Team/development
Browse files Browse the repository at this point in the history
Update 2.4 (Desktop) Patch 3
  • Loading branch information
floribe2000 authored Feb 10, 2024
2 parents ba57a5d + 58be1cd commit dec53e6
Show file tree
Hide file tree
Showing 30 changed files with 127 additions and 132 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
LICENSE
README.md
**/appsettings.local.json
**/wwwroot/lib
7 changes: 4 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = stati

csharp_new_line_before_members_in_object_initializers = false
csharp_preferred_modifier_order = public, private, protected, internal, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async:suggestion
csharp_style_var_elsewhere = false:suggestion
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion
Expand Down Expand Up @@ -71,8 +71,8 @@ resharper_csharp_keep_blank_lines_in_code = 1
resharper_csharp_keep_blank_lines_in_declarations = 1
resharper_csharp_wrap_after_declaration_lpar = true
resharper_csharp_wrap_parameters_style = chop_if_long
resharper_for_built_in_types = use_var_when_evident
resharper_for_other_types = use_var_when_evident
resharper_for_built_in_types = use_var
resharper_for_other_types = use_var
resharper_for_simple_types = use_var
resharper_object_creation_when_type_not_evident = target_typed
resharper_parentheses_redundancy_style = remove_if_not_clarifies_precedence
Expand Down Expand Up @@ -149,6 +149,7 @@ dotnet_diagnostic.CA1304.severity = suggestion # Specify cultureInfo
dotnet_diagnostic.CA1309.severity = suggestion # Use ordinal StringComparison
dotnet_diagnostic.CA1311.severity = suggestion # Specify a culture or use an invariant version
dotnet_diagnostic.CA1822.severity = suggestion # Mark member as static
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types when possible for improved performance

[*.axaml]
max_line_length = 160
Expand Down
9 changes: 7 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<Project>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<CommonTargetFramework>net8.0</CommonTargetFramework>
<DesktopTargetFramework>net8.0-windows</DesktopTargetFramework>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>$(CommonTargetFramework)</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>
</Project>
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WoWs-ShipBuilder
<p align="center">
<img src="https://github.com/WoWs-Builder-Team/WoWs-ShipBuilder/blob/main/.github/logo_white_text_background.png?raw=true" width="359"/>
<img src=".github/logo_white_text_background.png" width="359"/>
</p>

## General Information
Expand All @@ -24,7 +24,7 @@ Update checks only run on application startup so it won't mess up your system wi

## Telemetry data and error reports

We do not collect any personal data in our application because it's simply not necessary for the app to work.
We do not collect any personal data in our application because it's simply not necessary for the app to work.
However, we do automatically collect error reports.
If the application encounters an error, it automatically sends a report to [Sentry](https://sentry.io/) containing the error data. This data does not contain IP addresses or other personal information.
An error is not always visible for you as most errors should be caught internally and handled using fallback actions.
Expand All @@ -39,7 +39,7 @@ If you want to see the program translate in your language, you can follow the gu
Hosting the server where we store the data used by the program has a monthly cost. If you like the program and would like to help us out, you can donate at https://ko-fi.com/wowsshipbuilder. The app will always be free and with no ads. When you donate, you will also get a special role in our discord server.

## Discord
We have a discord server that you can join by clicking [here](https://discord.gg/C8EaepZJDY) .
We have a discord server that you can join by clicking [here](https://discord.gg/C8EaepZJDY) .

## Sponsorships and Support

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static (double waterLineProjection, double perpendicularToWaterProjectio
{
double impactAngle;
List<KeyValuePair<double, Ballistic>> ballistic = BallisticHelper.CalculateBallistic(shell, maxRange, shell.Penetration).Where(x => x.Key >= aimingRange).ToList();
if (ballistic.Any())
if (ballistic.Count != 0)
{
impactAngle = ballistic[0].Value.ImpactAngle;
}
Expand Down
2 changes: 1 addition & 1 deletion WoWsShipBuilder.Common/Features/Builds/BuildValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static async Task<BuildStringValidationResult> ValidateBuildString(string
List<char> invalidChars = Path.GetInvalidFileNameChars().ToList();
invalidChars.Add(';');
List<char> invalidCharsInBuildName = invalidChars.FindAll(buildName.Contains);
return invalidCharsInBuildName.Any() ? $"Invalid characters {string.Join(' ', invalidCharsInBuildName)}" : null;
return invalidCharsInBuildName.Count != 0 ? $"Invalid characters {string.Join(' ', invalidCharsInBuildName)}" : null;
}

public static async Task<string?> RetrieveLongUrlFromShortLink(string shortUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public partial record CvAircraftDataContainer : DataContainerBase

public static List<CvAircraftDataContainer>? FromShip(Ship ship, List<ShipUpgrade> shipConfiguration, List<Modifier> modifiers)
{
if (!ship.CvPlanes.Any())
if (ship.CvPlanes.IsEmpty)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public partial record PingerGunDataContainer : DataContainerBase

public static PingerGunDataContainer? FromShip(Ship ship, IEnumerable<ShipUpgrade> shipConfiguration, List<Modifier> modifiers)
{
if (!ship.PingerGunList.Any())
if (ship.PingerGunList.IsEmpty)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ public static int ApplyModifiers(this List<Modifier> modifierList, string proper

public static void UpdateConsumableModifierValue(this List<Modifier> consumableModifierList, List<Modifier> modifierList, string propertySelector, string modifierName)
{
var modifier = consumableModifierList.Find(x => x.Name.Equals(modifierName))!;
var newValue = (float)modifierList.ApplyModifiers(propertySelector, (decimal)modifier.Value);
var modifier = consumableModifierList.Find(x => x.Name.Equals(modifierName));
var newValue = (float)modifierList.ApplyModifiers(propertySelector, (decimal)(modifier?.Value ?? 0));
if (modifier == null)
{
return;
}

consumableModifierList.Remove(modifier);
consumableModifierList.Add(new Modifier(modifier.Name, newValue, "", modifier));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static ConsumableDataContainer FromTypeAndVariant(string name, string va
{
var consumableIdentifier = $"{name} {variant}";
var usingFallback = false;
if (!(AppData.ConsumableList?.TryGetValue(consumableIdentifier, out var consumable) ?? false))
if (!AppData.ConsumableList.TryGetValue(consumableIdentifier, out var consumable))
{
Logging.Logger.LogError("Consumable {Identifier} not found in cached consumable list. Using dummy consumable instead", consumableIdentifier);
usingFallback = true;
Expand Down Expand Up @@ -99,7 +99,7 @@ private static ConsumableDataContainer FromTypeAndVariant(string name, string va
consumableModifiers.UpdateConsumableModifierValue(modifiers, "ConsumableDataContainer.TimeDelayAttack.PCY035", "timeDelayAttack");
consumableModifiers.UpdateConsumableModifierValue(modifiers, "ConsumableDataContainer.TimeDelayAppear.PCY035", "timeFromHeaven");

var plane = AppData.FindAircraft(consumable.PlaneName[..consumable.PlaneName.IndexOf("_", StringComparison.Ordinal)]);
var plane = AppData.FindAircraft(consumable.PlaneName[..consumable.PlaneName.IndexOf('_', StringComparison.Ordinal)]);
var oldCruisingSpeed = consumableModifiers.Find(x => x.Name.Equals("cruisingSpeed", StringComparison.Ordinal));
if (oldCruisingSpeed is not null)
{
Expand Down Expand Up @@ -257,7 +257,7 @@ private static ConsumableDataContainer FromTypeAndVariant(string name, string va
consumableModifiers.UpdateConsumableModifierValue(modifiers, "ConsumableDataContainer.ExtraFighters.PCY012.PCY03", "fightersNum");
var maxKills = consumableModifiers.First(x => x.Name.Equals("fightersNum", StringComparison.Ordinal)).Value;

var plane = AppData.FindAircraft(consumable.PlaneName[..consumable.PlaneName.IndexOf("_", StringComparison.Ordinal)]);
var plane = AppData.FindAircraft(consumable.PlaneName[..consumable.PlaneName.IndexOf('_', StringComparison.Ordinal)]);

var oldCruisingModifier = consumableModifiers.Find(x => x.Name.Equals("cruisingSpeed", StringComparison.Ordinal));
if (oldCruisingModifier is not null)
Expand Down Expand Up @@ -303,12 +303,15 @@ private static ConsumableDataContainer FromTypeAndVariant(string name, string va
else if (name.Contains("PCY045", StringComparison.InvariantCultureIgnoreCase))
{
// Hydrophone
// used prior to 13.1
consumableModifiers.UpdateConsumableModifierValue(modifiers, "ConsumableDataContainer.HydrophoneUpdateFrequency.PCY045", "hydrophoneUpdateFrequency");
cooldown = modifiers.ApplyModifiers("ConsumableDataContainer.Reload.PCY045", cooldown);
}
else if (name.Contains("PCY048", StringComparison.InvariantCultureIgnoreCase))
{
// Submarine Surveillance
prepTime = modifiers.ApplyModifiers("ConsumableDataContainer.PrepTime.PCY048", prepTime);
cooldown = modifiers.ApplyModifiers("ConsumableDataContainer.Reload.PCY048", cooldown);
}
}
else if (usingFallback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private Dictionary<Guid, GridDataWrapper> FilteredShipList

public Dictionary<Guid, GridDataWrapper> PinnedShipList { get; } = new();

public List<ShipComparisonDataSections> DataSections { get; private set; } = new() { ShipComparisonDataSections.General };
public List<ShipComparisonDataSections> DataSections { get; private set; } = [ShipComparisonDataSections.General];

public ShipComparisonDataSections SelectedDataSection { get; set; } = ShipComparisonDataSections.General;

Expand Down Expand Up @@ -163,11 +163,7 @@ public void ToggleShowPinnedShipOnly()

public async Task ToggleTierSelection(int value)
{
if (this.SelectedTiers.Contains(value))
{
this.SelectedTiers.Remove(value);
}
else
if (!this.SelectedTiers.Remove(value))
{
this.SelectedTiers.Add(value);
}
Expand All @@ -177,11 +173,7 @@ public async Task ToggleTierSelection(int value)

public async Task ToggleClassSelection(ShipClass value)
{
if (this.SelectedClasses.Contains(value))
{
this.SelectedClasses.Remove(value);
}
else
if (!this.SelectedClasses.Remove(value))
{
this.SelectedClasses.Add(value);
}
Expand All @@ -191,11 +183,7 @@ public async Task ToggleClassSelection(ShipClass value)

public async Task ToggleNationSelection(Nation value)
{
if (this.SelectedNations.Contains(value))
{
this.SelectedNations.Remove(value);
}
else
if (!this.SelectedNations.Remove(value))
{
this.SelectedNations.Add(value);
}
Expand All @@ -205,11 +193,7 @@ public async Task ToggleNationSelection(Nation value)

public async Task ToggleCategorySelection(ShipCategory value)
{
if (this.SelectedCategories.Contains(value))
{
this.SelectedCategories.Remove(value);
}
else
if (!this.SelectedCategories.Remove(value))
{
this.SelectedCategories.Add(value);
}
Expand Down Expand Up @@ -293,7 +277,7 @@ public Dictionary<Guid, GridDataWrapper> RemoveBuilds(IEnumerable<KeyValuePair<G
var buildList = wrappers.ToDictionary(x => x.Key, x => x.Value);
foreach (var wrapper in buildList)
{
if (this.FilteredShipList.Count(x => x.Value.Ship.Index.Equals(wrapper.Value.Ship.Index)) > 1)
if (this.FilteredShipList.Count(x => x.Value.Ship.Index.Equals(wrapper.Value.Ship.Index, StringComparison.Ordinal)) > 1)
{
this.FilteredShipList.Remove(wrapper.Key);

Expand Down Expand Up @@ -341,11 +325,7 @@ public void ResetAllBuilds()

public async Task AddPinnedShip(GridDataWrapper wrapper)
{
if (!this.PinnedShipList.ContainsKey(wrapper.Id))
{
this.PinnedShipList.Add(wrapper.Id, wrapper);
}
else
if (!this.PinnedShipList.TryAdd(wrapper.Id, wrapper))
{
await this.RemovePinnedShip(wrapper);
}
Expand All @@ -355,11 +335,7 @@ public async Task AddPinnedShip(GridDataWrapper wrapper)

public void AddSelectedShip(GridDataWrapper wrapper)
{
if (!this.SelectedShipList.ContainsKey(wrapper.Id))
{
this.SelectedShipList.Add(wrapper.Id, wrapper);
}
else
if (!this.SelectedShipList.TryAdd(wrapper.Id, wrapper))
{
this.RemoveSelectedShip(wrapper);
}
Expand Down Expand Up @@ -438,14 +414,14 @@ public void DuplicateSelectedShips()
this.PinnedShipList.Add(newWrapper.Id, newWrapper);
}

if (this.MainBatteryDispersionCache.ContainsKey(selectedShip.Key))
if (this.MainBatteryDispersionCache.TryGetValue(selectedShip.Key, out var value))
{
this.MainBatteryDispersionCache[newWrapper.Id] = this.MainBatteryDispersionCache[selectedShip.Key];
this.MainBatteryDispersionCache[newWrapper.Id] = value;
}

if (this.SecondaryBatteryDispersionCache.ContainsKey(selectedShip.Key))
if (this.SecondaryBatteryDispersionCache.TryGetValue(selectedShip.Key, out var secondaryValue))
{
this.SecondaryBatteryDispersionCache[newWrapper.Id] = this.SecondaryBatteryDispersionCache[selectedShip.Key];
this.SecondaryBatteryDispersionCache[newWrapper.Id] = secondaryValue;
}
}

Expand Down Expand Up @@ -515,7 +491,7 @@ public void SetFiringRange(double value, bool isMainBattery)

private Dictionary<Guid, GridDataWrapper> GetShipsToBeDisplayed(bool disableHideShipsIfNoSelectedSection)
{
Dictionary<Guid, GridDataWrapper> list = this.ShowPinnedShipsOnly ? this.PinnedShipList : this.FilteredShipList;
var list = this.ShowPinnedShipsOnly ? this.PinnedShipList : this.FilteredShipList;

if (!disableHideShipsIfNoSelectedSection)
{
Expand Down Expand Up @@ -582,7 +558,7 @@ private void ChangeModulesBatch()

private List<ShipUpgrade> GetShipConfiguration(Ship ship)
{
List<ShipUpgrade> shipConfiguration = this.UseUpgradedModules
var shipConfiguration = this.UseUpgradedModules
? ShipModuleHelper.GroupAndSortUpgrades(ship.ShipUpgradeInfo.ShipUpgrades)
.OrderBy(entry => entry.Key)
.Select(entry => entry.Value)
Expand All @@ -608,7 +584,7 @@ private Dictionary<Guid, GridDataWrapper> HideShipsIfNoSelectedSection(IEnumerab
return list.ToDictionary(x => x.Key, x => x.Value);
}

Dictionary<Guid, GridDataWrapper> newList = this.SelectedDataSection switch
var newList = this.SelectedDataSection switch
{
ShipComparisonDataSections.MainBattery => list.Where(x => x.Value.ShipDataContainer.MainBatteryDataContainer is not null).ToDictionary(x => x.Key, x => x.Value),
ShipComparisonDataSections.He => list.Where(x => x.Value.HeShell?.Damage is not null).ToDictionary(x => x.Key, x => x.Value),
Expand Down Expand Up @@ -637,7 +613,7 @@ private Dictionary<Guid, GridDataWrapper> HideShipsIfNoSelectedSection(IEnumerab
private void GetDataSectionsToDisplay()
{
var displayedShipList = this.GetShipsToBeDisplayed(true);
this.DataSections = !displayedShipList.Any() ? new() { ShipComparisonDataSections.General } : this.HideEmptyDataSections(displayedShipList);
this.DataSections = displayedShipList.Count == 0 ? [ShipComparisonDataSections.General] : this.HideEmptyDataSections(displayedShipList);
}

[SuppressMessage("Performance", "CA1822", Justification = "not static to preserve file structure")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Captain? SelectedCaptain
this.SkillList = this.ConvertSkillToViewModel(this.currentClass, newCaptain);
this.CaptainTalentsList.Clear();

if (newCaptain!.UniqueSkills.Any())
if (!newCaptain!.UniqueSkills.IsEmpty)
{
this.CaptainWithTalents = true;
foreach ((string _, UniqueSkill talent) in newCaptain.UniqueSkills)
Expand Down Expand Up @@ -265,7 +265,7 @@ public void AddSkill(Skill skill)
public List<Modifier> GetModifiersList()
{
var modifiers = this.SkillOrderList.ToList()
.Where(skill => skill.Modifiers.Any() && skill.SkillNumber != ArSkillNumber && skill.SkillNumber != ArSkillNumberSubs && skill.SkillNumber != FuriousSkillNumber && skill.SkillNumber != ImprovedRepairPartyReadinessSkillNumber && skill.SkillNumber != ManualSecondaryBatteryAimingSkillNumber)
.Where(skill => !skill.Modifiers.IsEmpty && skill.SkillNumber != ArSkillNumber && skill.SkillNumber != ArSkillNumberSubs && skill.SkillNumber != FuriousSkillNumber && skill.SkillNumber != ImprovedRepairPartyReadinessSkillNumber && skill.SkillNumber != ManualSecondaryBatteryAimingSkillNumber)
.SelectMany(m => m.Modifiers)
.ToList();

Expand Down Expand Up @@ -414,7 +414,7 @@ private IEnumerable<Modifier> CollectTalentModifiers()
.SelectMany(talent => talent.Modifiers.Select(modifier => new Modifier(modifier.Name, float.Pow(modifier.Value, talent.ActivationNumbers), "", modifier)));
modifiers.AddRange(talentMultipleActivationModifiers);

var talentFireChanceModifier = this.CaptainTalentsList.Where(talent => talent.Status && talent.Modifiers.Any(modifier => modifier.Name.Equals("burnProbabilityBonus", StringComparison.Ordinal)))
var talentFireChanceModifier = this.CaptainTalentsList.Where(talent => talent.Status && talent.Modifiers.Exists(modifier => modifier.Name.Equals("burnProbabilityBonus", StringComparison.Ordinal)))
.SelectMany(talent => talent.Modifiers.Select(modifier => new Modifier(modifier.Name, float.Round(modifier.Value * talent.ActivationNumbers, 2), "", modifier)));
modifiers.AddRange(talentFireChanceModifier);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ private static List<KeyValuePair<string, SignalItemViewModel>> LoadSignalList()

public void SignalCommandExecute(Exterior flag)
{
if (this.SelectedSignals.Contains(flag))
if (this.SelectedSignals.Remove(flag))
{
this.SelectedSignals.Remove(flag);
this.SignalsNumber--;
}
else
Expand Down
10 changes: 9 additions & 1 deletion WoWsShipBuilder.Common/WoWsShipBuilder.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.1" />
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
<PackageReference Include="MudBlazor" Version="6.11.1" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
Expand Down Expand Up @@ -63,4 +63,12 @@
</Compile>
</ItemGroup>

<!-- Workaround for libman files not being added to the publish directory on first build, see https://github.com/aspnet/LibraryManager/issues/680#issuecomment-1140320218 -->
<Target Name="_LibraryManagerRestoreContentItems" AfterTargets="LibraryManagerRestore">
<ItemGroup>
<Content Remove="@(FilesForPackagingFromProject)" />
<Content Include="@(FilesForPackagingFromProject)" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>
</Target>

</Project>
Loading

0 comments on commit dec53e6

Please sign in to comment.