Skip to content

Commit 4aacef7

Browse files
committed
fix up mappings for space station
see #118
1 parent 1242b2b commit 4aacef7

5 files changed

Lines changed: 49 additions & 6 deletions

File tree

src/Helldivers-2-API/Controllers/V1/SpaceStationController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static async Task<IResult> Index(HttpContext context, IStore<SpaceStation
2525
/// Fetches a specific <see cref="SpaceStation" /> identified by <paramref name="index" />.
2626
/// </summary>
2727
[ProducesResponseType<SpaceStation>(StatusCodes.Status200OK)]
28-
public static async Task<IResult> Show(HttpContext context, IStore<SpaceStation, long> store, [FromRoute] int index)
28+
public static async Task<IResult> Show(HttpContext context, IStore<SpaceStation, long> store, [FromRoute] long index)
2929
{
3030
var station = await store.GetAsync(index, context.RequestAborted);
3131

src/Helldivers-2-API/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
v1.MapGet("/planet-events", Helldivers.API.Controllers.V1.PlanetController.WithEvents);
283283

284284
v1.MapGet("/space-stations", Helldivers.API.Controllers.V1.SpaceStationController.Index);
285-
v1.MapGet("/space/stations/{index:int}", Helldivers.API.Controllers.V1.SpaceStationController.Show);
285+
v1.MapGet("/space-stations/{index:long}", Helldivers.API.Controllers.V1.SpaceStationController.Show);
286286

287287
v1.MapGet("/steam", Helldivers.API.Controllers.V1.SteamController.Index);
288288
v1.MapGet("/steam/{gid}", Helldivers.API.Controllers.V1.SteamController.Show);

src/Helldivers-2-Core/Mapping/V1/SpaceStationMapper.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,29 @@ private SpaceStation Map(Dictionary<string, Models.ArrowHead.SpaceStation> trans
5353

5454
private TacticalAction MapTacticalAction(MappingContext context, Helldivers.Models.ArrowHead.SpaceStations.TacticalAction raw)
5555
{
56-
// TODO: map actions.
57-
return new TacticalAction();
56+
return new TacticalAction(
57+
Id32: raw.Id32,
58+
MediaId32: raw.MediaId32,
59+
Name: raw.Name,
60+
Description: raw.Description,
61+
StrategicDescription: raw.StrategicDescription,
62+
Status: raw.Status,
63+
StatusExpire: context.RelativeGameStart.AddSeconds(raw.StatusExpireAtWarTimeSeconds),
64+
Costs: raw.Cost.Select(MapCost).ToList(),
65+
EffectIds: raw.EffectIds
66+
);
67+
}
68+
69+
private Cost MapCost(Models.ArrowHead.SpaceStations.Cost cost)
70+
{
71+
return new Cost(
72+
Id: cost.Id,
73+
ItemMixId: cost.ItemMixId,
74+
TargetValue: cost.TargetValue,
75+
CurrentValue: cost.CurrentValue,
76+
DeltaPerSecond: cost.DeltaPerSecond,
77+
MaxDonationAmmount: cost.MaxDonationAmmount,
78+
MaxDonationPeriodSeconds: cost.MaxDonationPeriodSeconds
79+
);
5880
}
5981
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
namespace Helldivers.Models.V1.SpaceStations;
22

3-
public sealed record Cost();
3+
public sealed record Cost(
4+
string Id,
5+
long ItemMixId,
6+
long TargetValue,
7+
double CurrentValue,
8+
long DeltaPerSecond,
9+
long MaxDonationAmmount,
10+
long MaxDonationPeriodSeconds
11+
);
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
namespace Helldivers.Models.V1.SpaceStations;
22

3-
public sealed record TacticalAction();
3+
/// <summary>
4+
/// Represents a tactical action that the Space Station can take.
5+
/// </summary>
6+
public sealed record TacticalAction(
7+
long Id32,
8+
long MediaId32,
9+
string Name,
10+
string Description,
11+
string StrategicDescription,
12+
int Status,
13+
DateTime StatusExpire,
14+
List<Cost> Costs,
15+
List<int> EffectIds
16+
);

0 commit comments

Comments
 (0)