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

Fixed serialization of ancient item appearance #512

Merged
merged 1 commit into from
Oct 24, 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
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
Loading