Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
GameEventAcceptAndWin |
|
| 1.2;1.2 |
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 | 0 | public class GameEventAcceptAndWin extends GameEvent { |
41 | private int resigningPoints; | |
42 | ||
43 | @Override | |
44 | public Type getType() { | |
45 | 0 | return(Type.AcceptAndWin); |
46 | } | |
47 | ||
48 | @Override | |
49 | public Life getLife() { | |
50 | 0 | 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 | 0 | 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 | 0 | this.resigningPoints = resigningPoints; |
65 | 0 | } |
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 | 0 | String[] ss = s.split(" "); |
74 | 0 | playerName = ss[0]; |
75 | 0 | this.setWho(b.getXOFromName(playerName)); |
76 | try { | |
77 | 0 | this.resigningPoints = Integer.parseInt(ss[4]); |
78 | 0 | } catch (NumberFormatException e) { |
79 | 0 | e.printStackTrace(); |
80 | 0 | } |
81 | ||
82 | 0 | } |
83 | ||
84 | ||
85 | } |