diff --git a/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobReward.cs b/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobReward.cs index dba977598..6f934a100 100644 --- a/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobReward.cs +++ b/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobReward.cs @@ -3,7 +3,8 @@ namespace Edelstein.Common.Gameplay.Game.Objects.Mob.Rewards; public record MobReward( - int ID + int ID, + double Proc = 1.0 ) : IMobReward { public int? ItemID { get; init; } diff --git a/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewardPoolManager.cs b/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewardPoolManager.cs index 1bbe920d2..11d35dcf7 100644 --- a/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewardPoolManager.cs +++ b/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewardPoolManager.cs @@ -16,14 +16,20 @@ public class MobRewardPoolManager : public async Task> CalculateRewards(IFieldUser user, IFieldMob mob) { + var random = new Random(); var pool = await Retrieve(mob.Template.ID); - var items = new List(); - if (pool != null) - items.AddRange(await pool.RetrieveAll()); - items.AddRange(await Global.RetrieveAll()); - - return items + return + (pool != null + ? await pool.RetrieveAll() + : new List()) + .Concat(await Global.RetrieveAll()) + .Where(r => + { + // TODO filters + + return random.NextSingle() <= r.Proc; + }) .OrderBy(i => Random.Shared.Next()) .ToImmutableArray(); } diff --git a/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Templates/MobRewardTemplate.cs b/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Templates/MobRewardTemplate.cs index a76a1aeaf..432ed4c45 100644 --- a/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Templates/MobRewardTemplate.cs +++ b/src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Templates/MobRewardTemplate.cs @@ -26,6 +26,8 @@ public class MobRewardTemplate : ITemplate, IMobReward public DateTime? DateStart { get; } public DateTime? DateEnd { get; } + public double Proc { get; } + public MobRewardTemplate(int id, IDataNode property) { ID = id; @@ -36,5 +38,7 @@ public MobRewardTemplate(int id, IDataNode property) NumberMin = property.ResolveInt("min"); NumberMax = property.ResolveInt("max"); + + Proc = property.ResolveDouble("prob") ?? 1.0; } } diff --git a/src/protocol/Edelstein.Protocol.Gameplay.Game/Objects/Mob/Rewards/IMobReward.cs b/src/protocol/Edelstein.Protocol.Gameplay.Game/Objects/Mob/Rewards/IMobReward.cs index 0b726c8db..e7b9e9b77 100644 --- a/src/protocol/Edelstein.Protocol.Gameplay.Game/Objects/Mob/Rewards/IMobReward.cs +++ b/src/protocol/Edelstein.Protocol.Gameplay.Game/Objects/Mob/Rewards/IMobReward.cs @@ -21,4 +21,6 @@ public interface IMobReward : IReward DateTime? DateStart { get; } DateTime? DateEnd { get; } + + double Proc { get; } }