Search in sources :

Example 1 with Quest

use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.

the class QuestController method solveQuest.

@RequestMapping(value = "/{questId}/solveQuest/", method = RequestMethod.PUT)
public void solveQuest(@PathVariable(value = "questId") final Long questId) {
    final Quest quest = this.questRepository.findOne(questId);
    if (quest != null) {
        quest.setStatus(QuestStates.SOLVED);
        questRepository.save(quest);
        gratificationService.rewardDevelopersForSolvingQuest(quest);
        adventureService.updateAdventure(quest.getAdventure());
    }
}
Also used : Quest(com.viadee.sonarQuest.entities.Quest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Quest

use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.

the class TaskController method addToQuest.

@CrossOrigin
@RequestMapping(value = "/{taskId}/addToQuest/{questId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public TaskDto addToQuest(@PathVariable(value = "taskId") final Long taskId, @PathVariable(value = "questId") final Long questId) {
    Task task = this.taskRepository.findOne(taskId);
    if (task != null) {
        final Quest quest = this.questRepository.findOne(questId);
        task.setQuest(quest);
        task.setStatus(TaskStates.OPEN);
        task = this.taskRepository.save(task);
    }
    return toTaskDto(task);
}
Also used : SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) Task(com.viadee.sonarQuest.entities.Task) Quest(com.viadee.sonarQuest.entities.Quest) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Quest

use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.

the class GratificationService method rewardParticipation.

private void rewardParticipation(final Participation participation) {
    final Developer developer = participation.getDeveloper();
    final Quest quest = participation.getQuest();
    developer.addGold(quest.getGold());
    developer.addXp(quest.getXp());
    developer.setLevel(levelService.getLevelByDeveloperXp(developer.getXp()));
    developerRepository.save(developer);
}
Also used : Developer(com.viadee.sonarQuest.entities.Developer) Quest(com.viadee.sonarQuest.entities.Quest)

Example 4 with Quest

use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.

the class ParticipationController method createParticipation.

@CrossOrigin
@RequestMapping(value = "/{questid}/{developerid}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public Participation createParticipation(@PathVariable(value = "questid") Long questid, @PathVariable(value = "developerid") Long developerid) {
    Quest foundQuest = questRepository.findOne(questid);
    Developer foundDeveloper = developerRepository.findOne(developerid);
    Participation foundParticipation = participationRepository.findByQuestAndDeveloper(foundQuest, foundDeveloper);
    Participation participation = null;
    if ((foundQuest != null) && (foundDeveloper != null) && (foundParticipation == null)) {
        participation = new Participation(foundQuest, foundDeveloper);
        participation = participationRepository.save(participation);
    }
    return participation;
}
Also used : Participation(com.viadee.sonarQuest.entities.Participation) Developer(com.viadee.sonarQuest.entities.Developer) Quest(com.viadee.sonarQuest.entities.Quest)

Example 5 with Quest

use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.

the class QuestController method addWorld.

@CrossOrigin
@RequestMapping(value = "/{questId}/addWorld/{worldId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public QuestDto addWorld(@PathVariable(value = "questId") final Long questId, @PathVariable(value = "worldId") final Long worldId) {
    Quest quest = this.questRepository.findOne(questId);
    if (quest != null) {
        final World world = this.worldRepository.findOne(worldId);
        quest.setWorld(world);
        quest = this.questRepository.save(quest);
    }
    return toQuestDto(quest);
}
Also used : World(com.viadee.sonarQuest.entities.World) Quest(com.viadee.sonarQuest.entities.Quest) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Quest (com.viadee.sonarQuest.entities.Quest)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 CrossOrigin (org.springframework.web.bind.annotation.CrossOrigin)6 Developer (com.viadee.sonarQuest.entities.Developer)4 Participation (com.viadee.sonarQuest.entities.Participation)4 Task (com.viadee.sonarQuest.entities.Task)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 Adventure (com.viadee.sonarQuest.entities.Adventure)2 World (com.viadee.sonarQuest.entities.World)2 Test (org.junit.Test)2 SpecialTask (com.viadee.sonarQuest.entities.SpecialTask)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1