2 * Quoridor server and related libraries
3 * Copyright (C) 2009-2010 Martin Rexa
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://www.gnu.org/licenses/.
19 package cz.xelfi.quoridor.statistics;
21 import cz.xelfi.quoridor.webidor.GameId;
22 import cz.xelfi.quoridor.webidor.GameStatus;
23 import cz.xelfi.quoridor.Move;
25 import java.util.HashSet;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.ArrayList;
30 import javax.xml.bind.annotation.XmlElement;
31 import javax.xml.bind.annotation.XmlElementWrapper;
32 import javax.xml.bind.annotation.XmlRootElement;
33 //import javax.xml.bind.annotation.XmlAccessType;
34 //import javax.xml.bind.annotation.XmlAccessorType;
35 import javax.xml.bind.annotation.XmlAttribute;
43 //@XmlAccessorType(XmlAccessType.FIELD)
44 public class OpeningNodeView {
47 @XmlElementWrapper(name="whiteGames")
48 @XmlElement(name="gameId")
49 List<GameId> whiteGames;
50 @XmlElementWrapper(name="blackGames")
51 @XmlElement(name="gameId")
52 List<GameId> blackGames;
53 Map<Move, OpeningNodeViewEntry> entries;
56 public OpeningNodeView(){
59 public OpeningNodeView(String code){
61 entries = new HashMap<Move, OpeningNodeViewEntry>();
62 whiteGames = new ArrayList<GameId>();
63 blackGames = new ArrayList<GameId>();
68 public String getNodeCode(){
72 public void processGame(Move m, String code, GameId gId){
73 OpeningNodeViewEntry e = entries.get(m);
75 e = new OpeningNodeViewEntry(m,code);
82 @XmlElementWrapper(name="children")
83 @XmlElement(name="item")
84 public Set<OpeningNodeViewEntry> getChildren(){
85 Set<OpeningNodeViewEntry> result = new HashSet<OpeningNodeViewEntry>();
86 for(Map.Entry<Move, OpeningNodeViewEntry> e: entries.entrySet()){
87 result.add(e.getValue());
93 public void addFinishedGame(GameId gId){
94 if(gId.getStatus().equals(GameStatus.whiteWon))
96 if(gId.getStatus().equals(GameStatus.blackWon))
102 public int getWhiteCount(){
103 return whiteGames.size();
107 public int getBlackCount(){
108 return blackGames.size();
113 public boolean getChildrenNotEmpty(){
114 return !entries.isEmpty();
117 public boolean isEmpty(){