Treasure update

This commit is contained in:
Mini-Chiss 2015-02-10 12:09:37 +13:00
parent 26463ba75d
commit af95d3ba4e
9 changed files with 85 additions and 32 deletions

View File

@ -291,10 +291,11 @@ public class RewardManager
int currentReward = 0; int currentReward = 0;
Reward[] rewards = new Reward[4]; Reward[] rewards = new Reward[4];
boolean hasUncommon = false; boolean hasUncommon = false;
boolean canGiveMythical = true;
while (currentReward < 4) while (currentReward < 4)
{ {
Reward reward = nextReward(player, rewards, currentReward == 3 && !hasUncommon, type); Reward reward = nextReward(player, rewards, currentReward == 3 && !hasUncommon, type, canGiveMythical);
if (reward == null) if (reward == null)
{ {
@ -305,6 +306,13 @@ public class RewardManager
{ {
hasUncommon = true; hasUncommon = true;
} }
//Only allow 1 Mythical
if (reward.getRarity().ordinal() >= RewardRarity.MYTHICAL.ordinal())
{
canGiveMythical = false;
}
rewards[currentReward] = reward; rewards[currentReward] = reward;
currentReward++; currentReward++;
} }
@ -328,14 +336,14 @@ public class RewardManager
// return nextReward(player, excludedRewards, false, isChestOpening); // return nextReward(player, excludedRewards, false, isChestOpening);
// } // }
public Reward nextReward(Player player, Reward[] excludedRewards, boolean requiresUncommon, RewardType type) public Reward nextReward(Player player, Reward[] excludedRewards, boolean requiresUncommon, RewardType type, boolean canGiveMythical)
{ {
RewardRarity rarity = type.generateRarity(requiresUncommon); RewardRarity rarity = type.generateRarity(requiresUncommon);
//Dont give Rank Upgrade if already has Legend //Dont give Rank Upgrade if already has Legend
if (rarity == RewardRarity.MYTHICAL) if (rarity == RewardRarity.MYTHICAL)
{ {
if (_clientManager.Get(player).GetRank().Has(Rank.LEGEND)) if (!canGiveMythical || _clientManager.Get(player).GetRank().Has(Rank.LEGEND))
{ {
rarity = RewardRarity.LEGENDARY; rarity = RewardRarity.LEGENDARY;
} }

View File

@ -4,9 +4,9 @@ public enum RewardType
{ {
//% Chances Mythic Legend Rare Uncommon //% Chances Mythic Legend Rare Uncommon
GameLoot( 0.000001, 0.001, 0.004, 3), GameLoot( 0.000001, 0.001, 0.004, 3),
BasicChest( 0, 0.01, 0.04, 5), OldChest( 0, 0.01, 0.04, 5),
HeroicChest( 0, 1, 4, 25), AncientChest( 0, 1, 4, 25),
LegendaryChest( 0.5, 2.5, 10, 40); MythicalChest( 0.5, 2.5, 10, 40);
private double _mythicalChance; private double _mythicalChance;
private double _legendaryChance; private double _legendaryChance;

View File

@ -91,7 +91,7 @@ public class Treasure
_chestData[i] = new ChestData(chestBlocks[i]); _chestData[i] = new ChestData(chestBlocks[i]);
} }
if (_treasureType == TreasureType.HEROIC || _treasureType == TreasureType.LEGENDARY) if (_treasureType == TreasureType.ANCIENT || _treasureType == TreasureType.MYTHICAL)
_animations.add(new BlockChangeAnimation(this, _otherBlockInfo)); _animations.add(new BlockChangeAnimation(this, _otherBlockInfo));
} }

View File

@ -99,7 +99,7 @@ public class TreasureLocation implements Listener
setHoloChestVisible(false); setHoloChestVisible(false);
if (treasureType == TreasureType.HEROIC || treasureType == TreasureType.LEGENDARY) if (treasureType == TreasureType.ANCIENT || treasureType == TreasureType.MYTHICAL)
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName())); Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + treasureType.getName()));
Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardType()); Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardType());

View File

@ -7,11 +7,11 @@ import mineplex.core.reward.RewardType;
public enum TreasureType public enum TreasureType
{ {
BASIC(C.cYellow + "Basic Chest", "Basic Chest", RewardType.BasicChest, Material.CHEST, TreasureStyle.BASIC), OLD(C.cYellow + "Basic Chest", "Basic Chest", RewardType.OldChest, Material.CHEST, TreasureStyle.BASIC),
HEROIC(C.cGold + "Heroic Chest", "Heroic Chest", RewardType.HeroicChest, Material.TRAPPED_CHEST, TreasureStyle.HEROIC), ANCIENT(C.cGold + "Heroic Chest", "Heroic Chest", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.HEROIC),
LEGENDARY(C.cRed + "Legendary Chest", "Legendary Chest", RewardType.LegendaryChest, Material.ENDER_CHEST, TreasureStyle.LEGENDARY); MYTHICAL(C.cRed + "Legendary Chest", "Legendary Chest", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.LEGENDARY);
private final String _name; private final String _name;
private final RewardType _rewardType; private final RewardType _rewardType;

View File

@ -51,13 +51,13 @@ public class BlockChangeAnimation extends Animation
} }
else if (b.getType() == Material.SMOOTH_BRICK) else if (b.getType() == Material.SMOOTH_BRICK)
{ {
Material newMaterial = getTreasure().getTreasureType() == TreasureType.HEROIC ? Material.NETHER_BRICK : Material.QUARTZ_BLOCK; Material newMaterial = getTreasure().getTreasureType() == TreasureType.ANCIENT ? Material.NETHER_BRICK : Material.QUARTZ_BLOCK;
_blockInfoList.add(new BlockInfo(b)); _blockInfoList.add(new BlockInfo(b));
b.setType(newMaterial); b.setType(newMaterial);
} }
else if (b.getType() == Material.SMOOTH_STAIRS || b.getType() == Material.COBBLESTONE_STAIRS) else if (b.getType() == Material.SMOOTH_STAIRS || b.getType() == Material.COBBLESTONE_STAIRS)
{ {
Material newMaterial = getTreasure().getTreasureType() == TreasureType.HEROIC ? Material.NETHER_BRICK_STAIRS : Material.QUARTZ_STAIRS; Material newMaterial = getTreasure().getTreasureType() == TreasureType.ANCIENT ? Material.NETHER_BRICK_STAIRS : Material.QUARTZ_STAIRS;
_blockInfoList.add(new BlockInfo(b)); _blockInfoList.add(new BlockInfo(b));
b.setType(newMaterial); b.setType(newMaterial);
} }

View File

@ -80,11 +80,11 @@ public class ChestSpawnAnimation extends Animation
_particleLocation.add(_particleDirection); _particleLocation.add(_particleDirection);
//Play Particels //Play Particels
if (getTreasure().getTreasureType() == TreasureType.BASIC) if (getTreasure().getTreasureType() == TreasureType.OLD)
{ {
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1); UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1);
} }
else if (getTreasure().getTreasureType() == TreasureType.HEROIC) else if (getTreasure().getTreasureType() == TreasureType.ANCIENT)
{ {
float x = (float) (Math.sin(getTicks()/4D)); float x = (float) (Math.sin(getTicks()/4D));
float z = (float) (Math.cos(getTicks()/4D)); float z = (float) (Math.cos(getTicks()/4D));
@ -95,7 +95,7 @@ public class ChestSpawnAnimation extends Animation
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1); UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1);
} }
else if (getTreasure().getTreasureType() == TreasureType.LEGENDARY) else if (getTreasure().getTreasureType() == TreasureType.MYTHICAL)
{ {
float y = 5 * scale; float y = 5 * scale;
double width = 0.7 * ((double) getTicks() / (double) ANIMATION_DURATION); double width = 0.7 * ((double) getTicks() / (double) ANIMATION_DURATION);

View File

@ -0,0 +1,37 @@
package mineplex.core.treasure.gui;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.shop.item.IButton;
public class BuyBasicChestButton implements IButton
{
private Player _player;
private InventoryManager _inventoryManager;
public BuyBasicChestButton(Player player, InventoryManager inventoryManager)
{
_player = player;
_inventoryManager = inventoryManager;
}
@Override
public void onClick(Player player, ClickType clickType)
{
//need to do this :o
// Shop.OpenPageForPlayer(player, new ConfirmationPage<CosmeticManager, CosmeticShop>(Plugin, Shop, ClientManager, DonationManager, new Runnable()
// {
// public void run()
// {
// _inventoryManager.addItemToInventory(player, "Item", "Old Chest", 1);
// Refresh();
// }
// }, this, new TreasureKey(), CurrencyType.Coins, Player));
_inventoryManager.addItemToInventory(player, "Item", "Old Chest", 1);
}
}

View File

@ -36,38 +36,46 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
@Override @Override
protected void BuildPage() protected void BuildPage()
{ {
int basicCount = _inventoryManager.Get(Player).getItemCount(TreasureType.BASIC.getItemName()); int basicCount = _inventoryManager.Get(Player).getItemCount(TreasureType.OLD.getItemName());
int heroicCount = _inventoryManager.Get(Player).getItemCount(TreasureType.HEROIC.getItemName()); int heroicCount = _inventoryManager.Get(Player).getItemCount(TreasureType.ANCIENT.getItemName());
int legendaryCount = _inventoryManager.Get(Player).getItemCount(TreasureType.LEGENDARY.getItemName()); int legendaryCount = _inventoryManager.Get(Player).getItemCount(TreasureType.MYTHICAL.getItemName());
List<String> basicLore = new ArrayList<String>(); List<String> basicLore = new ArrayList<String>();
basicLore.add(" "); basicLore.add(" ");
basicLore.add(F.value("Basic Chests Owned", "" + basicCount)); basicLore.add(F.value("Old Chests Owned", "" + basicCount));
basicLore.add(" "); basicLore.add(" ");
if (basicCount > 0) if (basicCount > 0)
basicLore.add(ChatColor.RESET + "Click to open!"); basicLore.add(ChatColor.RESET + "Click to Open!");
else
{
basicLore.add(ChatColor.RESET + "Cost: " + C.cYellow + "1000 Coins");
basicLore.add(ChatColor.RESET + "Click to Purchase!");
}
List<String> heroicLore = new ArrayList<String>(); List<String> heroicLore = new ArrayList<String>();
heroicLore.add(" "); heroicLore.add(" ");
heroicLore.add(F.value("Heroic Chests Owned", "" + heroicCount)); heroicLore.add(F.value("Ancient Chests Owned", "" + heroicCount));
heroicLore.add(" "); heroicLore.add(" ");
if (heroicCount > 0) if (heroicCount > 0)
heroicLore.add(ChatColor.RESET + "Click to open!"); heroicLore.add(ChatColor.RESET + "Click to Open!");
List<String> legendaryLore = new ArrayList<String>(); List<String> legendaryLore = new ArrayList<String>();
legendaryLore.add(" "); legendaryLore.add(" ");
legendaryLore.add(F.value("Legendary Chests Owned", "" + legendaryCount)); legendaryLore.add(F.value("Mythical Chests Owned", "" + legendaryCount));
legendaryLore.add(" "); legendaryLore.add(" ");
if (legendaryCount > 0) if (legendaryCount > 0)
legendaryLore.add(ChatColor.RESET + "Click to open!"); legendaryLore.add(ChatColor.RESET + "Click to Open!");
ShopItem basic = new ShopItem(Material.CHEST, C.cGreen + C.Bold + "Old Chest", basicLore.toArray(new String[0]), 0, false, false);
ShopItem heroic = new ShopItem(Material.TRAPPED_CHEST, C.cGold + C.Bold + "Ancient Chest", heroicLore.toArray(new String[0]), 0, false, false);
ShopItem legendary = new ShopItem(Material.ENDER_CHEST, C.cRed + C.Bold + "Mythical Chest", legendaryLore.toArray(new String[0]), 0, false, false);
ShopItem basic = new ShopItem(Material.CHEST, C.cGreen + C.Bold + "Basic Chest", basicLore.toArray(new String[0]), 0, false, false); if (basicCount > 0)
ShopItem heroic = new ShopItem(Material.TRAPPED_CHEST, C.cGold + C.Bold + "Heroic Chest", heroicLore.toArray(new String[0]), 0, false, false); AddButton(2, basic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.OLD));
ShopItem legendary = new ShopItem(Material.ENDER_CHEST, C.cRed + C.Bold + "Legendary Chest", legendaryLore.toArray(new String[0]), 0, false, false); else
AddButton(2, basic, new BuyBasicChestButton(Player, _inventoryManager));
AddButton(2, basic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.BASIC)); AddButton(4, heroic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.ANCIENT));
AddButton(4, heroic, new OpenTreasureButton(Player, _treasureLocation, TreasureType.HEROIC)); AddButton(6, legendary, new OpenTreasureButton(Player, _treasureLocation, TreasureType.MYTHICAL));
AddButton(6, legendary, new OpenTreasureButton(Player, _treasureLocation, TreasureType.LEGENDARY));
} }
} }