diff --git a/src/main/java/com/ntlab/irisserver/entities/Turn.java b/src/main/java/com/ntlab/irisserver/entities/Turn.java index aad634e..b6bae7b 100644 --- a/src/main/java/com/ntlab/irisserver/entities/Turn.java +++ b/src/main/java/com/ntlab/irisserver/entities/Turn.java @@ -17,7 +17,7 @@ @JsonProperty("max") private int max; - private List> questions = new ArrayList<>(); //> + private List questions[] = new ArrayList[16]; //> private List openlist = new ArrayList<>(); @@ -45,17 +45,17 @@ public List getOpenListAll() {return openlist;} //リストそのものを返す。 - public List> getQuestionsList() {return questions;} + public List[] getQuestionsList() {return questions;} //--------------------------------------------------------- //questions操作 - public List getQuestions(int cno){return questions.get(cno);} + public List getQuestions(int cno){return questions[cno];} - public void addQuestions(int cno, Member m){questions.get(cno).add(m);} + public void addQuestions(int cno, Member m){questions[cno].add(m);} public void delieteQuestions(int cno, Member m){ - List list = questions.get(cno); + List list = questions[cno]; for(Iterator it = list.iterator(); it.hasNext();){ Member member = (Member) it.next(); if(member.getNickname() == m.getNickname()){ @@ -66,7 +66,7 @@ } - public int sizeQuestions(){return questions.size();} + public int sizeQuestions(int cno){return questions[cno].size();} //openlist操作 diff --git a/src/main/java/com/ntlab/irisserver/resources/TestRest.java b/src/main/java/com/ntlab/irisserver/resources/TestRest.java index ff26ad3..4699fa7 100644 --- a/src/main/java/com/ntlab/irisserver/resources/TestRest.java +++ b/src/main/java/com/ntlab/irisserver/resources/TestRest.java @@ -1,5 +1,6 @@ package com.ntlab.irisserver.resources; +import com.ntlab.irisserver.entities.Drawing; import com.ntlab.irisserver.entities.Game; import com.ntlab.irisserver.entities.Member; import com.ntlab.irisserver.entities.Room; @@ -52,7 +53,7 @@ @PUT @Path("/test") - public void putTestRoom(){ + public void putTestRoom() throws IOException { KeywordManager km = KeywordManager.getInstance(); RoomManager rm = RoomManager.getInstance(); rm.createTestRoom(); @@ -88,7 +89,7 @@ //両部屋:gameインスタンス作成,stateの初期化 String path = null; dr.setState(2); - gr.setState(3); + gr.setState(2); try { path = applicationContext.getResource("file:").getFile().getAbsolutePath()+"/apache-tomcat-9.0.10/webapps/irisdata/keywords.txt"; @@ -100,6 +101,69 @@ Game game = new Game(gr, keywords); //gametest部屋:絵の格納 + for(int i = 0; i < 16; i++){ + Drawing draw = new Drawing(); + switch (i) { + case 0: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test01.jpg"; + break; + case 1: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test02.jpg"; + break; + case 2: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test03.jpg"; + break; + case 3: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test04.jpg"; + break; + case 4: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test05.jpg"; + break; + case 5: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test06.jpg"; + break; + case 6: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test07.jpg"; + break; + case 7: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test08.jpg"; + break; + case 8: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test09.jpg"; + break; + case 9: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test10.jpg"; + break; + case 10: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test11.jpg"; + break; + case 11: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test12.jpg"; + break; + case 12: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test13.jpg"; + break; + case 13: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test14.jpg"; + break; + case 14: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test15.jpg"; + break; + case 15: + path = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image/test16.jpg"; + break; + default: + break; + } + draw.setDrawing(path); + if(i<8){ + game.putDrawing(i*2, draw); + }else{ + game.putDrawing(i*2-15, draw); + } + + } + } diff --git a/src/main/java/com/ntlab/irisserver/resources/TurnsRest.java b/src/main/java/com/ntlab/irisserver/resources/TurnsRest.java index 088e7ad..1a5d546 100644 --- a/src/main/java/com/ntlab/irisserver/resources/TurnsRest.java +++ b/src/main/java/com/ntlab/irisserver/resources/TurnsRest.java @@ -101,25 +101,25 @@ //------------------------------------------------------------------------ // rooms/{rid}/game/turns/{tno}/questions: -// @GET //カードごとの疑っている人のリストを取得...は動かなくて糞 -// @Path("/{rid}/game/turns/{tno}/questions") -// @Produces(MediaType.APPLICATION_JSON) -// public List getqmember(@PathParam("rid") String rid, @PathParam("tno") int tno, @FormParam("cno") int cno){ -// -// RoomManager rm = RoomManager.getInstance(); -// Room room = rm.getRoom(rid); -// Game game = room.getGame(); -// Turn t = game.getTurn(tno); -// -// if (t == null) { -// //部屋がなければエラー -// var response = Response.status(Response.Status.NO_CONTENT); -// response.status(404).entity("部屋が存在しません"); -// throw new WebApplicationException(response.build()); -// } -// -// return t.getQuestions(cno); -// } + @GET //カードごとの疑っている人のリストを取得...は動かなくて糞 + @Path("/{rid}/game/turns/{tno}//questions") + @Produces(MediaType.APPLICATION_JSON) + public List[] getqmember(@PathParam("rid") String rid, @PathParam("tno") int tno){ + + RoomManager rm = RoomManager.getInstance(); + Room room = rm.getRoom(rid); + Game game = room.getGame(); + Turn t = game.getTurn(tno); + + if (t == null) { + //部屋がなければエラー + var response = Response.status(Response.Status.NO_CONTENT); + response.status(404).entity("部屋が存在しません"); + throw new WebApplicationException(response.build()); + } + + return t.getQuestionsList(); + } @POST //怪しいの切り替え @Path("/{rid}/game/turns/{tno}/questions") @@ -174,6 +174,7 @@ Turn t = game.getTurn(tno); Cell card = game.getCell(cno); + t.addOpenList(card); card.setIsOpen(true); }