0

I am currently trying to make a discord bot similar to Polymars's SokoBot (github page for it: https://github.com/PolyMarsDev/Sokobot) and I am trying to make a way to add walls along the borders using a two dimensional array but when I have realized I need to check the array index instead of a value in the array. Yet there is no way to search this up on Google without a page for the basics of a two dimensional array to come up. So I came here to ask for help.

Here is the method for this:

public void createLevel(String diff, int width, int height) {
    int enemies;
    int crates;
    int spikeTraps;
    int slownessTraps;

    int roomArea = width * height;

    int xCoordinate;
    int yCoordinate;

    String[][] level;
    level = new String[width][height];

    if (diff == "veryEasy") {
        enemies = ThreadLocalRandom.current().nextInt(1, 3);
        crates = ThreadLocalRandom.current().nextInt(0, 1);
        spikeTraps = 0;
        slownessTraps = ThreadLocalRandom.current().nextInt(0, 1);
    } else if (diff == "easy") {
        enemies = ThreadLocalRandom.current().nextInt(2, 4);
        crates = ThreadLocalRandom.current().nextInt(1, 2);
        spikeTraps = ThreadLocalRandom.current().nextInt(0, 1);
        slownessTraps = ThreadLocalRandom.current().nextInt(0, 2);
    } else if (diff == "medium") {
        enemies = ThreadLocalRandom.current().nextInt(3, 6);
        crates = ThreadLocalRandom.current().nextInt(2, 3);
        spikeTraps = ThreadLocalRandom.current().nextInt(1, 2);
        slownessTraps = ThreadLocalRandom.current().nextInt(1, 3);
    } else if (diff == "hard") {
        enemies = ThreadLocalRandom.current().nextInt(5, 8);
        crates = ThreadLocalRandom.current().nextInt(3, 4);
        spikeTraps = ThreadLocalRandom.current().nextInt(2, 3);
        slownessTraps = ThreadLocalRandom.current().nextInt(2, 4);
    } else if (diff == "veryHard") {
        enemies = ThreadLocalRandom.current().nextInt(7, 11);
        crates = ThreadLocalRandom.current().nextInt(4, 5);
        spikeTraps = ThreadLocalRandom.current().nextInt(3, 4);
        slownessTraps = ThreadLocalRandom.current().nextInt(3, 5);
    } else if (diff == "impossible") {
        enemies = ThreadLocalRandom.current().nextInt(9, 14);
        crates = ThreadLocalRandom.current().nextInt(5, 6);
        spikeTraps = ThreadLocalRandom.current().nextInt(4, 5);
        slownessTraps = ThreadLocalRandom.current().nextInt(4, 6);
    }

    for (int i = 0; i < level.length; i++) {
        if (xCoordinate == level[0][yCoordinate]) {

        }
        for (int j = 0; j < level[i].length; j++) {

        }
    }

    setLevelToMake(level.toString());
}

Here is the GitHub page for the bot if you want a further look: https://github.com/abysssal/DungeonBot

Abyssal
  • 1
  • 3

0 Answers0