Package name.moore.kevin.ze.game
Class buildQueue
java.lang.Object
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<build>,Collection<build>,Deque<build>,List<build>,Queue<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 Summary
FieldsModifier and TypeFieldDescriptionprivate com.simsilica.es.EntityIdThe facility doing the building for this buildqueue.private buildSet with a completed ticket - the caller needs to then collect it and remove from queue.private static longprivate static org.slf4j.Loggerprivate com.simsilica.es.EntityIdThe planet this builder is located at.private StringA unique ID given to this queue.Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionbuildQueue(com.simsilica.es.EntityId builder, com.simsilica.es.EntityId planet) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd the build to the queue.Calculate how many days remaining construction is still in the queue.Find any tickets in state BLOCKED.com.simsilica.es.EntityIdFind any tickets in state COMPLETED.Get a single ticket identified as COMPLETED and remove from queue.Find any tickets in state BLOCKED.com.simsilica.es.EntityIdgetUID()Each queue created can have a uniqueID generated to act as an identifier.progress()A day has passed, progress one of the INPROGRESS tickets, possibly resulting in it becoming COMPLETE.Methods inherited from class java.util.LinkedList
add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArrayMethods inherited from class java.util.AbstractSequentialList
iteratorMethods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, replaceAll, retainAll, sort, subList
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
hashcounter
private static long hashcounter -
UID
A unique ID given to this queue. -
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 builderThe 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 planetThe planet this builder is located at. While it's possible to work this out from thebuilderfield, 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
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
Add the build to the queue.- Specified by:
addin interfaceCollection<build>- Specified by:
addin interfaceDeque<build>- Specified by:
addin interfaceList<build>- Specified by:
addin interfaceQueue<build>- Overrides:
addin classLinkedList<build>- Parameters:
b-- Returns:
- true if the build was added (no reason why it wouldn't be).
-
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
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
Get a single ticket identified as COMPLETED and remove from queue. This will be null if no ticket is available.- Returns:
-
getDeadandRemove
-
getBlocked
Find any tickets in state BLOCKED.- Returns:
- blocked tickets or EMPTY_LIST
-
getInprogress
Find any tickets in state BLOCKED.- Returns:
- inprogress tickets or EMPTY_LIST
-
getCompleted
Find any tickets in state COMPLETED.- Returns:
- completed tickets or EMPTY_LIST
-
getTickets
-