Skip to content

Commit

Permalink
Merge pull request #523 from MUnique/dev/#503-fix-raven-level-up
Browse files Browse the repository at this point in the history
Stop raven level up, when level limit by stats reached
  • Loading branch information
sven-n authored Nov 5, 2024
2 parents ac5f2d2 + 59a2ff4 commit f873650
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/DataModel/ItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ public static bool IsTrainablePet(this ItemDefinition itemDefinition)
return itemDefinition.PetExperienceFormula is not null;
}

/// <summary>
/// Determines whether the specified item is a dark raven.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>
/// <c>true</c> if the specified item is raven; otherwise, <c>false</c>.
/// </returns>
public static bool IsDarkRaven(this Item item)
{
return item.Definition is { Group: 13, Number: 5 };
}

/// <summary>
/// Gets the dark raven leadership requirement, based on pet level.
/// TODO: Make somehow configurable?
/// </summary>
/// <param name="item">The item.</param>
/// <param name="petLevel">The pet level.</param>
/// <returns>The required leadership.</returns>
public static int GetDarkRavenLeadershipRequirement(this Item item, int petLevel)
{
return petLevel * 15 + 185;
}

/// <summary>
/// Determines whether this item can have a skill.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/GameLogic/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,8 @@ async ValueTask AddExpToPetAsync(Item pet, double experience)
{
pet.PetExperience += (int)experience;

while (pet.PetExperience >= pet.Definition!.GetExperienceOfPetLevel((byte)(pet.Level + 1), pet.Definition!.MaximumItemLevel))
while (pet.PetExperience >= pet.Definition!.GetExperienceOfPetLevel((byte)(pet.Level + 1), pet.Definition!.MaximumItemLevel)
&& (!pet.IsDarkRaven() || pet.GetDarkRavenLeadershipRequirement(pet.Level + 1) <= this.Attributes![Stats.TotalLeadership]))
{
pet.Level++;

Expand Down

0 comments on commit f873650

Please sign in to comment.