/.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
- package info.reflectionsofmind.connexion.platform.cli;
- import info.reflectionsofmind.connexion.platform.control.control.IConnectControl;
- import info.reflectionsofmind.connexion.platform.control.control.IHostControl;
- import info.reflectionsofmind.connexion.platform.control.control.IMainControl;
- import info.reflectionsofmind.connexion.platform.game.IGame;
-
- public class MainInterpreter implements IMainControl, IInterpreter
- {
- private final CommandLineRoot root;
-
- public MainInterpreter(final CommandLineRoot root)
- {
- this.root = root;
- }
-
- public CommandLineRoot getRoot()
- {
- return this.root;
- }
-
- public IHostControl hostGame(final IGame game)
- {
- final HostInterpreter control = new HostInterpreter();
- getRoot().setInterpreter(control);
- return control;
- }
-
- public IConnectControl joinGame(final IGame game)
- {
- final ConnectInterpreter control = new ConnectInterpreter();
- getRoot().setInterpreter(control);
- return control;
- }
-
- public void interpret(final String command)
- {
- if ("host".equals(command)) hostGame(getRoot().getConfiguration().getGames().get(0));
- if ("join".equals(command)) joinGame(getRoot().getConfiguration().getGames().get(0));
- }
- }