Beispiel #1
0
 public static void setPoints(Player player) {
   int points = 0;
   for (AchievementData achievement : AchievementData.values()) {
     if (player.getAchievementAttributes().getCompletion()[achievement.ordinal()]) {
       points++;
     }
   }
   player.getPointsHandler().setAchievementPoints(points, false);
 }
Beispiel #2
0
 public static boolean handleButton(Player player, int button) {
   if (!(button >= -28531 && button <= -28425)) {
     return false;
   }
   int index = -1;
   if (button >= -28531 && button <= -28502) {
     index = 28531 + button;
   } else if (button >= -28499 && button <= -28469) {
     index = 30 + 28499 + button;
   } else if (button >= -28466 && button <= -28435) {
     index = 61 + 28466 + button;
   } else if (button >= -28432 && button <= -28425) {
     index = 93 + 28432 + button;
   }
   if (index >= 0 && index < AchievementData.values().length) {
     AchievementData achievement = AchievementData.values()[index];
     if (player.getAchievementAttributes().getCompletion()[achievement.ordinal()]) {
       player
           .getPacketSender()
           .sendMessage(
               "<img=10> <col=339900>You have completed the achievement: "
                   + achievement.interfaceLine
                   + ".");
     } else if (achievement.progressData == null) {
       player
           .getPacketSender()
           .sendMessage(
               "<img=10> <col=660000>You have not started the achievement: "
                   + achievement.interfaceLine
                   + ".");
     } else {
       int progress = player.getAchievementAttributes().getProgress()[achievement.progressData[0]];
       int requiredProgress = achievement.progressData[1];
       if (progress == 0) {
         player
             .getPacketSender()
             .sendMessage(
                 "<img=10> <col=660000>You have not started the achievement: "
                     + achievement.interfaceLine
                     + ".");
       } else if (progress != requiredProgress) {
         player
             .getPacketSender()
             .sendMessage(
                 "<img=10> <col=FFFF00>Your progress for this achievement is currently at: "
                     + Misc.insertCommasToNumber("" + progress)
                     + "/"
                     + Misc.insertCommasToNumber("" + requiredProgress)
                     + ".");
       }
     }
   }
   return true;
 }
Beispiel #3
0
 public static void updateInterface(Player player) {
   for (AchievementData achievement : AchievementData.values()) {
     boolean completed = player.getAchievementAttributes().getCompletion()[achievement.ordinal()];
     boolean progress =
         achievement.progressData != null
             && player.getAchievementAttributes().getProgress()[achievement.progressData[0]] > 0;
     player
         .getPacketSender()
         .sendString(
             achievement.interfaceFrame,
             (completed ? "@gre@" : progress ? "@yel@" : "@red@") + achievement.interfaceLine);
   }
   player
       .getPacketSender()
       .sendString(
           37001,
           "Achievements: "
               + player.getPointsHandler().getAchievementPoints()
               + "/"
               + AchievementData.values().length);
 }
Beispiel #4
0
  public static void finishAchievement(Player player, AchievementData achievement) {
    if (player.getAchievementAttributes().getCompletion()[achievement.ordinal()]) return;
    player.getAchievementAttributes().getCompletion()[achievement.ordinal()] = true;
    player
        .getPacketSender()
        .sendString(achievement.interfaceFrame, ("@gre@") + achievement.interfaceLine)
        .sendMessage(
            "<img=10> <col=339900>You have completed the achievement "
                + Misc.formatText(achievement.toString().toLowerCase() + "."))
        .sendString(
            37001,
            "Achievements: "
                + player.getPointsHandler().getAchievementPoints()
                + "/"
                + AchievementData.values().length);

    if (achievement.getDifficulty() == Difficulty.HARD) {
      doProgress(player, AchievementData.COMPLETE_ALL_HARD_TASKS);
    }

    player.getPointsHandler().setAchievementPoints(1, true);
  }
Beispiel #5
0
 public static void doProgress(Player player, AchievementData achievement, int amt) {
   if (player.getAchievementAttributes().getCompletion()[achievement.ordinal()]) return;
   if (achievement.progressData != null) {
     int progressIndex = achievement.progressData[0];
     int amountNeeded = achievement.progressData[1];
     int previousDone = player.getAchievementAttributes().getProgress()[progressIndex];
     if ((previousDone + amt) < amountNeeded) {
       player.getAchievementAttributes().getProgress()[progressIndex] = previousDone + amt;
       if (previousDone == 0)
         player
             .getPacketSender()
             .sendString(achievement.interfaceFrame, "@yel@" + achievement.interfaceLine);
     } else {
       finishAchievement(player, achievement);
     }
   }
 }
Beispiel #6
0
  public static class AchievementAttributes {

    public AchievementAttributes() {}

    /** ACHIEVEMENTS * */
    private boolean[] completed = new boolean[AchievementData.values().length];

    private int[] progress = new int[53];

    public boolean[] getCompletion() {
      return completed;
    }

    public void setCompletion(int index, boolean value) {
      this.completed[index] = value;
    }

    public void setCompletion(boolean[] completed) {
      this.completed = completed;
    }

    public int[] getProgress() {
      return progress;
    }

    public void setProgress(int index, int value) {
      this.progress[index] = value;
    }

    public void setProgress(int[] progress) {
      this.progress = progress;
    }

    /** MISC * */
    private int coinsGambled;

    private double totalLoyaltyPointsEarned;
    private boolean[] godsKilled = new boolean[5];

    public int getCoinsGambled() {
      return coinsGambled;
    }

    public void setCoinsGambled(int coinsGambled) {
      this.coinsGambled = coinsGambled;
    }

    public double getTotalLoyaltyPointsEarned() {
      return totalLoyaltyPointsEarned;
    }

    public void incrementTotalLoyaltyPointsEarned(double totalLoyaltyPointsEarned) {
      this.totalLoyaltyPointsEarned += totalLoyaltyPointsEarned;
    }

    public boolean[] getGodsKilled() {
      return godsKilled;
    }

    public void setGodKilled(int index, boolean godKilled) {
      this.godsKilled[index] = godKilled;
    }

    public void setGodsKilled(boolean[] b) {
      this.godsKilled = b;
    }
  }