@SuppressWarnings("unchecked") private void receiveUpdateMinefields(Packet packet) { // only update information if you know about the minefield Vector<Minefield> newMines = new Vector<>(); for (Minefield mf : (Vector<Minefield>) packet.getObject(0)) { if (getOwner().getLocalPlayer().containsMinefield(mf)) { newMines.add(mf); } } if (newMines.size() > 0) { getGame().resetMinefieldDensity(newMines); } }
@Override protected Vector<Coords> calculateArtyAutoHitHexes() { final String METHOD_NAME = "calculateArtyAutoHitHexes()"; methodBegin(getClass(), METHOD_NAME); try { // currently returns no artillery hit spots // make an empty list final PlayerIDandList<Coords> artyAutoHitHexes = new PlayerIDandList<>(); // attach my player id to it artyAutoHitHexes.setPlayerID(getLocalPlayer().getId()); return artyAutoHitHexes; } finally { methodEnd(getClass(), METHOD_NAME); } }
private boolean isEnemyInfantry(final Entity entity, final Coords coords) { return entity.hasETypeFlag(Entity.ETYPE_INFANTRY) && !entity.hasETypeFlag(Entity.ETYPE_MECHWARRIOR) && entity.getOwner().isEnemyOf(getLocalPlayer()) && !getStrategicBuildingTargets().contains(coords); }
@Override protected void checkMoral() { moralUtil.checkMoral(behaviorSettings.isForcedWithdrawal(), behaviorSettings.getBraveryIndex(), behaviorSettings.getSelfPreservationIndex(), getLocalPlayer(), game); }
private boolean isEnemyGunEmplacement(final Entity entity, final Coords coords) { return entity.hasETypeFlag(Entity.ETYPE_GUN_EMPLACEMENT) && entity.getOwner().isEnemyOf(getLocalPlayer()) && !getStrategicBuildingTargets().contains(coords) && (null != entity.getCrew()) && !entity.getCrew().isDead(); }
/** * Worker function that calculates the shooter's "best" actions that result in a TAG being fired. * @param shooter * @param game * @param owner * @return */ private WeaponFireInfo getTAGInfo(Mounted weapon, Entity shooter, IGame game, Princess owner) { WeaponFireInfo retval = null; double hitOdds = 0.0; // pretty simple logic here: take the best shot that you have for(Targetable target : FireControl.getAllTargetableEnemyEntities(owner.getLocalPlayer(), game, owner.getFireControlState())) { WeaponFireInfo wfi = new WeaponFireInfo(shooter, target, weapon, game, false, owner); if(wfi.getProbabilityToHit() > hitOdds) { hitOdds = wfi.getProbabilityToHit(); retval = wfi; } } return retval; }
FireControl.getAllTargetableEnemyEntities(getLocalPlayer(), getGame(), fireControlState);
FireControl.getAllTargetableEnemyEntities(getLocalPlayer(), getGame(), fireControlState);
IPlayer princessPlayer = princess.getLocalPlayer(); if (princessPlayer == null) { princess.log(getClass(), METHOD_NAME, LogLevel.ERROR, "Princess Player is NULL.");
Mockito.doNothing().when(mockPrincess).log(Matchers.any(Class.class), Matchers.anyString(), Matchers.any(LogLevel.class), Matchers.anyString()); Mockito.doReturn(mockBotPlayerVGer).when(mockPrincess).getLocalPlayer(); Mockito.doNothing().when(mockPrincess).sendChat(Matchers.anyString()); testChatProcessor.additionalPrincessCommands(mockChatEvent, mockPrincess); Mockito.doNothing().when(mockPrincess).log(Matchers.any(Class.class), Matchers.anyString(), Matchers.any(LogLevel.class), Matchers.anyString()); Mockito.doReturn(mockBotPlayerVGer).when(mockPrincess).getLocalPlayer(); Mockito.doNothing().when(mockPrincess).sendChat(Matchers.anyString()); testChatProcessor.additionalPrincessCommands(mockChatEvent, mockPrincess); Mockito.doNothing().when(mockPrincess).log(Matchers.any(Class.class), Matchers.anyString(), Matchers.any(LogLevel.class), Matchers.anyString()); Mockito.doReturn(mockBotPlayerVGer).when(mockPrincess).getLocalPlayer(); Mockito.doNothing().when(mockPrincess).sendChat(Matchers.anyString()); testChatProcessor.additionalPrincessCommands(mockChatEvent, mockPrincess); Mockito.doNothing().when(mockPrincess).log(Matchers.any(Class.class), Matchers.anyString(), Matchers.any(LogLevel.class), Matchers.anyString()); Mockito.doReturn(mockBotPlayerVGer).when(mockPrincess).getLocalPlayer(); Mockito.doNothing().when(mockPrincess).sendChat(Matchers.anyString()); testChatProcessor.additionalPrincessCommands(mockChatEvent, mockPrincess); Mockito.doNothing().when(mockPrincess).log(Matchers.any(Class.class), Matchers.anyString(), Matchers.any(LogLevel.class), Matchers.anyString()); Mockito.doReturn(mockBotPlayerVGer).when(mockPrincess).getLocalPlayer(); Mockito.doNothing().when(mockPrincess).sendChat(Matchers.anyString()); testChatProcessor.additionalPrincessCommands(mockChatEvent, mockPrincess);