blob: dd548f15c2d55e320fc1ad9e62ff05ab39f8f81f (
plain)
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
|
package esieequest;
import java.util.Arrays;
import java.util.List;
import javax.swing.JApplet;
import esieequest.engine.GameEngine;
import esieequest.ui.View;
import esieequest.ui.rich.app.Applet;
import esieequest.ui.rich.app.Window;
import esieequest.ui.text.Console;
import esieequest.ui.text.FileReader;
/**
* The main class of the program.
*
* Instantiates the game and makes it possible to run it via the command line,
* as a graphical application in a window or as an applet.
*
* @author Pacien TRAN-GIRARD
* @author Benoît LUBRANO DI SBARAGLIONE
*/
public class Main extends JApplet {
private static final long serialVersionUID = 1L;
/**
* The applet initialiser. Automatically called when the program is started
* as an applet.
*/
@Override
public void init() {
final Applet applet = new Applet(this);
new GameEngine(applet);
}
/**
* The main initialiser for the windowed and the command line views.
* Automatically called when the program is started as a standalone
* application.
*
* @param args
* the command line arguments
*/
public static void main(final String[] args) {
final List<String> arguments = Arrays.asList(args);
View view;
if (arguments.contains("--file")) {
if (arguments.size() < 2) {
System.out.println("Error: no input file specified.");
return;
}
view = new FileReader(arguments.get(1));
} else if (arguments.contains("--console")) {
view = new Console();
} else {
view = new Window();
}
new GameEngine(view);
}
}
|