Я пишу карточную игру, и у меня есть конкретное логическое значение, которое я установил в false, CitizenLimiter. Я хочу установить для этого логического значения значение true, когда карта гражданина в моей игре играется в общей сложности 4 раза. Это должно позволить вам помешать вам разыграть карту и вместо этого разыграть другую карту. Моя проблема в том, что cardLimiter, переменная, которую я использую для подсчета количества раз, когда игра выигрывает, автоматически устанавливает в значение citizenLimiter значение true после первого использования карты. Что мне нужно сделать, чтобы решить эту проблему?
Я пытался использовать вложенный цикл, а также пытался установить переменную, необходимую для изменения значения логического значения на другое.
public static void emperorsTurn() {
if (cardLimiter <= 4){
citizenLimiter = true;
}
Random cards = new Random();
int computerinput = 0;
int numberx = 5;
for (int counter = 1; counter <= 3; counter++) {
computerinput = 1 + cards.nextInt(2);
}
Scanner sc = new Scanner(System.in);
System.out.println("Please pick the card you are playing. \n if you are playing the Emperor press 1, if you are playing the citizen press 2 ");
int userinput = sc.nextInt();
if (userinput == 1 && computerinput == 1 && emperorLimiter == false) {
System.out.println("you have played the emperor! \n the emperor is defeated by the slave");
emperorLimiter =true;
System.out.println("you can no longer use the emperor");
} else if ((userinput == 1 && computerinput == 1 && emperorLimiter == true)) {
System.out.println("you cannot play the emperor this turn \n you have played the citizen instead. The citizen is defeated by the slave");
//make it so that the win/ lose is shown here
} else if (userinput == 1 && computerinput == 2 && emperorLimiter == false) {
System.out.println("you have played the emperor the emperor defeats the citizen");
winOrLose();
numberx--;
} else if (userinput == 2 ) { //when the user input is 2
if (computerinput == 1 && citizenLimiter == false) {
System.out.println("you have played the citizen, this defeats the slave");
cardLimiter++;
} else if (computerinput == 2 && citizenLimiter == false) {
System.out.println("you have played the citizen, this ties with the citizen");
cardLimiter++;
}
if (computerinput==1 && citizenLimiter == true) {
System.out.println("you are out of citizen cards, you play the emperor instead, this is defeated by the slave");
//i need to make it so that once you are out of a certain type of card it plays the emperor instead
}
else if (computerinput == 2 && citizenLimiter == true ){
System.out.println("you are out of citizen cards, you play the emperor instead, this defeats the citizen");
}
}
}