package keshe;
import java.util.Random;

/**
 * 描述：  游戏规则 ，点击选中两个相同的数字即可消除这两个数字，没有过多的复杂判断
 * MapTool.java 类用于生产数字和判断选中的两个数字是否相同
 **/
public class MapTool {
    //创建数字地图1
    public static int[][] createMap1() {
        int[][] map = new int[10][10];
        Random rand = new Random();
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {
                map[i][j] = rand.nextInt(9) + 1;
            }
        }
        return map;
    }
    //创建数字地图2
    public static int[][] createMap2() {
        int[][] map = new int[15][15];
        Random rand = new Random();
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {
                map[i][j] = rand.nextInt(14) + 1;
            }
        }
        return map;
    }
    //创建数字地图3
    public static int[][] createMap3() {
        int[][] map = new int[20][20];
        Random rand = new Random();
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {
                map[i][j] = rand.nextInt(19) + 1;
            }
        }
        return map;
    }

    //消除相同的方块，打印消除方块的位置
    public static int[][] removed(int[][] map, int pi, int pj, int ci, int cj) {
        if (map[pi][pj] == map[ci][cj] && (pj != cj || pi != ci)) {
            System.out.println("消除：map[" + ci + "][" + cj + "]，map[" + pi + "][" + pj + "]");
            map[pi][pj] = 0;
            map[ci][cj] = 0;
        }
        return map;
    }
}