private boolean isAlive(IPlayer player) { return isAlive(player.getPlayerId()); }
public FogOfWar(short width, short height, IPlayer player) { this.width = width; this.height = height; this.team = player.getTeamId(); this.sight = new byte[width][height]; }
private boolean canSelectPlayer(IPlayer player) { return canSelectPlayer(player.getPlayerId()); }
/** * * @param player * The player id of the first player. * @param otherAttackable * The other attackable. (Must not be null!) * * @return */ public static boolean isEnemy(IPlayer player, IAttackable otherAttackable) { return otherAttackable.getPlayer().getTeamId() != player.getTeamId() && otherAttackable.isAttackable(); }
private int maximumAllowedCount(EBuildingType buildingType) { if (!limitByWeakestEnemy) { return Integer.MAX_VALUE; } List<IPlayer> enemies = aiStatistics.getAliveEnemiesOf(player); float sumOfBuildings = 0; for (IPlayer enemy : enemies) { sumOfBuildings += aiStatistics.getTotalNumberOfBuildingTypeForPlayer(buildingType, enemy.getPlayerId()); } return Math.max(1, (int) (sumOfBuildings / enemies.size())); }
private boolean isPlayerOK(IPlayerable playerable) { return (MatchConstants.ENABLE_ALL_PLAYER_FOG_OF_WAR || (playerable.getPlayer().getTeamId() == team)); }
private Color getColor(IMapObject object) { Color color = null; if (object instanceof IPlayerable) { color = context.getPlayerColor(((IPlayerable) object).getPlayer().getPlayerId()); } return color; }
private boolean hasSameTeam(int x, int y, IPathCalculatable requester) { Player player = partitionsGrid.getPlayerAt(x, y); return player != null && player.getTeamId() == requester.getPlayer().getTeamId(); }
private boolean hasSamePlayer(int x, int y, IPathCalculatable requester) { return partitionsGrid.getPlayerIdAt(x, y) == requester.getPlayer().getPlayerId(); }
private List<IPlayer> getEnemiesOf(IPlayer player) { byte teamId = player.getTeamId(); return stream(players).filter(currPlayer -> currPlayer.getTeamId() != teamId).collect(Collectors.toList()); }
public int getCountOfMovablesOfPlayer(IPlayer player, Set<EMovableType> types) { byte playerId = player.getPlayerId(); return stream(types).mapToInt(type -> getPositionsOfMovablesWithTypeForPlayer(playerId, type).size()).sum(); }
@Override public boolean isBlocked(IPathCalculatable requester, int x, int y) { if (requester.isShip()) { return !isWaterSafe(x, y); } return flagsGrid.isBlocked(x, y) || (requester.needsPlayersGround() && requester.getPlayer().getPlayerId() != partitionsGrid.getPlayerIdAt(x, y)); }
private boolean isDanger() { if (aiStatistics.getTotalNumberOfBuildingTypeForPlayer(BARRACK, playerId) < 1) { int numberOfSwordsmen = aiStatistics.getCountOfMovablesOfPlayer(player, EMovableType.SWORDSMEN); if (aiStatistics.getTotalNumberOfBuildingTypeForPlayer(TOWER, playerId) >= numberOfSwordsmen) { return true; } for (IPlayer enemy : aiStatistics.getAliveEnemiesOf(player)) { if (aiStatistics.getNumberOfBuildingTypeForPlayer(WEAPONSMITH, enemy.getPlayerId()) > 0) { return true; } } } return false; }
private ShortPoint2D getTargetEnemyDoorToAttack(IPlayer enemyToAttack) { List<ShortPoint2D> myMilitaryBuildings = aiStatistics.getBuildingPositionsOfTypesForPlayer(EBuildingType.MILITARY_BUILDINGS, player.playerId); ShortPoint2D myBaseAveragePoint = AiStatistics.calculateAveragePointFromList(myMilitaryBuildings); List<ShortPoint2D> enemyMilitaryBuildings = aiStatistics.getBuildingPositionsOfTypesForPlayer(EBuildingType.MILITARY_BUILDINGS, enemyToAttack.getPlayerId()); ShortPoint2D nearestEnemyBuildingPosition = AiStatistics.detectNearestPointFromList(myBaseAveragePoint, enemyMilitaryBuildings); return aiStatistics.getBuildingAt(nearestEnemyBuildingPosition).getDoor(); }
private ISelectable getSelectableAt(ShortPoint2D pos) { if (grid.isInBounds(pos)) { final IBuilding building = grid.getBuildingAt(pos.x, pos.y); if (building != null && canSelectPlayer(building.getPlayer().getPlayerId())) { return building; } else { final IGuiMovable selectableMovable = getSelectableMovable(pos.x, pos.y).orElse(null); if (selectableMovable != null) { return selectableMovable; } } } return null; }
final boolean isValidPosition(IPathCalculatable pathCalculatable, int x, int y) { if (pathCalculatable.isShip()) { return isNavigable(x, y); } return isInBounds(x, y) && !flagsGrid.isBlocked(x, y) && (!pathCalculatable.needsPlayersGround() || pathCalculatable.getPlayer().getPlayerId() == partitionsGrid.getPlayerIdAt(x, y)); }
@Override public void update() { buildingsToBuild.clear(); this.mapBuildingCounts = aiStatistics.getAiMapInformation().getBuildingCounts(player.getPlayerId()); addMinimalBuildingMaterialBuildings(); if (isVerySmallMap()) { addSmallWeaponProduction(); addFoodAndBuildingMaterialAndWeaponAndGoldIndustry(); addManaBuildings(); } else { addManaBuildings(); addFoodAndBuildingMaterialAndWeaponAndGoldIndustry(); addSecondToolSmith(); } }
private void selectArea(SelectAreaAction action) { final SelectionSet selectionSet = new SelectionSet(); action.getArea().stream().filterBounds(grid.getWidth(), grid.getHeight()).forEach((x, y) -> { final IGuiMovable movable = grid.getMovable(x, y); if (movable != null && canSelectPlayer(movable.getPlayer().getPlayerId())) { selectionSet.add(movable); } final IBuilding building = grid.getBuildingAt(x, y); if (building != null && canSelectPlayer(building.getPlayer().getPlayerId())) { selectionSet.add(building); } }); setSelection(selectionSet); }