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.

pop() tuple[EffectStack, Effect]
Returns:

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

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.