145 lines
4.7 KiB
C#
145 lines
4.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using JD.Guinness.WPF.Module.Configuration.XBoxOne;
|
|
using JD.Guinness.WPF.Module.Extension;
|
|
using JD.MicrosoftAchievement.Service;
|
|
using JD.Oasis.Service.API;
|
|
|
|
namespace JD.Guinness.WPF.Module.Model.XBoxOne
|
|
{
|
|
public sealed class XBoxOneAchievement : APlatformChallenge
|
|
{
|
|
private string _nameId;
|
|
private string _lockedObjectiveId;
|
|
private string _unlockedObjectiveId;
|
|
private int _gamerscore;
|
|
private bool _isSecret;
|
|
private bool _isBaseAchievement;
|
|
private string _imagePath;
|
|
private LocalizedLine _lockedObjective;
|
|
private LocalizedLine _unlockedObjective;
|
|
|
|
public string NameId
|
|
{
|
|
get => _nameId;
|
|
set => SetProperty(ref _nameId, value);
|
|
}
|
|
|
|
public string LockedObjectiveId
|
|
{
|
|
get => _lockedObjectiveId;
|
|
set => SetProperty(ref _lockedObjectiveId, value);
|
|
}
|
|
|
|
public string UnlockedObjectiveId
|
|
{
|
|
get => _unlockedObjectiveId;
|
|
set => SetProperty(ref _unlockedObjectiveId, value);
|
|
}
|
|
|
|
public int Gamerscore
|
|
{
|
|
get => _gamerscore;
|
|
set => SetProperty(ref _gamerscore, value);
|
|
}
|
|
|
|
public bool IsSecret
|
|
{
|
|
get => _isSecret;
|
|
set => SetProperty(ref _isSecret, value);
|
|
}
|
|
|
|
public bool IsBaseAchievement
|
|
{
|
|
get => _isBaseAchievement;
|
|
set => SetProperty(ref _isBaseAchievement, value);
|
|
}
|
|
|
|
public string ImagePath
|
|
{
|
|
get => _imagePath;
|
|
set => SetProperty(ref _imagePath, value);
|
|
}
|
|
|
|
public LocalizedLine LockedObjective
|
|
{
|
|
get => _lockedObjective;
|
|
set => SetProperty(ref _lockedObjective, value);
|
|
}
|
|
|
|
public LocalizedLine UnlockedObjective
|
|
{
|
|
get => _unlockedObjective;
|
|
set => SetProperty(ref _unlockedObjective, value);
|
|
}
|
|
|
|
public XBoxOneAchievement(Challenge challenge)
|
|
: base(challenge)
|
|
{ }
|
|
|
|
public XBoxOneAchievement DuplicateInto(Challenge challenge)
|
|
{
|
|
XBoxOneAchievement achievement = new XBoxOneAchievement(challenge)
|
|
{
|
|
Gamerscore = Gamerscore,
|
|
Id = Id,
|
|
ImagePath = ImagePath,
|
|
IsBaseAchievement = IsBaseAchievement,
|
|
IsSecret = IsSecret,
|
|
LockedObjective = LockedObjective,
|
|
LockedObjectiveId = LockedObjectiveId,
|
|
NameId = NameId,
|
|
UnlockedObjective = UnlockedObjective,
|
|
UnlockedObjectiveId = UnlockedObjectiveId
|
|
};
|
|
achievement.CustomData.Add(CustomData.Values);
|
|
|
|
return achievement;
|
|
}
|
|
|
|
public Achievement ToServiceAchievement() => new Achievement(
|
|
Id,
|
|
NameId,
|
|
LockedObjectiveId,
|
|
UnlockedObjectiveId,
|
|
IsSecret,
|
|
IsBaseAchievement,
|
|
Gamerscore);
|
|
|
|
public IEnumerable<LocalizedString> ToLocalizedStrings(IEnumerable<LanguageInfo> languages)
|
|
{
|
|
yield return new LocalizedString(
|
|
NameId,
|
|
languages.Where(l => !string.IsNullOrEmpty(l.MicrosoftId)).ToDictionary(
|
|
l => l.MicrosoftId,
|
|
l => Challenge.Name.GetTranslation(l.Language)));
|
|
|
|
yield return new LocalizedString(
|
|
LockedObjectiveId,
|
|
languages.Where(l => !string.IsNullOrEmpty(l.MicrosoftId)).ToDictionary(
|
|
l => l.MicrosoftId,
|
|
l => LockedObjective.GetTranslation(l.Language) ?? Challenge.Objective.GetTranslation(l.Language)));
|
|
|
|
yield return new LocalizedString(
|
|
UnlockedObjectiveId,
|
|
languages.Where(l => !string.IsNullOrEmpty(l.MicrosoftId)).ToDictionary(
|
|
l => l.MicrosoftId,
|
|
l => UnlockedObjective.GetTranslation(l.Language) ?? Challenge.Objective.GetTranslation(l.Language)));
|
|
}
|
|
|
|
public XBoxOneAchievementSave ToSave(string workspacePath) => new XBoxOneAchievementSave
|
|
{
|
|
Extra = CustomData.Values.ToDictionary(p => p.Key, p => p.Value),
|
|
Gamerscore = Gamerscore,
|
|
Id = Id,
|
|
ImagePath = ImagePath.ToRelativePath(workspacePath),
|
|
IsBaseAchievement = IsBaseAchievement,
|
|
IsSecret = IsSecret,
|
|
LockedObjectiveId = LockedObjectiveId,
|
|
LockObjective = LockedObjective?.Id,
|
|
NameId = NameId,
|
|
UnlockedObjective = UnlockedObjective?.Id,
|
|
UnlockedObjectiveId = UnlockedObjectiveId
|
|
};
|
|
}
|
|
}
|