Support multi named tiers of achievements, allow rewarding of xp/gems/crowns upon increasing achievement tiers, and replace old castle siege achievements with new ones

This commit is contained in:
AlexTheCoder 2017-05-04 18:36:02 -04:00
parent 43739743bf
commit 901fecb49a
4 changed files with 130 additions and 32 deletions

View File

@ -375,28 +375,76 @@ public enum Achievement
AchievementCategory.MASTER_BUILDERS), AchievementCategory.MASTER_BUILDERS),
//Castle Siege //Castle Siege
CASTLE_SIEGE_WINS("FOR THE KING!", 600, CASTLE_SIEGE_KILL_STREAK("Kill Streak", 0,
new String[]{"Castle Siege.ForTheKing"}, new String[]{"Castle Siege New.KillStreak", "Castle Siege TDM.KillStreak"},
new String[]{"Win as Defenders 50 times"}, new String[]{"Earn Kill Streak Rewards"},
new int[]{50}, new int[][]{new int[]{0, 50, 500}, new int[]{0, 100, 750}, new int[]{0, 150, 1000}, new int[]{0, 200, 1500}, new int[]{0, 400, 2000}, new int[]{0, 500, 2500}, new int[]{0, 1000, 3000}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4000}, new int[]{0, 5000, 100000}},
new int[]{10, 20, 50, 100, 200, 250, 500, 750, 1000, 2000},
"Novice I",
new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_SIEGE), AchievementCategory.CASTLE_SIEGE),
CASTLE_SIEGE_KINGSLAYER("Kingslayer", 800, CASTLE_SIEGE_FIRST_BLOOD("First Blood", 0,
new String[]{"Castle Siege.KingSlayer"}, new String[]{"Castle Siege New.FirstBlood", "Castle Siege TDM.FirstBlood"},
new String[]{"Get the killing blow on the King"}, new String[]{"Obtain the first kill in a Match"},
new int[]{1}, new int[][]{new int[]{0, 100, 100}, new int[]{0, 150, 200}, new int[]{0, 200, 300}, new int[]{0, 250, 400}, new int[]{0, 500, 500}},
new int[]{2, 5, 10, 25, 50},
"Novice I",
new String[]{"Novice II", "Novice III", "Novice IV", "Novice V"},
AchievementCategory.CASTLE_SIEGE), AchievementCategory.CASTLE_SIEGE),
CASTLE_SIEGE_BLOOD_THIRSTY("Blood Thirsty", 1200, CASTLE_SIEGE_FIGHTER_KIT("Fighter", 0,
new String[]{"Castle Siege.BloodThirsty"}, new String[]{"Castle Siege New.FighterKitKills", "Castle Siege TDM.FighterKitKills"},
new String[]{"Kill 50 Undead in a single game"}, new String[]{"Kill opponents while wearing the Fighter Kit"},
new int[]{1}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}},
new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000},
"Novice I",
new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_SIEGE), AchievementCategory.CASTLE_SIEGE),
CASTLE_SIEGE_ASSASSIN("Assassin", 1000, CASTLE_SIEGE_TANK_KIT("Tank", 0,
new String[]{"Castle Siege.Assassin"}, new String[]{"Castle Siege New.TankKitKills", "Castle Siege TDM.TankKitKills"},
new String[]{"Do 50% or more of the damage to the king"}, new String[]{"Kill opponents while wearing the Tank Kit"},
new int[]{1}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}},
new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000},
"Novice I",
new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_SIEGE),
CASTLE_SIEGE_ARCHER_KIT("Archer", 0,
new String[]{"Castle Siege New.ArcherKitKills", "Castle Siege TDM.ArcherKitKills"},
new String[]{"Kill opponents while wearing the Archer Kit"},
new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}},
new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000},
"Novice I",
new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_SIEGE),
CASTLE_SIEGE_DEMOLITIONIST_KIT("Demolitionist", 0,
new String[]{"Castle Siege New.DemolitionistKitKills", "Castle Siege TDM.DemolitionistKitKills"},
new String[]{"Kill opponents while wearing the Demolitionist Kit"},
new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}},
new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000},
"Novice I",
new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_SIEGE),
CASTLE_SIEGE_WINNER("Siege", 0,
new String[]{"Castle Siege New.Wins", "Castle Siege TDM.Wins"},
new String[]{"Win games of Castle Siege"},
new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}},
new int[]{2, 5, 25, 50, 100, 150, 250, 500, 1000, 2000},
"Novice I",
new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_SIEGE),
CASTLE_SIEGE_MEDALIST("Medalist", 0,
new String[]{"Castle Siege New.MedalsEarned", "Castle Siege TDM.MedalsEarned"},
new String[]{"Earn Bronze, Silver, or Gold Medals in Castle Siege Matches"},
new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}},
new int[]{2, 50, 150, 250, 500, 1000, 1500, 2500, 5000, 10000},
"Novice I",
new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"},
AchievementCategory.CASTLE_SIEGE), AchievementCategory.CASTLE_SIEGE),
//Champions //Champions
@ -1135,17 +1183,36 @@ public enum Achievement
private String _name; private String _name;
private String[] _desc; private String[] _desc;
private String[] _stats; private String[] _stats;
private int[][] _levelUpRewards;
private int[] _levels; private int[] _levels;
private String _defaultLevelName;
private String[] _levelNames;
private int _gems; private int _gems;
private AchievementCategory _category; private AchievementCategory _category;
Achievement(String name, int gems, String[] stats, String[] desc, int[][] levelUpRewards, int[] levels, String defaultLevelName, String[] levelNames, AchievementCategory category)
{
_name = name;
_gems = gems;
_desc = desc;
_stats = stats;
_levelUpRewards = levelUpRewards;
_levels = levels;
_defaultLevelName = defaultLevelName;
_levelNames = levelNames;
_category = category;
}
Achievement(String name, int gems, String[] stats, String[] desc, int[] levels, AchievementCategory category) Achievement(String name, int gems, String[] stats, String[] desc, int[] levels, AchievementCategory category)
{ {
_name = name; _name = name;
_gems = gems; _gems = gems;
_desc = desc; _desc = desc;
_stats = stats; _stats = stats;
_levelUpRewards = new int[][] {};
_levels = levels; _levels = levels;
_levelNames = new String[] {};
_defaultLevelName = "";
_category = category; _category = category;
} }
@ -1229,11 +1296,26 @@ public enum Achievement
return _stats; return _stats;
} }
public int[][] getLevelUpRewards()
{
return _levelUpRewards;
}
public int[] getLevels() public int[] getLevels()
{ {
return _levels; return _levels;
} }
public String getDefaultLevelName()
{
return _defaultLevelName;
}
public String[] getLevelNames()
{
return _levelNames;
}
public int getMaxLevel() public int getMaxLevel()
{ {
return _levels.length; return _levels.length;
@ -1249,6 +1331,11 @@ public enum Achievement
return _levels.length == 1; return _levels.length == 1;
} }
public boolean hasLevelNames()
{
return _levelNames.length > 0;
}
public AchievementCategory getCategory() public AchievementCategory getCategory()
{ {
return _category; return _category;

View File

@ -85,10 +85,9 @@ public enum AchievementCategory
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit", false, GameDisplay.Wizards.getGameId()), Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit", false, GameDisplay.Wizards.getGameId()),
CASTLE_SIEGE("Castle Siege", null, CASTLE_SIEGE("Castle Siege", new String[] {"Castle Siege New", "Castle Siege TDM"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"), new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.CROWNS_EARNED },
new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED }, Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiegeNew.getGameId()),
Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiege.getGameId()),
BAWK_BAWK_BATTLES("Bawk Bawk Battles", null, BAWK_BAWK_BATTLES("Bawk Bawk Battles", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },

View File

@ -89,6 +89,7 @@ public class StatDisplay
public static final StatDisplay KILLS = new StatDisplay("Kills"); public static final StatDisplay KILLS = new StatDisplay("Kills");
public static final StatDisplay DEATHS = new StatDisplay("Deaths"); public static final StatDisplay DEATHS = new StatDisplay("Deaths");
public static final StatDisplay GEMS_EARNED = new StatDisplay("Gems Earned", "GemsEarned"); public static final StatDisplay GEMS_EARNED = new StatDisplay("Gems Earned", "GemsEarned");
public static final StatDisplay CROWNS_EARNED = new StatDisplay("Crowns Earned", "CrownsEarned");
public static final StatDisplay TIME_IN_GAME = new StatDisplay("Time In Game", "TimeInGame"); public static final StatDisplay TIME_IN_GAME = new StatDisplay("Time In Game", "TimeInGame");
public static final StatDisplay GAMES_PLAYED = new StatDisplay("Games Played", "Wins", "Losses"); public static final StatDisplay GAMES_PLAYED = new StatDisplay("Games Played", "Wins", "Losses");

View File

@ -3,6 +3,15 @@ package mineplex.core.achievement.ui.page;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.Achievement; import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementCategory; import mineplex.core.achievement.AchievementCategory;
@ -20,14 +29,6 @@ import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.stats.PlayerStats; import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class AchievementPage extends ShopPageBase<AchievementManager, AchievementShop> public class AchievementPage extends ShopPageBase<AchievementManager, AchievementShop>
{ {
private static int ACHIEVEMENT_MIDDLE_INDEX = 31; private static int ACHIEVEMENT_MIDDLE_INDEX = 31;
@ -68,6 +69,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
{ {
AchievementData data = getPlugin().get(_targetStats, achievement); AchievementData data = getPlugin().get(_targetStats, achievement);
boolean singleLevel = achievement.isSingleLevel(); boolean singleLevel = achievement.isSingleLevel();
boolean levelNames = achievement.hasLevelNames();
boolean hasUnlocked = data.getLevel() >= achievement.getMaxLevel(); boolean hasUnlocked = data.getLevel() >= achievement.getMaxLevel();
if (!hasUnlocked) if (!hasUnlocked)
@ -80,7 +82,16 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
String itemName = (hasUnlocked ? C.cGreen : C.cRed) + achievement.getName(); String itemName = (hasUnlocked ? C.cGreen : C.cRed) + achievement.getName();
if (!singleLevel) if (!singleLevel)
{
if (!levelNames)
{
itemName += ChatColor.WHITE + " Level " + data.getLevel() + "/" + achievement.getMaxLevel(); itemName += ChatColor.WHITE + " Level " + data.getLevel() + "/" + achievement.getMaxLevel();
}
else
{
itemName += ChatColor.GOLD + " Tier: " + (data.getLevel() == 0 ? achievement.getDefaultLevelName() : achievement.getLevelNames()[Math.min(data.getLevel(), achievement.getLevelNames().length) - 1]);
}
}
ArrayList<String> lore = new ArrayList<String>(); ArrayList<String> lore = new ArrayList<String>();
lore.add(" "); lore.add(" ");