Newer
Older
IrisServer / src / main / java / com / ntlab / irisserver / resources / SettingsRest.java
package com.ntlab.irisserver.resources;

import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Component
@Path("rooms")
public class SettingsRest {
    //お絵描きの制限時間、単位は秒、初期値は10
    int drawingTimerTimes = 10;
    //ゲーム画面での諜報員が考える時間の長さ、単位は秒、初期値30
    int gameTimerTimes = 30;
    //最初のヒントの追加考察時間、単位は秒、初期値10
    int gameTimerFirstThinkingTimes = 10;

    boolean drawingTimer = false;
    boolean gameTimer = true;
    /*
    RoomManager rm = RoomManager.getInstance();
    */



    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/{rid}/settings")
    public Object GetSettings(@PathParam("rid") String rid){

        var response = Response.status(Response.Status.NO_CONTENT);
        //Room r = rm.getRoom(rid);
        //部屋が存在しない
        /*
        if(r == null) {
            response.status(404).entity("部屋が存在しません");
            throw new WebApplicationException(response.build());
        }
        */

        return "drawingTime:" + drawingTimer + ",\n" +
                "drawingTimerTimes:" + drawingTimerTimes + ",\n" +
                "gameTimer:" + gameTimer +",\n" +
                "gameTimerTimes:" + gameTimerTimes + ",\n" +
                "gameTimerInitializeTimes:" + gameTimerFirstThinkingTimes;
    }

    @PUT
    @Path("/{rid}/settings")
    public void PutSettings(@PathParam("rid") String rid,
                              @FormParam("drawingTimer") boolean dTimer,
                              @FormParam("drawingTimerTimes") int dTimerTimes,
                              @FormParam("gameTimer") boolean gTimer,
                              @FormParam("gameTimerTimes") int gTimerTimes,
                              @FormParam("gameTimerFirstThinkingTimes") int gTimerFTTimes){
        drawingTimer = dTimer;
        drawingTimerTimes = dTimerTimes;
        gameTimer = gTimer;
        gameTimerTimes = gTimerTimes;
        gameTimerFirstThinkingTimes =gTimerFTTimes;

    }

    public void DrawingSetting(){
    }

    public void GameSetting(){
    }
}