diff --git a/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java b/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java index fb9712b..2138508 100644 --- a/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java +++ b/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java @@ -48,6 +48,10 @@ ArrayList viewMembers = new ArrayList<>(); ArrayList oldMembers = new ArrayList<>(); List allMembers = new ArrayList<>(); + List Mteam = new ArrayList<>(); + List Steam = new ArrayList<>(); + List Rteam = new ArrayList<>(); + List Bteam = new ArrayList<>(); String roomId = "null"; String myName = "null"; //String nickname; @@ -228,10 +232,14 @@ startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - roomViewModel.startDrawing(roomId, myName); + if(ConditionStart()){ + roomViewModel.startDrawing(roomId, myName); - Intent intent = new Intent(OwnerRoomActivity.this,DrawingActivity.class); - startActivity(intent); + Intent intent = new Intent(OwnerRoomActivity.this,DrawingActivity.class); + startActivity(intent); + }else{ + Snackbar.make(v, "スタート条件を満たしていません", Snackbar.LENGTH_LONG).show(); + } } }); @@ -309,4 +317,36 @@ } } + public boolean ConditionStart() { + for(int i=0; i< allMembers.size(); i++){ + + if(allMembers.get(i).getMaster()){ + Mteam.add(i); + }else{ + Steam.add(i); + } + + if(allMembers.get(i).getBelongs().equals("r")){ + Rteam.add(i); + }else if(allMembers.get(i).getBelongs().equals("b")) { + Bteam.add(i); + } + + } + + if(Mteam.size() != 2){ + return false; + } + + if(Rteam.size() < 2){ + return false; + } + + if(Bteam.size() < 2){ + return false; + } + + return true; + } + } \ No newline at end of file