function multiplayer:broadcastStartGame()
	local selection = interface:_returnLobbyMapListSelection( )
	local mapName = interface:_returnMapListTable( )[selection]
	local eventTable = {
		_type = "StartGameMap",
		_value = ""..mapName.."",
	}
	local serEvent = mServer:ser(eventTable)
	local result = mServer:broadcastToAllClients( ""..serEvent.."\n" )
	self:serverStartGame(mapName)
end

function multiplayer:SyncStats( )

end

function multiplayer:broadcastEndTurn( )
	local turn = unit:_returnTurn( )

	local eventTable = {
		_type = "EndTurn",
		_value = turn,
	}

	local serEvent = mServer:ser(eventTable)

	if turn == 1 then -- server send message
		mServer:broadcastToAllClients(""..serEvent.."\n")
	else -- it's the client who sends da message
		mClient:sendMessage(""..serEvent.."\n")
	end
end

function multiplayer:sendEventCreateUnit(__team, __x, __y, __type, __moneyToRemove)
	local turn = unit:_returnTurn( )
	print("DEEPER: TYPE OF UNIT: "..type(_unit).."")
	local eventTable = {
		_type = "CreateUnit",
		_team = __team,
		_x = __x,
		_y = __y,
		_tp = __type,
		_gold = __moneyToRemove,
	}
	print("SIZE OF EVENT TABLE: "..#eventTable.."")

	

	local serEvent = mServer:ser(eventTable)
	print("SER EVENT CONTAINS: "..serEvent.."")
	if turn == 1 then -- server send message
		mServer:broadcastToAllClients(""..serEvent.."\n")
	else -- it's the client who sends da message
		mClient:sendMessage(""..serEvent.."\n")
	end
	
end

function multiplayer:sendEventMoveUnit(__id, _startX, _startY, _endX, _endY)
	local turn = unit:_returnTurn( )
	local eventTable = {
		_type = "MoveUnit",
		_id = __id,
		_x = _startX,
		_y = _startY,
		_ex = _endX,
		_ey = _endY,
	}	


	local serEvent = mServer:ser(eventTable)
	print("SER EVENT CONTAINS: "..serEvent.."")
	if turn == 1 then -- server send message
		mServer:broadcastToAllClients(""..serEvent.."\n")
	else -- it's the client who sends da message
		mClient:sendMessage(""..serEvent.."\n")
	end

end

function multiplayer:sendEventDamage(__id1, __damage1, __id2, __damage2)
	local turn = unit:_returnTurn( )
	local eventTable = {
		_type = "DamageUnit",
		_id1 = __id1,
		_damage1 = __damage1,
		_id2 = __id2,
		_damage2 = _damage2,
	}	


	local serEvent = mServer:ser(eventTable)
	print("SER EVENT CONTAINS: "..serEvent.."")
	if turn == 1 then -- server send message
		mServer:broadcastToAllClients(""..serEvent.."\n")
	else -- it's the client who sends da message
		mClient:sendMessage(""..serEvent.."\n")
	end
end

function multiplayer:serverStartGame(_mapName)
	Game.mapFile = "".._mapName..""
	Game.player1 = "Human"
	player1.name = "Human"
	Game.player2 = "Computer"
	player2.name = "Computer"			
	interface:_setUpdateState(2)
	_bGuiLoaded = false
	_bGameLoaded = false
	Game:dropUI(g, resources )
	Game.lastState = 12
	currentState = 13
			
end



function multiplayer:sendSelection(  )
	-- get current active selection
		local selection = interface:_returnLobbyMapListSelection( )
		local eventTable = {
			_type = "ChangeMapSelection",
			_value = selection,
		}
		local serEvent = mServer:ser(eventTable)
		local result = mServer:broadcastToAllClients( ""..serEvent.."\n" )
		print("Result is: "..type(result).."")
end

function multiplayer:clientStartGame(_event)
		Game.mapFile = _event
		Game.player1 = "Computer"
		player1.name = "Computer"
		Game.player2 = "Human"
		player2.name = "Human"		
		
		interface:_setUpdateState(2)
		_bGuiLoaded = false
		_bGameLoaded = false
		Game:dropUI(g, resources )
		Game.lastState = 12
		currentState = 13	
end