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/.
18 package cz.xelfi.quoridor.statistics;
20 import cz.xelfi.quoridor.webidor.GameId;
21 import cz.xelfi.quoridor.webidor.GameStatus;
22 import cz.xelfi.quoridor.Move;
24 import java.util.HashSet;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.ArrayList;
29 import javax.xml.bind.annotation.XmlElement;
30 import javax.xml.bind.annotation.XmlElementWrapper;
31 import javax.xml.bind.annotation.XmlRootElement;
32 //import javax.xml.bind.annotation.XmlAccessType;
33 //import javax.xml.bind.annotation.XmlAccessorType;
34 import javax.xml.bind.annotation.XmlAttribute;
42 //@XmlAccessorType(XmlAccessType.FIELD)
43 public class OpeningNodeView {
46 @XmlElementWrapper(name="whiteGames")
47 @XmlElement(name="gameId")
48 List<GameId> whiteGames;
49 @XmlElementWrapper(name="blackGames")
50 @XmlElement(name="gameId")
51 List<GameId> blackGames;
52 Map<Move, OpeningNodeViewEntry> entries;
55 public OpeningNodeView(){
58 public OpeningNodeView(String code){
60 entries = new HashMap<Move, OpeningNodeViewEntry>();
61 whiteGames = new ArrayList<GameId>();
62 blackGames = new ArrayList<GameId>();
67 public String getNodeCode(){
71 public void processGame(Move m, String code, GameId gId){
72 OpeningNodeViewEntry e = entries.get(m);
74 e = new OpeningNodeViewEntry(m,code);
81 @XmlElementWrapper(name="children")
82 @XmlElement(name="item")
83 public Set<OpeningNodeViewEntry> getChildren(){
84 Set<OpeningNodeViewEntry> result = new HashSet<OpeningNodeViewEntry>();
85 for(Map.Entry<Move, OpeningNodeViewEntry> e: entries.entrySet()){
86 result.add(e.getValue());
92 public void addFinishedGame(GameId gId){
93 if(gId.getStatus().equals(GameStatus.whiteWon))
95 if(gId.getStatus().equals(GameStatus.blackWon))
101 public int getWhiteCount(){
102 return whiteGames.size();
106 public int getBlackCount(){
107 return blackGames.size();
112 public boolean getChildrenNotEmpty(){
113 return !entries.isEmpty();
116 public boolean isEmpty(){