Merge branch 'master' of http://nitta-lab-www.is.konan-u.ac.jp/gitbucket/git/nitta-lab-2022/IrisServer into Shimokawa
commit 0375e84679e14a4b981a9c928e657e50ebdff950
2 parents 1cbcd6c + abbb712
g-akagi authored on 15 Jul 2022
Showing 6 changed files
View
32
src/main/java/com/ntlab/irisserver/entities/Game.java
String keyword = keywordList.get(dno);
return keyword;
}
 
public Map<Integer, String> getKeywords() {
return keywordList;
public List<String> getKeywords() {
List<String> keywords = new ArrayList<>();
for(int i=0; i<16; i++){
keywords.add(keywordList.get(map.get(i)));
}
return keywords;
}
 
public List<Boolean> getOpens(){
List<Boolean> opens= new ArrayList<>();
for(int i=0; i<16; i++){
Cell cell = cellList.get(i);
boolean isOpen = cell.getIsOpen();
opens.add(isOpen);
}
return opens;
}
 
public Map<Member, List<Integer>> getAssignments(){
return assignments;
View
2
■■■
src/main/java/com/ntlab/irisserver/resources/DrawingsRest.java
String pathDirectory = "";
String drawingPath = "";
 
try {
pathDirectory = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps";
pathDirectory = applicationContext.getResource("file:").getFile().getAbsolutePath() + "/apache-tomcat-9.0.10/webapps/irisdata/image";
System.out.println("kota0210/保存前のディレクトリのパス:" + pathDirectory.toString());
System.out.println("kota0210/クライアントから届いたBASE64の文字列"+ drawingStr.toString());
// utilsのBase64Decodeにデコードしてもらって、そのついでに保存してもらう
drawingPath = Base64Decode.saveAsFile(rid, dno, pathDirectory, drawingStr);
View
12
src/main/java/com/ntlab/irisserver/resources/GameRest.java
public List<String> getKeywords(@PathParam("rid") String rid){
RoomManager rm = RoomManager.getInstance();
Room room = rm.getRoom(rid);
Game game = room.getGame();
Map<Integer, String> keywordList = game.getKeywords();
List<Integer> map = game.getMap();
List<String> keywords = new ArrayList<>();
for(int i=0; i<16; i++){
keywords.add(keywordList.get(map.get(i)));
}
List<String> keywords = game.getKeywords();
return keywords;
}
 
}
View
11
src/main/java/com/ntlab/irisserver/resources/GameStateRest.java
@Path("/{rid}/game/opens")
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Boolean> getOpens(@PathParam("rid") String rid){
List<Boolean> opens= new ArrayList<>();
RoomManager rm = RoomManager.getInstance();
Room room = rm.getRoom(rid);
Game game = room.getGame();
for(int i=0; i<16; i++){
Cell cell = game.getCell(i);
boolean isOpen = cell.getIsOpen();
opens.add(isOpen);
}
List<Boolean> opens = game.getOpens();
return opens;
}
 
@Path("/{rid}/game/turn")
View
48
src/main/java/com/ntlab/irisserver/resources/TestRest.java
package com.ntlab.irisserver.resources;
 
import com.ntlab.irisserver.entities.Game;
import com.ntlab.irisserver.entities.Member;
import com.ntlab.irisserver.entities.Room;
import com.ntlab.irisserver.models.KeywordManager;
import com.ntlab.irisserver.models.RoomManager;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
 
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Random;
 
@Component
@Path("/rooms")
 
public class TestRest {
public class TestRest implements ApplicationContextAware {
 
private org.springframework.context.ApplicationContext applicationContext;
 
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
 
@PUT
@Path("/test")
public void putTestRoom(){
infog.setBelongs("b");
}
}
 
//drawtestの設定
//両部屋:gameインスタンス作成,stateの初期化
String path = null;
dr.setState(2);
dr.setState(3);
try {
path = applicationContext.getResource("file:").getFile().getAbsolutePath()+"/apache-tomcat-9.0.10/webapps/irisdata/keywords.txt";
} catch (IOException e) {
e.printStackTrace();
}
String[] keywords = km.getKeywords(path);
Game dgame = new Game(dr, keywords);
Game game = new Game(gr, keywords);
 
//gametest部屋:絵の格納
 
}
 
 
}
View
4
src/main/java/com/ntlab/irisserver/utils/Base64Decode.java
System.out.println("kota0210/デコードできた");
 
//ファイルを作成する
String fileName = rid + "-" + dno.toString() + ".png";
String path2 = "irisdata";
String path = path1 + "/" + path2 + "/" + fileName;
String path = path1 + "/" + fileName;
 
System.out.println("kota0210/path作れました"+path.toString());
 
File file = new File(path);