forked from jo3bingham/TibiaAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDailyRewardHistory.cs
More file actions
47 lines (42 loc) · 1.73 KB
/
DailyRewardHistory.cs
File metadata and controls
47 lines (42 loc) · 1.73 KB
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
46
47
using System;
using System.Collections.Generic;
using OXGaming.TibiaAPI.Constants;
namespace OXGaming.TibiaAPI.Network.ServerPackets
{
public class DailyRewardHistory : ServerPacket
{
public List<(uint Timestamp, bool WasAdjustedByCustomerSupport, string Text, ushort StreakCount)> History { get; } =
new List<(uint Timestamp, bool WasAdjustedByCustomerSupport, string Text, ushort StreakCount)>();
public DailyRewardHistory(Client client)
{
Client = client;
PacketType = ServerPacketType.DailyRewardHistory;
}
public override void ParseFromNetworkMessage(NetworkMessage message)
{
History.Capacity = message.ReadByte();
for (var i = 0; i < History.Capacity; ++i)
{
var timestamp = message.ReadUInt32();
var wasAdjustedByCustomerSupport = message.ReadBool();
var text = message.ReadString();
var streakCount = message.ReadUInt16();
History.Add((timestamp, wasAdjustedByCustomerSupport, text, streakCount));
}
}
public override void AppendToNetworkMessage(NetworkMessage message)
{
message.Write((byte)ServerPacketType.DailyRewardHistory);
var count = Math.Min(History.Count, byte.MaxValue);
message.Write((byte)count);
for (var i = 0; i < count; ++i)
{
var (Timestamp, WasAdjustedByCustomerSupport, Text, StreakCount) = History[i];
message.Write(Timestamp);
message.Write(WasAdjustedByCustomerSupport);
message.Write(Text);
message.Write(StreakCount);
}
}
}
}