content: package cn.xeblog.plugin.game.tetris;
  
  /**
   * @description: 游戏地图
   * @author: sherlock
   * @date: 2023-09-07 14:02:18
   * 原作者：我是小木鱼
   * 原文地址：https://blog.csdn.net/lag_csdn/article/details/124711977
   */
  public class TetrisMap
  {
  	/** 游戏大地图（存储方块[1~7]和围墙[-1]及空块[0]的信息，共21行12列252个小方格） */
  	private static byte[][] map = 
  		{
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},	
  			{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1}	
  		};
  	
  	/** 方块图形（存储七种形状及其四种旋转变形<逆时针旋转90度>，每种旋转变形用包含4×4的数组表示具体图形<盯住大于零的数字猛看，就能看到图形了>） */
  	private static byte shape[][][][] = new byte[][][][]
  	{
  		//长条形方块
  		{
  			//旋转变形一
  			{
  				{0, 0, 0, 0},
  				{1, 1, 1, 1},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形二
  			{
  				{0, 1, 0, 0},
  				{0, 1, 0, 0},
  				{0, 1, 0, 0},
  				{0, 1, 0, 0}
  			},
  			//旋转变形三
  			{
  				{0, 0, 0, 0},
  				{1, 1, 1, 1},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形四
  			{
  				{0, 1, 0, 0},
  				{0, 1, 0, 0},
  				{0, 1, 0, 0},
  				{0, 1, 0, 0}
  			}
  		},
  		//Z形方块
  		{
  			//旋转变形一
  			{
  				{2, 2, 0, 0},
  				{0, 2, 2, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形二
  			{
  				{0, 2, 0, 0},
  				{2, 2, 0, 0},
  				{2, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形三
  			{
  				{2, 2, 0, 0},
  				{0, 2, 2, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形四
  			{
  				{0, 2, 0, 0},
  				{2, 2, 0, 0},
  				{2, 0, 0, 0},
  				{0, 0, 0, 0}
  			}
  		},
  		//倒Z字形方块
  		{
  			//旋转变形一
  			{
  				{0, 3, 3, 0},
  				{3, 3, 0, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形二
  			{
  				{3, 0, 0, 0},
  				{3, 3, 0, 0},
  				{0, 3, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形三
  			{
  				{0, 3, 3, 0},
  				{3, 3, 0, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形四
  			{
  				{3, 0, 0, 0},
  				{3, 3, 0, 0},
  				{0, 3, 0, 0},
  				{0, 0, 0, 0}
  			}
  		},
  		//J形方块
  		{
  			//旋转变形一
  			{
  				{0, 4, 0, 0},
  				{0, 4, 0, 0},
  				{4, 4, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形二
  			{
  				{4, 4, 4, 0},
  				{0, 0, 4, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形三
  			{
  				{4, 4, 0, 0},
  				{4, 0, 0, 0},
  				{4, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形四
  			{
  				{4, 0, 0, 0},
  				{4, 4, 4, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			}
  		},
  		//L字形
  		{
  			//旋转变形一
  			{
  				{5, 0, 0, 0},
  				{5, 0, 0, 0},
  				{5, 5, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形二
  			{
  				{0, 0, 5, 0},
  				{5, 5, 5, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形三
  			{
  				{5, 5, 0, 0},
  				{0, 5, 0, 0},
  				{0, 5, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形四
  			{
  				{5, 5, 5, 0},
  				{5, 0, 0, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			}
  		},
  		//T字形方块
  		{
  			//旋转变形一
  			{
  				{0, 6, 0, 0},
  				{6, 6, 6, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形二
  			{
  				{0, 6, 0, 0},
  				{6, 6, 0, 0},
  				{0, 6, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形三
  			{
  				{6, 6, 6, 0},
  				{0, 6, 0, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形四
  			{
  				{6, 0, 0, 0},
  				{6, 6, 0, 0},
  				{6, 0, 0, 0},
  				{0, 0, 0, 0}
  			}
  		},
  		//田字形方块
  		{
  			//旋转变形一
  			{
  				{7, 7, 0, 0},
  				{7, 7, 0, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形二
  			{
  				{7, 7, 0, 0},
  				{7, 7, 0, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形三
  			{
  				{7, 7, 0, 0},
  				{7, 7, 0, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			},
  			//旋转变形四
  			{
  				{7, 7, 0, 0},
  				{7, 7, 0, 0},
  				{0, 0, 0, 0},
  				{0, 0, 0, 0}
  			}
  		}
  	};
  	
  	/**
  	 * 功能：返回大地图<br>
  	 * 备注：由于原始地图数据不允许修改，因此只返回复制后的地图赝品<br>
  	 */
  	public static byte[][] getMap()
  	{
  		//由于数组是个对象，而原始地图是不允许被修改的，所以不能直接赋值（引用地址），得复制一个新的地图让游戏随便修改。
  		int row = map.length;
  		int column = map[0].length;
  		byte[][] copyMap = new byte[row][column];
  		for(int i=0;i<row;i++)
  		{
  			for(int j=0;j<column;j++)
  			{
  				copyMap[i][j] = map[i][j];
  			}
  		}
  		return copyMap;
  	}
  	
  	/**
  	 * 功能：返回方块图形<br>
  	 * 参数：int _blockType -> 方块类型<br>
  	 * 参数：int _turnState -> 旋转状态<br>
  	 * 备注：由于原始方块图形数据不允许修改，因此只返回复制后的方块图形赝品<br>
  	 */
  	public static byte[][] getShape(int _blockType,int _turnState)
  	{
  		byte[][] temp = shape[_blockType][_turnState];
  		//开始复制
  		int row = temp.length;
  		int column = temp[0].length;
  		byte[][] shapeMap = new byte[row][column];
  		for(int i=0;i<row;i++)
  		{
  			for(int j=0;j<column;j++)
  			{
  				shapeMap[i][j] = temp[i][j];
  			}
  		}
  		return shapeMap;
  	}
  	
  }
  