// 旋转
Square.prototype.canRotate = function (isValid) {
let d = (this.dire + 1) % 4;
let test = [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
];
for (let i = 0; i < this.data.length; i++) {
for (let j = 0; j < this.data[0].length; j++) {
test[i][j] = this.rotates[d][i][j];
}
}
return isValid(this.origin, test);
};
Square.prototype._rotate = function (num) {
if (!num) {
num = 1;
}
this.dir = (this.dir + num) % 4;
this.dire += 1;
for (let i = 0; i < this.data.length; i++) {
for (let j = 0; j < this.data[0].length; j++) {
this.data[i][j] = this.rotates[this.dire][i][j];
}
}
};