cz.cuni.amis.pogamut.defcon.communication.worldview.modules.managers.fleets
Class FleetsManager

Package class diagram package FleetsManager
java.lang.Object
  extended by cz.cuni.amis.pogamut.defcon.communication.worldview.modules.managers.fleets.FleetsManager

public class FleetsManager
extends Object

Manages all known fleets. Be they either own or enemies. Also takes care of updating of all you fleets AIs.

Author:
Radek 'Black_Hand' Pibil

Nested Class Summary
 class FleetsManager.FleetWithAI
          Fleet and AI pair.
protected  class FleetsManager.QueuedPlacing
           
 
Field Summary
protected  SortedMap<Integer,List<Fleet>> enemyFleets
           
protected  IWorldObjectListener<Fleet> listener
           
protected  DefConAgentLogicController<?> logic
           
protected  ILogicUpdateListener logicUpdateListener
           
protected  LinkedList<FleetsManager.QueuedPlacing> oldPlacings
           
protected  ArrayList<FleetsManager.FleetWithAI> ownFleets
           
protected  int ownTeamId
           
protected  LinkedList<FleetsManager.QueuedPlacing> queuedPlacings
           
 
Constructor Summary
FleetsManager(DefConAgentLogicController<?> logic)
           
 
Method Summary
protected  void addEnemyFleet(Fleet fleet)
           
protected  void addFleet(Fleet fleet)
           
protected  void addOwnFleet(Fleet fleet)
           
 boolean assignAI(Fleet fleet, IFleetAI ai)
          Assigns AI to the given fleet.
 boolean assignAI(int fleetId, IFleetAI ai)
          This wont work most likely, because of the quirky WorldObjectId
 SortedMap<Integer,List<Fleet>> getEnemyFleets()
          Returns the list of enemy fleets.
 List<Fleet> getEnemyFleets(int enemyId)
          Returns the list of enemy fleets.
 List<FleetsManager.FleetWithAI> getOwnFleets()
          Returns the list of own fleets.
protected  boolean isValidPlacement(Location location, int count)
           
 boolean placeFleet(DefConLocation location, UnitType[] ships, Object initData, IPlacingFinishedListener finishedListener)
          Tries to place fleet on a given location (queues the command).
 boolean placeFleet(List<DefConLocation> orderedPlacements, UnitType[] fleetComposition, int fleetsCount, Object initData, IPlacingFinishedListener finishedListener)
          Tries to place the fleet on one of the given positions (queues the command, if it finds suitable place), starting from the head.
protected  boolean placeFleetWorker(DefConLocation location, UnitType[] ships)
           
protected  boolean queuePlacingsContain(Location location)
           
protected  void removeEnemyFleet(Fleet fleet)
           
protected  void removeFleet(Fleet fleet)
           
protected  void removeOwnFleet(Fleet fleet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logic

protected final DefConAgentLogicController<?> logic

enemyFleets

protected final SortedMap<Integer,List<Fleet>> enemyFleets

ownFleets

protected final ArrayList<FleetsManager.FleetWithAI> ownFleets

ownTeamId

protected final int ownTeamId

queuedPlacings

protected final LinkedList<FleetsManager.QueuedPlacing> queuedPlacings

oldPlacings

protected final LinkedList<FleetsManager.QueuedPlacing> oldPlacings

listener

protected final IWorldObjectListener<Fleet> listener

logicUpdateListener

protected final ILogicUpdateListener logicUpdateListener
Constructor Detail

FleetsManager

@Inject
public FleetsManager(DefConAgentLogicController<?> logic)
Method Detail

queuePlacingsContain

protected boolean queuePlacingsContain(Location location)

addFleet

protected void addFleet(Fleet fleet)

removeFleet

protected void removeFleet(Fleet fleet)

addEnemyFleet

protected void addEnemyFleet(Fleet fleet)

removeEnemyFleet

protected void removeEnemyFleet(Fleet fleet)

addOwnFleet

protected void addOwnFleet(Fleet fleet)

removeOwnFleet

protected void removeOwnFleet(Fleet fleet)

getEnemyFleets

public SortedMap<Integer,List<Fleet>> getEnemyFleets()
Returns the list of enemy fleets.

Returns:

getEnemyFleets

public List<Fleet> getEnemyFleets(int enemyId)
Returns the list of enemy fleets.

Returns:

getOwnFleets

public List<FleetsManager.FleetWithAI> getOwnFleets()
Returns the list of own fleets.

Returns:

assignAI

public boolean assignAI(Fleet fleet,
                        IFleetAI ai)
Assigns AI to the given fleet.

Parameters:
fleet -
ai -
Returns:

assignAI

public boolean assignAI(int fleetId,
                        IFleetAI ai)
This wont work most likely, because of the quirky WorldObjectId

Parameters:
fleetId -
ai -
Returns:

placeFleet

public boolean placeFleet(DefConLocation location,
                          UnitType[] ships,
                          Object initData,
                          IPlacingFinishedListener finishedListener)
Tries to place fleet on a given location (queues the command).

Parameters:
location -
ships -
Returns:
tentative success in placing of the fleet. if true then check the event for definitive confirmation.

isValidPlacement

protected boolean isValidPlacement(Location location,
                                   int count)

placeFleetWorker

protected boolean placeFleetWorker(DefConLocation location,
                                   UnitType[] ships)

placeFleet

public boolean placeFleet(List<DefConLocation> orderedPlacements,
                          UnitType[] fleetComposition,
                          int fleetsCount,
                          Object initData,
                          IPlacingFinishedListener finishedListener)
Tries to place the fleet on one of the given positions (queues the command, if it finds suitable place), starting from the head.

Parameters:
orderedPlacements - given positions with preference
fleetComposition - ship types
Returns:
true if at least one fleet might be placeable (listener is going to be called)


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.