Adding a context manager for Event #6412
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
dev QOL addition
Key Changes
MASDummyClass
)Event
that can be used to do things to/with an event object without having to None check -MAS_EVL
example:
The above will not crash even if a bad label (or no event object found) occurs, unless you write code that would have crashed normally anyway (like calling
ev.checkAffection
with no arguments, etc...).In a bad scenario, the behavior of different actions on the
ev
var vary:Event
class is used as a fallback for everything else.Two caveats:
ev
, the object actually being called on is theMASDummyClass
. if pre-determined default behavior is more desirable, then_default_values
can be expanded.Important things to remember
The normal way (None checking
mas_getEV
) allows us to include backup scenarios if something is off or data is missing. Thiswith
version ofEvent
should only be used when we don't care about a bad case.Testing
Event
object can be done with an instance ofMAS_EVL
regardless of the eventlabel's validity. If the eventlable is real, then theEvent
object will be modified. Otherwise nothing should happen. And as a reminder, anything that doesn't work with a realEvent
object will not work with the context manager version.