use of com.faforever.client.api.dto.AchievementDefinition in project downlords-faf-client by FAForever.
the class UserInfoWindowController method updatePlayerAchievements.
private void updatePlayerAchievements(List<? extends PlayerAchievement> playerAchievements) {
PlayerAchievement mostRecentPlayerAchievement = null;
ObservableList<Node> children = unlockedAchievementsContainer.getChildren();
Platform.runLater(children::clear);
for (PlayerAchievement playerAchievement : playerAchievements) {
AchievementItemController achievementItemController = achievementItemById.get(playerAchievement.getAchievement().getId());
achievementItemController.setPlayerAchievement(playerAchievement);
if (isUnlocked(playerAchievement)) {
Platform.runLater(() -> children.add(achievementItemController.getRoot()));
if (mostRecentPlayerAchievement == null || playerAchievement.getUpdateTime().compareTo(mostRecentPlayerAchievement.getUpdateTime()) > 0) {
mostRecentPlayerAchievement = playerAchievement;
}
}
}
if (mostRecentPlayerAchievement == null) {
mostRecentAchievementPane.setVisible(false);
} else {
mostRecentAchievementPane.setVisible(true);
AchievementDefinition mostRecentAchievement = achievementDefinitionById.get(mostRecentPlayerAchievement.getAchievement().getId());
if (mostRecentAchievement == null) {
return;
}
String mostRecentAchievementName = mostRecentAchievement.getName();
String mostRecentAchievementDescription = mostRecentAchievement.getDescription();
Platform.runLater(() -> {
mostRecentAchievementNameLabel.setText(mostRecentAchievementName);
mostRecentAchievementDescriptionLabel.setText(mostRecentAchievementDescription);
mostRecentAchievementImageView.setImage(achievementService.getImage(mostRecentAchievement, UNLOCKED));
});
}
}
use of com.faforever.client.api.dto.AchievementDefinition in project downlords-faf-client by FAForever.
the class FafApiAccessorImplTest method testGetPlayerAchievements.
@Test
@SuppressWarnings("unchecked")
public void testGetPlayerAchievements() {
PlayerAchievement playerAchievement1 = new PlayerAchievement();
playerAchievement1.setId("1");
playerAchievement1.setAchievement(new AchievementDefinition().setId("1-2-3"));
PlayerAchievement playerAchievement2 = new PlayerAchievement();
playerAchievement2.setId("2");
playerAchievement2.setAchievement(new AchievementDefinition().setId("2-3-4"));
List<PlayerAchievement> result = Arrays.asList(playerAchievement1, playerAchievement2);
when(restOperations.getForObject(anyString(), eq(List.class))).thenReturn(result).thenReturn(emptyList());
assertThat(instance.getPlayerAchievements(123), is(result));
verify(restOperations).getForObject("/data/playerAchievement?filter=player.id==\"123\"&page[size]=10000&page[number]=1", List.class);
}
use of com.faforever.client.api.dto.AchievementDefinition in project downlords-faf-client by FAForever.
the class FafApiAccessorImplTest method testGetAchievementDefinition.
@Test
public void testGetAchievementDefinition() {
AchievementDefinition achievementDefinition = new AchievementDefinition();
achievementDefinition.setId("1-2-3");
when(restOperations.getForObject(startsWith("/data/achievement/123"), eq(AchievementDefinition.class), anyMap())).thenReturn(achievementDefinition);
assertThat(instance.getAchievementDefinition("123"), is(achievementDefinition));
}
use of com.faforever.client.api.dto.AchievementDefinition in project downlords-faf-client by FAForever.
the class AchievementServiceImplTest method testLoadAndCacheImageRevealed.
@Test
public void testLoadAndCacheImageRevealed() throws Exception {
AchievementDefinition achievementDefinition = AchievementDefinitionBuilder.create().defaultValues().get();
Path cacheSubDir = Paths.get("achievements").resolve(AchievementState.REVEALED.name().toLowerCase());
instance.getImage(achievementDefinition, REVEALED);
verify(assetService).loadAndCacheImage(new URL(achievementDefinition.getRevealedIconUrl()), cacheSubDir, null, 128, 128);
}
use of com.faforever.client.api.dto.AchievementDefinition in project downlords-faf-client by FAForever.
the class MockFafApiAccessor method getAchievementDefinition.
@Override
public AchievementDefinition getAchievementDefinition(String achievementId) {
AchievementDefinition achievementDefinition = new AchievementDefinition();
achievementDefinition.setName("Mock achievement");
achievementDefinition.setDescription("Congratulations! You read this text.");
achievementDefinition.setType(AchievementType.STANDARD);
return achievementDefinition;
}
Aggregations