import Foundation

/// Result codes sent by the server.
enum ResultCode: Int {
    case success = 0
    case error = 1
    case invalid = 2
    case usernameTaken = 3
}

/// Result packet (0x02) — server response to user actions.
struct PacketResult: Packet {
    static let packetId = 0x02

    var resultCode: Int = 0

    func write(to stream: Stream) {
        stream.writeInt16(resultCode)
    }

    mutating func read(from stream: Stream) {
        resultCode = stream.readInt16()
    }
}
