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

[definitions] Morality and Attitude enums should be exposed to perform bitwise operations with them #19

Open
joelalejandro opened this issue Aug 24, 2019 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers module: definitions
Milestone

Comments

@joelalejandro
Copy link
Member

joelalejandro commented Aug 24, 2019

Since these enums are implemented as bitwise operators, if we want to do an action based only on a part of the CreatureAlignment, right now we need:

// Do something if the creature is Lawful.
if (
  creature.alignment === CreatureAlignment.LawfulGood 
  || creature.alignment === CreatureAlignment.LawfulNeutral
  || creature.alignment === CreatureAlignment.LawfulEvil
) {
  // ...
}

While we could have a simpler, shorter form:

// Do something if the creature is Lawful.
if (creature.alignment & CreatureAttitude.Lawful) {
  // ...
}

We would need to export the CreatureMorality and CreatureAttitude enumerables in the @xethya/definitions package.

@joelalejandro joelalejandro added enhancement New feature or request good first issue Good for newcomers module: definitions labels Aug 24, 2019
@joelalejandro joelalejandro added this to the Genesis (1.0) milestone Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers module: definitions
Projects
None yet
Development

No branches or pull requests

1 participant