PageRenderTime 31ms CodeModel.GetById 17ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/.metadata/.plugins/org.eclipse.core.resources/.history/f8/6060466f83a3001e1dff9ae635b3e1ee

https://bitbucket.org/fixpoint/connexion
#! | 40 lines | 34 code | 6 blank | 0 comment | 0 complexity | 63ae603f737812a902849016070e6ba0 MD5 | raw file
 1package info.reflectionsofmind.connexion.platform.cli;
 2import info.reflectionsofmind.connexion.platform.control.control.IConnectControl;
 3import info.reflectionsofmind.connexion.platform.control.control.IHostControl;
 4import info.reflectionsofmind.connexion.platform.control.control.IMainControl;
 5import info.reflectionsofmind.connexion.platform.game.IGame;
 6
 7public class MainInterpreter implements IMainControl, IInterpreter
 8{
 9	private final CommandLineRoot root;
10	
11	public MainInterpreter(final CommandLineRoot root)
12	{
13		this.root = root;
14	}
15	
16	public CommandLineRoot getRoot()
17	{
18		return this.root;
19	}
20	
21	public IHostControl hostGame(final IGame game)
22	{
23		final HostInterpreter control = new HostInterpreter();
24		getRoot().setInterpreter(control);
25		return control;
26	}
27	
28	public IConnectControl joinGame(final IGame game)
29	{
30		final ConnectInterpreter control = new ConnectInterpreter();
31		getRoot().setInterpreter(control);
32		return control;
33	}
34	
35	public void interpret(final String command)
36	{
37		if ("host".equals(command)) hostGame(getRoot().getConfiguration().getGames().get(0));
38		if ("join".equals(command)) joinGame(getRoot().getConfiguration().getGames().get(0));
39	}
40}