 func ==(lhs: User, rhs: User) -> Bool {
 	return lhs.uuid.hashValue == rhs.uuid.hashValue
 }
+
+/*
+try row.set("username", username)
+try row.set("uuid", uuid)
+try row.set("latestIP", ip)
+try row.set("remainingTiles", remainingTiles)
+try row.set("lastConnected", lastConnected)
+try row.set("availableColors", getColorListString(colors: availableColors))
+*/
+
+//Database preparation
+extension User: Preparation {
+	static func prepare(_ database: Database) throws {
+		try database.create(self) { users in
+			users.id()
+			users.string("username")
+			users.string("uuid")
+			users.string("latestIP")
+			users.int("remainingTiles")
+			users.string("lastConnected")
+			users.string("availableColors")
+		}
+	}
+	
+	static func revert(_ database: Database) throws {
+		try database.delete(self)
+	}
+}

//

import Vapor

class User: Hashable {
	//funcs for UUID gen, username store, getUser from DB, etc
	var username: String? = nil //Username is optional
	var uuid: String			//uuid is mandatory
	var ip: String
	var socket: WebSocket!
	
	var availableColors: [TileColor]
	var remainingTiles: Int
	var lastConnected: Date //Used to keep track of accumulated tiles while disconnected
	
	var hashValue: Int {
		return self.uuid.hashValue

		self.uuid = User.randomUUID(length: 20)
		self.availableColors = []
		self.remainingTiles = 50
		self.lastConnected = String()
		self.ip = ""
	}
	
