Пример #1
0
 private void checkCollisionWithObjectForPuck() {
   ArrayList<Player> playerArray = new ArrayList<>();
   playerArray.addAll(team0.getPlayers());
   playerArray.addAll(team1.getPlayers());
   for (Player otherPlayer : playerArray) {
     puck.checkCollisionWithObject(otherPlayer, endTurnStepTime);
   }
 }
Пример #2
0
  @SuppressWarnings("deprecation")
  public void openTeamSelection(Game game) {
    BedwarsOpenTeamSelectionEvent openEvent = new BedwarsOpenTeamSelectionEvent(game, this.player);
    Main.getInstance().getServer().getPluginManager().callEvent(openEvent);

    if (openEvent.isCancelled()) {
      return;
    }

    HashMap<String, Team> teams = game.getTeams();

    int nom = (teams.size() % 9 == 0) ? 9 : (teams.size() % 9);
    Inventory inv =
        Bukkit.createInventory(this.player, teams.size() + (9 - nom), Main._l("lobby.chooseteam"));
    for (Team team : teams.values()) {
      List<Player> players = team.getPlayers();
      if (players.size() >= team.getMaxPlayers()) {
        continue;
      }

      ItemStack is = new ItemStack(Material.WOOL, 1, team.getColor().getDyeColor().getData());
      ItemMeta im = is.getItemMeta();
      im.setDisplayName(team.getChatColor() + team.getName());
      ArrayList<String> teamplayers = new ArrayList<>();

      int teamPlayerSize = team.getPlayers().size();
      int maxPlayers = team.getMaxPlayers();

      String current = "0";
      if (teamPlayerSize >= maxPlayers) {
        current = ChatColor.RED + String.valueOf(teamPlayerSize);
      } else {
        current = ChatColor.YELLOW + String.valueOf(teamPlayerSize);
      }

      teamplayers.add(
          ChatColor.GRAY
              + "("
              + current
              + ChatColor.GRAY
              + "/"
              + ChatColor.YELLOW
              + String.valueOf(maxPlayers)
              + ChatColor.GRAY
              + ")");
      teamplayers.add(ChatColor.WHITE + "---------");

      for (Player teamPlayer : players) {
        teamplayers.add(team.getChatColor() + teamPlayer.getName());
      }

      im.setLore(teamplayers);
      is.setItemMeta(im);
      inv.addItem(is);
    }

    this.player.openInventory(inv);
  }
Пример #3
0
 private void moveAllObjects(long timeStep) {
   ArrayList<Player> playerArray = new ArrayList<>();
   playerArray.addAll(team0.getPlayers());
   playerArray.addAll(team1.getPlayers());
   for (Player player : playerArray) {
     player.moveObject(timeStep);
     checkCollisionWithOtherObjectForPlayer(player);
   }
   puck.moveObject(timeStep);
   checkCollisionWithObjectForPuck();
 }
Пример #4
0
 private void checkCollisionWithOtherObjectForPlayer(Player player) {
   ArrayList<Player> playerArray = new ArrayList<>();
   playerArray.addAll(team0.getPlayers());
   playerArray.addAll(team1.getPlayers());
   for (Player otherPlayer : playerArray) {
     if (!player.equals(otherPlayer)) {
       player.checkCollisionWithObject(otherPlayer, endTurnStepTime);
     }
   }
   player.checkCollisionWithObject(puck, endTurnStepTime);
 }
 public boolean validateTeam(Team team) {
   if (team == null) return false;
   if (team.getName() == null) return false;
   if (team.getName().trim().equals("")) return false;
   if (team.getTrainer() == null) return false;
   if (team.getPlayers() == null) return false;
   if (team.getPlayers().length != 22) return false;
   for (Player player : team.getPlayers()) {
     if (player == null) return false;
   }
   if (team.getYearOfFoundation() == null) return false;
   if (team.getYearOfFoundation() < 1950) return false;
   return true;
 }
Пример #6
0
 private boolean checkAnyMovement() {
   for (int i = 0; i < team0.getPlayers().size(); i++) {
     if (team0.getTeamMember(i).isMoving()) {
       return true;
     }
   }
   for (int i = 0; i < team1.getPlayers().size(); i++) {
     if (team1.getTeamMember(i).isMoving()) {
       return true;
     }
   }
   if (puck.isMoving()) {
     return true;
   }
   return false;
 }
Пример #7
0
 private static void setBookState(EntityPlayer player, boolean state) {
   Team team = QuestingData.getQuestingData(player).getTeam();
   for (Team.PlayerEntry entry : team.getPlayers()) {
     if (entry.isInTeam() && entry.getName().equals(QuestingData.getUserName(player))) {
       entry.setBookOpen(state);
       break;
     }
   }
 }
Пример #8
0
 private void setDirectionAndForceValues(Team team) {
   int[] directionValues = paint.getDirectionValues(team);
   int[] forceValues = paint.getForceValues(team);
   for (int i = 0; i < team.getPlayers().size(); i++) {
     team.getTeamMember(i).setDirection(directionValues[i]);
     // *100 är för att göra om det till N från kN
     team.getTeamMember(i).setForce(forceValues[i] * 100);
   }
 }
Пример #9
0
  public void deleteFullGame() {
    Session session = DatabaseManager.getSession();
    session.beginTransaction();

    for (Team team : this.getTeams().values()) {
      for (Player player : team.getPlayers()) {
        session.delete(player);
      }

      session.delete(team);
    }

    session.delete(this);

    Query query = session.createQuery("delete from GameSignup as g where g.game.id = :id");
    query.setInteger("id", this.getId());

    query.executeUpdate();

    session.getTransaction().commit();
    session.close();
  }
Пример #10
0
    void drawScreen(Team teamPassed) {

      if (teamPassed != null) {
        // We're editing a current team
        team = teamPassed;
        for (Player player : team.getPlayers()) {
          JPanel thisPlayer = player.playerPreview();
          JButton modify = new JButton(ResourceRetriever.getImage("edit.png", 16, 16));
          modify.setMargin(new Insets(0, 0, 0, 0));
          modify.addActionListener(
              (ActionEvent e) -> {
                new ModifyPlayerPopup(player, this, null);
              });
          JButton delete = new JButton(ResourceRetriever.getImage("X.png", 16, 16));
          delete.setMargin(new Insets(0, 0, 0, 0));
          delete.addActionListener(
              (ActionEvent e) -> {
                Object[] options = {"Remove Player from team", "Delete Player", "Cancel"};
                JFrame frame = new JFrame();
                int answer =
                    JOptionPane.showOptionDialog(
                        frame,
                        "Are you sure you would like to delete \"" + player.name + "?\"",
                        "Confirm Delete",
                        JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE,
                        Global.QUESTIONPIC,
                        options,
                        options[2]);
                if (answer == 0) {
                  team.removePlayer(player);
                  refresh();
                } else if (answer == 1) {
                  // Teams without uniqueID's don't get added to players yet,
                  //   so the player needs to be manually removed.
                  if (team.globalIndex == -1) {
                    team.removePlayer(player);
                  }
                  player.delete();
                  refresh();
                }
              });
          thisPlayer.add(delete, "east");
          thisPlayer.add(modify, "east");
          thisPlayer.setBorder(BorderFactory.createLineBorder(Color.black));
          players.add(thisPlayer, "growx");
        }
        name.setText(team.name);
      } else {
        // This is a new Team
        team = new Team("New Team");
        name.setText(team.name);
        name.setFont(new Font("Ariel", Font.PLAIN, 20));
        name.select(0, name.getText().length());
      }

      players.setBorder(BorderFactory.createLineBorder(Color.black));

      south.add(addPlayers);
      south.add(new JLabel("Players"));
      south.add(players, "span, grow");
      south.add(cancel, "span, right, split 2");
      south.add(save, "span, right");

      Eve.add(name);
      Eve.add(south);
    }
Пример #11
0
    public ModifyTeamScreen(Team teamPassed, Screen callerScreen) {

      Eve.setLayout(new MigLayout("flowy", "[grow, fill]", "[][grow, fill]"));

      cancel.addActionListener(
          (ActionEvent e) -> {
            caller.Return();
          });

      save.addActionListener(
          (ActionEvent e) -> {
            team.name = name.getText();
            if (team.globalIndex == -1) {
              team.saveTeam(true);
            } else {
              team.saveTeam(false);
            }
            callerScreen.refresh();
            caller.Return();
          });
      addPlayers.setMargin(new Insets(0, 0, 0, 0));
      addPlayers.addActionListener(
          (ActionEvent e) -> {
            if (team.getPlayers().length < 5) {
              JButton cancelB = new JButton("Cancel");
              cancelB.addActionListener(
                  (ActionEvent f) -> {
                    inner.removeAll();
                    popup.dispose();
                  });
              inner.add(cancelB);
              JButton newPlayer = new JButton("New Player");
              newPlayer.addActionListener(
                  (ActionEvent f) -> {
                    inner.removeAll();
                    popup.dispose();
                    ModifyPlayerPopup addNewPlayer = new ModifyPlayerPopup(null, this, team);
                  });
              inner.add(newPlayer);
              inner.add(new JSeparator(), "growx");
              for (Player player : Global.Players) {
                boolean playerInCurrentTeam = false;
                for (Player teamPlayer : team.getPlayers()) {
                  if (teamPlayer.globalIndex == player.globalIndex) {
                    playerInCurrentTeam = true;
                    break;
                  }
                }
                if (!playerInCurrentTeam) {
                  JPanel oldPlayer = player.playerPreview();
                  JButton choose = new JButton("Add!");
                  choose.addActionListener(
                      (ActionEvent f) -> {
                        team.addPlayer(player);
                        inner.removeAll();
                        popup.dispose();
                        refresh();
                      });
                  oldPlayer.add(choose, "east");
                  oldPlayer.setBorder(BorderFactory.createLineBorder(Color.black));
                  inner.add(oldPlayer);
                }
              }
              innerScroll.getVerticalScrollBar().setUnitIncrement(16);
              innerScroll.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);
              popup.add(innerScroll);
              popup.setSize(350, 400);
              popup.setLocation(MouseInfo.getPointerInfo().getLocation());
              popup.setVisible(true);
            } else {
              JOptionPane.showMessageDialog(
                  null,
                  "You cannot add more than 5 players per team.\nPlease remove one before adding another.");
            }
          });

      caller = callerScreen;

      drawScreen(teamPassed);
    }
Пример #12
0
    void drawScreen() {
      matchup.add(teamName);
      matchup.add(new JLabel("vs."));
      matchup.add(enemyName);

      myPicksFrame.add(new JLabel("picks"), "span, center, wrap");
      for (JLabel portait : myPicks) {
        myPicksPortraits.add(portait);
      }
      myPicksFrame.add(myPicksPortraits);

      theirPicks.add(new JLabel("picks"), "span, center, wrap");
      for (JLabel portait : enemyPicks) {
        theirPicksPortraits.add(portait);
      }
      theirPicks.add(theirPicksPortraits);

      myBansFrame.add(new JLabel("bans"), "span, center, wrap");
      for (JLabel portait : myBans) {
        myBansPortraits.add(portait);
      }
      myBansFrame.add(myBansPortraits);

      theirBans.add(new JLabel("bans"), "span, center, wrap");
      for (JLabel portait : enemyBans) {
        theirBansPortraits.add(portait);
      }
      theirBans.add(theirBansPortraits);

      if (team == null) {
        allyPool = new PoolBuilder(false, "small", null, null);
        players.add(allyPool.pool);
      } else {
        for (Player player : team.getPlayers()) {
          players.add(new JLabel(player.name));
          JPanel heroes = new JPanel(new MigLayout("", "[grow 49, fill][grow 1][grow 49, fill]"));
          JPanel regHeroes = new JPanel(new WrapLayout(FlowLayout.LEADING));
          JPanel stunHeroes = new JPanel(new WrapLayout(FlowLayout.LEADING));
          int numOfStuns = 0;
          for (Hero hero : player.getPlayList()) {
            if (hero.hasCharacteristic(Global.Characteristics.RSTUN)) {
              stunHeroes.add(new JLabel(hero.portraitSmall));
              numOfStuns++;
            } else {
              regHeroes.add(new JLabel(hero.portraitSmall));
            }
          }
          heroes.add(regHeroes);
          if (numOfStuns > 0) {
            heroes.add(new JSeparator(SwingConstants.VERTICAL), "growy");
            heroes.add(stunHeroes);
          }
          heroes.setBorder(BorderFactory.createLineBorder(Color.black));
          players.add(heroes);
        }
      }
      enemyPool = new PoolBuilder(false, "small", new Returner(), null);
      theirPool.add(enemyPool.pool);

      Eve.add(matchup, "span, grow");
      Eve.add(myPicksFrame, "c");
      Eve.add(theirPicks, "c");
      Eve.add(myBansFrame, "c");
      Eve.add(theirBans, "c");
      // Eve.add(players, "top, span");
      Eve.add(theirPool);
      // Eve.add(back);

      Adam.setSize(windowSize);
    }