1 /****************************************************************************** 2 * CommandDispatcher.java - Interface for dispatching commands through the system 3 * $Id$ 4 * 5 * BuckoFIBS - Backgammon by BuckoSoft 6 * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp. 7 * 8 * $Log$ 9 * Revision 1.10 2011/05/22 22:58:59 dick 10 * GAME_MOVE becomes GAME_EVENT. 11 * 12 * Revision 1.9 2011/05/22 05:10:51 dick 13 * We don't need accept_or_decline_double anymore. It's handled by the GameManager. 14 * 15 * Revision 1.8 2011/05/21 04:56:42 dick 16 * Work on integrating GUI game functions by routing them through the game manager now. 17 * Particularly, YourMove and ResumeGame. 18 * 19 * Revision 1.7 2011/05/15 02:18:36 dick 20 * c.b.f.B.gui.board becomes c.b.f.B.gui.boardTab. 21 * 22 * Revision 1.6 2011/05/10 16:08:20 dick 23 * Fix the javadoc pointers to the source code. 24 * 25 * Revision 1.5 2010/12/22 04:35:16 dick 26 * Add getMainDialog(). 27 * 28 * Revision 1.4 2010/03/03 13:12:21 inim 29 * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8 30 * 31 * Revision 1.3 2010/03/03 12:19:49 inim 32 * 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. 33 * 34 * Revision 1.2 2010/02/08 09:14:13 dick 35 * Add support for autoGreedyBearoff. When the game turns to a race, enable greedy bearoffs. 36 * 37 * Revision 1.1 2010/02/04 05:57:53 inim 38 * Mavenized project folder layout 39 * 40 * Revision 1.46 2010/01/29 23:14:08 dick 41 * Handle the RatingsGraphConfigDialog. 42 * 43 * Revision 1.45 2010/01/23 06:14:49 dick 44 * Add YOU_INVITED. 45 * 46 * Revision 1.44 2009/03/04 19:06:53 dick 47 * If you doubleclick on a player in the playerList, then generate a player report request. 48 * 49 * Revision 1.43 2009/02/24 05:49:56 dick 50 * Handle state changes to the ROP flags. 51 * 52 * Revision 1.42 2009/02/14 12:19:37 dick 53 * Add SHOW_ABOUT_DIALOG 54 * 55 * Revision 1.41 2009/02/12 06:25:25 dick 56 * Add BEAR_OFF and PLAY_CUE. 57 * 58 * Revision 1.40 2009/02/09 22:44:42 dick 59 * Add SEND_RESIGN. 60 * 61 * Revision 1.39 2009/02/06 07:56:48 dick 62 * Working on doubles. 63 * 64 * Revision 1.38 2009/02/05 06:00:00 dick 65 * Add TOGGLE_DOUBLE and ROLL_OR_DOUBLE. 66 * 67 * Revision 1.37 2009/02/03 09:45:04 dick 68 * Now that ClientReceiveParser can talk directly to MainDialog, we need our message routes posted here. 69 * 70 * Revision 1.36 2009/02/01 21:23:23 dick 71 * Add SAVED_MATCH and MISS_MANNERS to track other players' behavior. 72 * 73 * Revision 1.35 2009/01/31 06:11:00 dick 74 * Anyone who dispatches commands must also be a ToolbarHandler. 75 * 76 * Revision 1.34 2009/01/27 19:14:43 dick 77 * Add INVITE_WARNING 78 * 79 * Revision 1.33 2009/01/27 06:57:25 dick 80 * Handle the system uninviting us. 81 * 82 * Revision 1.32 2009/01/22 05:01:48 dick 83 * SEND_CHAT_COMMAND becomes the more generic SEND_COMMAND. 84 * 85 * Revision 1.31 2009/01/18 06:38:25 dick 86 * RECEIVE_NETWORK_MESSAGE is obsolete. 87 * 88 * Revision 1.30 2009/01/18 05:18:06 dick 89 * Add dispatch(String, String) and dispatch(Object). 90 * 91 * Revision 1.29 2009/01/18 04:52:16 dick 92 * CommandDispatcher becomes CommandDispatcherImpl. 93 * CommandDispatcher is now the interface describing the API for the dispatcher. 94 * 95 */ 96 97 /* 98 * This program is free software: you can redistribute it and/or modify 99 * it under the terms of the GNU General Public License as published by 100 * the Free Software Foundation, either version 3 of the License, or 101 * (at your option) any later version. 102 * 103 * This program is distributed in the hope that it will be useful, 104 * but WITHOUT ANY WARRANTY; without even the implied warranty of 105 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 106 * GNU General Public License for more details. 107 * 108 * You should have received a copy of the GNU General Public License 109 * along with this program. If not, see <http://www.gnu.org/licenses/>. 110 * 111 * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>. 112 * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp. 113 * 114 */ 115 package com.buckosoft.fibs.BuckoFIBS; 116 117 import com.buckosoft.fibs.BuckoFIBS.gui.MainDialog; 118 import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.ToolbarHandler; 119 120 /** Interface for dispatching commands through the BuckoFIBS system. 121 * @author Dick Balaska 122 * @since 2009/01/17 123 * @version $Revision$ <br> $Date$ 124 * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/javacom/buckosoft/fibs/BuckoFIBS/CommandDispatcher.java">cvs CommandDispatcher.java</a> 125 */ 126 public interface CommandDispatcher extends ToolbarHandler { 127 enum Command { 128 SHOW_CONNECTION_DIALOG, 129 SHOW_NEW_ACCOUNT_DIALOG, 130 DISCONNECT_FROM_NETWORK, 131 SHOW_PREFERENCES_DIALOG, 132 SHOW_PREFS4MSGS_DIALOG, 133 SHOW_ABOUT_DIALOG, 134 SHOW_RATINGS_GRAPH_DIALOG, 135 SET_RATING_GRAPH_CONFIG, 136 REGISTER_NEW_USER, // Includes a roundabout way to CONNECT_TO_SERVER 137 BAD_NEW_USER, // Server says pick someone else 138 CONNECT_TO_SERVER, 139 SYSTEM_MESSAGE, 140 SHUTTING_DOWN, 141 NETWORK_CONNECTED, 142 // RECEIVE_NETWORK_MESSAGE, 143 PLAYER_CHANGED, 144 PLAYER_GONE, 145 INVITE, 146 INVITED, 147 INVITE_WARNING, 148 WATCHING, 149 ACCEPT_INVITATION, 150 DECLINE_INVITATION, 151 UNINVITED, 152 YOU_INVITED, 153 START_GAME, 154 RESUME_GAME, 155 MATCH_OVER, 156 TOGGLE_READY_TO_PLAY, 157 TOGGLE_GREEDY_BEAROFF, 158 READY_TO_PLAY, 159 TOGGLE_DOUBLE, 160 SEND_MOVE, 161 /** Bearing off is automatic, and just does end of turn handling */ 162 BEAR_OFF, 163 SEND_COMMAND, 164 YOUR_MOVE, 165 ROLL_OR_DOUBLE, 166 SEND_ROLL, 167 SEND_DOUBLE, 168 SEND_ACCEPT, 169 SEND_REJECT, 170 SEND_RESIGN, 171 /** The 2nd line received from FIBS. Describe my settings. */ 172 OWN_INFO, 173 /** A Saved Match line from FIBS */ 174 SAVED_MATCH, 175 /** A MissManners warning from FIBS */ 176 MISS_MANNERS, 177 /** All game events (roll, move, double) get routed through the GameManager */ 178 GAME_EVENT, 179 /** Parse a board received from FIBS */ 180 FIBS_BOARD, 181 /** Either player is pushing the cube */ 182 DOUBLE, 183 WATCH, 184 GET_PLAYER_REPORT, 185 PLAY_CUE 186 } 187 188 /** Set the Properties/User preferences 189 * @param properties The loaded properties 190 */ 191 void setProperties(BFProperties properties); 192 193 /** Get a reference to our properties 194 * @return The properties object 195 */ 196 BFProperties getProperties(); 197 198 /** Set the reference to the instance of MainDialog 199 * @param mainDialog The MainDialog that is running 200 */ 201 void setMainDialog(MainDialog mainDialog); 202 203 /** Fetch the reference to the MainDialog 204 * @return The MainDialog 205 */ 206 MainDialog getMainDialog(); 207 208 /** Primary entry point to the command dispatcher 209 * @param command The command to execute 210 */ 211 void dispatch(Command command); 212 213 /** Primary entry point to the command dispatcher 214 * what takes a single string as an argument 215 * @param command The Command to Execute 216 * @param arg1 A string that the dispatched function wants 217 */ 218 void dispatch(Command command, String arg1); 219 220 /** Primary entry point to the command dispatcher 221 * what takes two strings as an argument 222 * @param command The Command to Execute 223 * @param arg1 A string that the dispatched function wants 224 * @param arg2 Another string that the dispatched function wants 225 */ 226 void dispatch(Command command, String arg1, String arg2); 227 228 /** Primary entry point to the command dispatcher 229 * what takes an Object as an argument 230 * @param command The Command to Execute 231 * @param obj An Object that the dispatched function wants 232 */ 233 void dispatch(Command command, Object obj); 234 235 /** Write a message to the System message pane in the specified color. 236 * @param type The style of the text 237 * @param s The message to write 238 */ 239 public void writeSystemMessage(int type, String s); 240 241 /** Write a message to the System message pane in the normal color. 242 * Terminate the message with a crlf. 243 * @param s The message to write 244 */ 245 void writeSystemMessageln(String s); 246 247 /** Write a message to the System message pane in the specified color. 248 * @param type The style of the text 249 * @param s The message to write 250 */ 251 void writeSystemMessageln(int type, String s); 252 253 void writeRegisterUserMessage(String s); 254 255 /** Send a message to the fibs server appending a crlf to the end 256 * @param s The message to send 257 * @return success 258 */ 259 boolean writeNetworkMessageln(String s); 260 261 /** Write a message to the chat message pane in the normal color. 262 * Terminate the message with a crlf. 263 * @param name The user what sent the message 264 * @param cookie The mode used to send the message (shout, whisper, kibitz, etc) 265 * @param text The message to write 266 */ 267 void writeChatMessageln(String name, int cookie, String text); 268 269 /** Write a message to the game pane appending a crlf to the end. 270 * @param s The message to write 271 */ 272 void writeGameMessageln(String s); 273 274 /** Write a message in the error color (red) to the game pane appending a crlf to the end. 275 * @param s The message to write 276 */ 277 void writeGameErrorln(String s); 278 279 /** User has changed the state of the Ready, Online, or Playing button 280 * @param rop The current/new state of the Ready[0], Online[1], and Playing[2] buttons. 281 */ 282 void ropChanged(boolean[] rop); 283 }