Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
public void countPoints() {
/*playerPoints[0]=0;
playerPoints[1]=0;
checked.clear();*/
int tmp;
for (int z1=0;z1<this.firstD;z1++) {
for(int x=0;x<this.secondD;x++) {
for(int y=0;y<this.thirdD;y++) {
tmp = field[z1][x][y];
if(tmp !=2) {
if(testVertikal(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testHorizontal(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDiagonalDown(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDiagonalUp(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
}
}
}
}
print();
output.setText("Spieler 1: "+playerPoints[0]+" Player 2: "+playerPoints[1]);
}
public boolean testVertikal(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((y+1)<this.thirdD && found==false && contin==true) {
if(!checked.contains(z1+"-"+x+"-"+y)) {
y++;
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add(z1+"-"+x+"-"+(y-1));
checked.add(z1+"-"+x+"-"+(y-2));
checked.add(z1+"-"+x+"-"+(y-3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public void countPoints() {
/*playerPoints[0]=0;
playerPoints[1]=0;
checked.clear();*/
int tmp;
for (int z1=0;z1<this.firstD;z1++) {
for(int x=0;x<this.secondD;x++) {
for(int y=0;y<this.thirdD;y++) {
tmp = field[z1][x][y];
if(tmp !=2) {
if(testVertikal(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testHorizontal(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDiagonalDown(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDiagonalUp(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepth(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepthDown(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepthUp(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepthRight(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepthLeft(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepthRightUp(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepthLeftUp(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepthRightDown(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
else if(testDepthLeftDown(z1,x,y,tmp)) {
playerPoints[tmp]++;
}
}
}
}
}
//print();
output.setText("Spieler 1: "+playerPoints[0]+" Player 2: "+playerPoints[1]);
}
public boolean testVertikal(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((y+1)<this.thirdD && found==false && contin==true) {
if(!checked.contains(z1+"-"+x+"-"+y)) {
y++;
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add(z1+"-"+x+"-"+(y-1));
checked.add(z1+"-"+x+"-"+(y-2));
checked.add(z1+"-"+x+"-"+(y-3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testHorizontal(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x+1)<this.secondD && found==false && contin==true) {
if(!checked.contains(z1+"-"+x+"-"+y)) {
x++;
//System.out.println(x+1);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add(z1+"-"+(x-1)+"-"+y);
checked.add(z1+"-"+(x-2)+"-"+y);
checked.add(z1+"-"+(x-3)+"-"+y);
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDiagonalDown(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x+1)<this.secondD && (y+1)<this.thirdD && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
x++;
y++;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add(z1+"-"+(x-1)+"-"+(y-1));
checked.add(z1+"-"+(x-2)+"-"+(y-2));
checked.add(z1+"-"+(x-3)+"-"+(y-3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDiagonalUp(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x+1)<this.secondD && (y-1)>=0 && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
x++;
y--;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add(z1+"-"+(x+1)+"-"+(y+1));
checked.add(z1+"-"+(x+2)+"-"+(y+2));
checked.add(z1+"-"+(x+3)+"-"+(y+3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepth(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while(found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+x+"-"+y);
checked.add((z1-2)+"-"+x+"-"+y);
checked.add((z1-3)+"-"+x+"-"+y);
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepthDown(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((y+1)<this.thirdD && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
y++;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+x+"-"+(y-1));
checked.add((z1-2)+"-"+x+"-"+(y-2));
checked.add((z1-3)+"-"+x+"-"+(y-3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepthUp(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((y-1)>=0 && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
y--;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+x+"-"+(y+1));
checked.add((z1-2)+"-"+x+"-"+(y+2));
checked.add((z1-3)+"-"+x+"-"+(y+3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepthRight(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x+1)<this.secondD && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
x++;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+(x-1)+"-"+y);
checked.add((z1-2)+"-"+(x-2)+"-"+y);
checked.add((z1-3)+"-"+(x-3)+"-"+y);
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepthLeft(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x-1)>=0 && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
x--;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+(x+1)+"-"+y);
checked.add((z1-2)+"-"+(x+2)+"-"+y);
checked.add((z1-3)+"-"+(x+3)+"-"+y);
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepthRightDown(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x+1)<this.secondD && (y+1)<this.thirdD && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
x++;
y++;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+(x-1)+"-"+(y-1));
checked.add((z1-2)+"-"+(x-2)+"-"+(y-2));
checked.add((z1-3)+"-"+(x-3)+"-"+(y-3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepthLeftDown(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x-1)>=0 && (y+1)<this.thirdD && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
x--;
y++;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+(x+1)+"-"+(y-1));
checked.add((z1-2)+"-"+(x+2)+"-"+(y-2));
checked.add((z1-3)+"-"+(x+3)+"-"+(y-3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepthRightUp(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x+1)<this.secondD && (y-1)>=0 && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
x++;
y--;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+(x-1)+"-"+(y+1));
checked.add((z1-2)+"-"+(x-2)+"-"+(y+2));
checked.add((z1-3)+"-"+(x-3)+"-"+(y+3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}
public boolean testDepthLeftUp(int z1, int x, int y, int user) {
boolean found=false;
boolean contin=true;
int counter=1;
while((x-1)>=0 && (y-1)>=0 && found==false && contin==true) {
//System.out.println("Punkt: "+z1+"-"+x+"-"+y);
if(!checked.contains(z1+"-"+x+"-"+y)) {
if((z1+1)==this.firstD) {
z1=0;
}
else {
z1++;
}
x--;
y--;
//System.out.println(x+1);
//System.out.println("Punkt1: "+z1+"-"+x+"-"+y);
if(field[z1][x][y]==user && !checked.contains(z1+"-"+x+"-"+y)) {
counter++;
if(counter==4) {
checked.add(z1+"-"+x+"-"+y);
checked.add((z1-1)+"-"+(x+1)+"-"+(y+1));
checked.add((z1-2)+"-"+(x+2)+"-"+(y+2));
checked.add((z1-3)+"-"+(x+3)+"-"+(y+3));
return true;
}
}
else {
counter=1;
contin=false;
}
}
else {
contin=false;
}
}
return found;
}