#include <iostream>
#include <unistd.h>
#include <time.h>
#include <cstdlib>
#include "scoreBoard.h"
#include "ansi.h"


using namespace std;


int main(void) {
 ScoreBoard sb;
 int count=0;

 //seed the random number generator
 srand(time(0));

 cout << clearScreen << cursorOff;

 while(true) {

   sb.draw();
   count++;

   //simulate a game of pong
   switch(rand() % 6) {
   case 0:
     break;

   case 1:
   case 2:
     sb.addPlayer1();
     break;
   case 3:
   case 4:
     sb.addPlayer2();
     break;

   case 5:
     break;
   }

   if(sb.hasEnded()) {
     cout << normal << cursorPosition(10, 7)
          << "Player " << sb.getWinner() << " wins!" << endl;
     sleep(2);
     sb.reset();
     cout << clearScreen;
   }


   //delay
   usleep(500000);
   sb.erase();
   sb.update();
 }
}