#ifndef _DESCRIPTOR_H_
#define _DESCRIPTOR_H_

#include <string>

enum { STATUS_LOGIN, STATUS_GETNAME, STATUS_CONFIRM_NAME, STATUS_NEW_PWORD, STATUS_CONFIRM_NEW_PWORD, STATUS_PWORD, STATUS_WELCOME, STATUS_INGAME, STATUS_QUIT};

class Descriptor {
  public:
    Descriptor();		// Default constructor, sets socket to 0 (not reccomended)
    ~Descriptor();		// Default deconstructor, does nothing as of yet
    Descriptor(int sock);	// Contructor 2, sets socket to arg1
    void closeD();		// Cleans up the descriptor and closes it
    void setSocket(int sock);	// Sets socket
    int getSocket();		// Gets socket
    void addReadBuf(string str);	// Adds a string to the read buffer
    void addWriteBuf(string str);	// Adds a string to the write buffer
    void writeBuf();		// Writes the buffer to the descriptor, clears afterwords
    string getReadBuf();	// Returns descriptor's readbuf
    string getWriteBuf();	// Returns descriptor's writebuf
    void clearReadBuf();	// Clears the read buffer
    bool bufEnd();		// checks to see if the readbuf ends with a carriage return
    void setReadyBuf(bool ready);	// Sets ready
    bool isReadyBuf();		// Returns true if buffer is ready for processing
    string argument(int n);	// Returns the nth argument (word) in the readbuf
    string argumentBut(int n);	// Returns everything but the nth argument (word) in the readbuf
    int getStatus();		// Gets the status (enumerated above)
    void setStatus(int stat);	// Sets the status (enumerated above)

  private:
    int socket;			// The class' socket number
    int status;
    string readbuf;		// Read buffer, handles input
    string writebuf;		// Pending to write
    bool bready;		// Ready to process output
    void writeTo(string str);	// write_to_socket, writes to the descriptor's screen, called by writeBuf()
};

#endif