package model; /** * Created by loic on 21/09/16. */ public class LineAlgorithm { private int score=0; public int[] mergeRight(int[] line){ line=gravityRight(line); for(int i=(line.length-1);i>=0;i--){ if(i>0){ int a=line[i]; int b=line[i-1]; if(a==b && a!=-1){ line[i]=a+b; line[i-1]=-1; i--; this.score+=(a+b); } } } line=gravityRight(line); return line; } private static int[] gravityRight(int[] line){ for(int i=0;i= 0; j--) { int a = line[j]; if (j > 0) { int b = line[j - 1]; if (a == -1) { line[j] = b; line[j - 1] = -1; } } } } return line; } public static int[] clearLine(int[] line){ for(int i=0;i=0;i--){ reversedLine[j]=line[i]; j++; } return reversedLine; } public static boolean linesIsEquals(int[] line1, int[] line2){ if(line1.length!=line2.length){ return false; } else { for (int i=0;i