I am trying to create a Rock, Paper, Scissors game (where you play against a bot) using four different classes (SSPViewer, SSPController, SSPPlayer and SSPUserInput) + one main class. The game is supposed to use two different windows/JPanels. One with buttons that the user can click on and one showing the score etc.
The current problem that I have is that I cannot get the game to count score at all. Everything else about the design within the program is working as it should. I think that it has to do with some logic in the code, but I cannot seem to find the problem.
Here is some code from the Viewer and Controller-classes:
Controller:
public void game(int Humanchoice){
if (pointsBot < 3 && pointsHuman < 3){
int computer = bot.newChoice();
// rock = 1, paper = 2, scissors = 3;
//reglerna - poäng utdelning
if (Humanchoice == 1 && computer == 3){
pointsHuman++;
viewer.setScoreHuman(pointsHuman);
}
else if (Humanchoice == 2 && computer == 3){
pointsBot++;
viewer.setScoreBot(pointsBot);
}
else if (Humanchoice == 1 && computer == 2){
pointsBot++;
viewer.setScoreBot(pointsBot);
}
else if (Humanchoice == 3 && computer == 2){
pointsHuman++;
viewer.setScoreHuman(pointsHuman);
}
else if (Humanchoice == 2 && computer == 1){
pointsHuman++;
viewer.setScoreHuman(pointsHuman);
}
else if (Humanchoice == 3 && computer == 1){
pointsBot++;
viewer.setScoreBot(pointsBot);
}
}
}
Viewer:
public void setHumanChoice(String ChoiceHuman) {
Choice.setText(ChoiceHuman);
}
public void setBotChoice(String ChoiceBot) {
Choice2.setText(ChoiceBot);
}
public void setScoreHuman(int pointsHuman) {
HumanNbr.setText("" + pointsHuman);
}
public void setScoreBot(int pointsBot) {
ComputerNbr.setText("" + pointsBot);
}
}