/**
  * Diese Methode erhält das Paket. Darauf hin wird eine Lognachricht erzeugt. Im Anschluss wird
  * der Listener für den Datenkanal aus dem Server entfernt und die GUI mitr den Daten des Geräts
  * upgedatet.
  *
  * @param p Das Paket
  * @param temp_imei Eine IMEI
  * @param c Der Server
  */
 @Override
 public void handlePacket(Packet p, String temp_imei, Server c) {
   gui.logTxt("Call monitoring data has been received");
   c.getChannelHandlerMap().get(imei).getStorage(channel).reset();
   CallStatusPacket packet = (CallStatusPacket) p;
   gui.addMonitoredCall(imei, packet.getType(), packet.getPhonenumber());
 }
 @Override
 public void handlePacket(Packet p, String temp_imei, Server c) {
   gui.logTxt("SMS data has been received");
   c.getChannelHandlerMap().get(imei).getStorage(channel).reset();
   ShortSMSPacket packet = (ShortSMSPacket) p;
   gui.addMonitoredSMS(imei, packet.getAddress(), packet.getDate(), packet.getBody());
 }
Esempio n. 3
0
  public void advanceGame() {

    if (mainButtonState != GAME_OVER_STATE) {
      if (amountNotBroke() == 1) {
        mainButtonState = GAME_OVER_STATE;
      }

      if (currentPlayer.isBroke()) {
        // Prints when a player looses
        String[] options1 = {"Deal with it."};

        int nrOfOptions = 1;
        String[] options = new String[nrOfOptions];
        for (int i = 0; i < options.length; i++) {
          options[i] = options1[i];
        }

        String message = getCurentPlayer().getName() + ", you have lost";
        while ((gui.getUserButtonPressed(options, message, "You have lost the game")) == -1) ;
      }

      if (mainButtonState == ROLL_STATE) {
        boolean playerBroke = moveController.playerTurn(currentPlayer);

        if (!playerBroke)
          playerBroke = fieldController.LandOnField(currentPlayer, currentPlayer.getPosition());

        currentPlayer.setBroke(playerBroke);

        if (!dice.isTwoOfAKind() || currentPlayer.isBroke() || currentPlayer.isInPrisson())
          mainButtonState = END_TURN_STATE;
      }
      // This runs when the player end his turn
      else if (mainButtonState == END_TURN_STATE) {
        if (!currentPlayer.isBroke()) {
          // add player back to the queue
          playerQueue.add(currentPlayer);
        }
        // pick next player from the queue
        currentPlayer = playerQueue.remove();
        currentPlayer.setTwoOfAKindRollCount(0);
        mainButtonState = ROLL_STATE;
      }
    }
    if (mainButtonState == GAME_OVER_STATE) {
      // You have won message.
      String[] options1 = {"Proceed"};

      int nrOfOptions = 1;
      String[] options = new String[nrOfOptions];
      for (int i = 0; i < options.length; i++) {
        options[i] = options1[i];
      }

      String message = getWinner().getName() + ", you have won! Contragratulations";
      while ((gui.getUserButtonPressed(options, message, "You have won the game")) == -1) ;
    }
  }
Esempio n. 4
0
 public void run() {
   while (true) {
     try {
       Thread.sleep(1000);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     juego.mover();
     if (gui.getLock()) {
       juego.mover(gui.getDirection());
       gui.toggleLock();
     }
   }
 }
Esempio n. 5
0
  public ProductBar(GUI gui) {
    this.gui = gui;
    int productListSize;
    primaryStage = gui.getPrimaryStage();

    // double elementHeight = gui.getScreenHeight()*.10;
    // double elementWidth = gui.getScreenWidth()*.07;

    productList = new ArrayList<>();
    initializeProductList();

    productListSize = productList.size();
    elements = new ArrayList<>();

    for (int i = 0; i < productListSize; ++i) {
      EnumFood food = productList.get(i);
      elements.add(new ProductBarElement(food, gui, 1, 1, i));
    }

    setAlignment(Pos.CENTER);
    getChildren().addAll(elements);
  }
Esempio n. 6
0
 @Override
 public void valueChanged(ListSelectionEvent arg0) {
   gui.onBicycleSelect();
 }
  @Override
  public void actionPerformed(ActionEvent arg0) {
    String actionName = arg0.getActionCommand();
    String serviceName = null;
    String user = null;

    if (column == 1) {
      user = ((String) table.getValueAt(row, column)).split("\\s+")[0];
      serviceName = (String) table.getValueAt(row, column - 1);
    } else {
      serviceName = (String) table.getValueAt(row, column);
    }

    // verify action name

    // Launch Offer Request
    if (actionName.equals(ComponentNames.buyerServiceMenu[0])) {
      gui.getMed().launchService(serviceName, gui.getUser().getUsername());
      gui.launchOfferRequest(serviceName);
    } else
    // Drop offer request
    if (actionName.equals(ComponentNames.buyerServiceMenu[1])) {
      gui.dropOfferRequest(serviceName);
    } else
    // Accept offer
    if (actionName.equals(ComponentNames.buyerUserMenu[0])) {
      List<String> usersHavingStatus =
          gui.getUser().getUsersHavingStatus(user, StatusMessages.offerMade, serviceName);

      gui.getMed().acceptOfferGui(gui.getUser().username, serviceName, user, usersHavingStatus);
      gui.acceptOffer(serviceName, user);
    } else
    // refuse offer
    if (actionName.equals(ComponentNames.buyerUserMenu[1])) {
      gui.refuseOffer(serviceName, user);
    } else
    // Make offer
    if (actionName.equals(ComponentNames.sellerServiceMenu[0])) {
      gui.makeOffer(serviceName, user);
    } else
    // Drop auction
    if (actionName.equals(ComponentNames.sellerServiceMenu[1])) {
      gui.dropAuction(serviceName, user);
    }
  }