View Javadoc
1   /**************************************************************************
2    Copyright 2005 Webstersmalley
3   
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7   
8    http://www.apache.org/licenses/LICENSE-2.0
9   
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15   *************************************************************************/
16  /*
17   * Created on 23-Aug-2005
18   */
19  package com.webstersmalley.chessweb.model;
20  
21  import java.util.Collection;
22  import java.util.HashSet;
23  
24  /*** Which team (black, white) the piece is on. */
25  public final class Team {
26      
27      /*** White's start row (2nd row up). * */
28      private static final int WHITE_START_ROW = 2;
29  
30      /*** Black's start row (2nd row down). * */
31      private static final int BLACK_START_ROW = 7;
32  
33      /*** White team. */
34      public static final Team WHITE = new Team("white", 1, WHITE_START_ROW);
35  
36      /*** Black team. */
37      public static final Team BLACK = new Team("black", -1, BLACK_START_ROW);
38  
39      /*** String representing the side. */
40      private String side;
41  
42      /*** Pawn increment direction. */
43      private int pawnIncrement;
44  
45      /*** Pawn start row . */
46      private int pawnStartingRank;
47  
48      /***
49       * Constructs a new Team. Private so that we can do a typesafe enum.
50       * 
51       * @param side
52       *            The side
53       * @param pawnIncrement
54       *            How much to move pawns by (direction only)
55       * @param pawnStartingRow
56       *            Which row the pawns start on
57       */
58      private Team(final String side, final int pawnIncrement,
59              final int pawnStartingRow) {
60          this.side = side;
61          this.pawnIncrement = pawnIncrement;
62          this.pawnStartingRank = pawnStartingRow;
63      }
64  
65      /***
66       * Returns the name of the team.
67       * 
68       * @return the team name.
69       */
70      public String toString() {
71          return side;
72      }
73  
74      /***
75       * @return Returns the pawnIncrement.
76       */
77      public int getPawnIncrement() {
78          return pawnIncrement;
79      }
80  
81      /***
82       * @return Returns the pawnStartPosition
83       */
84      public int getPawnStartingRank() {
85          return pawnStartingRank;
86      }
87  
88  }