package com.ntlab.irisserver.resources; import com.ntlab.irisserver.entities.Member; import com.ntlab.irisserver.entities.Room; import com.ntlab.irisserver.models.RoomManager; import org.springframework.stereotype.Component; import javax.ws.rs.*; import java.util.List; @Component @Path("/rooms") public class MemberRest { //所属チーム(n:無所属, r:赤, b:青) String belongs = "n"; //スパイマスターかどうか boolean is_master = false; int i = 0; /* @GET @Path("/{rid}/members/{nickname}") public String getMember(@FormParam("rid") int rid, @FormParam("nickname") int nickname) { return "Hello World"; } */ // チーム変更・役職変更のメソッド @Path("/{rid}/members/{nickname}") @PUT public String putMember(@PathParam("rid") String rid, @FormParam("nickname") String nickname) { RoomManager rm = RoomManager.getInstance(); Room room = rm.getRoom("rid"); List<Member> m = room.getMembers(); return "変更しました"; } // プレイヤーを退出させるメソッド @Path("/{rid}/members/{nickname}") @DELETE public String deleteMember(@PathParam("rid") String rid, @FormParam("nickname") String nickname) { RoomManager rm = RoomManager.getInstance(); Room room = rm.getRoom("rid"); List<Member> m = room.getMembers(); for( i = 0; i < 10; i++ ) { Member name = m.get(i); if ( nickname == name.getNickname() ) { nickname = null; } } return "退出しました"; } }