Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

effects defaults to empty array for all room objects #117

wants to merge 2 commits into from

Conversation

Will-Crain
Copy link

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.

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.
@AlinaNova21
Copy link
Contributor

Why not just default it to empty array instead? that way its always one consistent type

@Will-Crain
Copy link
Author

Will-Crain commented Jun 15, 2019

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.

@AlinaNova21
Copy link
Contributor

I would say just add

} else {
  this.effects = []
}```
to the if statement

@AlinaNova21
Copy link
Contributor

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.
@Will-Crain Will-Crain changed the title effects gets set to undefined if effects array length is 0 effects defaults to empty array for all room objects Jun 15, 2019
Copy link
Contributor

@sparr sparr left a 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.

@o4kapuk o4kapuk self-assigned this Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants