Build-Your-Own-World / byow / Core / Room.java
Room.java
Raw
package byow.Core;

import java.util.Random;

public class Room {
    int x;
    int y;
    int width;
    int height;
    int center;
    Boolean splitVert;
    Room bigRoom;
    Room subRoomOne;
    Room subRoomTwo;
    public static final int MIN_SIZE = 6;
    
    public Room() {
        this.x = 0;
        this.y = 0;
        this.width = 50;
        this.height = 50;
    }

    public Room(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;

    }

    public boolean isSubRoom() {
        return this.subRoomOne == null && this.subRoomTwo == null;
    }


    public static boolean getSplitDirection(Random random, int width, int height) {
        if (width / height >= 1.25) {
            return false;
        } else if (height / width >= 1.25) {
            return true;
        } else {
            return random.nextBoolean();
        }
    }

    public boolean ableToSplit(int width, int height) {
        return Math.min(width, height) / 2 >= MIN_SIZE;
    }
}