/.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

  1. package info.reflectionsofmind.connexion.platform.cli;
  2. import info.reflectionsofmind.connexion.platform.control.control.IConnectControl;
  3. import info.reflectionsofmind.connexion.platform.control.control.IHostControl;
  4. import info.reflectionsofmind.connexion.platform.control.control.IMainControl;
  5. import info.reflectionsofmind.connexion.platform.game.IGame;
  6. public class MainInterpreter implements IMainControl, IInterpreter
  7. {
  8. private final CommandLineRoot root;
  9. public MainInterpreter(final CommandLineRoot root)
  10. {
  11. this.root = root;
  12. }
  13. public CommandLineRoot getRoot()
  14. {
  15. return this.root;
  16. }
  17. public IHostControl hostGame(final IGame game)
  18. {
  19. final HostInterpreter control = new HostInterpreter();
  20. getRoot().setInterpreter(control);
  21. return control;
  22. }
  23. public IConnectControl joinGame(final IGame game)
  24. {
  25. final ConnectInterpreter control = new ConnectInterpreter();
  26. getRoot().setInterpreter(control);
  27. return control;
  28. }
  29. public void interpret(final String command)
  30. {
  31. if ("host".equals(command)) hostGame(getRoot().getConfiguration().getGames().get(0));
  32. if ("join".equals(command)) joinGame(getRoot().getConfiguration().getGames().get(0));
  33. }
  34. }