package com.ntlab.irisserver; 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.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.web.bind.annotation.RestController; import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Random; @SpringBootApplication public class IrisServerApplication { public static void main(String[] args) { ApplicationContext applicationContext = SpringApplication.run(IrisServerApplication.class, args); String path; try { path = applicationContext.getResource("file:").getFile().getAbsolutePath()+"/apache-tomcat-9.0.10/webapps/irisdata/keywords.txt"; } catch (IOException e) { e.printStackTrace(); } KeywordManager km = KeywordManager.getInstance(); RoomManager rm = RoomManager.getInstance(); rm.createTestRoom(); Room dr = rm.getRoom("drawtest"); Room gr = rm.getRoom("gametest"); dr.addMember("draw"); gr.addMember("game"); //メンバー設定() 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); dr.addMember(rname); gr.addMember(rname); List<Member> members = dr.getMembers(); length = members.size(); } //チームシャッフル List<Member> dm = dr.getMembers(); List<Member> gm = gr.getMembers(); Collections.shuffle(dm); Collections.shuffle(gm); for(int i=0; i < 10; i++){ if(i >= dm.size())break; Member infod = dm.get(i); Member infog = gm.get(i); if(i==0){ infod.setMaster(true); infog.setMaster(true); dr.changeTeamAndMaster(infod.getNickname(), "r", true); gr.changeTeamAndMaster(infog.getNickname(), "r", true); }else if(i==1){ infod.setMaster(true); infog.setMaster(true); dr.changeTeamAndMaster(infod.getNickname(), "b", true); gr.changeTeamAndMaster(infog.getNickname(), "b", true); }else{ infod.setMaster(false); infog.setMaster(false); } if(i % 2 == 0){ infod.setBelongs("r"); infog.setBelongs("r"); }else{ infod.setBelongs("b"); infog.setBelongs("b"); } } //drawtestの設定 } }