Search in sources :

Example 1 with PlayerAchievement

use of com.faforever.client.api.dto.PlayerAchievement in project downlords-faf-client by FAForever.

the class AchievementItemControllerTest method testSetPlayerAchievementStandardDoesntUpdateProgress.

@Test
public void testSetPlayerAchievementStandardDoesntUpdateProgress() throws Exception {
    instance.setAchievementDefinition(AchievementDefinitionBuilder.create().defaultValues().type(AchievementType.STANDARD).get());
    PlayerAchievement playerAchievement = PlayerAchievementBuilder.create().defaultValues().state(com.faforever.client.api.dto.AchievementState.UNLOCKED).currentSteps(50).get();
    instance.setPlayerAchievement(playerAchievement);
    assertThat(instance.progressBar.getProgress(), is(0.0));
}
Also used : PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 2 with PlayerAchievement

use of com.faforever.client.api.dto.PlayerAchievement in project downlords-faf-client by FAForever.

the class AchievementItemControllerTest method testSetPlayerAchievementIdDoesntMatch.

@Test(expected = IllegalStateException.class)
public void testSetPlayerAchievementIdDoesntMatch() throws Exception {
    instance.setAchievementDefinition(AchievementDefinitionBuilder.create().defaultValues().get());
    PlayerAchievement playerAchievement = PlayerAchievementBuilder.create().defaultValues().achievementId("foobar").get();
    instance.setPlayerAchievement(playerAchievement);
}
Also used : PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 3 with PlayerAchievement

use of com.faforever.client.api.dto.PlayerAchievement 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));
        });
    }
}
Also used : Node(javafx.scene.Node) PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) AchievementItemController(com.faforever.client.achievements.AchievementItemController) AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition)

Example 4 with PlayerAchievement

use of com.faforever.client.api.dto.PlayerAchievement in project downlords-faf-client by FAForever.

the class AchievementServiceImplTest method testGetPlayerAchievementsForCurrentUser.

@Test
public void testGetPlayerAchievementsForCurrentUser() throws Exception {
    instance.playerAchievements.add(new PlayerAchievement());
    instance.getPlayerAchievements(PLAYER_ID);
    verify(fafService).addOnMessageListener(ArgumentMatchers.any(), ArgumentMatchers.any());
    verifyNoMoreInteractions(fafService);
}
Also used : PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) Test(org.junit.Test)

Example 5 with PlayerAchievement

use of com.faforever.client.api.dto.PlayerAchievement in project downlords-faf-client by FAForever.

the class AchievementItemControllerTest method testSetPlayerAchievementRevealed.

@Test
public void testSetPlayerAchievementRevealed() throws Exception {
    instance.setAchievementDefinition(AchievementDefinitionBuilder.create().defaultValues().get());
    PlayerAchievement playerAchievement = PlayerAchievementBuilder.create().defaultValues().state(com.faforever.client.api.dto.AchievementState.REVEALED).get();
    instance.setPlayerAchievement(playerAchievement);
    assertThat(instance.imageView.getEffect(), is(instanceOf(ColorAdjust.class)));
    assertThat(instance.imageView.getOpacity(), is(0.5));
}
Also used : PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

PlayerAchievement (com.faforever.client.api.dto.PlayerAchievement)8 Test (org.junit.Test)7 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)4 AchievementDefinition (com.faforever.client.api.dto.AchievementDefinition)2 AchievementItemController (com.faforever.client.achievements.AchievementItemController)1 Node (javafx.scene.Node)1