View Javadoc
1   /******************************************************************************
2    * GameEventBoard.java - The Board line from Fibs.  A state more than an event.
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.1  2011/05/22 05:08:59  dick
10   * All GameEvent objects are named starting with GameEvent.
11   *
12   * Revision 1.6  2011/05/21 06:07:56  dick
13   * Javadoc.
14   *
15   * Revision 1.5  2011/05/21 05:15:51  dick
16   * Board is persistent.
17   * Add postEvent.  The last event in the queue may want to be attached to/go after this board.
18   *
19   * Revision 1.4  2011/05/16 21:20:25  dick
20   * toString() gives some helpful debug info.
21   *
22   * Revision 1.3  2011/05/16 14:15:49  dick
23   * Javadoc.
24   *
25   * Revision 1.2  2011/05/16 11:35:11  dick
26   * GameEvent is an abstract class, not an interface, so we can have some common methods.
27   *
28   * Revision 1.1  2011/05/15 02:16:39  dick
29   * Move the GameEvent objects to c.b.f.domain.gameEvent.
30   *
31   * Revision 1.2  2011/05/13 14:22:08  dick
32   * Implement GameEvent.
33   *
34   * Revision 1.1  2011/05/11 22:20:47  dick
35   * Line becomes GameLine.
36   *
37   * Revision 1.3  2010/03/03 13:12:21  inim
38   * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8
39   *
40   * Revision 1.2  2010/03/03 12:19:48  inim
41   * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010.
42   *
43   * Revision 1.1  2010/02/04 05:57:53  inim
44   * Mavenized project folder layout
45   *
46   * Revision 1.4  2009/02/17 14:45:09  dick
47   * Javadoc.
48   *
49   * Revision 1.3  2009/02/14 15:41:57  dick
50   * BuckoFIBS is released under the GNU license.
51   * Javadoc.
52   *
53   * Revision 1.2  2009/01/31 08:53:30  dick
54   * Store the number of checkers to move with this Line.
55   *
56   * Revision 1.1  2009/01/31 06:02:18  dick
57   * A single line of text from FIBS.
58   */
59  
60  /* 
61   * This program is free software: you can redistribute it and/or modify
62   * it under the terms of the GNU General Public License as published by
63   * the Free Software Foundation, either version 3 of the License, or
64   * (at your option) any later version.
65   *
66   * This program is distributed in the hope that it will be useful,
67   * but WITHOUT ANY WARRANTY; without even the implied warranty of
68   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
69   * GNU General Public License for more details.
70   *
71   * You should have received a copy of the GNU General Public License
72   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
73   *
74   * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
75   * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
76   * 
77   */
78  package com.buckosoft.fibs.domain.gameEvent;
79  
80  import com.buckosoft.fibs.domain.Board;
81  
82  
83  /** Define the Board event.  Board really is a state snapshot more than an event.
84   * @author Dick Balaska
85   * @since 2009/01/30
86   * @version $Revision$ <br> $Date$
87   * @see com.buckosoft.fibs.BuckoFIBS.GameManager
88   * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/domain/GameEventBoard.java">cvs GameEventBoard.java</a>
89   */
90  public class GameEventBoard extends GameEvent {
91  	private	Board		board = new Board();
92  	private	int			checkersToMove = 0;
93  	private	GameEvent	postEvent = null;
94  	
95  	/** Create an empty Line
96  	 */
97  	public GameEventBoard() {}
98  	
99  	/** Create a line with these values.
100 	 * @param line The line of text received from FIBS
101 	 */
102 	public GameEventBoard(String line) {
103 		this.board.parseFibsBoard(line);
104 	}
105 
106 	@Override
107 	public Type getType() {
108 		return(Type.Board);
109 	}
110 
111 	@Override
112 	public Life getLife() {
113 		return(Life.Persistent);
114 	}
115 
116 	/** Return the Board
117 	 * @return the Board
118 	 */
119 	public Board getBoard() {
120 		return(board);
121 	}
122 
123 	/** If this board is your move, then this is the number of checkers to move.
124 	 * If it is not your move, this value is 0.
125 	 * This is only valid if you are playing, not watching.
126 	 * @return the diceToMove
127 	 */
128 	public int getCheckersToMove() {
129 		return checkersToMove;
130 	}
131 	/** Set the number of checkers to move on this board.
132 	 * @param diceToMove the diceToMove to set
133 	 */
134 	public void setCheckersToMove(int diceToMove) {
135 		this.checkersToMove = diceToMove;
136 	}
137 
138 	/**
139 	 * @return the modEvent
140 	 */
141 	public GameEvent getPostEvent() {
142 		return postEvent;
143 	}
144 
145 	/**
146 	 * @param modEvent the modEvent to set
147 	 */
148 	public void setPostEvent(GameEvent postEvent) {
149 		this.postEvent = postEvent;
150 	}
151 
152 	public String toString() {
153 		String s = "board:" + board.getPlayerName()[0] + ":" + board.getPlayerName()[1];
154 		return(s);		
155 	}
156 }