-
Notifications
You must be signed in to change notification settings - Fork 16
/
BoardTakeHandler.cs
45 lines (38 loc) · 1.23 KB
/
BoardTakeHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using AutomaticTypeMapper;
using EOLib.Domain.Interact.Board;
using EOLib.Domain.Login;
using EOLib.Net;
using EOLib.Net.Handlers;
using Optional;
namespace EOLib.PacketHandlers.Board
{
/// <summary>
/// Sent by the server to read a post on a board
/// </summary>
[AutoMappedType]
public class BoardTakeHandler : InGameOnlyPacketHandler
{
private readonly IBoardRepository _boardRepository;
public override PacketFamily Family => PacketFamily.Board;
public override PacketAction Action => PacketAction.Take;
public BoardTakeHandler(IPlayerInfoProvider playerInfoProvider,
IBoardRepository boardRepository)
: base(playerInfoProvider)
{
_boardRepository = boardRepository;
}
public override bool HandlePacket(IPacket packet)
{
var postId = packet.ReadShort();
var message = packet.ReadEndString();
_boardRepository.ActivePost.MatchSome(post =>
{
if (post.PostId == postId)
{
_boardRepository.ActivePostMessage = Option.Some(message);
}
});
return true;
}
}
}