/** * @param toPlayer * @return */ public boolean isOwner(IPlayer toPlayer) { if ((owner == null) || owner.equals(toPlayer)) { return true; } return false; }
/** * Returns the number of entities owned by the player, regardless of their * status, as long as they are in the game. */ public int getEntitiesOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player)) { count++; } } return count; }
/** * Returns the number of entities owned by the player, regardless of their * status. */ public int getAllEntitiesOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player)) { count++; } } for (Entity entity : vOutOfGame) { if (entity.getOwner().equals(player)) { count++; } } return count; }
/** * Get the entities for the player. * * @param player - the <code>Player</code> whose entities are required. * @param hide - should fighters loaded into squadrons be excluded? * @return a <code>Vector</code> of <code>Entity</code>s. */ public ArrayList<Entity> getPlayerEntities(IPlayer player, boolean hide) { ArrayList<Entity> output = new ArrayList<Entity>(); for (Entity entity : entities) { if (entity.isPartOfFighterSquadron() && hide) { continue; } if (player.equals(entity.getOwner())) { output.add(entity); } } return output; }
/** * get the total BV (unmodified by force size mod) for the units of this * player that have fled the field * * @return the BV */ @Override public int getFledBV() { Enumeration<Entity> fledUnits = game.getRetreatedEntities(); int bv = 0; while (fledUnits.hasMoreElements()) { Entity entity = fledUnits.nextElement(); if (entity.getOwner().equals(this)) { bv += entity.calculateBattleValue(); } } return bv; }
private void maybeShowPopup(MouseEvent e) { JPopupMenu popup = new JPopupMenu(); int row = tablePlayers.rowAtPoint(e.getPoint()); IPlayer player = playerModel.getPlayerAt(row); boolean isOwner = player.equals(clientgui.getClient().getLocalPlayer()); boolean isBot = clientgui.getBots().get(player.getName()) != null; if (e.isPopupTrigger()) { JMenuItem menuItem = null; // JMenu menu = null; menuItem = new JMenuItem("Configure ..."); menuItem.setActionCommand("CONFIGURE|" + row); menuItem.addActionListener(this); menuItem.setEnabled(isOwner || isBot); popup.add(menuItem); popup.show(e.getComponent(), e.getX(), e.getY()); } }
/** * Determines whether this special hex should be obscurred from the given * <code>IPlayer</code>. * * @param other * @return */ public boolean isObscured(IPlayer other) { if (obscured == SHD_OBSCURED_OWNER && other != null && owner.equals(other)){ return false; } else if (obscured == SHD_OBSCURED_TEAM && other != null && owner.getTeam() == other.getTeam()){ return false; } else if (obscured == SHD_OBSCURED_ALL){ return false; } return true; }
/** * Get the entities for the player. * * @param player - the <code>Player</code> whose entities are required. * @param hide - should fighters loaded into squadrons be excluded from this list? * @return a <code>Vector</code> of <code>Entity</code>s. */ public ArrayList<Integer> getPlayerEntityIds(IPlayer player, boolean hide) { ArrayList<Integer> output = new ArrayList<Integer>(); for (Entity entity : entities) { if (entity.isPartOfFighterSquadron() && hide) { continue; } if (player.equals(entity.getOwner())) { output.add(entity.getId()); } } return output; }
public List<Entity> getEntitiesOwned() { ArrayList<Entity> result = new ArrayList<>(); for (Entity entity : game.getEntitiesVector()) { if (entity.getOwner().equals(getLocalPlayer()) && (entity.getPosition() != null) && !entity.isOffBoard()) { result.add(entity); } } return result; }
/** * Returns the number of non-destroyed entityes owned by the player */ public int getLiveEntitiesOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player) && !entity.isDestroyed() && !entity.isCarcass()) { count++; } } return count; }
/** * Returns the number of remaining selectable Protomechs owned by a player. */ public int getProtomechsLeft(int playerId) { IPlayer player = getPlayer(playerId); int remaining = 0; for (Entity entity : entities) { if (player.equals(entity.getOwner()) && entity.isSelectableThisTurn() && (entity instanceof Protomech)) { remaining++; } } return remaining; }
/** * Returns the number of remaining selectable infantry owned by a player. */ public int getInfantryLeft(int playerId) { IPlayer player = getPlayer(playerId); int remaining = 0; for (Entity entity : entities) { if (player.equals(entity.getOwner()) && entity.isSelectableThisTurn() && (entity instanceof Infantry)) { remaining++; } } return remaining; }
public void addPlayer(IPlayer player) { players.add(player); int bv = 0; int cost = 0; double ton = 0; for (Entity entity : clientgui.getClient().getEntitiesVector()) { if (entity.getOwner().equals(player)) { bv += entity.calculateBattleValue(); cost += entity.getCost(false); ton += entity.getWeight(); } } bvs.add(bv); costs.add(cost); tons.add(ton); fireTableDataChanged(); }
/** * Returns the number of Mechs that <code>playerId</code> has not moved * yet this turn. * * @param playerId * @return number of vehicles <code>playerId</code> has not moved yet this * turn */ public int getMechsLeft(int playerId) { IPlayer player = getPlayer(playerId); int remaining = 0; for (Entity entity : entities) { if (player.equals(entity.getOwner()) && entity.isSelectableThisTurn() && (entity instanceof Mech)) { remaining++; } } return remaining; }
@Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = tablePlayers.rowAtPoint(e.getPoint()); IPlayer player = playerModel.getPlayerAt(row); if (player != null) { boolean isOwner = player.equals(clientgui.getClient().getLocalPlayer()); boolean isBot = clientgui.getBots().get(player.getName()) != null; if ((isOwner || isBot)) { customizePlayer(); } } } }
@Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = tableEntities.rowAtPoint(e.getPoint()); Entity entity = mekModel.getEntityAt(row); if (entity != null) { boolean isOwner = entity.getOwner().equals(clientgui.getClient().getLocalPlayer()); boolean isBot = clientgui.getBots().get(entity.getOwner().getName()) != null; if ((isOwner || isBot)) { customizeMech(entity); } } } }
public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting()) { return; } if (event.getSource().equals(entities)) { int selected = entities.getSelectedIndex(); if (selected == -1) { ta.setText(""); return; } else if (!client.getGame().getEntity(entityArray[selected]).getOwner().equals(client.getLocalPlayer())) { ta.setText("(enemy unit)"); } else { Entity entity = client.getGame().getEntity(entityArray[selected]); MechView mechView = new MechView(entity, client.getGame().getOptions().booleanOption(OptionsConstants.BASE_SHOW_BAY_DETAIL)); ta.setText(mechView.getMechReadout()); } } } }
/** * Returns the number of non-destroyed entities owned by the player, * including entities not yet deployed. Ignore offboard units and captured * Mek pilots. */ public int getLiveDeployedEntitiesOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player) && !entity.isDestroyed() && !entity.isCarcass() && !entity.isOffBoard() && !entity.isCaptured()) { count++; } } return count; }
/** * Returns the number of non-destroyed deployed entities owned by the * player. Ignore offboard units and captured Mek pilots. */ public int getLiveCommandersOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player) && !entity.isDestroyed() && !entity.isCarcass() && entity.isCommander() && !entity.isOffBoard() && !entity.isCaptured()) { count++; } } return count; }
/** * Returns true if the player has a valid unit with the Tactical Genius * pilot special ability. */ public boolean hasTacticalGenius(IPlayer player) { for (Entity entity : entities) { if (entity.hasAbility(OptionsConstants.MISC_TACTICAL_GENIUS) && entity.getOwner().equals(player) && !entity.isDestroyed() && entity.isDeployed() && !entity.isCarcass() && !entity.getCrew().isUnconscious()) { return true; } } return false; }