Skip to content

Commit

Permalink
Merge pull request #512 from MUnique/dev/fix-ancients
Browse files Browse the repository at this point in the history
Fixed serialization of ancient item appearance
  • Loading branch information
sven-n authored Oct 24, 2024
2 parents a02c337 + a639b31 commit 19768c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/GameLogic/CharacterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ public static bool HasFullAncientSetEquipped(this Character character)
i.ItemSlot <= InventoryConstants.LastEquippableItemSlotIndex
&& i.ItemSlot >= InventoryConstants.FirstEquippableItemSlotIndex
&& i.ItemSetGroups.Any(group => group.AncientSetDiscriminator > 0))
.Select(i => new { Item = i.Definition, Set = i.ItemSetGroups.First(s => s.AncientSetDiscriminator > 0) });
var ancientSets = equippedAncientSetItems.Select(i => i.Set).Distinct();
return ancientSets.Any(set => set.ItemSetGroup?.Items.All(setItem => equippedAncientSetItems.Any(i => i.Item == setItem.ItemDefinition && i.Set == set)) ?? false);
.Select(i =>
new
{
Item = i.Definition,
Set = i.ItemSetGroups.First(s => s.AncientSetDiscriminator > 0),
});
var ancientSets = equippedAncientSetItems.Select(i => i.Set.ItemSetGroup).WhereNotNull().Distinct();
return ancientSets.Any(set =>
set.Items.All(setItem => equippedAncientSetItems.Any(i =>
object.Equals(i.Item, setItem.ItemDefinition)
&& object.Equals(i.Set.ItemSetGroup, set))));
}

/// <summary>
Expand Down
9 changes: 8 additions & 1 deletion src/GameLogic/ItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static byte GetMaximumDurabilityOfOnePiece(this Item item)
/// </returns>
public static bool IsAncient(this Item item)
{
return item.ItemOptions.Any(link => link.ItemOption?.OptionType == ItemOptionTypes.AncientBonus);
return item.ItemSetGroups.Any(itemSet => itemSet.AncientSetDiscriminator > 0);
}

/// <summary>
Expand Down Expand Up @@ -305,6 +305,13 @@ public static ItemAppearance GetAppearance(this Item item)
.Select(option => option.ItemOption!.OptionType!)
.Distinct()
.ForEach(appearance.VisibleOptions.Add);
if (item.IsAncient())
{
// 1. The ancient option is not included in the item.ItemOptions.
// 2. The bonus option is not always existing for ancient items. And it's not marked as visible.
// -> we check it based on the item set group.
appearance.VisibleOptions.Add(ItemOptionTypes.AncientOption);
}
return appearance;
}

Expand Down

0 comments on commit 19768c2

Please sign in to comment.