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

Fix infinity arrow adding after quest completion #410

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 18 additions & 1 deletion src/GameLogic/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1786,9 +1786,26 @@ private void RaisePlayerLeftMap(GameMap map)
this.PlayerLeftMap?.Invoke(this, (this, map));
}

/// <summary>
/// Adds the missing stat attributes, e.g. after the character class has been changed outside of the game.
/// </summary>
private void AddMissingStatAttributes()
{
if (this.SelectedCharacter is not { CharacterClass: { } characterClass } character)
{
return;
}

var missingStats = characterClass.StatAttributes.Where(a => this.SelectedCharacter.Attributes.All(c => c.Definition != a.Attribute));

var attributes = missingStats.Select(a => this.PersistenceContext.CreateNew<StatAttribute>(a.Attribute, a.BaseValue)).ToList();
attributes.ForEach(character.Attributes.Add);
}

private async ValueTask OnPlayerEnteredWorldAsync()
{
this.Attributes = new ItemAwareAttributeSystem(this.Account!, this.SelectedCharacter!);
this.AddMissingStatAttributes();
this.Inventory = new InventoryStorage(this, this.GameContext);
this.ShopStorage = new ShopStorage(this);
this.TemporaryStorage = new Storage(InventoryConstants.TemporaryStorageSize, new TemporaryItemStorage());
Expand Down Expand Up @@ -2123,4 +2140,4 @@ public GMMagicEffectDefinition()
this.PowerUpDefinitions = new List<PowerUpDefinition>(0);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public override void Initialize()
{
this.GameConfiguration.ExperienceRate = 1.0f;
this.GameConfiguration.MaximumLevel = 400;
this.GameConfiguration.MaximumMasterLevel = 400;
this.GameConfiguration.InfoRange = 12;
this.GameConfiguration.AreaSkillHitsPlayer = false;
this.GameConfiguration.MaximumInventoryMoney = int.MaxValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ protected override async ValueTask ApplyAsync(IContext context, GameConfiguratio
skillReward.Value = 1;
skillReward.SkillReward = gameConfiguration.Skills.First(s => s.Number == (short)SkillNumber.InfinityArrow);
skillReward.RewardType = QuestRewardType.Skill;
quest.Rewards.Add(skillReward);
}
}
2 changes: 1 addition & 1 deletion src/Persistence/Initialization/Updates/UpdateVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ public enum UpdateVersion
/// <summary>
/// The version of the <see cref="InfinityArrowSkillOnQuestCompletionPlugIn"/>.
/// </summary>
InfinityArrowSkillOnQuestCompletion = 14,
InfinityArrowSkillOnQuestCompletion = 15,
}
1 change: 1 addition & 0 deletions src/Persistence/Initialization/VersionSeasonSix/Quests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ private void GainHeroStatus(CharacterClassNumber characterClass)
skillReward.Value = 1;
skillReward.SkillReward = this.GameConfiguration.Skills.First(s => s.Number == (short)SkillNumber.InfinityArrow);
skillReward.RewardType = QuestRewardType.Skill;
heroStatus.Rewards.Add(skillReward);
}

heroStatus.Rewards.Add(pointReward);
Expand Down
Loading