return result;
}
private Bulletin giveReward(Quest quest){
Bulletin bulletin;
LOGGER.debug("Giving rewards for quest completion");
switch(quest.getReward()){
case EXPERIENCE:
SummaryStatistics stats = new SummaryStatistics();
for(Character character : quest.getCharacters()){
stats.addValue(character.getExperience());
}
double avgTeamExperience = stats.getMean();
int reward = (int) Math.round(avgTeamExperience * ((double)Utils.getRandomInt(10, 25)/100));
for(Character character : quest.getCharacters()){
character.setExperience(character.getExperience() + reward);
}
bulletin = new Bulletin(new Message.CharactersAllGainExperience(quest.getCharacters(), reward));
break;
case RARE_ITEM:
bulletin = new Bulletin(new Message.CharactersFoundItems(quest.getCharacters()));
for(Character character : quest.getCharacters()){
Item newItem = Item.findRandomByRarity(true);
characterItemManager.offerCharacterAnItem(newItem, character);
bulletin.add(new Message.CharacterFoundItem(character, newItem));
}
break;
default:
throw new IllegalStateException("Quest reward must be EXPERIENCE or RARE_ITEM.");