Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update MapCellState to hold optinal chest key instead of chest object
Client only needs to know if the chest is locked and that it is a chest - server handles spawn info
- Loading branch information
1 parent
b7f95ee
commit 291e930
Showing
8 changed files
with
97 additions
and
57 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 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
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,53 @@ | ||
using System.Linq; | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.IO.Map; | ||
using EOLib.IO.Repositories; | ||
using Optional; | ||
|
||
namespace EOLib.Domain.Map | ||
{ | ||
[AutoMappedType] | ||
public class UnlockChestValidator : IUnlockChestValidator | ||
{ | ||
private readonly ICharacterInventoryProvider _characterInventoryProvider; | ||
private readonly IEIFFileProvider _eifFileProvider; | ||
|
||
public UnlockChestValidator(ICharacterInventoryProvider characterInventoryProvider, | ||
IEIFFileProvider eifFileProvider) | ||
{ | ||
_characterInventoryProvider = characterInventoryProvider; | ||
_eifFileProvider = eifFileProvider; | ||
} | ||
|
||
public bool CanMainCharacterOpenChest(ChestKey requiredKey) | ||
{ | ||
return GetRequiredKeyName(requiredKey).Match( | ||
some: keyName => _characterInventoryProvider | ||
.ItemInventory | ||
.Where(x => _eifFileProvider.EIFFile[x.ItemID].Type == IO.ItemType.Key) | ||
.Select(x => _eifFileProvider.EIFFile[x.ItemID].Name) | ||
.Any(keyName.Equals), | ||
none: () => true); | ||
} | ||
|
||
public Option<string> GetRequiredKeyName(ChestKey requiredKey) | ||
{ | ||
switch (requiredKey) | ||
{ | ||
case ChestKey.Normal: return Option.Some("Normal Key"); | ||
case ChestKey.Silver: return Option.Some("Silver Key"); | ||
case ChestKey.Crystal: return Option.Some("Crystal Key"); | ||
case ChestKey.Wraith: return Option.Some("Wraith Key"); | ||
default: return Option.None<string>(); | ||
} | ||
} | ||
} | ||
|
||
public interface IUnlockChestValidator | ||
{ | ||
bool CanMainCharacterOpenChest(ChestKey requiredKey); | ||
|
||
Option<string> GetRequiredKeyName(ChestKey requiredKey); | ||
} | ||
} |
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