
package com.lofibucket.yotris.logic;

import java.util.ArrayList;
import java.util.Random;

public class TetriminoShape {

	private static final boolean[][] I = 
			new boolean[][] 
			{
			{false, true, 	false, false},
			{false, true, 	false, false},
			{false, true, 	false, false},
			{false, true, 	false, false}
			};

	private static final boolean[][] J = 
			new boolean[][] 
			{
			{false, false, 	false},
			{true,  true, 	true},
			{false, false, 	true}
			};

	private static final boolean[][] L = 
			new boolean[][] 
			{
			{false, false, 	false},
			{true,  true, 	true},
			{true, 	false, 	false}
			};

	private static final boolean[][] O = 
			new boolean[][] 
			{
			{true, 	true},
			{true, 	true},
			};

	private static final boolean[][] S = 
			new boolean[][] 
			{
			{false,	false, 	false},
			{false, true, 	true},
			{true,  true, 	false}
			};

	private static final boolean[][] T = 
			new boolean[][] 
			{
			{false,	false, 	false},
			{true, true, 	true},
			{false,  true, 	false}
			};

	private static final boolean[][] Z = 
			new boolean[][] 
			{
			{false,	false, 	false},
			{true, true, 	false},
			{false, true, 	true}
			};

	public static boolean[][] getShape(String shape) {
		switch (shape) {

			case "I":
				return I;
			case "J":
				return J;
			case "L":
				return L;
			case "O":
				return O;
			case "S":
				return S;
			case "T":
				return T;
			case "Z":
				return Z;
			default:
				// TODO throw a proper error here
				System.out.println("Error: invalid shape ID for getTetrimino.");
				return O;
		}
	}

	public static boolean[][] getRandomShape() {
		ArrayList<boolean[][]> shapes = new ArrayList<>();
		Random random = new Random();

		shapes.add(I);
		shapes.add(J);
		shapes.add(L);
		shapes.add(O);
		shapes.add(S);
		shapes.add(T);
		shapes.add(Z);

		return shapes.get(random.nextInt(shapes.size()));
	}
}

@@ -1566,37 +1566,38 @@
 ;%0A%09%09%7D%0A%09%7D%0A%0A%09p
-ublic
+rivate
  static 
 boolean%5B%5D%5B%5D 
@@ -1576,32 +1576,42 @@
 %09private static 
+ArrayList%3C
 boolean%5B%5D%5B%5D getR
@@ -1609,23 +1609,22 @@
 %5B%5D%5B%5D
+%3E
  get
-Random
+All
 Shape
+s
 () %7B
@@ -1680,40 +1680,8 @@
 %3E();
-%0A%09%09Random random = new Random();
 %0A%0A%09%09
@@ -1780,16 +1780,16 @@
 add(T);%0A
-
 %09%09shapes
@@ -1798,16 +1798,166 @@
 dd(Z);%0A%0A
+%09%09return shapes;%0A%09%7D%0A%0A%09public static boolean%5B%5D%5B%5D getRandomShape() %7B%0A%09%09ArrayList%3Cboolean%5B%5D%5B%5D%3E shapes = getAllShapes();%0A%09%09Random random = new Random();%0A%0A
 %09%09return

reorganize tetriminoshape