コード例 #1
0
 public void MoveFigure(ChessFigurePosition position1, ChessFigurePosition position2)
 {
     this[position2] = this[position1];
     this[position1] = ChessFigure._;
 }
コード例 #2
0
 public void DeleteFigure(ChessFigurePosition position)
 {
     if (this[position] != ChessFigure._)
     {
         this[position] = ChessFigure._;
     }
     else {
         throw new InvalidOperationException("There are no chess figures at this position.");
     }
 }
コード例 #3
0
 public void CreateFigure(ChessFigurePosition position, ChessFigure figure)
 {
     if (this[position] == ChessFigure._)
     {
         this[position] = figure;
     }
     else {
         throw new InvalidOperationException("There's a chess figure at this position.");
     }
 }
コード例 #4
0
 public ChessFigure this[ChessFigurePosition position]
 {
     get
     {
         return Array[position.Column - ChessFigurePosition.MIN_COLUMN, position.Row - ChessFigurePosition.MIN_ROW];
     }
     set
     {
         Array[position.Column - ChessFigurePosition.MIN_COLUMN, position.Row - ChessFigurePosition.MIN_ROW] = value;
     }
 }
コード例 #5
0
 public void MoveFigure(ChessFigurePosition position1, ChessFigurePosition position2,string a,string b)
 {
     networking.MoveFigure(a, b);
     board.MoveFigure(position1, position2);
 }
コード例 #6
0
 // Передвигает фигуру с одной клетки на другую
 void move(string args)
 {
     string[] positions = args.Split(new char[] { ' ', '\t', '-' }, StringSplitOptions.RemoveEmptyEntries);
     if (positions.Length != 2)
         SafePrint(@"Incorrect format. Try something like ""e2-e4"".");
     else {
         ChessFigurePosition tmp1 = new ChessFigurePosition(positions[0]);
         ChessFigurePosition tmp2 = new ChessFigurePosition(positions[1]);
         if (gameData.Board[tmp1] == ChessFigure._) {
             SafePrint("Cant move a non-existent figure.");
             return;
         }
         if (positions[0] == positions[1]) {
             SafePrint("You can't move yourself.");
             return;
         }
         gameData.MoveFigure(tmp1, tmp2, positions[0], positions[1]);
         print(args);
     }
 }