private void SetFlags(LocationInfoFlags f, bool value)
 {
     if (value)
     {
         _flags |= f;
     }
     else
     {
         _flags &= ~f;
     }
 }
        public LocationInfoFlags Build()
        {
            _flags = LocationInfoFlags.None;

            if (_ahead?.Owner == null)
            {
                return(_flags);
            }

            _lord = _ahead.Owner;

            // if the character is dead then nothing else is possible
            if (_lord.IsDead)
            {
                return(_flags);
            }

            // if the character is hidden then nothing else is possible
            if (_lord.IsHidden)
            {
                SetFlags(LocationInfoFlags.Hide, true);
                return(_flags);
            }

            CheckTake();

            // Move Forward && Blocked
            if (_tunnel)
            {
                CheckMoveInTunnel();
            }
            else
            {
                CheckMoveBlocked();
                CheckEnterTunnel();
            }

            CheckEnterBattle();
            CheckCourageEnterBattle();
            CheckFollowingEnterBattle();

            CheckLocationAheadFull();

            CheckAlreadyInBattle();

            // LOM Specific

            CheckHide();

            CheckSeek();

            // if in battle there is nothing more we can do
            if (_engine.Scenario is MidnightScenario && _here?.FoeArmies > 0)
            {
                return(_flags);
            }

            CheckRecruit();

            CheckPostGuard();

            CheckRest();

            CheckFight();

            CheckStubbornAttacker();

            CheckStubbornMover();

            // DDR specific

            CheckGiveObject();

            CheckUseObject();

            return(_flags);
        }