public static void ParseTile(EngineParserState state, EngineTile tile)
        {
            Contract.Assert(tile.Type.IsSlicer());

            var mustSeek = tile.Type == EngineGlyphType.SlicerEnd && tile.TimesAccessed == 0;

            if (state.GetAndFlushInverting() && tile.TimesAccessed == 0)
            {
                mustSeek = true;
            }

            tile.TimesAccessed++;

            if (mustSeek)
            {
                while (!state.Position.IsBeginning)
                {
                    state.Position.MoveBackward();
                    if (state[state.Position].Type == EngineGlyphType.SlicerStart)
                    {
                        break;
                    }
                }
            }
            else
            {
                state.Position.MoveForward();
            }
        }
        public static void ParseTile(EngineParserState state, EngineTile tile)
        {
//            Contract.Assert(tile.Type == EngineGlyphType.Nothing);

            tile.TimesAccessed++;
            state.Position.MoveForward();
        }
        public static void ParseTile(EngineParserState state, EngineTile tile)
        {
            Contract.Assert(tile.Type.IsNumeral());

            state.CurrentNumberGroup += StateParserUtils.GetNumeralValue(tile, state.GetAndFlushInverting());
            tile.TimesAccessed++;
            state.Position.MoveForward();
        }
        public static void ParseTile(EngineParserState state, EngineTile tile)
        {
            Contract.Assert(tile.Type == EngineGlyphType.ModifierInvert);

            tile.TimesAccessed++;
            state.Position.MoveForward();
            state.ToggleInverting();
        }
예제 #5
0
        public static void ParseTile(EngineParserState state, EngineTile tile)
        {
            Contract.Assert(tile.Type == EngineGlyphType.OperationMultiplier);

            StateParserUtils.PerformOperation(state);
            state.LastOperator = state.GetAndFlushInverting() ? EngineOperatorType.Division : EngineOperatorType.Multiplication;
            tile.TimesAccessed++;
            state.Position.MoveForward();
        }
        public static void ParseTile(EngineParserState state, EngineTile tile)
        {
            Contract.Assert(tile.Type.IsAction());

            StateParserUtils.PerformOperation(state);

            AddAction(state, GetActionType(tile, state.GetAndFlushInverting()));
            tile.TimesAccessed++;
            state.Position.MoveForward();
        }
        public static void ParseTile(EngineParserState state, EngineTile tile)
        {
            Contract.Assert(tile.Type.IsBomb());

            if (!state.GetAndFlushInverting())
            {
                state.Explode(1);
            }

            tile.TimesAccessed++;
            state.Position.MoveForward();
        }
예제 #8
0
        public static void ParseTile(EngineParserState state, EngineTile tile)
        {
            Contract.Assert(tile.Type == EngineGlyphType.ModifierIgnore);

            tile.TimesAccessed++;
            state.Position.MoveForward();
            if (!state.GetAndFlushInverting())
            {
                StateParserUtils.SkipEmptyTiles(state);
                state.Position.MoveForward();
            }
        }
        private static void AddAction(EngineParserState state, EngineActionType actionType)
        {
            if (state.LastNumberGroup < 0)
            {
                return;
            }
            if (state.LastNumberGroup == 0)
            {
                state.LastNumberGroup = 1;
            }

            state.AddAction(actionType, state.LastNumberGroup);
            state.LastNumberGroup = 0;
        }
예제 #10
0
        private static EngineTile FindTarget(EngineParserState state, EngineDirection direction, int depth)
        {
            if (depth >= 16)
            {
                return(null);
            }

            var foundTile = StateParserUtils.Raycast(state, state.Position, direction);

            if (foundTile == null)
            {
                return(null);
            }
            return(foundTile.Type.IsCameleon() ? FindTarget(state, foundTile.Type.GetDirection(), depth + 1) : foundTile);
        }
예제 #11
0
        public static void ParseTile(EngineParserState state, EngineTile tile)
        {
            Contract.Assert(tile.Type.IsCameleon());

            var baseDirection = tile.Type.GetDirection();
            var target        = FindTarget(state, state.GetAndFlushInverting() ? baseDirection.Opposite : baseDirection, 0);

            if (target == null)
            {
                state.Position.MoveForward();
            }
            else
            {
                target = new EngineTile(target.Type)
                {
                    TimesAccessed = tile.TimesAccessed
                };
                state.EngineParser.ParseTile(target);
            }
            tile.TimesAccessed++;
        }