コード例 #1
0
        private void MovePawn(Pawn p, int steps)
        {
            int coordx = -1;
            int coordy = -1;

            while (true)
            {
                string[] s = Console.ReadLine().Split('-');
                Int32.TryParse(s[0], out coordx);
                Int32.TryParse(s[1], out coordy);
                if (coordx != -1 && coordy != -1)
                {
                    IField targetField = _game.Fields.Where(x => x.CoordX == coordx && x.CoordY == coordy).FirstOrDefault();
                    if (_game.validMove(p.Position, targetField, steps))
                    {
                        if (targetField != null && targetField.CanPlace(p))
                        {
                            p.Move(p.Position, targetField);// targetField.PlaceMoveable(p);
                        }
                        break;
                    }
                }
                Console.WriteLine("Invalid coords try again");
            }
        }