Beispiel #1
0
        public List <Move> GetMoves(GameboardImpl gameboard_ref)
        {
            List <Move> ret = new List <Move>();

            var command = gameboard_ref.commands [gameboard_ref.cur_command_idx];

            if (command.crystals_count >= cost)
            {
                if (isMagic)
                {
                    List <GameboardCell> target_cell = gameboard_ref.AddRangedMoves(gameboard_ref.cur_command_idx, healing > 0, strength > 0);
                    foreach (var cell in target_cell)
                    {
                        ret.Add(new MagicMoveImpl(cell, command.hand.FindIndex(x => x == this), cell.unit.command_idx == gameboard_ref.cur_command_idx));
                    }
                }
                else
                {
                    List <OrientedCell> available_cells = gameboard_ref.CalcAvailableCellsForCard(isGiant);

                    foreach (var cell in available_cells)
                    {
                        ret.Add(new CardMoveImpl(cell.cell, cell.orientation, command.hand.FindIndex(x => x == this)));
                    }
                }
            }

            return(ret);
        }
Beispiel #2
0
        public List <Move> GetMoves(GameboardImpl gameboard_ref)
        {
            List <Move> ret         = new List <Move>();
            List <Move> simpleMoves = new List <Move>();

            if (!made_move)
            {
                List <Routing.CAvailableCells> available_cells = new List <Routing.CAvailableCells>();

                if (isTeleport)                 //ToDo fill available_cells in case of giant teleport
                {
                    foreach (var cell in gameboard_ref.cells)
                    {
                        if (cell.active && cell.unit == null)                         //ToDo move to GameboardImpl
                        {
                            available_cells.Add(new Routing.CAvailableCells(new OrientedCell {
                                cell = cell
                            }, 0));
                        }
                    }
                }
                else
                {
                    available_cells = new Routing(gameboard_ref).CalcAvailableCells(oriented_cell, isGiant ? speed * 2 : speed);
                }

                if (isRangedAttack)
                {
                    List <GameboardCell> target_cell = gameboard_ref.AddRangedMoves(command_idx, healing > 0, strength > 0);
                    foreach (var cell in target_cell)
                    {
                        ret.Add(new KillMoveImpl(oriented_cell.cell, oriented_cell.orientation, oriented_cell.cell, cell, 0, cell.unit.command_idx == command_idx));
                    }
                }

                if (!isRangedAttack)
                {
                    AddNeighborKills(gameboard_ref, oriented_cell, ret, 0);
                }

                foreach (var cell in available_cells)
                {
                    simpleMoves.Add(new MoveImpl(cell.cell, cell.orientation, oriented_cell.cell, cell.steps));

                    if (!isRangedAttack)
                    {
                        AddNeighborKills(gameboard_ref, cell, ret, cell.steps);
                    }
                }

                ret.Sort((x, y) => x.Steps - y.Steps);
                simpleMoves.Sort((x, y) => y.Steps - x.Steps);

                ret.AddRange(simpleMoves);

                ret.Add(new SkipMoveImpl(oriented_cell.cell));
            }

            return(ret);
        }