Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jebzou committed Dec 12, 2024
2 parents eeb65a9 + 25dc17e commit e9ec85a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 42 deletions.
36 changes: 34 additions & 2 deletions ElectronicObserver/Data/PoiDbSubmission/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using System.Text.Json.Nodes;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
using ElectronicObserver.Data.PoiDbSubmission.PoiDbRouteSubmission;
using ElectronicObserverTypes;

namespace ElectronicObserver.Data.PoiDbSubmission;
Expand All @@ -9,9 +14,36 @@ public static JsonNode MakeShip(this IShipData ship)
{
string rawData = ship.RawData.ToString();

return JsonNode.Parse(rawData)!;
List<PoiDbRouteEquipment?> poiSlot = ship.SlotInstance
.Select(MakePoiEquipment)
.ToList();
PoiDbRouteEquipment? poiSlotEx = ship.ExpansionSlotInstance.MakePoiEquipment();

JsonNode shipJson = JsonNode.Parse(rawData)!;
shipJson["poi_slot"] = JsonSerializer.SerializeToNode(poiSlot);
shipJson["poi_slot_ex"] = JsonSerializer.SerializeToNode(poiSlotEx);

return shipJson;
}

[return: NotNullIfNotNull(nameof(equipment))]
public static PoiDbRouteEquipment? MakePoiEquipment(this IEquipmentData? equipment) => equipment switch
{
null => null,
_ => new()
{
ApiId = equipment.MasterID,
ApiSlotitemId = equipment.EquipmentID,
ApiLocked = equipment.IsLocked switch
{
true => 1,
false => 0,
},
ApiLevel = equipment.Level,
ApiAlv = equipment.AircraftLevel,
},
};

public static JsonNode MakeEquipment(this IEquipmentData equipment)
{
string rawData = equipment.RawData.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ namespace ElectronicObserver.Data.PoiDbSubmission.PoiDbRouteSubmission;
public class LosValues
{
[JsonPropertyName("sakuOne25")]
public required double? SakuOne25 { get; set; }
public required string? SakuOne25 { get; set; }

[JsonPropertyName("sakuOne25a")]
public required double? SakuOne25a { get; set; }
public required string? SakuOne25a { get; set; }

[JsonPropertyName("sakuOne33x1")]
public required double SakuOne33x1 { get; set; }
public required string SakuOne33x1 { get; set; }

[JsonPropertyName("sakuOne33x2")]
public required double SakuOne33x2 { get; set; }
public required string SakuOne33x2 { get; set; }

[JsonPropertyName("sakuOne33x3")]
public required double SakuOne33x3 { get; set; }
public required string SakuOne33x3 { get; set; }

[JsonPropertyName("sakuOne33x4")]
public required double SakuOne33x4 { get; set; }
public required string SakuOne33x4 { get; set; }

[JsonPropertyName("sakuTwo25")]
public required double? SakuTwo25 { get; set; }
public required string? SakuTwo25 { get; set; }

[JsonPropertyName("sakuTwo25a")]
public required double? SakuTwo25a { get; set; }
public required string? SakuTwo25a { get; set; }

[JsonPropertyName("sakuTwo33x1")]
public required double? SakuTwo33x1 { get; set; }
public required string? SakuTwo33x1 { get; set; }

[JsonPropertyName("sakuTwo33x2")]
public required double? SakuTwo33x2 { get; set; }
public required string? SakuTwo33x2 { get; set; }

[JsonPropertyName("sakuTwo33x3")]
public required double? SakuTwo33x3 { get; set; }
public required string? SakuTwo33x3 { get; set; }

[JsonPropertyName("sakuTwo33x4")]
public required double? SakuTwo33x4 { get; set; }
public required string? SakuTwo33x4 { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using ElectronicObserver.KancolleApi.Types.ApiGetMember.Mapinfo;
using ElectronicObserver.KancolleApi.Types.ApiReqMap.Next;
using ElectronicObserver.KancolleApi.Types.ApiReqMap.Start;
using ElectronicObserver.Utility.Data;
using ElectronicObserverTypes;

namespace ElectronicObserver.Data.PoiDbSubmission.PoiDbRouteSubmission;
Expand Down Expand Up @@ -142,11 +143,7 @@ private void SubmitData()
List<List<object>> slot1 = Fleet1.MembersInstance!
.OfType<ShipData>()
.Select(s => s.SlotInstance
.Select(e => e switch
{
null => (object)-1,
_ => MakeEquipment(e),
})
.Select(e => e.MakePoiEquipment() ?? (object)-1)
.ToList())
.ToList();

Expand All @@ -158,11 +155,7 @@ private void SubmitData()
List<List<object>>? slot2 = Fleet2?.MembersInstance!
.OfType<ShipData>()
.Select(s => s.SlotInstance
.Select(e => e switch
{
null => (object)-1,
_ => MakeEquipment(e),
})
.Select(e => e.MakePoiEquipment() ?? (object)-1)
.ToList())
.ToList();

Expand All @@ -187,16 +180,16 @@ private void SubmitData()
{
SakuOne25 = null,
SakuOne25a = null,
SakuOne33x1 = Fleet1.GetSearchingAbility(1),
SakuOne33x2 = Fleet1.GetSearchingAbility(2),
SakuOne33x3 = Fleet1.GetSearchingAbility(3),
SakuOne33x4 = Fleet1.GetSearchingAbility(4),
SakuOne33x1 = GetSearch(Fleet1, 1),
SakuOne33x2 = GetSearch(Fleet1, 2),
SakuOne33x3 = GetSearch(Fleet1, 3),
SakuOne33x4 = GetSearch(Fleet1, 4),
SakuTwo25 = null,
SakuTwo25a = null,
SakuTwo33x1 = Fleet2?.GetSearchingAbility(1),
SakuTwo33x2 = Fleet2?.GetSearchingAbility(2),
SakuTwo33x3 = Fleet2?.GetSearchingAbility(3),
SakuTwo33x4 = Fleet2?.GetSearchingAbility(4),
SakuTwo33x1 = GetSearch(Fleet2, 1),
SakuTwo33x2 = GetSearch(Fleet2, 2),
SakuTwo33x3 = GetSearch(Fleet2, 3),
SakuTwo33x4 = GetSearch(Fleet2, 4),
},
ApiCellData = cellCount,
Version = Version,
Expand Down Expand Up @@ -235,16 +228,11 @@ private void SubmitData()
ApiSlotitemLevel = ship.ExpansionSlotInstance?.Level ?? -1,
};

public static PoiDbRouteEquipment MakeEquipment(IEquipmentData equipment) => new()
[return: NotNullIfNotNull(nameof(fleet))]
private static string? GetSearch(IFleetData? fleet, int weight) => fleet switch
{
ApiId = equipment.MasterID,
ApiSlotitemId = equipment.EquipmentID,
ApiLocked = equipment.IsLocked switch
{
true => 1,
false => 0,
},
ApiLevel = equipment.Level,
ApiAlv = equipment.AircraftLevel,
null => null,
_ => Math.Round(Calculator.GetSearchingAbility_New33(fleet, weight), 2, MidpointRounding.ToNegativeInfinity)
.ToString("F2")
};
}

0 comments on commit e9ec85a

Please sign in to comment.