Skip to content

Commit

Permalink
Drop record viewer refactor (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
myangelkamikaze authored Mar 29, 2024
1 parent edad079 commit 4398424
Show file tree
Hide file tree
Showing 17 changed files with 586 additions and 477 deletions.
21 changes: 19 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_diagnostic.CA1822.severity = silent
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
end_of_line = crlf
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
###############################
# C# Coding Conventions #
###############################
Expand Down Expand Up @@ -129,7 +134,19 @@ csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
# IDE0160: Convert to block scoped namespace
csharp_style_namespace_declarations = file_scoped
csharp_style_namespace_declarations = file_scoped:silent
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_prefer_static_local_function = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_prefer_readonly_struct_member = true:suggestion
# S1066: Mergeable "if" statements should be combined
dotnet_diagnostic.S1066.severity = none
###############################
# VB Coding Conventions #
###############################
Expand Down
52 changes: 17 additions & 35 deletions ElectronicObserver/Data/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ElectronicObserverTypes;
using ElectronicObserver.Window.Dialog.QuestTrackerManager.Enums;
using ElectronicObserverTypes;

namespace ElectronicObserver.Data;

Expand Down Expand Up @@ -759,28 +760,17 @@ public static string GetSearchingResultShort(int id)
/// <summary>
/// 勝利ランクを表すIDを取得します。
/// </summary>
public static int GetWinRank(string rank)
public static BattleRank GetWinRank(string rank) => rank.ToUpper() switch
{
switch (rank.ToUpper())
{
case "E":
return 1;
case "D":
return 2;
case "C":
return 3;
case "B":
return 4;
case "A":
return 5;
case "S":
return 6;
case "SS":
return 7;
default:
return 0;
}
}
"E" => BattleRank.E,
"D" => BattleRank.D,
"C" => BattleRank.C,
"B" => BattleRank.B,
"A" => BattleRank.A,
"S" => BattleRank.S,
"SS" => BattleRank.SS,
_ => BattleRank.Any,
};

/// <summary>
/// 勝利ランクを表す文字列を取得します。
Expand Down Expand Up @@ -1001,20 +991,12 @@ public static string GetExpeditionResult(int value)
#endregion

#region Servers
public class KCServer
public class KCServer(int num, string name, string jp, string ip)
{
public int Num { get; set; }
public string Name { get; set; }
public string Jp { get; set; }
public string Ip { get; set; }

public KCServer(int num, string name, string jp, string ip)
{
this.Num = num;
this.Name = name;
this.Jp = jp;
this.Ip = ip;
}
public int Num { get; set; } = num;
public string Name { get; set; } = name;
public string Jp { get; set; } = jp;
public string Ip { get; set; } = ip;
}

public static KCServer getKCServer(int num)
Expand Down
14 changes: 4 additions & 10 deletions ElectronicObserver/Data/Quest/ProgressAGo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ElectronicObserver.Data.Quest;
/// 任務「あ号作戦」の進捗を管理します。
/// </summary>
[DataContract(Name = "ProgressAGo")]
public class ProgressAGo : ProgressData
public class ProgressAGo(QuestData quest) : ProgressData(quest, 0)
{

/// <summary>
Expand Down Expand Up @@ -125,12 +125,6 @@ private int bossWinCountTemp
#endregion


public ProgressAGo(QuestData quest)
: base(quest, 0)
{
}


public override double ProgressPercentage
{
get
Expand Down Expand Up @@ -218,17 +212,17 @@ public void IncrementBattle(string rank, bool isBoss)
}


int irank = Constants.GetWinRank(rank);
int irank = (int)Constants.GetWinRank(rank);

if (isBoss)
{
if (q != null) bossCount++; else bossCountTemp++;

if (irank >= Constants.GetWinRank("B"))
if (irank >= (int)Constants.GetWinRank("B"))
if (q != null) bossWinCount++; else bossWinCountTemp++;
}

if (irank >= Constants.GetWinRank("S"))
if (irank >= (int)Constants.GetWinRank("S"))
if (q != null) sWinCount++; else sWinCountTemp++;

}
Expand Down
26 changes: 10 additions & 16 deletions ElectronicObserver/Data/Quest/ProgressBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,31 @@ namespace ElectronicObserver.Data.Quest;
/// 戦闘系の任務の進捗を管理します。
/// </summary>
[DataContract(Name = "ProgressBattle")]
public class ProgressBattle : ProgressData
public class ProgressBattle(QuestData quest, int maxCount, string lowestRank, int[] targetArea, bool isBossOnly)
: ProgressData(quest, maxCount)
{

/// <summary>
/// 条件を満たす最低ランク
/// </summary>
[DataMember]
private int LowestRank { get; set; }
private int LowestRank { get; set; } = (int)Constants.GetWinRank(lowestRank);

/// <summary>
/// 対象となる海域
/// </summary>
[DataMember]
private HashSet<int> TargetArea { get; set; }
private HashSet<int>? TargetArea { get; set; } = targetArea switch
{
null => null,
_ => new HashSet<int>(targetArea),
};

/// <summary>
/// ボス限定かどうか
/// </summary>
[DataMember]
private bool IsBossOnly { get; set; }


public ProgressBattle(QuestData quest, int maxCount, string lowestRank, int[] targetArea, bool isBossOnly)
: base(quest, maxCount)
{

LowestRank = Constants.GetWinRank(lowestRank);
TargetArea = targetArea == null ? null : new HashSet<int>(targetArea);
IsBossOnly = isBossOnly;
}

private bool IsBossOnly { get; set; } = isBossOnly;


public virtual void Increment(string rank, int areaID, bool isBoss)
Expand All @@ -48,7 +42,7 @@ public virtual void Increment(string rank, int areaID, bool isBoss)
if (TargetArea != null && !TargetArea.Contains(areaID))
return;

if (Constants.GetWinRank(rank) < LowestRank)
if ((int)Constants.GetWinRank(rank) < LowestRank)
return;

if (IsBossOnly && !isBoss)
Expand Down
6 changes: 3 additions & 3 deletions ElectronicObserver/Data/Quest/ProgressPractice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ public class ProgressPractice : ProgressData
public ProgressPractice(QuestData quest, int maxCount, bool winOnly)
: base(quest, maxCount)
{
LowestRank = winOnly ? Constants.GetWinRank("B") : Constants.GetWinRank("");
LowestRank = winOnly ? (int)Constants.GetWinRank("B") : (int)Constants.GetWinRank("");
WinOnly = winOnly;
}

public ProgressPractice(QuestData quest, int maxCount, string lowestRank)
: base(quest, maxCount)
{
LowestRank = Constants.GetWinRank(lowestRank);
LowestRank = (int)Constants.GetWinRank(lowestRank);
}

public void Increment(string rank)
{
if (Constants.GetWinRank(rank) < LowestRank) return;
if ((int)Constants.GetWinRank(rank) < LowestRank) return;

if (!MeetsSpecialRequirements(QuestID)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,7 @@
<data name="Today" xml:space="preserve">
<value>Today</value>
</data>
<data name="IgnoreCommonDrops" xml:space="preserve">
<value>Ignore common drops</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,7 @@
<data name="Today" xml:space="preserve">
<value>今日</value>
</data>
<data name="IgnoreCommonDrops" xml:space="preserve">
<value>一般的なドロップは無視</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class DialogDropRecordViewerTranslationViewModel : TranslationBaseViewMod
public string RecordView_RankA => DropRecordViewerResources.RecordView_RankA;
public string RecordView_RankB => DropRecordViewerResources.RecordView_RankB;

public string IgnoreCommonDrops => DropRecordViewerResources.IgnoreCommonDrops;

public string NameAny => DropRecordViewerResources.NameAny;
public string NameNotExist => DropRecordViewerResources.NameNotExist;
public string NameFullPort => DropRecordViewerResources.NameFullPort;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace ElectronicObserver.Window.Tools.DropRecordViewer;

public enum DropRecordContentType
{
Ship,
Item,
Equipment,
ShipItem,
ShipEquipment,
ItemEquipment,
ShipItemEquipment,
}
Loading

0 comments on commit 4398424

Please sign in to comment.