Effect Stack

from dgisim import EffectStack

__eq__ and __hash__ are implemented so that any two effect stacks with the equivalent content are equal to each other and have the same hash.

class EffectStack(effects: tuple[Effect, ...])

A class responsible for holding pending effects to be executed as a stack.

contains(effect_type: type[Effect]) bool
Returns:

True if there’s an effect of the exact type of`effect_type`.

encoding(encoding_plan: EncodingPlan) list[int]
Returns:

the encoding of this EffectStack.

is_empty() bool
Returns:

True if there no effects.

is_not_empty() bool
Returns:

True if there’s at least one effect.

peek() Effect
Returns:

the top effect.

peek_all_left() tuple[Effect, ...]
Returns:

all effects in pop order.

peek_all_rev_left() tuple[Effect, ...]
Returns:

all effects in push order.

pop() tuple[EffectStack, Effect]
Returns:

a tuple of left effects in the stack and popped effect.

pop_all_left() tuple[EffectStack, tuple[Effect, ...]]
Returns:

EffectStack with remaining effects and all popped effects.

pop_all_rev_left() tuple[EffectStack, tuple[Effect, ...]]
Returns:

EffectStack with remaining effects and all popped effects.

push_barrier_left() EffectStack
Returns:

the new EffectStack with a barrier left-pushed.

A barrier separates effects returned by peek_all into two groups, and only one group can be popped at a time.

push_left(effects: Effect | Sequence[Effect]) EffectStack
Returns:

the new EffectStack with effects pushed onto it. The push follows FIFO, like a queue.

push_many_fl(effects: Sequence[Effect]) EffectStack
Returns:

the new EffectStack with effects pushed onto it.

fl means the effects passed in are executed from the first to the last.

push_many_lf(effects: Sequence[Effect]) EffectStack
Returns:

the new EffectStack with effects pushed onto it.

lf means the effects passed in are executed from the last to the first.

push_one(effect: Effect) EffectStack
Returns:

the new EffectStack with effect pushed onto it.