diff --git a/src/main/java/game/StartDarkSoulsGame.java b/src/main/java/game/StartDarkSoulsGame.java index c744385..a4d91f7 100644 --- a/src/main/java/game/StartDarkSoulsGame.java +++ b/src/main/java/game/StartDarkSoulsGame.java @@ -96,6 +96,7 @@ public class StartDarkSoulsGame { choice1.setFont(normalFont); choice1.setFocusPainted(false); choice1.setActionCommand("c1"); + choice1.addActionListener(choiceHandler); choiceButtonPanel.add(choice1); choice2 = new JButton("Choice 2"); @@ -104,6 +105,7 @@ public class StartDarkSoulsGame { choice2.setFont(normalFont); choice2.setFocusPainted(false); choice2.setActionCommand("c2"); + choice2.addActionListener(choiceHandler); choiceButtonPanel.add(choice2); choice3 = new JButton("Choice 3"); @@ -112,6 +114,7 @@ public class StartDarkSoulsGame { choice3.setFont(normalFont); choice3.setFocusPainted(false); choice3.setActionCommand("c3"); + choice3.addActionListener(choiceHandler); choiceButtonPanel.add(choice3); choice4 = new JButton("Choice 4"); @@ -120,6 +123,7 @@ public class StartDarkSoulsGame { choice4.setFont(normalFont); choice4.setFocusPainted(false); choice4.setActionCommand("c4"); + choice4.addActionListener(choiceHandler); choiceButtonPanel.add(choice4); playerPanel = new JPanel(); @@ -158,7 +162,7 @@ public class StartDarkSoulsGame { townGate(); } public void townGate() { - position = "twonGate"; + position = "townGate"; mainTextArea.setText("You are at the Gate of the town.\n A guard is standing in front of you. WHAT DO YOU DO !?"); choice1.setText("Talk to the gurad "); choice2.setText("Attack the guard"); @@ -173,15 +177,32 @@ public class StartDarkSoulsGame { choice3.setText(""); choice4.setText(""); } - public class ChoiceHandler implements ActionListener{ - public void actionPerformed(ActionEvent event) { - String yourChoice = event.getActionCommand(); - } - } + + public class TitelScreenHandler implements ActionListener{ public void actionPerformed(ActionEvent event) { createGameScreen(); } } + public class ChoiceHandler implements ActionListener{ + public void actionPerformed(ActionEvent event) { + String yourChoice = event.getActionCommand(); + switch(position) { + case "townGate": + switch(yourChoice) { + case "c1": talkGuard(); break; + case "c2": break; + case "c3": break; + } + break; + case "talkGuard": + switch(yourChoice) { + case"c1": townGate();break; + } + break; + } + } + +} }