Package com.aldaviva.autorpg.display.bulletin

Examples of com.aldaviva.autorpg.display.bulletin.Bulletin


    String characterName = argv[1];
    String genderString = argv[2];
    boolean female = genderString.substring(0, 1).equalsIgnoreCase("f");
    String designation = StringUtils.split(argsExceptFirstArg, null, 2)[1];
    Character character = playerManager.createCharacter(userhost, characterName, designation, female);
    bulletinManager.publish(new Bulletin(new IrcMessage.CreatedCharacterSuccessfully(character)));
    return "Character created.";
  }
View Full Code Here


      return new IrcMessage.LoginFailedNoSuchUserSuggestion().toString();
    }
  }
 
  public static Bulletin createCharactersRejoinedBulletin(List<Character> characters){
    Bulletin bulletin = new Bulletin();
   
    if(!characters.isEmpty()){
      List<String> characterNames = new ArrayList<String>();
      for (Character character : characters) {
        characterNames.add(Style.CHARACTER_NAME+character.getName()+Style.NORMAL);
      }
     
      String namesList = Utils.commaAndList(characterNames);
     
      if(characters.size() == 1){
        namesList += " has joined.";
      } else {
        namesList += " have joined.";
      }
     
      bulletin.add(namesList);
    }

    return bulletin;
  }
View Full Code Here

      LOGGER.info(player.getName() + " set to offline after bot reconnection.");
      player.setOnline(false);
    }
   
    if(!charactersStillOnline.isEmpty()){
      Bulletin rejoinedBulletin = LoginAction.createCharactersRejoinedBulletin(charactersStillOnline);
      bulletinManager.publish(rejoinedBulletin, false);
    }
   
  }
View Full Code Here

   
    if(candidatePlayer != null){
      candidatePlayer.setOnline(true);
     
      charactersJoining.addAll(Character.findCharactersByPlayer(candidatePlayer).getResultList());
      Bulletin rejoinedBulletin = LoginAction.createCharactersRejoinedBulletin(charactersJoining);
      bulletinManager.publish(rejoinedBulletin, false);
      return new IrcMessage.WelcomeRejoined(candidatePlayer).toString();
    } else {
      return new IrcMessage.WelcomeNewPlayer(bot).toString();
    }
View Full Code Here

 
  private void updateQuest(Quest quest){
    int onlineCharacters = quest.countOnlineCharacters();
    if(onlineCharacters == 0){
      remove(quest);
      bulletinManager.publish(new Bulletin("Every character in this quest is offline. Quest over."));
    } else {
      int experienceDelta = (onlineCharacters * onlineCharacters);
      quest.setExpRemaining(quest.getExpRemaining() - experienceDelta);
     
      int step = quest.calculateCurrentStep();
View Full Code Here

      }
    }
  }
 
  private Bulletin stepReached(Quest quest){
    Bulletin result = new Bulletin();
   
    LOGGER.debug("quest reached step "+quest.getStep());
   
    switch(quest.getStep()){
      case 1: //just starting the quest
        result.add(new Message.QuestHasCharacters(quest));
        result.add(quest.getMission());
        result.add(quest.getStep1());
        break;
      case 2:
        result.add(quest.getStep1done());
        result.add(quest.getStep2());
        break;
      case 3:
        result.add(quest.getStep2done());
        result.add(quest.getStep3());
        break;
      case 4: //done
        result.add(quest.getStep3done());
        giveReward(quest);
        remove(quest);
        break;
      default:
        throw new IllegalStateException("Quest state is not in the range [1, 4].");
View Full Code Here

   
    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.");
View Full Code Here

      onLevelUp(character);
    }
  }
 
  private void onLevelUp(Character character){
    Bulletin bulletin = new Bulletin(new Message.CharacterLevelsUp(character));
    bulletinManager.publish(bulletin);
  }
View Full Code Here

   
    LOGGER.trace("Rolled a "+randomInt+" out of "+rollsPerDay+". For this event, a roll <= "+timesPerDay+" is required.");
   
    if (randomInt <= timesPerDay) {
      occur();
      bulletinManager.publish(new Bulletin(getAnnouncement()));
    }
  }
View Full Code Here

 
  public final void forceOccur(){
    occur();
    String announcement = getAnnouncement();
    if(announcement != null && !announcement.isEmpty()){
      bulletinManager.publish(new Bulletin(announcement));
    }
  }
View Full Code Here

TOP

Related Classes of com.aldaviva.autorpg.display.bulletin.Bulletin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.