API Reference¶
A priority queue scheduler for use in game development.
See the queued turns time system: http://www.roguebasin.com/index.php?title=Time_Systems#Queued_turns
- class turnq.Ticket(time: int, uid: int, value: T, insert_time: int)¶
Describes a scheduled object.
- get_progress(current_time: int) float¶
Return the current progress of this Ticket as a float from 0 to 1.
- get_time_passed(current_time: int) int¶
Return the amount of time passed since this Ticket was initially scheduled.
- insert_time: int¶
The time this ticket was inserted into the scheduler.
This can be used to get the delta time of this Ticket with time - insert_time or some equivalent.
- value: T¶
The scheduled object.
- class turnq.TurnQueue(time: int = 0, next_uid: int = 0, heap: list[Ticket[T]] = <factory>)¶
Turned queue manager.
- peek() Ticket[T]¶
Return the next scheduled ticket without removing it.
IndexError will be raised if the heap is empty.
- pop() Ticket[T]¶
Pop and return the next scheduled Ticket from the queue.
This will set TurnQueue.time to the tickets current time.