[SOLVED(not by fourm)] Chess Clock Broken Help

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
int bPin = 7;
int wPin = 6;
int mwTime = 30;
int mbTime = 30;
int swTime = 0;
int sbTime = 0;
int time = 10;
int wState =0;
int bState=0;
int n = 11;
int b = 1;
int x = 2;
int z =3;
int song =500;
int pbState = 0;
int pwState = 0;
int count = 30;
boolean wTurn = true;

void setup(){
 lcd.begin(16,2);
 pinMode(bPin,INPUT);
 pinMode(wPin,INPUT);
 
 
 
}
void loop(){
 
 wState = digitalRead(wPin);
 bState = digitalRead(bPin);
  
if(wState==HIGH&&bState==LOW){
lcd.setCursor(7,0);
  
  if(sbTime<10 && sbTime>0){    

lcd.setCursor(z,0);
lcd.print("0");
lcd.setCursor(z+1,0);
lcd.print(sbTime);
lcd.setCursor(0,0);
lcd.print(mbTime);
lcd.setCursor(x,0);
lcd.print(":");
delay(time);
sbTime--;

pwState =wState;
}
else if(sbTime>=10){
lcd.noCursor();
lcd.setCursor(z,0);
lcd.print(sbTime);
lcd.setCursor(0,0);
lcd.print(mbTime);
lcd.setCursor(x,0);
lcd.print(":");
delay(time);
sbTime--;
pwState = wState;

} 
else if(sbTime<=0){
 
  lcd.setCursor(z,0);
  lcd.print("00");
  lcd.setCursor(0,0);
  lcd.print(mbTime);
  lcd.setCursor(x,0);
  lcd.print(":");
  sbTime = 59;
  mbTime--;
  delay(time);
 pwState = wState;
  
  if(mbTime<10 && mbTime>-1){
    x = 1;
    z =2;
 pwState = wState;

}
  else if(mbTime>=10){
    x = 2;
    z=3;
  pwState = wState;

}
  else if(mbTime <=-1){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Game Over");
    lcd.setCursor(0,1);
    lcd.print("Black Timed Out");
    tone(9,300);
    delay(song);
    tone(9,500);
    delay(song);
    tone(9,300);
   delay(song);
    tone(9,500);
   delay(song);
    tone(9,300);
    delay(song);
    tone(9,500);
   delay(song);
    tone(9,300);
   delay(song);
    tone(9,500);
    delay(song);
    noTone(9);
    delay(1000000);
}
}



}
else if(bState==HIGH&&wState==LOW){
 
  if(swTime<10 && swTime>0){    

lcd.setCursor(14,0);
lcd.print("0");
lcd.setCursor(15,0);
lcd.print(swTime);
lcd.setCursor(n,0);
lcd.print(mwTime);
lcd.setCursor(13,0);
lcd.print(":");
delay(time);
swTime--;
}
else if(swTime>=10){

lcd.setCursor(14,0);
lcd.print(swTime);
lcd.setCursor(n,0);
lcd.print(mwTime);
lcd.setCursor(13,0);
lcd.print(":");
delay(time);
swTime--;
} 
else if(swTime<=0){
  
  lcd.setCursor(14,0);
  lcd.print("00");
  lcd.setCursor(n,0);
  lcd.print(mwTime);
  lcd.setCursor(13,0);
  lcd.print(":");
  swTime = 59;
  mwTime--;
  delay(time);
  if(mwTime<10 && mwTime>-1){
    n = 12;
  }
  else if(mwTime>=10){
    n = 11;
  }
  else if(mwTime <=-1){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Game Over");
    lcd.setCursor(0,1);
    lcd.print("White Timed Out");
    delay(1000000);
}
}

}
}

I am trying to make an chess clock on my arduino. The long segments of block are used only for the clock counting down. Is there a way to have one or two words like white_clock become those lines of code to save room in my program? And more importantly, the wButton must be held down to start black's time on the lcd, but when the bButton is pushed, white's time immediately starts. I have tried boolean variables for the program but they have not worked, I tested this program with leds instead of the clock blocks and the two variables worked with the skeleton function. Please help, Ben
I will reiterate, this program is supposed to display two values on a chess clock. The values are to count down in seconds and minutes, when the left button(wButton) is pressed the right time(bTime) starts. However, this is not what occurs. When the left(wButton) is pressed, it starts the right clock, but when it is released, the left clock starts again. When the right button is pressed, it starts the left clock until the left button is released like it is supposed to do.

wwb00:
Is there a way to have one or two words like white_clock become those lines of code to save room in my program?

First, please edit your post to put the code inside code tags as explained in the sticky posts at the top of the forum. Secondly, can you explain this question? It makes no sense to me.

I improved what I was asking I hope it makes sense, if not I will further clarify. :sunglasses: Thanks

wwb00:
When the right button is pressed, it starts the left clock until the left button is released like it is supposed to do.

Did you mean,
"When the right button is pressed, it starts the left clock until the left button is pressed like it is supposed to do." ?

Also, what do these variables do? Can you not give them meaningful names?

int n = 11;
int b = 1;
int x = 2;
int z = 3;

aarg:
Did you mean,
"When the right button is pressed, it starts the left clock until the left button is pressed like it is supposed to do." ?

Also, what do these variables do? Can you not give them meaningful names?

int n = 11;

int b = 1;
int x = 2;
int z = 3;

The variables n allows the lcd to print the number of minutes remaining in different places, when it is less then ten, the value moves one to the right becoming 12, x and z do the same thing for the colon and the number of seconds. B- im not quite sure why B is there...

Also, I mean, once the left button is pressed, and only when it is pressed, the right clock moves. Immediately when the left button is lifted, the left clock starts again.

When you have blocks of code that are repeated, then you probably want to pull those blocks of code out into a function, and call that function.

When you have multiple sets of variables that all have the same "shape" - in this case you have a white clock and a black clock that are identical - you usually pull those variables out into a C struct or a C++ class.