This commit is contained in:
qhy040404
2024-04-22 19:43:05 +08:00
parent 1a29908e5d
commit 883c1ca95f
13 changed files with 197 additions and 10 deletions

View File

@@ -23,6 +23,18 @@
"Equatable": true,
"EqualityOperators": true
},
{
"Name": "ChapterId",
"Documentation": "章节 Id",
"Equatable": true,
"EqualityOperators": true
},
{
"Name": "ChapterGroupId",
"Documentation": "章节分组 Id",
"Equatable": true,
"EqualityOperators": true
},
{
"Name": "EquipAffixId",
"Documentation": "装备属性 Id",
@@ -113,6 +125,12 @@
"Equatable": true,
"EqualityOperators": true
},
{
"Name": "QuestId",
"Documentation": "任务 Id",
"Equatable": true,
"EqualityOperators": true
},
{
"Name": "ReliquaryLevel",
"Documentation": "圣遗物等级 1 - 21",

View File

@@ -4,6 +4,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Snap.Hutao.Core.Abstraction;
using Snap.Hutao.Model.Entity.Abstraction;
using Snap.Hutao.Model.Primitive;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Hoyolab.Takumi.Binding;
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.DailyNote;
@@ -53,6 +54,52 @@ internal sealed class DailyNoteEntry : ObservableObject, IMappingFrom<DailyNoteE
/// </summary>
public DailyNote? DailyNote { get; set; }
[NotMapped]
public List<ChapterId> ArchonQuestIds { get; set; } = default!;
[NotMapped]
public int ArchonQuestStatusValue
{
get
{
if (DailyNote is { ArchonQuestProgress.List: { Count: > 0 } list })
{
return ArchonQuestIds.IndexOf(list.Single().Id);
}
return ArchonQuestIds.Count;
}
}
[NotMapped]
public string ArchonQuestStatusFormatted
{
get
{
if (DailyNote is { ArchonQuestProgress.List: { Count: > 0 } list })
{
return list.Single().Status.GetLocalizedDescription();
}
return SH.WebDailyNoteArchonQuestStatusFinished;
}
}
[NotMapped]
public string ArchonQuestChapterFormatted
{
get
{
if (DailyNote is { ArchonQuestProgress.List: { Count: > 0 } list })
{
ArchonQuest quest = list.Single();
return $"{quest.ChapterNum} {quest.ChapterTitle}";
}
return string.Empty;
}
}
/// <summary>
/// 刷新时间
/// </summary>
@@ -128,4 +175,4 @@ internal sealed class DailyNoteEntry : ObservableObject, IMappingFrom<DailyNoteE
other.ExpeditionNotifySuppressed = ExpeditionNotifySuppressed;
other.OnPropertyChanged(nameof(ExpeditionNotifySuppressed));
}
}
}

View File

@@ -3,14 +3,42 @@
namespace Snap.Hutao.Model.Intrinsic;
internal enum QuestType
internal enum QuestType : uint
{
/// <summary>
/// Archon Quest 魔神任务
/// </summary>
AQ,
/// <summary>
/// Fractions Quest 帮派任务
/// </summary>
FQ,
/// <summary>
/// Legend Quest 传说任务
/// </summary>
LQ,
/// <summary>
/// Event Quest 活动任务
/// </summary>
EQ,
/// <summary>
/// Daily Quest 日常任务
/// </summary>
DQ,
/// <summary>
/// Indescribable Quest 不可描述的任务?
/// </summary>
IQ,
VQ,
/// <summary>
/// World Quest 世界任务
/// </summary>
WQ,
}

View File

@@ -0,0 +1,34 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Model.Intrinsic;
using Snap.Hutao.Model.Primitive;
namespace Snap.Hutao.Model.Metadata;
internal sealed class Chapter
{
public ChapterId Id { get; set; }
public ChapterGroupId GroupId { get; set; }
public QuestId BeginQuestId { get; set; }
public QuestId EndQuestId { get; set; }
public uint NeedPlayerLevel { get; set; }
public string Number { get; set; } = default!;
public string Title { get; set; } = default!;
public string Icon { get; set; } = default!;
public string ImageTitle { get; set; } = default!;
public string SerialNumberIcon { get; set; } = default!;
public City CityId { get; set; }
public QuestType QuestType { get; set; }
}

View File

@@ -6,6 +6,7 @@ namespace Snap.Hutao.Model.Metadata;
// CityTaskOpenExcelConfig
internal enum City : uint
{
None = 0,
Mondstadt = 1,
Liyue = 2,
Inazuma = 3,

View File

@@ -0,0 +1,11 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Model.Metadata;
namespace Snap.Hutao.Service.DailyNote;
internal class DailyNoteMetadataContext : IDailyNoteMetadataContext
{
public List<Chapter> Chapters { get; set; } = default!;
}

View File

@@ -5,6 +5,9 @@ using CommunityToolkit.Mvvm.Messaging;
using Snap.Hutao.Core.DependencyInjection.Abstraction;
using Snap.Hutao.Message;
using Snap.Hutao.Model.Entity;
using Snap.Hutao.Service.Abstraction;
using Snap.Hutao.Service.Metadata;
using Snap.Hutao.Service.Metadata.ContextAbstraction;
using Snap.Hutao.Service.User;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Hoyolab;
@@ -83,9 +86,21 @@ internal sealed partial class DailyNoteService : IDailyNoteService, IRecipient<U
await userService.GetRoleCollectionAsync().ConfigureAwait(false);
await RefreshDailyNotesCoreAsync(forceRefresh, token).ConfigureAwait(false);
List<DailyNoteEntry> entryList = await dailyNoteDbService.GetDailyNoteEntryListIncludingUserAsync(token).ConfigureAwait(false);
entryList.ForEach(entry => { entry.UserGameRole = userService.GetUserGameRoleByUid(entry.Uid); });
entries = entryList.ToObservableCollection();
using (IServiceScope scope = serviceProvider.CreateScope())
{
DailyNoteMetadataContext context = await scope.GetRequiredService<IMetadataService>().GetContextAsync<DailyNoteMetadataContext>(token).ConfigureAwait(false);
List<DailyNoteEntry> entryList = await dailyNoteDbService.GetDailyNoteEntryIncludeUserListAsync(token).ConfigureAwait(false);
entryList.ForEach(entry =>
{
entry.UserGameRole = userService.GetUserGameRoleByUid(entry.Uid);
entry.ArchonQuestIds = context.Chapters
.Where(chapter => chapter.QuestType is Model.Intrinsic.QuestType.AQ)
.Select(chapter => chapter.Id)
.ToList();
});
entries = entryList.ToObservableCollection();
}
}
return entries;
@@ -159,4 +174,4 @@ internal sealed partial class DailyNoteService : IDailyNoteService, IRecipient<U
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Service.Metadata.ContextAbstraction;
namespace Snap.Hutao.Service.DailyNote;
internal interface IDailyNoteMetadataContext : IMetadataContext,
IMetadataListChapterSource
{
}

View File

@@ -0,0 +1,11 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Model.Metadata;
namespace Snap.Hutao.Service.Metadata.ContextAbstraction;
internal interface IMetadataListChapterSource
{
public List<Chapter> Chapters { get; set; }
}

View File

@@ -23,6 +23,11 @@ internal static class MetadataServiceContextExtension
listAchievementSource.Achievements = await metadataService.GetAchievementListAsync(token).ConfigureAwait(false);
}
if (context is IMetadataListChapterSource listChapterSource)
{
listChapterSource.Chapters = await metadataService.GetChapterListAsync(token).ConfigureAwait(false);
}
if (context is IMetadataListGachaEventSource listGachaEventSource)
{
listGachaEventSource.GachaEvents = await metadataService.GetGachaEventListAsync(token).ConfigureAwait(false);

View File

@@ -10,6 +10,7 @@ internal static class MetadataFileNames
public const string FileNameAvatar = "Avatar";
public const string FileNameAvatarCurve = "AvatarCurve";
public const string FileNameAvatarPromote = "AvatarPromote";
public const string FileNameChapter = "Chapter";
public const string FileNameDisplayItem = "DisplayItem";
public const string FileNameGachaEvent = "GachaEvent";
public const string FileNameMaterial = "Material";

View File

@@ -20,6 +20,11 @@ internal static class MetadataServiceListExtension
return metadataService.FromCacheOrFileAsync<List<Model.Metadata.Achievement.Achievement>>(FileNameAchievement, token);
}
public static ValueTask<List<Chapter>> GetChapterListAsync(this IMetadataService metadataService, CancellationToken token = default)
{
return metadataService.FromCacheOrFileAsync<List<Chapter>>(FileNameChapter, token);
}
public static ValueTask<List<AchievementGoal>> GetAchievementGoalListAsync(this IMetadataService metadataService, CancellationToken token = default)
{
return metadataService.FromCacheOrFileAsync<List<AchievementGoal>>(FileNameAchievementGoal, token);

View File

@@ -119,9 +119,9 @@
MinHeight="48"
Background="{x:Null}"
CornerRadius="{ThemeResource ControlCornerRadius}"
Maximum="{Binding DailyNote.ArchonQuestProgress.ArchonQuestIds.Count, Mode=OneWay}"
Maximum="{Binding ArchonQuestIds.Count, Mode=OneWay}"
Opacity="{StaticResource LargeBackgroundProgressBarOpacity}"
Value="{Binding DailyNote.ArchonQuestProgress.ArchonQuestStatusValue, Mode=OneWay}"/>
Value="{Binding ArchonQuestStatusValue, Mode=OneWay}"/>
<shci:CachedImage
Grid.Column="0"
Margin="4"
@@ -135,13 +135,13 @@
VerticalAlignment="Center">
<TextBlock
Style="{StaticResource SubtitleTextBlockStyle}"
Text="{Binding DailyNote.ArchonQuestProgress.ArchonQuestStatusFormatted, Mode=OneWay}"
Text="{Binding ArchonQuestStatusFormatted, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.ArchonQuestProgress.ArchonQuestChapterFormatted, Mode=OneWay}"
Text="{Binding ArchonQuestChapterFormatted, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"/>
</StackPanel>