import processing.core.*; 
import processing.data.*; 
import processing.event.*; 
import processing.opengl.*; 

import java.util.HashMap; 
import java.util.ArrayList; 
import java.io.File; 
import java.io.BufferedReader; 
import java.io.PrintWriter; 
import java.io.InputStream; 
import java.io.OutputStream; 
import java.io.IOException; 

public class ssp6 extends PApplet {


/*
MIT License

Copyright (c) 2023 Jan Bühring

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


*/
  public void setup() {
  background(255);
  
  fill(200);
     rect(50,50,100,30);
     fill(0);
     text("Stein", 60,70);
     
      fill(200);
     rect(50,100,100,30);
     fill(0);
     text("Schere", 60,120);
     
      fill(200);
     rect(50,150,100,30);
     fill(0);
     text("Papier", 60,170);
     
    
         fill(200);
     rect(250,50,100,30);
     fill(0);
     text("Stein", 260,70);
     
      fill(200);
     rect(250,100,100,30);
      fill(0);
     text("Schere", 260,120);
      fill(200);
     rect(250,150,100,30);
     fill(0);
     text("Papier", 260,170);
  
  fill(0);
     text("Stein - Schere - Papier", 100,10);
        fill(200);
     rect(70,28,60,15);
     fill(0);
     text("Bereit", 80,40);
     
         fill(200);
     rect(270,28,60,15);
     fill(0);
     text("Bereit", 280,40);
     
      fill(0);
     text("Stein - Schere - Papier", 100,10);
        fill(200);
     rect(170,128,60,15);
     fill(0);
     text("Start", 180,140);
         fill(200);
        rect(170,158,60,15);
     fill(0);
     text("refresh", 180,170);
      
}

int i=0;
int re=1;
int a0=-1;
int b1=-1;
int erg=-1;
int get=0;
int mouseoverx=0;
int mouseovery=0;
   public void draw(){
        fill(200);
        rect(170,158,60,15);
     fill(0);
     text("refresh", 180,170);
     
     if ((mouseoverx>=170&&mouseoverx<=230)&&(mouseovery>=158&&mouseovery<=173)) {
        if (mousePressed ){ 
     re=1;
      get=1;
     }}
     
            if ((mouseoverx>=170&&mouseoverx<=230)&&(mouseovery>=128&&mouseovery<=143)) {
        if (i==0&&mousePressed ){
  link("http://jan-buehring.de/i3.php");
     fill(255);
     rect(0,0,400,400);
    
    
    fill(200);
   rect(170,128,60,15);
 
  fill(0);
     text("Stein - Schere - Papier", 100,10);
        fill(200);
     rect(70,28,60,15);
     fill(0);
     text("Aktiv", 80,40);
     
         fill(200);
     rect(270,28,60,15);
     fill(0);
     text("Aktiv", 280,40);
 noStroke();
    fill(255);
     rect(160,28,80,40);
  stroke(0);
 i=1;
 a0=-1;
b1=-1;
erg=-1;
 fill(200);
     rect(50,50,100,30);
     fill(0);
     text("Stein", 60,70);
     
      fill(200);
     rect(50,100,100,30);
     fill(0);
     text("Schere", 60,120);
     
      fill(200);
     rect(50,150,100,30);
     fill(0);
     text("Papier", 60,170);
     
    
         fill(200);
     rect(250,50,100,30);
     fill(0);
     text("Stein", 260,70);
     
      fill(200);
     rect(250,100,100,30);
      fill(0);
     text("Schere", 260,120);
      fill(200);
     rect(250,150,100,30);
     fill(0);
     text("Papier", 260,170);
       fill(200);
     rect(170,128,60,15);
     fill(0);
     text("Start", 180,140);
 
 
 
 }}
     
     
      mouseoverx=(int)mouseX;
mouseovery=(int)mouseY;
      if ((mouseoverx>=50&&mouseoverx<=150)&&(mouseovery>=50&&mouseovery<=110)) {
    if   (mousePressed) {
        fill(200);
     rect(70,28,60,15);
     fill(0);
     text("Fertig", 80,40);
      link("http://jan-buehring.de/i0.php");
    get=1;
 }
  } 
  
       if ((mouseoverx>=50&&mouseoverx<=150)&&(mouseovery>=100&&mouseovery<=190)) {
    if   (mousePressed) {
          fill(200);
     rect(70,28,60,15);
     fill(0);
     text("Fertig", 80,40);
           link("http://jan-buehring.de/i1.php");
        get=1; 
        
     }
  } 
      
      
       if ((mouseoverx>=50&&mouseoverx<=150)&&(mouseovery>=150&&mouseovery<=210)) {
    if   (mousePressed) {
      link("http://jan-buehring.de/i2.php");
      fill(200);
     rect(70,28,60,15);
     fill(0);
     text("Fertig", 80,40);
    
      get=1;
   }
  } 
      
      
      
     
         if ((mouseoverx>=250&&mouseoverx<=350)&&(mouseovery>=50&&mouseovery<=110)) {
    if   (mousePressed) {
        fill(200);
     rect(270,28,60,15);
     fill(0);
     text("Fertig", 280,40);
     link("http://jan-buehring.de/ib0.php");
     get=1;
  }
  } 
  
       if ((mouseoverx>=250&&mouseoverx<=350)&&(mouseovery>=100&&mouseovery<=210)) {
    if   (mousePressed) {
          fill(200);
     rect(270,28,60,15);
     fill(0);
     text("Fertig", 280,40);
      link("http://jan-buehring.de/ib1.php");
       get=1;
       }
  } 
      
      
       if ((mouseoverx>=250&&mouseoverx<=350)&&(mouseovery>=150&&mouseovery<=310)) {
    if   (mousePressed) {
      fill(200);
     rect(270,28,60,15);
     fill(0);
     text("Fertig", 280,40);
       link("http://jan-buehring.de/ib2.php");
      get=1;
     }
  } 
  if (get==1||re==2){
      String[] xa0 = loadStrings("http://jan-buehring.de/a0.txt");
       String[] xa1 = loadStrings("http://jan-buehring.de/a1.txt");
         String[]    xa2 = loadStrings("http://jan-buehring.de/a2.txt");
             String[]      xb0 = loadStrings("http://jan-buehring.de/b0.txt");
                String[]       xb1 = loadStrings("http://jan-buehring.de/b1.txt");
                   String[]          xb2 = loadStrings("http://jan-buehring.de/b2.txt");
                        get=0;
                       
 String yyy1="1";
 String yyy2="1";
 String yyy3="1";
 String yyy4="1";
 String yyy5="1";
 String yyy6="1";

     if((yyy1.equals(xa0[0]) == true)){a0=0;}else
      if((yyy2.equals(xa1[0]) == true)){a0=1;}else
       if((yyy3.equals(xa2[0]) == true)){a0=2;}
        if((yyy4.equals(xb0[0]) == true)){b1=0;}else
         if((yyy5.equals(xb1[0]) == true)){b1=1;}else
          if((yyy6.equals(xb2[0]) == true)){b1=2;}
}
   
     if (a0==0&&b1==0)erg=2;
     if (a0==0&&b1==1)erg=0;
     if (a0==0&&b1==2)erg=1;
     
     if (a0==1&&b1==0)erg=1;
     if (a0==1&&b1==1)erg=2;
     if (a0==1&&b1==2)erg=0;
     
     if (a0==2&&b1==0)erg=0;
     if (a0==2&&b1==1)erg=1;
     if (a0==2&&b1==2)erg=2; 
 
   
     if (erg!=-1)
     {
       if (erg==0){fill(0);text("<Sieg!", 180,40); ;
a0=-1;
b1=-1;
erg=-1;
i=0;
}
        if (erg==1){fill(0);text("Sieg!>", 180,40);  ;
a0=-1;
b1=-1;
erg=-1;
i=0;}
         if (erg==2){ fill(0);text("=Unenschieden!=", 160,40); ;
a0=-1;
b1=-1;
erg=-1;
i=0;
}}



  if (re==1){
      String[] xa0 = loadStrings("http://jan-buehring.de/a0.txt");
       String[] xa1 = loadStrings("http://jan-buehring.de/a1.txt");
         String[]    xa2 = loadStrings("http://jan-buehring.de/a2.txt");
             String[]      xb0 = loadStrings("http://jan-buehring.de/b0.txt");
                String[]       xb1 = loadStrings("http://jan-buehring.de/b1.txt");
                   String[]          xb2 = loadStrings("http://jan-buehring.de/b2.txt");
                        re=0;
 String yyy1="1";
 String yyy2="1";
 String yyy3="1";
 String yyy4="1";
 String yyy5="1";
 String yyy6="1";

     if((yyy1.equals(xa0[0]) == false) && (yyy2.equals(xa1[0]) == false)&& (yyy3.equals(xa2[0]) == false) ){ 
        fill(200);
     rect(70,28,60,15);
     fill(0);
     text("Activ", 80,40);
      fill(200);
     rect(270,28,60,15);
    fill(0);
     text("Fertig", 280,40);
        get=1;re=2;
    }
   if((yyy4.equals(xb0[0]) == false) && (yyy5.equals(xb1[0]) == false)&& (yyy6.equals(xb2[0]) == false) ){      fill(200);
     fill(200);
     rect(270,28,60,15);
     fill(0);
     text("Activ", 280,40);
        fill(200);
     rect(70,28,60,15);
 
 fill(0);
     text("Fertig", 80,40); get=0;
     get=1;re=2;
}






if((yyy4.equals(xb0[0]) == false) && (yyy5.equals(xb1[0]) == false)&& (yyy6.equals(xb2[0]) == false) &&(yyy1.equals(xa0[0]) == false) && (yyy2.equals(xa1[0]) == false)&& (yyy3.equals(xa2[0]) == false) ){      fill(200);
    
     fill(200);
     rect(270,28,60,15);
     fill(0);
     text("Activ", 280,40);
        fill(200);
     rect(70,28,60,15);
 fill(0);
     text("Activ", 80,40); get=1;
}
 }   } 
  public void settings() {  size(400, 200); }
  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "ssp6" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}
