-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGameSystem.java
More file actions
160 lines (137 loc) · 5.81 KB
/
GameSystem.java
File metadata and controls
160 lines (137 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;
//Haseeb Saadut
public class GameSystem
{
public String credits;
public String Help;
public static void newGame() throws IOException
{
Scanner input = new Scanner(System.in);
System.out.println("Welcome player to ANIME: Please enter username");
String userinput = input.nextLine();
Player playerName = new Player(userinput);
File f = new File(userinput + " -Game.txt");
System.out.println("Creating game...");
PrintWriter pw = new PrintWriter((new FileWriter(f)));
pw.println(userinput);
pw.close();
}
public void loadGame() throws IOException
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the name of the file");
String playerName = input.next();
File f = new File(playerName + " -Game.txt");
if(f.exists())
{
String fileName = (playerName + " -Game.txt");
String GameTextLine = null;
try{
FileReader fr = new FileReader(fileName);
BufferedReader bufferedReader = new BufferedReader(fr);
System.out.println(fileName);
while((GameTextLine = bufferedReader.readLine()) != null) {
System.out.println(GameTextLine);
}
bufferedReader.close();
}
catch(FileNotFoundException ex) {
System.out.println("Error loading file " + fileName);
}
catch(IOException ex) {
ex.printStackTrace();
}
}
}
public void howToPlay()
{
System.out.println("Command Name Command Description ");
System.out.println("------------------------------------------------------------------------------------------------------------------------------");
System.out.println("New Game Creates a new Game ");
System.out.println("Load Game This will load a gamestate at previous savepoint ");
System.out.println("Display Credits Shows names of people who contributed to game ");
System.out.println("Quit Game Quits the game after confirming with player ");
System.out.println("Move Changes the location of the player after answering a prompt of which rooms are available to travel to");
System.out.println("Display Room Scene Describe for the player once more what is in the room ");
System.out.println("Search Room Player will search the room for an item that will go into inventory ");
System.out.println("Equip item Take an item found from room or inventory and equip onto player ");
System.out.println("Use Item Use an item for a variety of effects that will either affect the player or monster ");
System.out.println("Help Display a list of commands that will tell the player what he can do at any point in the game ");
System.out.println("Save Game Gives code so that player may enter that Title Screen to re-enter the game with the same progress ");
System.out.println("Quit Game Quits the game without saving");
System.out.println("Attack Gives player the action to attack an enemy with/without weapon ");
System.out.println("Use Item Allows player to use item in game for a variety of effects");
System.out.println("Run Allows player the option to flee from enemy");
System.out.println("Ask Riddle Ask the monster if they have any riddles");
System.out.println("Answer Riddle Gives player option to input an answer for a question");
System.out.println("Get Hint Shows a hint for the riddle ");
}
public void displayCredits()
{
System.out.println("Credit goes to these people for making this game:");
System.out.println("Haseeb Saadut, Jose Tenorio, Carlan Henry, Noble");
System.out.println();
System.out.println("And thanks to these people for making us work on it:");
System.out.println("Dale Burke, Danyelle Noortajalli, Ethan Patterson, JP Sprouse");
}
public void quitGame()
{
System.out.println("The game will now close...");
System.out.println("Are you sure?");
System.out.println("Yes No");
Scanner input = new Scanner(System.in);
String userinput = input.nextLine();
if(userinput.equals("yes"))
{
System.exit(1);
}
else
{
return;
}
}
public static void main (String args[]) throws IOException
{
Scanner input = new Scanner(System.in);
System.out.println("Welcome to the A Night To The Movies project: ");
System.out.println(" 1. New Game" );
System.out.println(" 2. Load Game");
System.out.println(" 3. Help");
System.out.println(" 4. Credits");
System.out.println(" 5. Quit");
int userInput = input.nextInt();
if (userInput == 1)
{
GameSystem.newGame();
}
else if (userInput == 2)
{
new GameSystem().loadGame();
}
else if (userInput == 3)
{
new GameSystem().howToPlay();
}
else if (userInput == 4)
{
new GameSystem().displayCredits();
}
else if (userInput == 5)
{
new GameSystem().quitGame();
}
else
{
System.out.println("Invalid choice....please choose from the above options");
}
}
}