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
jaroslav@266
     1
/**
jaroslav@264
     2
 * Quoridor server and related libraries
jaroslav@264
     3
 * Copyright (C) 2009-2010 Martin Rexa
jaroslav@178
     4
 *
jaroslav@264
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@264
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@264
     7
 * the Free Software Foundation, either version 3 of the License.
jaroslav@178
     8
 *
jaroslav@264
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@264
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@264
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@264
    12
 * GNU General Public License for more details.
jaroslav@178
    13
 *
jaroslav@264
    14
 * You should have received a copy of the GNU General Public License
jaroslav@264
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@264
    16
 * If not, see http://www.gnu.org/licenses/.
jaroslav@178
    17
 */
jaroslav@266
    18
jaroslav@178
    19
package cz.xelfi.quoridor.statistics;
jaroslav@178
    20
jaroslav@178
    21
import cz.xelfi.quoridor.Move;
jaroslav@178
    22
import cz.xelfi.quoridor.webidor.GameId;
jaroslav@178
    23
import cz.xelfi.quoridor.webidor.GameStatus;
jaroslav@178
    24
import javax.xml.bind.annotation.XmlAccessType;
jaroslav@178
    25
import javax.xml.bind.annotation.XmlAccessorType;
jaroslav@178
    26
jaroslav@178
    27
/**
jaroslav@178
    28
 *
jaroslav@178
    29
 * @author Martin Rexa
jaroslav@178
    30
 */
jaroslav@178
    31
@XmlAccessorType(XmlAccessType.FIELD)
jaroslav@178
    32
public class OpeningNodeViewEntry extends Object{
jaroslav@178
    33
    String move;
jaroslav@178
    34
    String code;
jaroslav@178
    35
    GameId gameId;
jaroslav@178
    36
    GameId whiteGame;
jaroslav@178
    37
    GameId blackGame;
jaroslav@178
    38
    int whiteWon;
jaroslav@178
    39
    int blackWon;
jaroslav@178
    40
jaroslav@178
    41
    public OpeningNodeViewEntry(){
jaroslav@178
    42
    }
jaroslav@178
    43
jaroslav@178
    44
    public OpeningNodeViewEntry(Move m, String code){
jaroslav@178
    45
        move = m.toString();
jaroslav@178
    46
        this.code = code;
jaroslav@178
    47
    }
jaroslav@178
    48
jaroslav@178
    49
    public void processGame(GameId gId){
jaroslav@178
    50
        gameId = gId;
jaroslav@178
    51
        if(gId.getStatus().equals(GameStatus.whiteWon)){
jaroslav@178
    52
            whiteWon++;
jaroslav@178
    53
            whiteGame = gId;
jaroslav@178
    54
        }
jaroslav@178
    55
        if(gId.getStatus().equals(GameStatus.blackWon)){
jaroslav@178
    56
            blackWon++;
jaroslav@178
    57
            blackGame = gId;
jaroslav@178
    58
        }
jaroslav@178
    59
    }
jaroslav@178
    60
jaroslav@178
    61
    @Override
jaroslav@178
    62
    public boolean equals(Object obj){
jaroslav@178
    63
        if (obj == null) {
jaroslav@178
    64
            return false;
jaroslav@178
    65
        }
jaroslav@178
    66
        if (getClass() != obj.getClass()) {
jaroslav@178
    67
            return false;
jaroslav@178
    68
        }
jaroslav@178
    69
        final OpeningNodeViewEntry other = (OpeningNodeViewEntry) obj;
jaroslav@178
    70
        return this.move.equals(other.move);
jaroslav@178
    71
    }
jaroslav@178
    72
jaroslav@178
    73
    @Override
jaroslav@178
    74
    public String toString(){
jaroslav@178
    75
        return move+": "+whiteWon+"/"+blackWon;
jaroslav@178
    76
    }
jaroslav@178
    77
jaroslav@178
    78
}