Class buildQueue

All Implemented Interfaces:
Serializable, Cloneable, Iterable<build>, Collection<build>, Deque<build>, List<build>, Queue<build>

public class buildQueue extends LinkedList<build>
Every facility capable of construction will have an associated buildQueue.

The queue contains build requests which detail what is to be built and the progressToCompleted being made. The queue progressToCompleted the ticket at the head of the queue until it is completed.

This class provides extra operations on the List such as calculating the total estimated construction time of all the build instructions in the queue. A LinkedList is used to preserve ordering.

Author:
Kevin Moore <dev@kevin.moore.name>
See Also:
Serialized Form
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • hashcounter

      private static long hashcounter
    • UID

      private String UID
      A unique ID given to this queue.
    • completed

      private build completed
      Set with a completed ticket - the caller needs to then collect it and remove from queue. The queue continues processing even if not removed.
      See Also:
      getCompleted()
    • builder

      private final com.simsilica.es.EntityId builder
      The facility doing the building for this buildqueue. Any ticket in the queue is being built here. this may be a shipyard, industry or a planet.
    • planet

      private final com.simsilica.es.EntityId planet
      The planet this builder is located at. While it's possible to work this out from the builder field, it's simpler to just record it here.
  • Constructor Details

    • buildQueue

      public buildQueue(com.simsilica.es.EntityId builder, com.simsilica.es.EntityId planet)
      Parameters:
      builder - the facility this queue is working for.
      planet - where the building is happening
  • Method Details

    • getUID

      public String getUID()
      Each queue created can have a uniqueID generated to act as an identifier.
      Returns:
    • getBuilder

      public com.simsilica.es.EntityId getBuilder()
    • getPlanet

      public com.simsilica.es.EntityId getPlanet()
    • add

      public boolean add(build b)
      Add the build to the queue.
      Specified by:
      add in interface Collection<build>
      Specified by:
      add in interface Deque<build>
      Specified by:
      add in interface List<build>
      Specified by:
      add in interface Queue<build>
      Overrides:
      add in class LinkedList<build>
      Parameters:
      b -
      Returns:
      true if the build was added (no reason why it wouldn't be).
    • calcDaysRemaining

      public Integer calcDaysRemaining()
      Calculate how many days remaining construction is still in the queue.

      Subtracts the days actually done from the estimates to get the remaining days.

      Returns:
    • progress

      public build progress()
      A day has passed, progress one of the INPROGRESS tickets, possibly resulting in it becoming COMPLETE.

      The currently building item is the first build ticket in the list that is INPROGRESS. Only one item in the queue can be progressed at a time.

      Returns:
      ticket that is selected for progress or null
    • getCompletedandRemove

      public build getCompletedandRemove()
      Get a single ticket identified as COMPLETED and remove from queue. This will be null if no ticket is available.
      Returns:
    • getDeadandRemove

      public List<build> getDeadandRemove()
    • getBlocked

      public List<build> getBlocked()
      Find any tickets in state BLOCKED.
      Returns:
      blocked tickets or EMPTY_LIST
    • getInprogress

      public List<build> getInprogress()
      Find any tickets in state BLOCKED.
      Returns:
      inprogress tickets or EMPTY_LIST
    • getCompleted

      public List<build> getCompleted()
      Find any tickets in state COMPLETED.
      Returns:
      completed tickets or EMPTY_LIST
    • getTickets

      private List<build> getTickets(build.PROGRESS p)