quoridor/src/main/java/cz/xelfi/quoridor/Board.java
changeset 107 152aedcc45d0
parent 92 de3dd5710a5c
child 178 4b78d4f028b3
     1.1 --- a/quoridor/src/main/java/cz/xelfi/quoridor/Board.java	Fri Sep 18 07:16:47 2009 +0200
     1.2 +++ b/quoridor/src/main/java/cz/xelfi/quoridor/Board.java	Tue Sep 22 23:06:16 2009 +0200
     1.3 @@ -302,13 +302,15 @@
     1.4          if (player.getFences () == 0) {
     1.5              throw new IllegalPositionException ("Not enough fences: " + player); // NOI18N
     1.6          }
     1.7 -        
     1.8 +
     1.9          int index = players.indexOf (player);
    1.10          Player[] arr = players.toArray (new Player[0]);
    1.11          arr[index] = new Player (arr[index].getXInternal(), arr[index].getYInternal(), arr[index].getFences() - 1, arr[index].endDirection);
    1.12          
    1.13          HashSet<Fence> fen = new HashSet<Fence> (this.fences);
    1.14 -        fen.add (fence);
    1.15 +        if (!fen.add (fence)) {
    1.16 +            throw new IllegalPositionException ("Fence already prsent: " + fence); // NOI18N
    1.17 +        }
    1.18          
    1.19          return new Board (turn + 1, Arrays.asList (arr), fen);
    1.20      }