Exemple #1
0
  @Override
  public ProjectTask createProjectTask(ProjectTaskModel projectTask) {
    ProjectTask result = null;

    try {
      SdSystemFactory sdSystemFactory = new SdSystemFactory();
      SdSystemModel sdSystemModel =
          ((SdSystemBasedSimulatorModel) projectTask.getSimulationModel()).getSdSystemModel();

      SdSystem sdSystem = (SdSystem) sdSystemFactory.createSdSystem(sdSystemModel);
      EquationModel eqModel =
          ((EquationProgressModel) projectTask.getProgressEquation()).getEquationModel();
      IEquation progressEquation = sdSystemFactory.createEquation(eqModel);
      result =
          new ProjectTask(
              projectTask.getName(),
              projectTask.getDescription(),
              new SdSystemBasedSimulator(sdSystem),
              progressEquation);
    } catch (GameException e) {
      e.printStackTrace();
    }

    return result;
  }
Exemple #2
0
  @Override
  public MarketPlace createMarketPlace(MarketPlaceModel marketPlace) {
    MarketPlace result = null;

    try {
      Map<String, Employee> employees = new TreeMap<>();
      for (MarketPlaceModel.AvailableEmployees.Entry entry :
          marketPlace.getAvailableEmployees().getEntry()) {
        employees.put(entry.getKey(), createEmployee(entry.getValue()));
      }

      result = new MarketPlace(employees);
    } catch (GameException e) {
      e.printStackTrace();
    }

    return result;
  }
Exemple #3
0
  /* (non-Javadoc)
   * @see org.promasi.game.IGameFactory#createCompany(org.promasi.game.model.CompanyModel)
   */
  @Override
  public Company createCompany(CompanyModel company) {
    Company result = null;

    try {
      result =
          new Company(
              company.getName(),
              company.getDescription(),
              new LocalTime(company.getStartTime()),
              new LocalTime(company.getEndTime()),
              company.getBudget(),
              company.getPrestigePoints());
    } catch (GameException e) {
      e.printStackTrace();
    }

    return result;
  }
Exemple #4
0
  public void placeShip(Ship ship) {
    if (!shipIsPlaceable(ship)) {
      throw GameException.CreateShipNotPlaceable();
    }

    for (Position position : ship.getShipPositions()) {
      setShipAtPosition(ship, position);
    }
    ships.add(ship);
  }
Exemple #5
0
  @Override
  public GameModel createGameModel(GameModelModel gameModel) {
    GameModel result = null;

    try {
      Queue<Project> projects = new LinkedList<>();
      for (ProjectModel projectModel : gameModel.getProjectModel()) {
        projects.add(createProject(projectModel));
      }

      result =
          new GameModel(
              gameModel.getGameName(),
              gameModel.getGameDescription(),
              createMarketPlace(gameModel.getMarketPlaceModel()),
              createCompany(gameModel.getCompanyModel()),
              projects);
    } catch (GameException e) {
      e.printStackTrace();
    }

    return result;
  }
Exemple #6
0
  /* (non-Javadoc)
   * @see org.promasi.game.IGameFactory#createProject(org.promasi.game.model.ProjectModel)
   */
  @Override
  public Project createProject(ProjectModel project) {
    Project result = null;

    try {
      Map<String, ProjectTask> tasks = new TreeMap<>();
      for (ProjectModel.ProjectTasks.Entry entry : project.getProjectTasks().getEntry()) {
        tasks.put(entry.getKey(), createProjectTask(entry.getValue()));
      }

      result =
          new Project(
              project.getName(),
              project.getDescription(),
              project.getProjectDuration(),
              tasks,
              project.getProjectPrice(),
              project.getDifficultyLevel());
    } catch (GameException e) {
      e.printStackTrace();
    }

    return result;
  }
Exemple #7
0
  @Override
  public Employee createEmployee(EmployeeModel employee) {
    Employee result = null;

    try {
      Map<String, Double> skills = new TreeMap<>();
      for (EmployeeModel.EmployeeSkills.Entry entry : employee.getEmployeeSkills().getEntry()) {
        skills.put(entry.getKey(), entry.getValue());
      }

      result =
          new Employee(
              employee.getFirstName(),
              employee.getLastName(),
              employee.getEmployeeId(),
              employee.getCurriculumVitae(),
              employee.getSalary(),
              skills);
    } catch (GameException e) {
      e.printStackTrace();
    }

    return result;
  }
Exemple #8
0
  public void shootAt(Position position) {
    if (!positionIsShootableAt(position)) {
      throw GameException.CreateAlreadyShotAt();
    }

    shots2DMap[position.getY()][position.getX()] = true;
    Ship ship = getShipAtPosition(position);

    shots.add(position);

    if (ship != null) {
      ship.hit();
      messageQueue.addHitMessage(position, ship);
    } else {
      messageQueue.addMissMessage(position);
    }
  }