|
| 1 | +using System; |
| 2 | + |
| 3 | +using OXGaming.TibiaAPI.Constants; |
| 4 | + |
| 5 | +namespace OXGaming.TibiaAPI.Network.ClientPackets |
| 6 | +{ |
| 7 | + public class FriendSystemAction : ClientPacket |
| 8 | + { |
| 9 | + public string PlayerName { get; set; } |
| 10 | + |
| 11 | + public uint BadgeId { get; set; } |
| 12 | + public uint PlayerId { get; set; } |
| 13 | + |
| 14 | + public byte Action { get; set; } |
| 15 | + public byte ConfigId { get; set; } |
| 16 | + public byte FriendshipLevel { get; set; } |
| 17 | + |
| 18 | + public bool AllowInspect { get; set; } |
| 19 | + public bool DisplayBadge { get; set; } |
| 20 | + public bool ShowAccountInfo { get; set; } |
| 21 | + public bool ShowCharacterInfo { get; set; } |
| 22 | + |
| 23 | + public FriendSystemAction(Client client) |
| 24 | + { |
| 25 | + Client = client; |
| 26 | + PacketType = ClientPacketType.FriendSystemAction; |
| 27 | + } |
| 28 | + |
| 29 | + public override void ParseFromNetworkMessage(NetworkMessage message) |
| 30 | + { |
| 31 | + // TODO: Figure out Actions 0x0C, 0x0E, 0x0F (if they exist), |
| 32 | + // and others (if there are any). |
| 33 | + Action = message.ReadByte(); |
| 34 | + if (Action == 0x00) // Open Window |
| 35 | + { |
| 36 | + } |
| 37 | + else if (Action == 0x01) // Get Invitations |
| 38 | + { |
| 39 | + } |
| 40 | + else if (Action == 0x02) // Get Blacklist |
| 41 | + { |
| 42 | + } |
| 43 | + else if (Action == 0x03) // Send Invitation |
| 44 | + { |
| 45 | + PlayerId = message.ReadUInt32(); |
| 46 | + } |
| 47 | + else if (Action == 0x04) // Accept Invitation |
| 48 | + { |
| 49 | + PlayerId = message.ReadUInt32(); |
| 50 | + FriendshipLevel = message.ReadByte(); |
| 51 | + } |
| 52 | + else if (Action == 0x05) // Decline Invitation |
| 53 | + { |
| 54 | + PlayerId = message.ReadUInt32(); |
| 55 | + } |
| 56 | + else if (Action == 0x06) // Cancel Invitation |
| 57 | + { |
| 58 | + PlayerId = message.ReadUInt32(); |
| 59 | + } |
| 60 | + else if (Action == 0x07) // Add to Blacklist |
| 61 | + { |
| 62 | + PlayerId = message.ReadUInt32(); |
| 63 | + } |
| 64 | + else if (Action == 0x08) // Remove from Blacklist |
| 65 | + { |
| 66 | + PlayerId = message.ReadUInt32(); |
| 67 | + } |
| 68 | + else if (Action == 0x09) // Unfriend |
| 69 | + { |
| 70 | + PlayerId = message.ReadUInt32(); |
| 71 | + } |
| 72 | + else if (Action == 0x0A) // Change Friendship Level |
| 73 | + { |
| 74 | + PlayerId = message.ReadUInt32(); |
| 75 | + FriendshipLevel = message.ReadByte(); |
| 76 | + } |
| 77 | + else if (Action == 0x0B) // Search |
| 78 | + { |
| 79 | + PlayerName = message.ReadString(); |
| 80 | + } |
| 81 | + else if (Action == 0x0D) // Change Badge Display |
| 82 | + { |
| 83 | + BadgeId = message.ReadUInt32(); |
| 84 | + DisplayBadge = message.ReadBool(); |
| 85 | + } |
| 86 | + else if (Action == 0x10) // Change Config |
| 87 | + { |
| 88 | + ConfigId = message.ReadByte(); |
| 89 | + ShowCharacterInfo = message.ReadBool(); |
| 90 | + ShowAccountInfo = message.ReadBool(); |
| 91 | + AllowInspect = message.ReadBool(); |
| 92 | + } |
| 93 | + else |
| 94 | + { |
| 95 | + throw new Exception($"Invalid Friend System Action: {Action}"); |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + public override void AppendToNetworkMessage(NetworkMessage message) |
| 100 | + { |
| 101 | + message.Write((byte)ClientPacketType.FriendSystemAction); |
| 102 | + message.Write(Action); |
| 103 | + if (Action == 0x00) // Open Window |
| 104 | + { |
| 105 | + } |
| 106 | + else if (Action == 0x01) // Get Invitations |
| 107 | + { |
| 108 | + } |
| 109 | + else if (Action == 0x02) // Get Blacklist |
| 110 | + { |
| 111 | + } |
| 112 | + else if (Action == 0x03) // Send Invitation |
| 113 | + { |
| 114 | + message.Write(PlayerId); |
| 115 | + } |
| 116 | + else if (Action == 0x04) // Accept Invitation |
| 117 | + { |
| 118 | + message.Write(PlayerId); |
| 119 | + message.Write(FriendshipLevel); |
| 120 | + } |
| 121 | + else if (Action == 0x05) // Decline Invitation |
| 122 | + { |
| 123 | + message.Write(PlayerId); |
| 124 | + } |
| 125 | + else if (Action == 0x06) // Cancel Invitation |
| 126 | + { |
| 127 | + message.Write(PlayerId); |
| 128 | + } |
| 129 | + else if (Action == 0x07) // Add to Blacklist |
| 130 | + { |
| 131 | + message.Write(PlayerId); |
| 132 | + } |
| 133 | + else if (Action == 0x08) // Remove from Blacklist |
| 134 | + { |
| 135 | + message.Write(PlayerId); |
| 136 | + } |
| 137 | + else if (Action == 0x09) // Unfriend |
| 138 | + { |
| 139 | + message.Write(PlayerId); |
| 140 | + } |
| 141 | + else if (Action == 0x0A) // Change Friendship Level |
| 142 | + { |
| 143 | + message.Write(PlayerId); |
| 144 | + message.Write(FriendshipLevel); |
| 145 | + } |
| 146 | + else if (Action == 0x0B) // Search |
| 147 | + { |
| 148 | + message.Write(PlayerName); |
| 149 | + } |
| 150 | + else if (Action == 0x0D) // Change Badge Display |
| 151 | + { |
| 152 | + message.Write(BadgeId); |
| 153 | + message.Write(DisplayBadge); |
| 154 | + } |
| 155 | + else if (Action == 0x10) // Change Config |
| 156 | + { |
| 157 | + message.Write(ConfigId); |
| 158 | + message.Write(ShowCharacterInfo); |
| 159 | + message.Write(ShowAccountInfo); |
| 160 | + message.Write(AllowInspect); |
| 161 | + } |
| 162 | + else |
| 163 | + { |
| 164 | + throw new Exception($"Invalid Friend System Action: {Action}"); |
| 165 | + } |
| 166 | + } |
| 167 | + } |
| 168 | +} |
0 commit comments