From 949d479d9ce1ed42a347ab9efc1f72f78489c4e9 Mon Sep 17 00:00:00 2001 From: Friederike von Gruben Date: Thu, 2 Feb 2023 01:07:10 +0100 Subject: [PATCH] Earn gold with quiz You can earn some gold with your quiz now --- src/main/java/org/bitbiome/commands/QuizCommand.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bitbiome/commands/QuizCommand.java b/src/main/java/org/bitbiome/commands/QuizCommand.java index 5748d7b..2c1007d 100644 --- a/src/main/java/org/bitbiome/commands/QuizCommand.java +++ b/src/main/java/org/bitbiome/commands/QuizCommand.java @@ -32,7 +32,13 @@ public class QuizCommand implements CommandAPI { int eingabe = quizScanner.nextInt(); if (answerIsCorrect(eingabe, korrekteAntwort, antworten)) { - print("Richtige Antwort!\n"); + String playerpath = "src\\main\\resources\\playerconfig.json"; + JSONObject playerconfig = JsonParser.readJSONFile(playerpath); + int gold = playerconfig.getInt("gold"); + gold = gold + 5; + playerconfig.put("gold", gold); + JsonParser.writeObject(playerpath, playerconfig); + print("Richtig! Du hast 5 Münzen verdient.\nDein Münzstand beträgt: " + gold); } else { print("Leider falsch... Richtig ist: " + korrekteAntwort + "\n"); }