@@ -0,0 +1,2703 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage ge.edu.freeuni.sdp.xo.game;%0A%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport javax.ws.rs.Consumes;%0Aimport javax.ws.rs.GET;%0Aimport javax.ws.rs.POST;%0Aimport javax.ws.rs.PUT;%0Aimport javax.ws.rs.Path;%0Aimport javax.ws.rs.PathParam;%0Aimport javax.ws.rs.Produces;%0Aimport javax.ws.rs.WebApplicationException;%0Aimport javax.ws.rs.core.MediaType;%0Aimport javax.ws.rs.core.Response;%0Aimport javax.ws.rs.core.Response.Status;%0A%0A/**%0A *%0A * @author toka%0A */%0A%0A@Path(%22%7BgameID%7D%22)%0A@Consumes(%7B MediaType.APPLICATION_JSON %7D)%0A@Produces(%7B MediaType.APPLICATION_JSON %7D)%0Apublic class GameService %7B%0A    %0A    static final HashMap%3CString, GameState%3E games = new HashMap%3C%3E();%0A    static%7B%0A        GameState state;%0A        state = new GameState();%0A        state.status = GameState.STATUS_PENDING;%0A        games.put(%22EmptyGame%22, state);%0A     %0A        state = new GameState();%0A        state.status = GameState.STATUS_RUNNING;%0A        state.table = Arrays.asList(16, 1, 2);%0A        games.put(%22RunningGame%22, state);%0A        %0A        state = new GameState();%0A        state.status = GameState.STATUS_FINISHED;%0A        state.table = Arrays.asList(16, 1, 4, 64, 32, 8, 256);%0A        state.winner = %22x-player_id%22;%0A        games.put(%22FinishedGame%22, state);%0A    %7D%0A%0A    @GET%0A    public GameState getState(@PathParam(%22gameID%22) String gameID)%7B%0A        GameState state = games.get(gameID);%0A        if(state == null)%0A            throw new WebApplicationException(Status.NOT_FOUND);%0A        return state;%0A    %7D%0A    %0A    @POST%0A    public Response registerPlayer(@PathParam(%22gameID%22) String gameID, JsonRequest request)%7B%0A        if(request.user_id == null) return Response.status(Status.BAD_REQUEST).build();%0A        System.out.println(request);%0A        System.out.println(%22game: %22+gameID);%0A        switch(gameID)%7B%0A            case %22ClosedGame%22: return Response.status(Status.CONFLICT).build();%0A            case %22OpenedGame%22: return Response.status(Status.OK).build();%0A            default: return Response.status(Status.NOT_FOUND).build();%0A        %7D%0A        %0A    %7D%0A    %0A    @PUT%0A    public GameState makeMove(@PathParam(%22gameID%22) String gameID, JsonRequest request)%7B%0A        System.out.println(%22user: %22+request.user_id + %22, cell: %22+request.cell);%0A        if(request.user_id == null %7C%7C request.cell == 0)%0A            throw new WebApplicationException(Status.BAD_REQUEST);%0A        %0A        GameState state = games.get(gameID);%0A        if(state == null)%0A            throw new WebApplicationException(Status.NOT_FOUND);%0A        %0A        return state;%0A    %7D%0A%7D%0A

add fake implementation of xo-game