예제 #1
0
  @Test
  public void testMaximumVisitsAchievementsShouldWorkAsExpected() throws Exception {
    AchievementBuilder achievementBuilder = new AchievementBuilder();
    achievementBuilder.setId("VISIT_ANY_DESERT_TWICE");
    achievementBuilder.setName("Visit Any Desert Twice");
    CounterMap<Id> maximumVisits = new CounterMap<>();
    maximumVisits.incrementCounter(new Id("DESERT"), 2);
    achievementBuilder.setMaximumNumberOfVisits(maximumVisits);
    Achievement achievement = achievementBuilder.createAchievement();

    Statistics statistics = new Statistics();
    Assert.assertFalse(achievement.isFulfilled(statistics));
    statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"));
    Assert.assertFalse(achievement.isFulfilled(statistics));
    statistics.getExplorationStatistics().addVisit(new Point(1, 1, 1), new Id("DESERT"));
    Assert.assertFalse(achievement.isFulfilled(statistics));
    statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"));
    Assert.assertTrue(achievement.isFulfilled(statistics));
  }
예제 #2
0
  @Test
  public void testVisitedLocationsBasedAchievementsShouldWorkAsExpected() throws Exception {
    AchievementBuilder achievementBuilder = new AchievementBuilder();
    achievementBuilder.setId("VISIT_TWO_DIFFERENT_DESERTS");
    achievementBuilder.setName("Visit Two Different Deserts");
    CounterMap<Id> visitedLocations = new CounterMap<>();
    visitedLocations.incrementCounter(new Id("DESERT"), 2);
    achievementBuilder.setVisitedLocations(visitedLocations);
    Achievement achievement = achievementBuilder.createAchievement();

    Statistics statistics = new Statistics();
    Assert.assertFalse(achievement.isFulfilled(statistics));
    statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"));
    Assert.assertFalse(achievement.isFulfilled(statistics));
    statistics.getExplorationStatistics().addVisit(new Point(0, 0, 0), new Id("DESERT"));
    Assert.assertFalse(achievement.isFulfilled(statistics));
    statistics.getExplorationStatistics().addVisit(new Point(1, 1, 1), new Id("DESERT"));
    Assert.assertTrue(achievement.isFulfilled(statistics));
  }