Exemplo n.º 1
0
        private PossibleMove CheckPath(int x, int y, int xoff, int yoff, BoardClass Board)
        {
            int xcur = x, ycur = y;
            var gaplen = 0;

            for (int steps = 0; steps < 100; steps++)
            {
                xcur += xoff;
                ycur += yoff;

                if (!Board.InBounds(xcur, ycur))
                {
                    return(null);
                }
                var valid = Board.IsWalkable(xcur, ycur);

                if (Board.Tiles[xcur, ycur].Type != CardType.Empty)
                {
                    if (gaplen > 0 && valid)
                    {
                        return new PossibleMove()
                               {
                                   FromX = x, FromY = y, ToX = xcur, ToY = ycur, ScoreValue = Board.Tiles[xcur, ycur].ScoreValue, Card = this, Destination = Board.Tiles[xcur, ycur]
                               }
                    }
                    ;
                    return(null);
                }

                gaplen++;
            }
            return(null);
        }
Exemplo n.º 2
0
        private PossibleMove CheckPath(int x, int y, int xoff, int yoff, BoardClass Board)
        {
            int xcur = x, ycur = y;

            var Me = Board.GetMeepleAt(x, y);

            if (Me == null)
            {
                return(null);
            }

            for (int steps = 0; steps < 100; steps++)
            {
                xcur += xoff;
                ycur += yoff;
                if (!Board.IsWalkable(xcur, ycur, false))
                {
                    break;
                }

                var Enemy = Board.GetMeepleAt(xcur, ycur);

                if (Enemy != null)
                {
                    if (Enemy.Player.ID == Me.Player.ID)
                    {
                        break;
                    }
                    if (Board.IsWalkable(xcur + xoff, ycur + yoff))
                    {
                        return(new PossibleMove()
                        {
                            FromX = x, FromY = y, ToX = xcur, ToY = ycur, ScoreValue = Board.Tiles[xcur, ycur].ScoreValue, Card = this, Destination = Board.Tiles[xcur, ycur]
                        });
                    }
                }
            }
            return(null);
        }
Exemplo n.º 3
0
        private PossibleMove CheckPath(int x, int y, int xoff, int yoff, BoardClass Board)
        {
            int          xcur = x, ycur = y;
            PossibleMove LastGood = null;

            for (int steps = 0; steps < 100; steps++)
            {
                xcur += xoff;
                ycur += yoff;
                if (!Board.IsWalkable(xcur, ycur))
                {
                    break;
                }
                LastGood = new PossibleMove()
                {
                    FromX = x, FromY = y, ToX = xcur, ToY = ycur, ScoreValue = Board.Tiles[xcur, ycur].ScoreValue, Card = this, Destination = Board.Tiles[xcur, ycur]
                };
            }
            return(LastGood);
        }
Exemplo n.º 4
0
        public List <PossibleMove> Walk(int x, int y, int steps, bool allowDiag, bool StealthScore, BoardClass Board)
        {
            var PossiblePaths = Board.GetWalkPattern(steps, allowDiag);
            var Result        = new List <PossibleMove>();

            foreach (var path in PossiblePaths)
            {
                int xcur = x, ycur = y;
                int sx = -1, sy = -1;
                var TotalScore = 0;
                var isValid    = true;

                foreach (var step in path)
                {
                    xcur += step.X;
                    ycur += step.Y;
                    if (StealthScore && sx == -1)
                    {
                        sx = xcur;
                        sy = ycur;
                    }
                    if (!Board.IsWalkable(xcur, ycur))
                    {
                        isValid = false;
                        break;
                    }
                    ;
                    TotalScore += Board.Tiles[xcur, ycur].ScoreValue;
                }

                if (isValid)
                {
                    Result.Add(new PossibleMove()
                    {
                        FromX = x, FromY = y, ToX = xcur, ToY = ycur, FirstX = sx, FirstY = sy, ScoreValue = StealthScore ? TotalScore : Board.Tiles[xcur, ycur].ScoreValue, Card = this, Destination = Board.Tiles[xcur, ycur]
                    });
                }
            }
            return(Result.Distinct().ToList());
        }
Exemplo n.º 5
0
        public override List <PossibleMove> PossibleMoves(int x, int y, BoardClass Board, int PlayerID)
        {
            var res = new List <PossibleMove>();

            var Occupied = Board.GetOccupiedTiles(PlayerID).Select(o => o.Type).ToList();

            for (int i = 0; i < Board.TilesX; i++)
            {
                for (int j = 0; j < Board.TilesY; j++)
                {
                    if (Board.IsWalkable(i, j))
                    {
                        if (!Occupied.Contains(Board.Tiles[i, j].Type))
                        {
                            res.Add(new PossibleMove()
                            {
                                FromX = x, FromY = y, ToX = i, ToY = j, ScoreValue = Board.Tiles[i, j].ScoreValue, Card = this, Destination = Board.Tiles[i, j]
                            });
                        }
                    }
                }
            }

            if (Board.Players[PlayerID].AI)
            {
                var newres = new List <PossibleMove>();
                var Types  = res.Select(o => new { Move = o, Type = Board.Tiles[o.ToX, o.ToY].Type }).Where(o => o.Type != CardType.Trap).GroupBy(o => o.Type).Select(o => o.ToList()).ToList();

                foreach (var g in Types)
                {
                    g.Shuffle();
                    newres.AddRange(g.Take(3).Select(o => o.Move));
                }
                res = newres;
            }

            return(res);
        }