Select Git revision
Paysant.java
-
CARION Baptiste authoredCARION Baptiste authored
Plateau.java 1.02 KiB
package main;
import java.util.Random;
import items.Crown;
public class Plateau {
private Region[][] plateau;
public Plateau() {
Random random = new Random();
this.plateau = new Region[6][6];
for (int i = 0; i < plateau.length; i++) {
for (int j = 0; j < plateau[0].length; j++) {
plateau[i][j] = new Region();
plateau[i][j].setX(i);
plateau[i][j].setY(j);
plateau[i][j].fillRegion();
}
}
int rd1;
int rd2;
do {
rd1 = (int)random.nextInt(10)+10;
rd2 = (int)random.nextInt(30);
this.getCase(rd1, rd2).setItem(new Crown(this.getCase(0, 0)));
} while (this.getCase(rd1, rd2).getType() != Type.GRASS);
}
public Case getCase(int x, int y) {
return plateau[x/5][y/5].region[x%5][y%5];
}
public Region getRegion(int x, int y ) {
return plateau[x/5][y/5];
}
public Region[][] getPlateau() {
return plateau;
}
public int getLength() {
return plateau.length * plateau[0][0].region.length;
}
public int getWidth() {
return plateau[0].length * plateau[0][0].region.length;
}
}