Skip to content

Commit

Permalink
Merge pull request #410 from MUnique/fix-infinity-arrow-adding
Browse files Browse the repository at this point in the history
Fix infinity arrow adding after quest completion
  • Loading branch information
sven-n authored May 6, 2024
2 parents 4b5ffb9 + ad96299 commit 0939e5a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
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

0 comments on commit 0939e5a

Please sign in to comment.