 
 import Foundation
 
+/// Representation of the player in a session.
+public class Player: NSObject, NSCoding {
 
+    /**
+        Core roles available in the Aldo Framework.
+    */
+    public enum Role: Int {
 
-public class Player: NSObject, NSCoding {
-    
-    public enum Role: Int {
+        /// Administrator of a session.
         case ADMIN = 0
+
+        /// Moderator of a session.
         case MODERATOR = 1
+
+        /// The regular player in a session.
         case USER = 2
     }
-    
+
     private var id: String
     private var username: String
     private var session: Session
     private var role: Role
     private var score: Int
-    
+
+    /**
+        Creates a *Player* containing all information that is passed.
+     
+        - Parameters:
+            - id: The player id.
+            - username: The username of the player.
+            - session: An instance of *Session* containing all information the player is in.
+            - role: The role of the player in the session.
+            - score: The score of the player.
+    */
     public init(id: String, username: String, session: Session, role: Int, score: Int) {
         self.id = id
         self.username = username

        aCoder.encode(NSNumber(value: self.role.rawValue), forKey: "role")
        aCoder.encode(NSNumber(value: self.score), forKey: "score")
    }
    
    public func getId() -> String {
        return self.id
    }
    
    public func getUsername() -> String {
        return self.username
    }
    
    public func setUsername(username: String) {
        self.username = username
    }
    
    public func getSession() -> Session {
        return self.session
    }
    
    public func setSession(session: Session) {
        self.session = session
    }
    
    public func getRole() -> Role {
        return self.role
    }
    
    public func isAdmin() -> Bool {
        return self.role == Role.ADMIN
    }
    
    public func isModerator() -> Bool {
        return self.role == Role.MODERATOR
    }
    
    public func isUser() -> Bool {
        return self.role == Role.USER
    }
    
    public func getScore() -> Int {
        return self.score
    }

        self.role = Role(rawValue: role)!
        self.score = score
    }

    required convenience public init(coder aDecoder: NSCoder) {
        let id = aDecoder.decodeObject(forKey: "id") as! String
        let username = aDecoder.decodeObject(forKey: "username") as! String
        let session = aDecoder.decodeObject(forKey: "session") as! Session
        let role = (aDecoder.decodeObject(forKey: "role") as! NSNumber).intValue
        let score = (aDecoder.decodeObject(forKey: "score") as! NSNumber).intValue

        self.init(id: id, username: username, session: session, role: role, score: score)
    }

    public func encode(with aCoder: NSCoder) {
        aCoder.encode(self.id, forKey: "id")
        aCoder.encode(self.username, forKey: "username")
