Esempio n. 1
0
 @Override
 public void run() {
   this.setVisible(true);
   toUIThread.setToInterface(this);
   while (!goButtonPressed) {
     try {
       Thread.sleep(1000);
     } catch (java.lang.InterruptedException error) {
       System.out.println("BLAM! SLEEP EXCEPTION!");
     }
   }
   startGame();
 }
Esempio n. 2
0
 public void startGame() {
   /*This is the method which is called by goButtonActionPerformed.
   It calls for the consturction of the Deal and Mail decks, along with the
   Board and StatWindow. It also contructs the Players, one after another,
   using a for loop to determine how many are to be created. Finally, it
   runs the game, calling takeYourTurn in player.*/
   devMode = false;
   toDeal = new Deal(this);
   toMail = new Mail(this);
   toBoard = new Board();
   // toStatWindow = new StatWindow(noOfPlayers, noOfMonths);
   System.out.println("Setting up the game...");
   toPlayer = new Player[noOfPlayers];
   for (int index = 0; index < noOfPlayers; index++) {
     toPlayer[index] = new Player(this, toBoard, index, toMail, toDeal);
   }
   toGameUI = new GameUI(noOfPlayers, this, toDeal, toMail, toBoard);
   for (int index = 0; index < noOfPlayers; index++) {
     toPlayer[index].setGameUI(toGameUI);
   }
   toDeal.updateCards(this);
   toMail.updateCards(this);
   toUIThread.setToGameUI(toGameUI);
   finished = false;
   toUIThreadsThread.start();
   toGameUI.distributeStartingMoney();
   this.passString("Setting up the game");
   index++;
   jackpot = 0;
   ready = true;
   while (!finished) {
     for (int index = 0; index < noOfPlayers; index++) {
       if (!toPlayer[index].finished) {
         toPlayer[index].takeYourTurn();
       }
     }
   }
 }