-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
176 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewardManager.cs
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewardManagerInit.cs
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewardPoolManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections.Immutable; | ||
using Edelstein.Common.Utilities.Repositories; | ||
using Edelstein.Protocol.Gameplay.Game.Objects.Mob; | ||
using Edelstein.Protocol.Gameplay.Game.Objects.Mob.Rewards; | ||
using Edelstein.Protocol.Gameplay.Game.Objects.User; | ||
using Edelstein.Protocol.Gameplay.Game.Rewards; | ||
using Edelstein.Protocol.Utilities.Repositories; | ||
|
||
namespace Edelstein.Common.Gameplay.Game.Objects.Mob.Rewards; | ||
|
||
public class MobRewardPoolManager : | ||
Repository<int, IRewardPool<IMobReward>>, | ||
IMobRewardPoolManager | ||
{ | ||
public IRepository<int, IMobReward> Global { get; } = new Repository<int, IMobReward>(); | ||
|
||
public async Task<ICollection<IMobReward>> CalculateRewards(IFieldUser user, IFieldMob mob) | ||
{ | ||
var pool = await Retrieve(mob.Template.ID); | ||
var items = new List<IMobReward>(); | ||
|
||
if (pool != null) | ||
items.AddRange(await pool.RetrieveAll()); | ||
items.AddRange(await Global.RetrieveAll()); | ||
|
||
return items.ToImmutableArray(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewardPoolManagerInit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Edelstein.Common.Gameplay.Game.Objects.Mob.Templates; | ||
using Edelstein.Common.Gameplay.Game.Rewards; | ||
using Edelstein.Protocol.Gameplay.Contracts; | ||
using Edelstein.Protocol.Gameplay.Game.Objects.Mob.Rewards; | ||
using Edelstein.Protocol.Utilities.Pipelines; | ||
using Edelstein.Protocol.Utilities.Templates; | ||
|
||
namespace Edelstein.Common.Gameplay.Game.Objects.Mob.Rewards; | ||
|
||
public class MobRewardPoolManagerInit : IPipelinePlug<StageStart> | ||
{ | ||
private readonly ITemplateManager<MobRewardPoolTemplate> _templates; | ||
private readonly IMobRewardPoolManager _manager; | ||
|
||
public MobRewardPoolManagerInit( | ||
ITemplateManager<MobRewardPoolTemplate> templates, | ||
IMobRewardPoolManager manager | ||
) | ||
{ | ||
_templates = templates; | ||
_manager = manager; | ||
} | ||
|
||
public async Task Handle(IPipelineContext ctx, StageStart message) | ||
{ | ||
foreach (var rewards in await _templates.RetrieveAll()) | ||
{ | ||
var pool = new RewardPool<IMobReward>(rewards.ID); | ||
foreach (var item in rewards.Items) | ||
await pool.Insert(item); | ||
await _manager.Insert(pool); | ||
} | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
src/common/Edelstein.Common.Gameplay.Game/Objects/Mob/Rewards/MobRewards.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/common/Edelstein.Common.Gameplay.Game/Rewards/RewardPool.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Edelstein.Common.Utilities.Repositories; | ||
using Edelstein.Protocol.Gameplay.Game.Rewards; | ||
|
||
namespace Edelstein.Common.Gameplay.Game.Rewards; | ||
|
||
public class RewardPool<TReward> : | ||
Repository<int, TReward>, | ||
IRewardPool<TReward> | ||
where TReward : IReward | ||
{ | ||
public int ID { get; } | ||
|
||
public RewardPool(int id) => ID = id; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/common/Edelstein.Common.Gameplay.Game/Rewards/RewardPoolManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Edelstein.Common.Utilities.Repositories; | ||
using Edelstein.Protocol.Gameplay.Game.Rewards; | ||
|
||
namespace Edelstein.Common.Gameplay.Game.Rewards; | ||
|
||
public class RewardPoolManager<TReward> : | ||
Repository<int, IRewardPool<TReward>>, | ||
IRewardPoolManager<TReward> | ||
where TReward : IReward | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
src/protocol/Edelstein.Protocol.Gameplay.Game/Objects/Mob/Rewards/IMobReward.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/protocol/Edelstein.Protocol.Gameplay.Game/Objects/Mob/Rewards/IMobRewardManager.cs
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/protocol/Edelstein.Protocol.Gameplay.Game/Objects/Mob/Rewards/IMobRewardPoolManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Edelstein.Protocol.Gameplay.Game.Objects.User; | ||
using Edelstein.Protocol.Gameplay.Game.Rewards; | ||
using Edelstein.Protocol.Utilities.Repositories; | ||
|
||
namespace Edelstein.Protocol.Gameplay.Game.Objects.Mob.Rewards; | ||
|
||
public interface IMobRewardPoolManager : IRewardPoolManager<IMobReward> | ||
{ | ||
IRepository<int, IMobReward> Global { get; } | ||
|
||
Task<ICollection<IMobReward>> CalculateRewards(IFieldUser user, IFieldMob mob); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/protocol/Edelstein.Protocol.Gameplay.Game/Rewards/IReward.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Edelstein.Protocol.Utilities.Repositories; | ||
|
||
namespace Edelstein.Protocol.Gameplay.Game.Rewards; | ||
|
||
public interface IReward : IIdentifiable<int> | ||
{ | ||
} |
10 changes: 10 additions & 0 deletions
10
src/protocol/Edelstein.Protocol.Gameplay.Game/Rewards/IRewardPool.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Edelstein.Protocol.Utilities.Repositories; | ||
|
||
namespace Edelstein.Protocol.Gameplay.Game.Rewards; | ||
|
||
public interface IRewardPool<TReward> : | ||
IIdentifiable<int>, | ||
IRepository<int, TReward> | ||
where TReward : IReward | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
src/protocol/Edelstein.Protocol.Gameplay.Game/Rewards/IRewardPoolManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Edelstein.Protocol.Utilities.Repositories; | ||
|
||
namespace Edelstein.Protocol.Gameplay.Game.Rewards; | ||
|
||
public interface IRewardPoolManager<TReward> : | ||
IRepository<int, IRewardPool<TReward>> | ||
where TReward : IReward | ||
{ | ||
} |