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
jaroslav@178
     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@178
    18
package cz.xelfi.quoridor.statistics;
jaroslav@178
    19
jaroslav@178
    20
import cz.xelfi.quoridor.Move;
jaroslav@178
    21
import cz.xelfi.quoridor.webidor.GameId;
jaroslav@178
    22
import cz.xelfi.quoridor.webidor.GameStatus;
jaroslav@178
    23
import javax.xml.bind.annotation.XmlAccessType;
jaroslav@178
    24
import javax.xml.bind.annotation.XmlAccessorType;
jaroslav@178
    25
jaroslav@178
    26
/**
jaroslav@178
    27
 *
jaroslav@178
    28
 * @author Martin Rexa
jaroslav@178
    29
 */
jaroslav@178
    30
@XmlAccessorType(XmlAccessType.FIELD)
jaroslav@178
    31
public class OpeningNodeViewEntry extends Object{
jaroslav@178
    32
    String move;
jaroslav@178
    33
    String code;
jaroslav@178
    34
    GameId gameId;
jaroslav@178
    35
    GameId whiteGame;
jaroslav@178
    36
    GameId blackGame;
jaroslav@178
    37
    int whiteWon;
jaroslav@178
    38
    int blackWon;
jaroslav@178
    39
jaroslav@178
    40
    public OpeningNodeViewEntry(){
jaroslav@178
    41
    }
jaroslav@178
    42
jaroslav@178
    43
    public OpeningNodeViewEntry(Move m, String code){
jaroslav@178
    44
        move = m.toString();
jaroslav@178
    45
        this.code = code;
jaroslav@178
    46
    }
jaroslav@178
    47
jaroslav@178
    48
    public void processGame(GameId gId){
jaroslav@178
    49
        gameId = gId;
jaroslav@178
    50
        if(gId.getStatus().equals(GameStatus.whiteWon)){
jaroslav@178
    51
            whiteWon++;
jaroslav@178
    52
            whiteGame = gId;
jaroslav@178
    53
        }
jaroslav@178
    54
        if(gId.getStatus().equals(GameStatus.blackWon)){
jaroslav@178
    55
            blackWon++;
jaroslav@178
    56
            blackGame = gId;
jaroslav@178
    57
        }
jaroslav@178
    58
    }
jaroslav@178
    59
jaroslav@178
    60
    @Override
jaroslav@178
    61
    public boolean equals(Object obj){
jaroslav@178
    62
        if (obj == null) {
jaroslav@178
    63
            return false;
jaroslav@178
    64
        }
jaroslav@178
    65
        if (getClass() != obj.getClass()) {
jaroslav@178
    66
            return false;
jaroslav@178
    67
        }
jaroslav@178
    68
        final OpeningNodeViewEntry other = (OpeningNodeViewEntry) obj;
jaroslav@178
    69
        return this.move.equals(other.move);
jaroslav@178
    70
    }
jaroslav@178
    71
jaroslav@178
    72
    @Override
jaroslav@178
    73
    public String toString(){
jaroslav@178
    74
        return move+": "+whiteWon+"/"+blackWon;
jaroslav@178
    75
    }
jaroslav@178
    76
jaroslav@178
    77
}