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