Skip to content

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

Open
markscho wants to merge 5 commits intoRanvierMUD:masterfrom
markscho:unfollowfix
Open

Fix: Can now force character independence regardless of current following status.#54
markscho wants to merge 5 commits intoRanvierMUD:masterfrom
markscho:unfollowfix

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