Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor endeavours and add royal regimen endeavours #389

Merged
merged 23 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b4762c3
Make MasterAssetGroup take a TGroupKey
LukeFZ Aug 6, 2023
508c599
Rework MissionProgressionInfo
LukeFZ Aug 6, 2023
de56eb9
Remove IsPartOfVoidBattleGroups hack
LukeFZ Aug 6, 2023
132306c
Rework mission progression services
LukeFZ Aug 6, 2023
885c2df
Move services over to new event types
LukeFZ Aug 6, 2023
e511512
Move tests
LukeFZ Aug 6, 2023
8bebf73
Add more event types, add royal regimen missions
LukeFZ Aug 7, 2023
e543d9f
Reduce log spam and make LevelUp events check for 0
LukeFZ Aug 7, 2023
7d94720
Add party power event
LukeFZ Aug 11, 2023
a48846b
Change over quest events
LukeFZ Aug 11, 2023
93c091d
Actually use GroupType for event quest check
LukeFZ Aug 11, 2023
d2bfab9
fix grammar in fortservice/move
LukeFZ Aug 11, 2023
57b877d
move tt initial progression into own method, add party power initial …
LukeFZ Aug 11, 2023
22cd76c
fix tests
LukeFZ Aug 12, 2023
d2af1b9
fix tests 2
LukeFZ Aug 12, 2023
1f69a2f
fix cases where initial mission progress had no entries to check
LukeFZ Aug 15, 2023
ac71109
fix mission test
LukeFZ Aug 15, 2023
e6b0be2
Merge branch 'develop' into missions-refactor
LukeFZ Aug 15, 2023
ef1f217
make GetFortPlantCount count buildings that are upgrading
LukeFZ Aug 15, 2023
4324d63
address comments
LukeFZ Aug 16, 2023
5233e6a
fix "Earn a Light-Attuned 5Star Void Weapon" checking for core weapon…
LukeFZ Aug 17, 2023
cb1cc37
Add savefile update to update regimen group 1 progress
LukeFZ Aug 17, 2023
0ef3f21
Merge branch 'develop' into missions-refactor
LukeFZ Aug 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DragaliaAPI.Integration.Test/Dragalia/PartyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ await this.Client.PostMsgpack<PartySetPartySettingData>(
}
},
"My New Party",
0,
false,
0
)
);
Expand Down Expand Up @@ -122,7 +122,7 @@ public async Task SetPartySetting_InvalidRequest_NotOwnedCharacter_ReturnsResult
new(1, Charas.GalaGatov, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
},
"My New Party",
0,
false,
0
);

Expand Down Expand Up @@ -153,7 +153,7 @@ public async Task SetPartySetting_InvalidRequest_NotOwnedDragonKeyId_ReturnsResu
new(1, Charas.ThePrince, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
},
"My New Party",
0,
false,
0
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ await this.Client.PostMsgpack<QuestReadStoryData>(
resp.data.update_data_list.mission_notice.drill_mission_notice.is_update.Should().Be(1);
resp.data.update_data_list.mission_notice.drill_mission_notice.completed_mission_count
.Should()
.Be(1);
.BeGreaterThan(1); // One has to be completed because of the above, multiple can be completed due to other factors
resp.data.update_data_list.mission_notice.drill_mission_notice.new_complete_mission_id_list
.Should()
.Contain(100200);
Expand Down
1 change: 1 addition & 0 deletions DragaliaAPI.Shared.Test/Unit/MasterAssetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public void QuestData_Get_ReturnsExpectedProperties()
new QuestData(
Id: 100010101,
Gid: 10001,
GroupType: QuestGroupType.MainStory,
QuestPlayModeType: QuestPlayModeTypes.Normal,
LimitedElementalType: 0,
LimitedElementalType2: 0,
Expand Down
8 changes: 8 additions & 0 deletions DragaliaAPI.Shared/Definitions/Enums/QuestGroupType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace DragaliaAPI.Shared.Definitions.Enums;

public enum QuestGroupType
{
None,
MainStory,
Event
}
10 changes: 4 additions & 6 deletions DragaliaAPI.Shared/MasterAsset/MasterAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@ public static class MasterAsset
public static readonly MasterAssetData<int, SpecialMissionGroup> SpecialMissionGroup =
new("Missions/MissionSpecialGroup.json", x => x.Id);

public static readonly MasterAssetData<
MissionProgressType,
MissionProgressionInfo
> MissionProgressionInfo = new("Missions/MissionProgressionInfo.json", x => x.Type);
public static readonly MasterAssetData<int, MissionProgressionInfo> MissionProgressionInfo =
new("Missions/MissionProgressionInfo.json", x => x.Id);

public static readonly MasterAssetData<
int,
Expand Down Expand Up @@ -324,10 +322,10 @@ public static readonly MasterAssetData<
public static readonly MasterAssetData<int, EventTradeGroup> EventTradeGroup =
new("Event/EventTradeGroup.json", x => x.Id);

public static readonly MasterAssetGroup<int, BuildEventReward> BuildEventReward =
public static readonly MasterAssetGroup<int, int, BuildEventReward> BuildEventReward =
new("Event/BuildEventReward.json", x => x.Id);

public static readonly MasterAssetGroup<int, RaidEventReward> RaidEventReward =
public static readonly MasterAssetGroup<int, int, RaidEventReward> RaidEventReward =
new("Event/RaidEventReward.json", x => x.Id);

public static readonly MasterAssetData<int, CombatEventLocation> CombatEventLocation =
Expand Down
23 changes: 12 additions & 11 deletions DragaliaAPI.Shared/MasterAsset/MasterAssetGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@

namespace DragaliaAPI.Shared.MasterAsset;

public class MasterAssetGroup<TKey, TItem>
public class MasterAssetGroup<TGroupKey, TKey, TItem>
where TItem : class
where TKey : notnull
where TGroupKey : notnull
{
private const string JsonFolder = "Resources";

private readonly string jsonFilename;
private readonly Func<TItem, TKey> keySelector;
private readonly Lazy<Dictionary<int, InternalKeyedCollection>> internalDictionary;
private readonly Lazy<Dictionary<TGroupKey, InternalKeyedCollection>> internalDictionary;

/// <summary>
/// Gets a <see cref="IEnumerable{TItem}"/> of all the collection's values.
Expand All @@ -30,15 +31,15 @@ public class MasterAssetGroup<TKey, TItem>
/// <param name="key">The key to index with.</param>
/// <returns>The returned value.</returns>
/// <exception cref="KeyNotFoundException">The given key was not present in the collection.</exception>
public IDictionary<TKey, TItem> Get(int key) => this[key];
public IDictionary<TKey, TItem> Get(TGroupKey key) => this[key];

/// <summary>
/// Get a <typeparam name="TItem"> instance corresponding to the given <typeparam name="TKey"/> key.</typeparam>
/// </summary>
/// <param name="key">The key to index with.</param>
/// <returns>The returned value.</returns>
/// <exception cref="KeyNotFoundException">The given key was not present in the collection.</exception>
public IDictionary<TKey, TItem> this[int key] =>
public IDictionary<TKey, TItem> this[TGroupKey key] =>
this.internalDictionary.Value[key].AsImmutableDictionary();

/// <summary>
Expand All @@ -47,20 +48,20 @@ public class MasterAssetGroup<TKey, TItem>
/// <param name="key">The key to index with.</param>
/// <param name="item">The returned value, if the master data contained it.</param>
/// <returns>A bool indicating whether the value was successfully retrieved.</returns>
public bool TryGetValue(int key, [NotNullWhen(true)] out IEnumerable<TItem>? item)
public bool TryGetValue(TGroupKey key, [NotNullWhen(true)] out IDictionary<TKey, TItem>? item)
{
bool result = this.internalDictionary.Value.TryGetValue(
key,
out InternalKeyedCollection? entry
);

item = result ? entry!.AsEnumerable() : null;
item = result ? entry!.AsImmutableDictionary() : null;

return result;
}

/// <summary>
/// Creates a new instance of <see cref="MasterAssetGroup{TKey,TItem}"/>.
/// Creates a new instance of <see cref="MasterAssetGroup{TGroupKey, TKey,TItem}"/>.
/// </summary>
/// <param name="jsonFilename">The filename of the JSON in <see cref="JsonFolder"/>.</param>
/// <param name="keySelector">A function that returns a unique <typeparamref name="TKey"/> value from a
Expand All @@ -72,22 +73,22 @@ public MasterAssetGroup(string jsonFilename, Func<TItem, TKey> keySelector)
this.internalDictionary = new(DataFactory);
}

private Dictionary<int, InternalKeyedCollection> DataFactory()
private Dictionary<TGroupKey, InternalKeyedCollection> DataFactory()
{
string path = Path.Join(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
JsonFolder,
jsonFilename
);

Dictionary<int, IEnumerable<TItem>> items =
JsonSerializer.Deserialize<Dictionary<int, IEnumerable<TItem>>>(
Dictionary<TGroupKey, IEnumerable<TItem>> items =
JsonSerializer.Deserialize<Dictionary<TGroupKey, IEnumerable<TItem>>>(
File.ReadAllText(path),
MasterAssetJsonOptions.Instance
)
?? throw new JsonException("Deserialized Dictionary<int, IEnumerable<TItem>> was null");

Dictionary<int, InternalKeyedCollection> dict = items.ToDictionary(
Dictionary<TGroupKey, InternalKeyedCollection> dict = items.ToDictionary(
x => x.Key,
x =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using DragaliaAPI.Shared.Definitions.Enums;
using System.Text.Json.Serialization;
using DragaliaAPI.Shared.Definitions.Enums;
using DragaliaAPI.Shared.Json;

namespace DragaliaAPI.Shared.MasterAsset.Models.Missions;

Expand All @@ -7,11 +9,11 @@ public record DrillMissionGroup(
string TextName,
string TextNameShort,
int Step,
int TextTitle,
string TextTitle,
string TextDetail,
EntityTypes UnlockEntityType1,
int UnlockEntityId1,
int UnlockEntityQuantity1,
string StartDate,
string EndDate
[property: JsonConverter(typeof(MasterAssetDateTimeOffsetConverter))] DateTimeOffset StartDate,
[property: JsonConverter(typeof(MasterAssetDateTimeOffsetConverter))] DateTimeOffset EndDate
LukeFZ marked this conversation as resolved.
Show resolved Hide resolved
);
145 changes: 145 additions & 0 deletions DragaliaAPI.Shared/MasterAsset/Models/Missions/MissionCompleteType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
namespace DragaliaAPI.Shared.MasterAsset.Models.Missions;

public enum MissionCompleteType
{
// Fort
/// <summary>
/// FortPlants plantId
/// </summary>
FortPlantLevelUp,

/// <summary>
/// FortPlants plantId
/// </summary>
FortPlantBuilt,

/// <summary>
/// FortPlants plantId
/// </summary>
FortPlantPlaced,

/// <summary>
/// None
/// </summary>
FortLevelUp,

// Quest
/// <summary>
/// int questId, int questGroupId, QuestPlayModeTypes playMode
/// </summary>
QuestCleared,

/// <summary>
/// int groupId, VariationTypes type, QuestPlayModeTypes playMode
/// </summary>
EventGroupCleared,

// Story
/// <summary>
/// int storyId
/// </summary>
QuestStoryCleared,

// Unit
/// <summary>
/// WeaponBodies bodyId, UnitElement element, int rarity, WeaponSeries series
/// </summary>
WeaponEarned,

/// <summary>
/// WeaponBodies bodyId, UnitElement element, int rarity, WeaponSeries series
/// </summary>
WeaponRefined,

/// <summary>
/// AbilityCrests crestId, PlusCountType type
/// </summary>
AbilityCrestBuildupPlusCount,

/// <summary>
/// AbilityCrests crestId
/// </summary>
AbilityCrestTotalPlusCountUp, // For missions that are "Upgrade a Wyrmprint's HP & Strength X Times"

/// <summary>
/// AbilityCrests crestId
/// </summary>
AbilityCrestLevelUp,

/// <summary>
/// Charas charaId, UnitElement element, PlusCountType type
/// </summary>
CharacterBuildupPlusCount,

/// <summary>
/// Charas charaId, UnitElement element
/// </summary>
CharacterLevelUp,

/// <summary>
/// Charas chara, UnitElement element
/// </summary>
CharacterManaNodeUnlock,

// Dragon
/// <summary>
/// Dragons dragon, UnitElement element
/// </summary>
DragonLevelUp,

/// <summary>
/// Dragons dragon, DragonGifts gift, UnitElement element
/// </summary>
DragonGiftSent,

/// <summary>
/// Dragons dragon, UnitElement element
/// </summary>
DragonBondLevelUp,

// Misc
/// <summary>
/// None
/// </summary>
ItemSummon,

/// <summary>
/// None
/// </summary>
PlayerLevelUp,

/// <summary>
/// None
/// </summary>
AccountLinked,

/// <summary>
/// UnitElement element
/// </summary>
PartyOptimized,

/// <summary>
/// None
/// </summary>
AbilityCrestTradeViewed,

/// <summary>
/// None (Unimplemented)
/// </summary>
GuildCheckInRewardClaimed,

/// <summary>
/// None
/// </summary>
PartyPowerReached,

/// <summary>
/// int tradeId, EntityTypes type, int id
/// </summary>
TreasureTrade,

/// <summary>
/// None
/// </summary>
UnimplementedAutoComplete = 99999, // Auto-completes upon receiving
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

namespace DragaliaAPI.Shared.MasterAsset.Models.Missions;

public record MissionInfo(
public record MissionProgressionInfo(
int Id,
[property: JsonConverter(typeof(JsonStringEnumConverter))] MissionType Type
);

public record MissionProgressionRequirement(
IEnumerable<MissionInfo> Missions,
[property: JsonConverter(typeof(JsonStringEnumConverter))] MissionType MissionType,
int MissionId,
[property: JsonConverter(typeof(JsonStringEnumConverter))] MissionCompleteType CompleteType,
bool UseTotalValue,
int? Parameter = null,
int? Parameter2 = null,
int? Parameter3 = null,
int? Parameter4 = null
);

public record MissionProgressionInfo(
[property: JsonConverter(typeof(JsonStringEnumConverter))] MissionProgressType Type,
IEnumerable<MissionProgressionRequirement> Requirements
);
7 changes: 2 additions & 5 deletions DragaliaAPI.Shared/MasterAsset/Models/QuestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace DragaliaAPI.Shared.MasterAsset.Models;
public record QuestData(
int Id,
int Gid,
QuestGroupType GroupType,
QuestPlayModeTypes QuestPlayModeType,
UnitElement LimitedElementalType,
UnitElement LimitedElementalType2,
Expand Down Expand Up @@ -55,9 +56,5 @@ public record QuestData(
new(this.Scene06, this.AreaName06),
}.Where(x => !string.IsNullOrEmpty(x.ScenePath) && !string.IsNullOrEmpty(x.AreaName));

public bool IsPartOfVoidBattleGroups =>
Gid is >= FirstVoidBattleGroupId and <= LastVoidBattleGroupId;

private const int FirstVoidBattleGroupId = 30001; // First group that has _BaseQuestGroupId == 30000 (VoidBattle)
private const int LastVoidBattleGroupId = 30107; // Last group that has _BaseQuestGroupId == 30000 (VoidBattle)
public bool IsEventQuest => GroupType == QuestGroupType.Event;
}
Loading
Loading