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

Fix: Can now force character independence regardless of current following status. #54

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

Conversation

markscho
Copy link
Contributor

Currently, if you want to ensure that character (NPC or Player) is not following anyone, you call the .unfollow() method. But this blows up if the character isn't currently following anyone.
Solution: Check to see if the character is currently following someone before attempting to perform standard unfollow procedures.

*/
this.emit('unfollowed', this.following);
this.following = null;
if (this.following) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a proponent of early return. So instead of wrapping the entire function body in an if, you can instead just do

if (!this.following) {
  return
}

@shawncplus shawncplus added the feedback PR/Issue has pending feedback label Feb 24, 2019
@shawncplus shawncplus added this to the 3.2 milestone Aug 22, 2019
azigler added a commit to azigler/core that referenced this pull request Jun 6, 2020
azigler added a commit to azigler/core that referenced this pull request Jun 6, 2020
azigler added a commit to azigler/core that referenced this pull request Jun 6, 2020
@azigler
Copy link

azigler commented Jun 7, 2020

I added the early return in #121.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback PR/Issue has pending feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants