1 /******************************************************************************
2 * GameEventAcceptAndWin - A Player has accepted the resign and wins the game.
3 * $Id$
4 *
5 * BuckoFIBS - Backgammon by BuckoSoft
6 * Copyright© 2011 - Dick Balaska - BuckoSoft, Corp.
7 *
8 * $Log$
9 */
10
11 /*
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
26 * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
27 *
28 */
29 package com.buckosoft.fibs.domain.gameEvent;
30
31 import com.buckosoft.fibs.domain.Board;
32
33 /** A Player has accepted the resign and wins the game.
34 * @author Dick Balaska
35 * @since 2011/06/04
36 * @version $Revision$ <br> $Date$
37 * @see com.buckosoft.fibs.BuckoFIBS.GameManager
38 * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/domain/gameEvent/GameEventAcceptAndWin.java">cvs GameEventAcceptAndWin.java</a>
39 */
40 public class GameEventAcceptAndWin extends GameEvent {
41 private int resigningPoints;
42
43 @Override
44 public Type getType() {
45 return(Type.AcceptAndWin);
46 }
47
48 @Override
49 public Life getLife() {
50 return(Life.Persistent);
51 }
52
53 /** Get how many points this resign event is for
54 * @return the resigningPoints
55 */
56 public int getResigningPoints() {
57 return(resigningPoints);
58 }
59
60 /** Set how many points this resign event is for
61 * @param resigningPoints the resigningPoints to set
62 */
63 public void setResigningPoints(int resigningPoints) {
64 this.resigningPoints = resigningPoints;
65 }
66
67 /** Parse the string that created this GameEvent. <br>
68 * <code>dickbalaska accepts and wins 3 points.</code>
69 * @param s The FIBS string
70 * @param b The Board prior to this resign (used to determine which player is resigning)
71 */
72 public void parse(String s, Board b) {
73 String[] ss = s.split(" ");
74 playerName = ss[0];
75 this.setWho(b.getXOFromName(playerName));
76 try {
77 this.resigningPoints = Integer.parseInt(ss[4]);
78 } catch (NumberFormatException e) {
79 e.printStackTrace();
80 }
81
82 }
83
84
85 }