I'm using a switch in order to understand which button was clicked. There are 6 total buttons. I'm using this:
public void characterClick(View v){
if(status){
switch (v.getId()){
case R.id.first:
demoniacList.add(new Demoniac());
first.setEnabled(false);
case R.id.second:
guardList.add(new Guard());
second.setEnabled(false);
case R.id.third:
masonsList.add(new Masons());
masonsList.add(new Masons());
third.setEnabled(false);
case R.id.fourth:
mediumList.add(new Medium());
fourth.setEnabled(false);
case R.id.fifth:
if (demoniacList.size() + guardList.size() + masonsList.size() +
mediumList.size() + villagerList.size() + werehamsterList.size() < players.size()-1) {
villagerList.add(new Villager());
} else {
villagerList.add(new Villager());
fifth.setEnabled(false);
}
case R.id.sixth:
werehamsterList.add(new Werehamster());
sixth.setEnabled(false);
}
} else {
switch (v.getId()){
case R.id.first:
demoniacList.remove(demoniacList.size()-1);
first.setEnabled(false);
case R.id.second:
guardList.remove(guardList.size()-1);
second.setEnabled(false);
case R.id.third:
masonsList.remove(masonsList.size()-1);
masonsList.remove(masonsList.size()-1);
third.setEnabled(false);
case R.id.fourth:
mediumList.remove(mediumList.size()-1);
fourth.setEnabled(false);
case R.id.fifth:
villagerList.remove(villagerList.size()-1);
if(villagerList.size() == 0){
fifth.setEnabled(false);
}
case R.id.sixth:
werehamsterList.remove(werehamsterList.size()-1);
sixth.setEnabled(false);
}
}
}
Each button should run the same method but each single button has a different case in the switch so each button has a different behavior.
Now, when I click the Guard one (the second) 4 buttons get disabled in total, not just the Gurad one as it should be instead.
Any ideas why? If you think I should add more code just tell me in the Idea!
