statistics/src/main/java/cz/xelfi/quoridor/statistics/OpeningNodeViewEntry.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 14 Sep 2010 08:56:13 +0200
changeset 264 d60370059c3c
parent 178 4b78d4f028b3
child 266 15fcdfc4cd4a
permissions -rw-r--r--
Changing headers to GPLv3
     1 /*
     2  * Quoridor server and related libraries
     3  * Copyright (C) 2009-2010 Martin Rexa
     4  *
     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.
     8  *
     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.
    13  *
    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/.
    17  */
    18 package cz.xelfi.quoridor.statistics;
    19 
    20 import cz.xelfi.quoridor.Move;
    21 import cz.xelfi.quoridor.webidor.GameId;
    22 import cz.xelfi.quoridor.webidor.GameStatus;
    23 import javax.xml.bind.annotation.XmlAccessType;
    24 import javax.xml.bind.annotation.XmlAccessorType;
    25 
    26 /**
    27  *
    28  * @author Martin Rexa
    29  */
    30 @XmlAccessorType(XmlAccessType.FIELD)
    31 public class OpeningNodeViewEntry extends Object{
    32     String move;
    33     String code;
    34     GameId gameId;
    35     GameId whiteGame;
    36     GameId blackGame;
    37     int whiteWon;
    38     int blackWon;
    39 
    40     public OpeningNodeViewEntry(){
    41     }
    42 
    43     public OpeningNodeViewEntry(Move m, String code){
    44         move = m.toString();
    45         this.code = code;
    46     }
    47 
    48     public void processGame(GameId gId){
    49         gameId = gId;
    50         if(gId.getStatus().equals(GameStatus.whiteWon)){
    51             whiteWon++;
    52             whiteGame = gId;
    53         }
    54         if(gId.getStatus().equals(GameStatus.blackWon)){
    55             blackWon++;
    56             blackGame = gId;
    57         }
    58     }
    59 
    60     @Override
    61     public boolean equals(Object obj){
    62         if (obj == null) {
    63             return false;
    64         }
    65         if (getClass() != obj.getClass()) {
    66             return false;
    67         }
    68         final OpeningNodeViewEntry other = (OpeningNodeViewEntry) obj;
    69         return this.move.equals(other.move);
    70     }
    71 
    72     @Override
    73     public String toString(){
    74         return move+": "+whiteWon+"/"+blackWon;
    75     }
    76 
    77 }