Skip to content
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
12 changes: 12 additions & 0 deletions src/DataModel/Configuration/GameConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ public partial class GameConfiguration
[MemberOfAggregate]
public virtual ICollection<MasterSkillRoot> MasterSkillRoots { get; protected set; } = null!;

/// <summary>
/// Gets or sets the attribute combinations.
/// </summary>
[MemberOfAggregate]
public virtual ICollection<AttributeRelationship> GlobalAttributeCombinations { get; protected set; } = null!;

/// <summary>
/// Gets or sets the base attribute values.
/// </summary>
[MemberOfAggregate]
public virtual ICollection<ConstValueAttribute> GlobalBaseAttributeValues { get; protected set; } = null!;

/// <summary>
/// Gets or sets the plug in configurations.
/// </summary>
Expand Down
6 changes: 5 additions & 1 deletion src/DataModel/GameConfigurationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ public static class GameConfigurationHelper
{
typeof(AttributeRelationship), c => c.CharacterClasses.SelectMany(a => a.AttributeCombinations)
.Concat(Enumerables![typeof(PowerUpDefinitionValue)](c).OfType<PowerUpDefinitionValue>().SelectMany(v => v.RelatedValues))
.Concat(c.GlobalAttributeCombinations)
},
{
typeof(ConstValueAttribute), c => c.CharacterClasses.SelectMany(a => a.BaseAttributeValues)
.Concat(c.GlobalBaseAttributeValues)
},
{ typeof(ConstValueAttribute), c => c.CharacterClasses.SelectMany(a => a.BaseAttributeValues) },
{ typeof(SkillComboDefinition), c => c.CharacterClasses.Select(a => a.ComboDefinition).WhereNotNull() },
{ typeof(SkillComboStep), c => c.CharacterClasses.Select(a => a.ComboDefinition).WhereNotNull().SelectMany(d => d.Steps) },
{ typeof(DropItemGroup), c => c.DropItemGroups },
Expand Down
8 changes: 5 additions & 3 deletions src/GameLogic/Attributes/ItemAwareAttributeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace MUnique.OpenMU.GameLogic.Attributes;

using MUnique.OpenMU.AttributeSystem;
using MUnique.OpenMU.DataModel.Configuration;

/// <summary>
/// An attribute system which considers items of a character.
Expand All @@ -16,11 +17,12 @@ public sealed class ItemAwareAttributeSystem : AttributeSystem, IDisposable
/// </summary>
/// <param name="account">The account.</param>
/// <param name="character">The character.</param>
public ItemAwareAttributeSystem(Account account, Character character)
/// <param name="gameConfiguration">The game configuration with global attributes.</param>
public ItemAwareAttributeSystem(Account account, Character character, GameConfiguration gameConfiguration)
: base(
character.Attributes.Concat(account.Attributes),
character.CharacterClass!.BaseAttributeValues,
character.CharacterClass.AttributeCombinations)
character.CharacterClass!.BaseAttributeValues.Concat(gameConfiguration.GlobalBaseAttributeValues),
character.CharacterClass.AttributeCombinations.Concat(gameConfiguration.GlobalAttributeCombinations))
{
this.ItemPowerUps = new Dictionary<Item, IReadOnlyList<PowerUpWrapper>>();
foreach (var attribute in this)
Expand Down
2 changes: 1 addition & 1 deletion src/GameLogic/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,7 @@ private async ValueTask OnPlayerEnteredWorldAsync()
selectedCharacter.CurrentMap ??= selectedCharacter.CharacterClass?.HomeMap;
this.AddMissingStatAttributes();

this.Attributes = new ItemAwareAttributeSystem(this.Account!, selectedCharacter);
this.Attributes = new ItemAwareAttributeSystem(this.Account!, selectedCharacter, this.GameContext.Configuration);
this.Attributes[Stats.NearbyPartyMemberCount] = 0;
this.LogInvalidInventoryItems();

Expand Down
42 changes: 42 additions & 0 deletions src/Persistence/BasicModel/GameConfiguration.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,48 @@ protected set
}
}

/// <summary>
/// Gets the raw collection of <see cref="GlobalAttributeCombinations" />.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("globalAttributeCombinations")]
public ICollection<AttributeRelationship> RawGlobalAttributeCombinations { get; } = new List<AttributeRelationship>();

/// <inheritdoc/>
[System.Text.Json.Serialization.JsonIgnore]
public override ICollection<MUnique.OpenMU.AttributeSystem.AttributeRelationship> GlobalAttributeCombinations
{
get => base.GlobalAttributeCombinations ??= new CollectionAdapter<MUnique.OpenMU.AttributeSystem.AttributeRelationship, AttributeRelationship>(this.RawGlobalAttributeCombinations);
protected set
{
this.GlobalAttributeCombinations.Clear();
foreach (var item in value)
{
this.GlobalAttributeCombinations.Add(item);
}
}
}

/// <summary>
/// Gets the raw collection of <see cref="GlobalBaseAttributeValues" />.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("globalBaseAttributeValues")]
public ICollection<ConstValueAttribute> RawGlobalBaseAttributeValues { get; } = new List<ConstValueAttribute>();

/// <inheritdoc/>
[System.Text.Json.Serialization.JsonIgnore]
public override ICollection<MUnique.OpenMU.AttributeSystem.ConstValueAttribute> GlobalBaseAttributeValues
{
get => base.GlobalBaseAttributeValues ??= new CollectionAdapter<MUnique.OpenMU.AttributeSystem.ConstValueAttribute, ConstValueAttribute>(this.RawGlobalBaseAttributeValues);
protected set
{
this.GlobalBaseAttributeValues.Clear();
foreach (var item in value)
{
this.GlobalBaseAttributeValues.Add(item);
}
}
}

/// <summary>
/// Gets the raw collection of <see cref="PlugInConfigurations" />.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Persistence/EntityFramework/CachingRepositoryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ protected override void Initialize()
this.LoggerFactory,
config => config.RawItemOptions.SelectMany(o => o.RawPossibleOptions).Distinct().ToList()));
this.RegisterRepository(new ConfigurationTypeRepository<AttributeDefinition>(this._parent, this.LoggerFactory, config => config.RawAttributes));
this.RegisterRepository(new ConfigurationTypeRepository<AttributeRelationship>(this._parent, this.LoggerFactory, config => config.RawGlobalAttributeCombinations));
this.RegisterRepository(new ConfigurationTypeRepository<ConstValueAttribute>(this._parent, this.LoggerFactory, config => config.RawGlobalBaseAttributeValues));
this.RegisterRepository(new ConfigurationTypeRepository<DropItemGroup>(this._parent, this.LoggerFactory, config => config.RawDropItemGroups));
this.RegisterRepository(new ConfigurationTypeRepository<CharacterClass>(this._parent, this.LoggerFactory, config => config.RawCharacterClasses));
this.RegisterRepository(new ConfigurationTypeRepository<ItemOptionType>(this._parent, this.LoggerFactory, config => config.RawItemOptionTypes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public static void Apply(this EntityTypeBuilder<CharacterClass> builder)
{
builder.Property(p => p.Name).HasConversion(LocalizedStringConverter.Instance);
builder.HasMany(c => c.RawBaseAttributeValues)
.WithOne(c => c.CharacterClass!);
.WithOne(c => c.CharacterClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static void Apply(this EntityTypeBuilder<GameConfiguration> builder)
builder.Property(c => c.ItemDropDuration).HasDefaultValue(TimeSpan.FromSeconds(60));
builder.Property(c => c.ExperienceFormula).HasDefaultValue("if(level == 0, 0, if(level < 256, 10 * (level + 8) * (level - 1) * (level - 1), (10 * (level + 8) * (level - 1) * (level - 1)) + (1000 * (level - 247) * (level - 256) * (level - 256))))");
builder.Property(c => c.MasterExperienceFormula).HasDefaultValue("(505 * level * level * level) + (35278500 * level) + (228045 * level * level)");
builder.HasMany(c => c.RawGlobalBaseAttributeValues).WithOne(c => c.GameConfiguration);
}

/// <summary>
Expand Down
Loading
Loading