////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////

package pp.monopoly;

import pp.util.config.Config;

import java.util.Map;
import java.util.TreeMap;

import static java.lang.Math.max;

/**
 * Provides access to the configuration settings for the Monopoly game.
 * <p>
 * This class allows for loading configuration settings from a properties file,
 * including the server port, map dimensions
 * </p>
 * <p>
 * <b>Note:</b> Attributes of this class are not marked as {@code final} to allow
 * for proper initialization when reading from a properties file.
 * </p>
 */
public class MonopolyConfig extends Config {

    /**
     * The default port number for the Monopoly server.
     */
    @Property("port")
    private int port = 1234;

    /**
     * The width of the game map in terms of grid units.
     */
    @Property("map.width")
    private int mapWidth = 10;

    /**
     * The height of the game map in terms of grid units.
     */
    @Property("map.height")
    private int mapHeight = 10;

    /**
     * Creates an instance of {@code MonopolyConfig} with default settings.
     */
    public MonopolyConfig() {
        // Default constructor
    }

    /**
     * Returns the port number configured for the Monopoly server.
     *
     * @return the port number
     */
    public int getPort() {
        return port;
    }

    /**
     * Returns the width of the game map. The width is guaranteed to be at least 2 units.
     *
     * @return the width of the game map
     */
    public int getMapWidth() {
        return max(mapWidth, 2);
    }

    /**
     * Returns the height of the game map. The height is guaranteed to be at least 2 units.
     *
     * @return the height of the game map
     */
    public int getMapHeight() {
        return max(mapHeight, 2);
    }

}
