-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
effects defaults to empty array for all room objects #117
base: master
Are you sure you want to change the base?
Conversation
Right now, there is a discrepency in how the `.effects` property on RoomObjects is handled. If there are no effects on an object, an object that has never had an effect on it has an undefined `effects` property, whereas objects that have had an effect on them in the past have an `effects` property of `[]` This change sets `effects` to undefined if there are no effects on the object, making this property consistent for all room objects.
Why not just default it to empty array instead? that way its always one consistent type |
I wasn't sure if defining a new property for all game objects would have any impact on performance, so I opted for a defined-on-demand. I'm not well versed in the server/database side of things, so if you think that defining a new property for all room objects wouldn't be an issue, I'd gladly change the PR to reflect that. |
I would say just add } else {
this.effects = []
}```
to the if statement |
shouldn't be any performance difference, in fact, would be cheaper than checking if its an array |
After some delibaration and advice, code was changed so `effects` is never undefined, but defaults to an empty array instead. This way, the `effects` property never changes data type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for consistent types to match the documented API.
Right now, there is a discrepency in how the
.effects
property on RoomObjects is handled.If there are no effects on an object, an object that has never had an effect on it has an undefined
effects
property, whereas objects that have had an effect on them in the past have aneffects
property of[]
This change sets
effects
to undefined if there are no effects on the object, making this property consistent for all room objects.