Closed halflumi closed 9 months ago
Thanks for your PR, but I think it could be improved, so it doesn't depend on magic values (level 220, 1 as reward) and is more tolerant to changes to the quest data:
case QuestRewardType.Attribute:
var attribute = player.SelectedCharacter!.Attributes.FirstOrDefault(a => a.Definition == reward.AttributeReward);
if (attribute is null)
{
attribute = player.PersistenceContext.CreateNew<StatAttribute>(reward.AttributeReward, 0);
player.SelectedCharacter.Attributes.Add(attribute);
}
attribute.Value += reward.Value;
// Compensate level-up points when doing a quest at a later level.
if (attribute.Definition == Stats.PointsPerLevelUp)
{
var playerLevel = (int)player.Attributes![Stats.Level];
player.SelectedCharacter.LevelUpPoints += (playerLevel - quest.MinimumCharacterLevel) * reward.Value;
}
await player.InvokeViewPlugInAsync<ILegacyQuestRewardPlugIn>(p => p.ShowAsync(player, QuestRewardType.Attribute, reward.Value, attribute.Definition)).ConfigureAwait(false);
break;
What do you think?
That's a good idea! I've adopted your code to the PR.
Closes #394