Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:11:36+00:00 2026-05-25T11:11:36+00:00

In one of my classes, I have an integer that stores a set of

  • 0

In one of my classes, I have an integer that stores a set of enum flags like so:

enum AttackFlags
{
    Contact = 1,                        //Move connects with target
    Projectile = 2,                         //Attack is projectile based
    Unblockable = 4,                        //Attack can not be blocked
    UncounterableLv1 = 8,                   //Attack can't be countered except by extreme counter attack skills/status effects
    UncounterableLv2 = 16,                  //Attack can not be countered
    Flinches = 32,                          //Has a chance to stun the enemy, pushing back their next turn
    Unreflectable = 64,                     //Attack penetrates reflect. Only checked for Magic attacks
    IgnoreDefenderStatusEffects = 128,      //Ignores active status effects on the defender
    IgnoreAttackerStatusEffects = 256,      //Ignores active status effects on the attacker
    IgnoreDefenderAbilities = 512,          //Ignore the defenders abilities
    IgnoreAttackerAbilities = 1024,         //Ignore the attackers abilities
    IgnoreArmorRating = 2048,               //Ignore the defensive boosts of armor
    IgnoreWeaponRating = 4096,              //Ignore the attack boost from weapons
    HighCritical = 8192,                    //The move has an increased chance to crit
    CausesStatus = 16384,                   //Can the move cause status effects?
    Elemental = 32768,                      //Is the move elemental based?
    Unimplemented = 65536,                  //has the move been implemented yet?
    ModsTimer = 131072,                     //Does it have an effect on the target or users timer?
    Heals = 262144,                         //Does the move heal?
    SecondaryEffects = 524288,              //Attack has additional effects besides basic attack
    PhysicalAttackFlag = 1048576,           //Is the Class Physically based? I.E. blocked by Protect and Shield
    MagicAttackFlag = 2097152,              //Is the move Magically Based? I.E. is it affected by things like Shell
    MultiHit = 4194304,                     //Does it enxcapsulate more then 1 hit
    SingleUse = 8388608,                    //Attack can only be used once per battle
    DoesNotCauseDamage = 16777216
};

class Attack
{
   int AtkFlags; //Stores AttackFlags |'d together

}

I’d like to add a method to my Attack class with the following signature

bool HasAttackFlags(int flags);

flags would be numerous AttackFlags |’d together. If I only wanted to check against a single flag, I could just & AtkFlags and flags together, but because I have to check against multiple possible flags this won’t work. How can I properly check for multiple flags? I’d like to avoid passing a vector/set of flags to check against as simply |’ing a set of flags together is simpler then constructing a vector/set

Thanks in advance

EDIT:

To clarify what I mean, I might have the following

Attack atk;
atk.AtkFlags = Contact | Projectile | Heals | MagicAttackFlag;

Then later, I’d want to check the flags on atk like so:

bool res = atk.HasAttackFlags(Contact | Projectile);

res should be true and conversely

bool res = atk.HasAttackFlags(Contact | Unreflectable);

should be false becase AtkFlags does not contain both Contact adn Unreflectable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:11:36+00:00Added an answer on May 25, 2026 at 11:11 am

    I am not sure I am following your question, because you seem to mention the obvious solution. So what is wrong with this as a solution, obviously add whatever additional flags you wish:

    bool HasAttackFlags(int flags) {
        return (flags&(contact|projectile))!=0;
    }
    

    EDIT: Oh… I think I just figured it out, do you want to check for the presence of 2 or more flags as a set? In which case you can simply modify the method to:

    bool HasAttackFlags(int flags) {
        return (flags&(contact|projectile))==(contact|projectile);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Hibernate to do mapping. One of my classes have a set
I have several classes that conceptually belong to one tier. They have no common
I have a field for addedBy in one of my classes. I've set up
I have some classes that, for one reason or another, cannot be or need
In one of my projects, I have some classes that represent entities that cannot
I have the following calls in one of my classes @Override public Integer save(NewsItem
I have a set of functions that are templated both by an integer type
I have a class library that contains a number of classes. I would like
I have two classes one of which inherits from the other. Im trying to
I have 2 classes where I have one to send commands to a socket,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.