diff --git a/src/main/java/com/ntlab/irisserver/models/RoomManager.java b/src/main/java/com/ntlab/irisserver/models/RoomManager.java index e985294..0f658b0 100644 --- a/src/main/java/com/ntlab/irisserver/models/RoomManager.java +++ b/src/main/java/com/ntlab/irisserver/models/RoomManager.java @@ -1,9 +1,12 @@ package com.ntlab.irisserver.models; +import com.ntlab.irisserver.entities.Game; +import com.ntlab.irisserver.entities.Member; import com.ntlab.irisserver.entities.Room; import org.springframework.stereotype.Component; import javax.ws.rs.*; import java.util.*; +import java.util.Random; @Component public class RoomManager { @@ -17,6 +20,57 @@ return theInstance; } + //コンストラクタ------------------------------------------------------ + public RoomManager(){ + Room r = new Room("test", "aaa"); + rooms.put("test", r); + r.addMember("aaa"); + + //メンバー設定() + int length = 0; + char[] rch; + rch = new char[3]; + String rname; + while(length < 10){ + for(int i = 0; i<3; i++){ + Random random = new Random(); + rch[i] = (char)(random.nextInt(26) + 'a'); + } + rname = new String(rch); + r.addMember(rname); + List members = r.getMembers(); + length = members.size(); + } + + //チームシャッフル + List m = r.getMembers(); + Collections.shuffle(m); + for(int i=0; i < 10; i++){ + if(i >= m.size())break; + Member info = m.get(i); + if(i==0){ + info.setMaster(true); + r.changeTeamAndMaster(info.getNickname(), "r", true); + }else if(i==1){ + info.setMaster(true); + r.changeTeamAndMaster(info.getNickname(), "b", true); + }else{ + info.setMaster(false); + } + if(i % 2 == 0){ + info.setBelongs("r"); + }else{ + info.setBelongs("b"); + } + } + + //gameインスタンス作成、取得 + + + } + //----------------------------------------------------------------- + + public Room createRoom(String owner) { UUID uuid = UUID.randomUUID(); String rid = uuid.toString(); //uuid型からstring型に変換