diff --git a/scripts/scripta b/scripts/scripta new file mode 100644 index 0000000..17f5014 --- /dev/null +++ b/scripts/scripta @@ -0,0 +1,30 @@ +WELCOME: +DLG Hi, welcome to the game. Are you ready to begin? +OPT YES -> BEGIN +OPT NO -> BEGINANYWAY +OPT IDK -> BEGINANYWAY +FIN + + +BEGIN: +DLG Okidokey, lets get started + +BEGINANYWAY: +DLG Well too bad we are starting anyway. +DLG Now pick a class. +OPT ROGUE -> ROGUE +OPT WARRIOR -> WARRIOR +OPT MAGE -> MAGE +FIN + +ROGUE: +DLG AH the rogue. Agile and clever +HALT + +WARRIOR: +DLG Warrior powerful and brave +HALT + +MAGE: +DLG You are a mage, Master of the Arcana. +HALT diff --git a/src/Game.java b/src/Game.java index 763e2eb..2d70b06 100644 --- a/src/Game.java +++ b/src/Game.java @@ -1,4 +1,8 @@ -import java.util.Scanner; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.*; /** * This class creates an object that will contain the core variables and methods of the game. @@ -9,6 +13,7 @@ public class Game { public Game() { this.playerName = "Jeff"; // name defaults to jeff. + } /** @@ -16,11 +21,13 @@ public class Game { */ - public void start() { + public void start() throws IOException { prntDlg("WELCOME TO DECISIONS"); // Welcome message playerName = usrInpt("Please enter your name:"); prntDlg("Well hello, $N"); + + readStory("scripts/scripta"); } /** @@ -29,17 +36,121 @@ public class Game { * * @param text the text you want to display. */ + + // TODO: Make this more readable. public void prntDlg(String text) { text = text.replace("$N", playerName); - System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"); + System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(text); - System.out.println("\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } + /** + * USER INPUT: it gets user input and returns it for use. + * + * @param text The text you want to prompt them with. + * @return The text the user entered. + */ public String usrInpt(String text) { Scanner myObj = new Scanner(System.in); // Create a Scanner object prntDlg(text); return myObj.nextLine(); } + + /** + * This function will interpret a story file you created. + *
+ * The story file must follow a fairly strict syntax.
+ * This is documented separately.
+ * This function determines how our story files will be read.
+ * It's VERY IMPORTANT to understand this function
+ *
+ * @param storyName the name of the story file you have stored.
+ * @throws IOException if something goes wrong.
+ */
+ public void readStory(String storyName) throws IOException {
+ // This is the name of the next branch to read.
+ // It is updated in the FIN command.
+ String nextBranch;
+
+
+ // This is an array of options to be compiled for the player to choose from.
+ // They are updated using the OPT command.
+ // They are compiled in the FIN then cleared afterwards for the next branch.
+ ArrayList