Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
GameEventResign |
|
| 1.25;1.25 |
1 | /****************************************************************************** | |
2 | * GameEventResign.java - A Player wants to resign. | |
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 | ||
34 | ||
35 | /** A Player wants to resign. i.e. "<code>You want to resign. bucko will win 2 points.</code>" | |
36 | * @author Dick Balaska | |
37 | * @since 2011/05/16 | |
38 | * @version $Revision$ <br> $Date$ | |
39 | * @see com.buckosoft.fibs.BuckoFIBS.GameManager | |
40 | * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/domain/gameEvent/GameEventResign.java">cvs GameEventResign.java</a> | |
41 | */ | |
42 | 0 | public class GameEventResign extends GameEvent { |
43 | private int resigningPoints; | |
44 | ||
45 | @Override | |
46 | public Type getType() { | |
47 | 0 | return(Type.Resign); |
48 | } | |
49 | ||
50 | @Override | |
51 | public Life getLife() { | |
52 | 0 | return(Life.Persistent); |
53 | } | |
54 | ||
55 | /** Get how many points this resign event is for | |
56 | * @return the resigningPoints | |
57 | */ | |
58 | public int getResigningPoints() { | |
59 | 0 | return(resigningPoints); |
60 | } | |
61 | ||
62 | ||
63 | /** Parse the string that created this GameEvent. <br> | |
64 | * <code>dickbalaska wants to resign. bucko will win 1 point.</code> | |
65 | * @param s The FIBS string | |
66 | * @param b The Board prior to this resign (used to determine which player is resigning) | |
67 | */ | |
68 | public void parse(String s, Board b) { | |
69 | 0 | String[] ss = s.split(" "); |
70 | 0 | playerName = ss[0]; |
71 | 0 | this.setWho(b.getXOFromName(playerName)); |
72 | try { | |
73 | 0 | this.resigningPoints = Integer.parseInt(ss[7]); |
74 | 0 | } catch (NumberFormatException e) { |
75 | 0 | e.printStackTrace(); |
76 | 0 | } |
77 | ||
78 | 0 | } |
79 | ||
80 | } |