Пример #1
0
 /** Action taken on button click Continue. Creates a player or displays an error. */
 @FXML
 public final void confirmChoices() {
   if (textName.getText().isEmpty()) {
     lblWarning.setText("Please enter a name.");
   } else {
     if (playerCount > 0) {
       // Gets the currently picked color
       final String pickedColor = cmbColor.getValue();
       // Create new player
       final Player tempPlayer =
           new Player(textName.getText(), cmbRace.getValue(), cmbColor.getValue());
       main.addPlayer(tempPlayer); // Add new player
       // Remove picked Color from list
       cmbColor.getItems().remove(pickedColor);
       // Sets combo boxes back to zero index
       cmbColor.getSelectionModel().select(0);
       cmbRace.getSelectionModel().select(0);
       textName.clear();
       lblWarning.setText("");
       playerCount--; // Decrement player count after creation
       playerNum++; // Increment player Label number
       lblPlayerNum.setText("Player " + playerNum + ": Choose Your Options");
     } else {
       // If just one player, and end case for last player
       final Player tempPlayer =
           new Player(textName.getText(), cmbRace.getValue(), cmbColor.getValue());
       main.addPlayer(tempPlayer);
       // Display the map Screen to start game
       main.showMapScreen();
     }
   }
 }
Пример #2
0
  public static void main(String[] args) {
    daemon.Daemon daemon = new Daemon("", "");
    // daemon.procesar();

    Main m = new Main(daemon);
    m.run();
  }
Пример #3
0
  private void btnToUnbekanntActionPerformed(ActionEvent e) {
    Lager unbekannt = LagerTools.getUnbekannt();
    StockTableModel2 model = (StockTableModel2) tblVorrat.getModel();
    Tools.log(txtLog, "Folgende Vorräte wurden auf Unbekannt umgebucht:");
    Tools.log(txtLog, "================================================");

    EntityManager em = Main.getEMF().createEntityManager();
    try {
      em.getTransaction().begin();

      for (int row = 0; row < model.getRowCount(); row++) {
        // Model Row Index Umwandlung ist hier unnötig. Markierungen bleiben unberücksichtigt.
        if (model.getStatus(row) == StockTableModel2.STATUS_FRAGLICH) {
          Stock stock = em.merge(model.getVorrat(row));
          em.lock(stock, LockModeType.OPTIMISTIC);
          Tools.log(txtLog, stock.getId(), stock.getProdukt().getBezeichnung(), "");
          stock.setLager(unbekannt);
        }
      }
      em.getTransaction().commit();
    } catch (OptimisticLockException ole) {
      em.getTransaction().rollback();
      Main.warn(ole);
    } catch (Exception ex) {
      em.getTransaction().rollback();
      Main.fatal(ex);
    } finally {
      em.close();
      loadVorratTable();
    }
    Tools.log(txtLog, "================================================");
  }
Пример #4
0
 public void sell() {
   destroy();
   int ret = 0;
   for (TowerType t = getTowerType(); t != null; t = t.getBase()) {
     ret += t.getCost();
   }
   m.getGame().setMoney(m.getGame().getMoney() + ret);
 }
Пример #5
0
  private void updateDeletes() {
    Integer reps = Main.getDatabase().getDeletedFiles().get(header.get(1));

    if (reps != null) {
      Main.getDatabase().changeRepDegree(header.get(1), reps - 1);
    }

    Main.getService().submit(new ReclaimProcess());
  }
Пример #6
0
 public boolean isNpcInRange() {
   for (NPC npc : m.getGame().getNpcs()) {
     if (isInRange(
         npc.getX(), npc.getY(), getX(), getY(), getRange() * m.getGame().getTileWidth())) {
       return true;
     }
   }
   return false;
 }
Пример #7
0
  public void reload() {
    removeNodes();

    DefaultMutableTreeNode hostNode = new DefaultMutableTreeNode(Main.getLocalhost());
    treeModel.insertNodeInto(hostNode, rootNode, rootNode.getChildCount());

    for (Trigger trigger : Main.getTriggerManager().getTriggers()) {
      DefaultMutableTreeNode triggerNode = new DefaultMutableTreeNode(trigger);
      treeModel.insertNodeInto(triggerNode, hostNode, hostNode.getChildCount());
    }
    expandAll();
  }
 @Override
 public void execute() {
   MainWindow.getInstance().setStatus("Begin validation");
   Main.log("Begin validation");
   for (IDiagramValidator validator : validators) {
     validator.execute();
   }
   if (validationList.getValidationItems().isEmpty()) {
     MainWindow.getInstance().setStatus("Validation success");
     Main.log("Validation success");
   } else {
     MainWindow.getInstance().setStatus("Validation fail");
     Main.log("Validation fail");
   }
 }
Пример #9
0
  public TriggersTree(TriggersConfigurationDialog tcd) {
    super(new GridLayout(1, 0));

    this.tcd = tcd;

    rootNode = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(rootNode);

    tree = new JTree(treeModel);
    treeRender = new TriggersTreeRender();
    treeCellEditor = new TriggersTreeCellEditor(tree, treeRender);

    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(false);
    tree.setRootVisible(false);
    tree.setDragEnabled(true);
    tree.setEditable(true);
    tree.addTreeSelectionListener(this);
    tree.setCellEditor(treeCellEditor);

    ToolTipManager.sharedInstance().registerComponent(tree);
    tree.setCellRenderer(treeRender);

    JScrollPane scrollPane = new JScrollPane(tree);
    add(scrollPane);

    reload();

    for (Trigger trigger : Main.getTriggerManager().getTriggers()) {
      setSelectedTrigger(trigger);
      return;
    }
  }
Пример #10
0
  @Override
  public void run() {

    while (true) {
      String message;
      try {
        while ((message = in.readLine()) != null) {
          System.out.println(message);
          Scanner myScanner = new Scanner(message);
          myScanner.useDelimiter("\\|");
          switch (myScanner.next()) {
            case "MSG":
              String temp = myScanner.next();
              DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
              Date date = new Date();
              System.out.println(dateFormat.format(date) + " " + username + ": " + temp);
              Main.sendMessage(dateFormat.format(date) + " " + username + ": " + temp);
              break;

            case "LOGOUT":
              disconnectClient();
            default:
              break;
          }

          try {
            Thread.sleep(10);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
      } catch (IOException e) {
      }
    }
  }
Пример #11
0
  public void damageGround(Projectile p) {
    NPC target = getClosestNPC(p.getX(), p.getY());

    if (target != null)
      if (getDistance(target.getX(), target.getY(), p.getX(), p.getY())
          < m.getGame().getTileWidth()) if (canAttack(this, target)) target.damage(getDamage());
  }
  @Override
  public Object execute(HashList param) throws Exception {
    for (HashBitmapPair pair : param) {
      Main.hashmap.put(Main.byteToString(pair.getHash()), pair);
    }

    return new Object();
  }
Пример #13
0
  private static void CalcularFrota() {

    CalcularFrota_Master cfm = new CalcularFrota_Master();
    int numFrota = cfm.CalcularFrota();

    System.out.println(FROTA_NECESSARIA + " = " + numFrota);
    System.out.println("\n" + Main.getTxtIni());
  }
Пример #14
0
  private void processDB() {
    FileManager fm = new FileManager(header.get(1), 0, true);
    if (fm.readChunk(Integer.parseInt(header.get(2)), Main.getDatabase().getUsername())) {
      Chunk ch = new Chunk(header.get(1), Integer.parseInt(header.get(2)), 0);

      Main.getDatabase().addChunk(ch);
      String msg = "DB " + header.get(1) + " " + header.get(2) + Main.getCRLF() + Main.getCRLF();

      byte[] msgByte = msg.getBytes(StandardCharsets.ISO_8859_1);
      byte[] msgFull = Main.appendArray(msgByte, fm.getChunkData());

      Random r = new Random();
      try {
        sleep(r.nextInt(400));
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      if (!ch.getSent()) {
        Main.getRestore().send(msgFull);
      }

      Main.getDatabase().removeChunk(header.get(1), Integer.parseInt(header.get(2)));
    }
  }
Пример #15
0
  private void storedProcess() {

    for (int j = 0; j < Main.getBackup().getSending().size(); j++) {
      if (Main.getBackup().getSending().get(j).getFileHash().equals(header.get(2))) {
        Main.getBackup().getSending().get(j).incStoreds(1);
        break;
      }
    }

    for (int i = 0; i < Main.getDatabase().getChunksSize(); i++) {
      Chunk chunk = Main.getDatabase().getChunk(i);
      if (chunk.getFileId().equals(header.get(2))
          && (chunk.getChunkNo() == Integer.parseInt(header.get(3)))) {
        chunk.setKnownReps(1);
        break;
      }
    }
  }
Пример #16
0
  private static void CriarRegioes(int numRegioes, int numPedidos) {
    Pedido[] pedidos = Mock.GetPedidos(numPedidos);
    Dataset[] dsFinal = CriarRegiao_Master.FormarRegioes(numRegioes, pedidos);

    Regiao[] regioes = RegiaoUtil.CriarRegioes(dsFinal, pedidos);

    mock.SetRegioes(regioes);
    System.out.println("\n" + Main.getTxtIni());
  }
Пример #17
0
  private void myInit() {
    cmbLager.setModel(tools.Tools.newComboboxModel(LagerTools.getAll()));
    cmbLager.setSelectedIndex(
        Integer.parseInt(Main.getProps().getProperty("touch" + MODULENUMBER + "lager")));
    loadLieferant();
    cmbLieferant.setSelectedIndex(0);
    ziel = (Lager) cmbLager.getSelectedItem();
    lieferant = null;
    txtSearch.requestFocus();
    btnSofortUmbuchen.setSelected(true);
    cbZombieRevive.setSelected(true);

    pageprinter = Main.printers.getPrinters().get("pageprinter");
    etiprinter1 = Main.printers.getPrinters().get(Main.getProps().getProperty("etitype1"));
    etiprinter2 = Main.printers.getPrinters().get(Main.getProps().getProperty("etitype2"));

    form1 = etiprinter1.getForms().get(Main.getProps().getProperty("etiform1"));
    form2 = etiprinter2.getForms().get(Main.getProps().getProperty("etiform2"));
  }
Пример #18
0
  void receive() throws UnsupportedEncodingException {

    while (running) {

      byte[] mssg = ctrlComm.receive();
      if (mssg != null) {
        Main.getService().submit(new ControlProcess(mssg));
      }
    }
  }
Пример #19
0
 public void disconnectClient() {
   Main.disconnectClient(username);
   try {
     out.close();
     in.close();
     clientSocket.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Пример #20
0
 private void removedProcess() {
   for (int i = 0; i < Main.getDatabase().getChunksSize(); i++) {
     Chunk chunk = Main.getDatabase().getChunk(i);
     if (chunk.getFileId().equals(header.get(2))
         && (chunk.getChunkNo() == Integer.parseInt(header.get(3)))) {
       chunk.setKnownReps(-1);
       if (chunk.getKnownReps() < chunk.getRepDegree()) {
         BackupSend send =
             new BackupSend(
                 chunk.getFileId(),
                 chunk.getRepDegree(),
                 false,
                 chunk.getChunkNo(),
                 chunk.getKnownReps());
         Main.getBackup().addSending(send);
         Main.getService().submit(send);
       }
       break;
     }
   }
 }
Пример #21
0
  public static ArrayList<Menuweekall> getAll() {
    ArrayList<Menuweekall> list = new ArrayList<Menuweekall>();

    EntityManager em = Main.getEMF().createEntityManager();
    Query queryMin = em.createQuery("SELECT t FROM Menuweekall t ORDER BY t.week DESC ");

    list.addAll(queryMin.getResultList());

    em.close();

    return list;
  }
Пример #22
0
 private void loadLieferant() {
   EntityManager em = Main.getEMF().createEntityManager();
   Query query = em.createQuery("SELECT l FROM Lieferanten l ORDER BY l.firma");
   try {
     java.util.List lieferant = query.getResultList();
     lieferant.add(0, "<html><i>Lieferant nicht &auml;ndern</i></html>");
     cmbLieferant.setModel(tools.Tools.newComboboxModel(new ArrayList<Lieferanten>(lieferant)));
   } catch (Exception e) { // nicht gefunden
     //
   } finally {
     em.close();
   }
 }
Пример #23
0
  public static Menuweekall get(LocalDate week) {
    ArrayList<Menuweekall> list = new ArrayList<Menuweekall>();

    EntityManager em = Main.getEMF().createEntityManager();
    Query queryMin = em.createQuery("SELECT t FROM Menuweekall t WHERE t.week = :week ");

    queryMin.setParameter("week", week.toDate());

    list.addAll(queryMin.getResultList());

    em.close();

    return list.isEmpty() ? null : list.get(0);
  }
Пример #24
0
  public void computeEXP() {

    if (!GameRules.playerCanLevel()) return;

    int expForAll = this.level * 2 + 18;

    for (Character c : Main.getCharacterList()) {
      if (c.isAlive()
          && c.getCenter().distance(this.getCenter()) <= 200
          && c != this
          && c.team != this.team) {
        c.expEarned(expForAll);
      }
    }
  }
Пример #25
0
  public NPC getClosestNPC(double x, double y) {
    double minDistance = Double.MAX_VALUE;
    NPC closest = null;

    for (NPC npc : m.getGame().getNpcs()) {
      if (!canAttack(this, npc)) {
        continue;
      }
      if (getDistance(npc.getX(), npc.getY(), x, y) < minDistance) {
        minDistance = getDistance(npc.getX(), npc.getY(), x, y);
        closest = npc;
      }
    }
    return closest;
  }
Пример #26
0
  public void attack() {
    NPC target = getClosestNPC();

    if (target != null) {
      setAAcd(getAAcd() + 1.0D / getAttackSpeed());
      setAnimation(ANIMATION_POST_ATTACK);

      Projectile p = new Projectile(m, getX(), getY(), target, this);
      p.setAnimationDeath(getProjectileAnimationDeath());
      p.setAnimationStand(getProjectileAnimationStand());
      p.setAnimationDeathDuration(getProjectileAnimationDeathDuration());
      p.setAnimationStandDuration(getProjectileAnimationStandDuration());
      m.getGame().setNewProjectile(p);
    }
  }
Пример #27
0
 public void drawWorld(Graphics2D g2d, World w) {
   Chunk[] c = w.getChunks();
   for (int ci = 0; ci < c.length; ci++) {
     Chunk ch = c[ci];
     for (int tx = 0; tx < ch.tiles.length; tx++) {
       for (int ty = 0; ty < ch.tiles[tx].length; ty++) {
         drawTile(g2d, ch.tiles[tx][ty]);
         if (Main.showChunks) {
           g2d.setColor(Main.getRandomColor(true));
           Rectangle r = ch.getR();
           g2d.drawRect(r.x, r.y, r.width, r.height);
         }
       }
     }
   }
 }
Пример #28
0
 @Override
 public void removeRow(int row) {
   Stock stock = (Stock) ((Object[]) data.get(row))[0];
   EntityManager em = Main.getEMF().createEntityManager();
   try {
     em.getTransaction().begin();
     em.remove(stock);
     data.remove(row);
     em.getTransaction().commit();
     fireTableRowsDeleted(row, row);
   } catch (Exception e) {
     Main.logger.fatal(e.getMessage(), e);
     em.getTransaction().rollback();
   } finally {
     em.close();
   }
 }
Пример #29
0
  private void cmbLagerItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {

      vorratsListeInsLogbuch();

      ziel = (Lager) cmbLager.getSelectedItem();
      Tools.log(txtLog, "=================================================================");
      Tools.log(txtLog, "Ab jetzt wird ins Lager: \"" + ziel.getBezeichnung() + "\" umgebucht.");
      Tools.log(txtLog, "=================================================================");
      Main.getProps()
          .put(
              "touch" + MODULENUMBER + "lager",
              new Integer(cmbLager.getSelectedIndex()).toString());
      loadVorratTable();
      txtSearch.requestFocus();
    }
  }
Пример #30
0
  private void loadVorratTable() {

    EntityManager em = Main.getEMF().createEntityManager();
    try {
      Query query =
          em.createQuery(
              "SELECT v, SUM(b.menge), 0 FROM Buchungen b JOIN b.stock v "
                  +
                  // die 0 ist ein kleiner Kniff und wird für das Umbuchen gebraucht.
                  " WHERE v.lager = :lager AND v.ausgang = "
                  + Const.MYSQL_DATETIME_BIS_AUF_WEITERES
                  + " GROUP BY v");

      query.setParameter("lager", (Lager) cmbLager.getSelectedItem());

      java.util.List list = query.getResultList();

      tblVorrat.setModel(new StockTableModel2(list, spaltenVorrat));
      Tools.packTable(tblVorrat, 0);

      tblVorrat
          .getColumnModel()
          .getColumn(StockTableModel2.COL_VORRAT_ID)
          .setCellRenderer(new UmbuchenRenderer());
      tblVorrat
          .getColumnModel()
          .getColumn(StockTableModel2.COL_BEZEICHNUNG)
          .setCellRenderer(new UmbuchenRenderer());
      tblVorrat
          .getColumnModel()
          .getColumn(StockTableModel2.COL_MENGE)
          .setCellRenderer(new UmbuchenRenderer());
      tblVorrat
          .getColumnModel()
          .getColumn(StockTableModel2.COL_ICON)
          .setCellRenderer(new UmbuchenRenderer());

    } catch (Exception e) { // nicht gefunden
      Main.logger.fatal(e.getMessage(), e);
      // e.printStackTrace();
    } finally {
      em.close();
    }
  }