import java.io.*;
import java.net.*;

public class PiMudServer {
    private static RoomManager roomManager;

    public static void main(String[] args) {
        roomManager = new RoomManager();  // Initialize the room manager
        initializeRooms();

        try (ServerSocket serverSocket = new ServerSocket(12345)) {
            while (true) {
                Socket client = serverSocket.accept();
                ClientHandler handler = new ClientHandler(client);
                new Thread(handler).start();
                System.out.println("New client connected: " + client.getInetAddress());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void initializeRooms() {
        // Example: Setting the starting room to a city
        Room startingRoom = roomManager.getRoom(0, 0);
        if (startingRoom != null) {
            startingRoom.setFeature("city");
            startingRoom.setDescription("A royal capital with a castle at its heart.");
        }
    }

    public static Room getStartingRoom() {
        return roomManager.getRoom(0, 0);  // For example, the starting room at (0, 0)
    }
}
