Initial version of statistics and ELO rating. Donated by Martin Rexa
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * The contents of this file are subject to the terms of either the GNU
5 * General Public License Version 2 only ("GPL") or the Common
6 * Development and Distribution License("CDDL") (collectively, the
7 * "License"). You may not use this file except in compliance with the
8 * License. You can obtain a copy of the License at
9 * http://www.netbeans.org/cddl-gplv2.html
10 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
11 * specific language governing permissions and limitations under the
12 * License. When distributing the software, include this License Header
13 * Notice in each file and include the License file at
14 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
15 * particular file as subject to the "Classpath" exception as provided
16 * by Sun in the GPL Version 2 section of the License file that
17 * accompanied this code. If applicable, add the following below the
18 * License Header, with the fields enclosed by brackets [] replaced by
19 * your own identifying information:
20 * "Portions Copyrighted [year] [name of copyright owner]"
24 * Portions Copyrighted 2010 Martin Rexa
27 package cz.xelfi.quoridor.statistics.resources;
29 import cz.xelfi.quoridor.statistics.EloList;
30 import cz.xelfi.quoridor.webidor.Game;
31 import cz.xelfi.quoridor.webidor.GameId;
32 import cz.xelfi.quoridor.webidor.GameStatus;
33 import javax.ws.rs.GET;
34 import javax.ws.rs.Path;
35 import javax.ws.rs.PathParam;
36 import javax.ws.rs.Produces;
37 import javax.ws.rs.core.MediaType;
43 public final class Elo {
50 public void processGame(Game game){
51 GameId gId = game.getId();
52 GameStatus status = gId.getStatus();
53 if(status.equals(GameStatus.whiteWon)){
54 list.putResult(gId.getWhite(), gId.getBlack());
55 }else if(status.equals(GameStatus.blackWon)){
56 list.putResult(gId.getBlack(), gId.getWhite());
62 @Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
63 public EloList getList(){
69 @Produces(MediaType.TEXT_PLAIN)
70 public String getElo(@PathParam("username") String id){
72 return Double.toString(list.getElo(id));