Start on Cake Wars Kit Progression
This commit is contained in:
parent
05b50d1c2b
commit
3758946dbc
@ -11,7 +11,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlugin
|
||||
public abstract class MiniClientPlugin<DataType> extends MiniPlugin
|
||||
{
|
||||
private static final Object _clientDataLock = new Object();
|
||||
|
||||
|
@ -10,10 +10,10 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
public abstract class MiniDbClientPlugin<DataType extends Object> extends MiniClientPlugin<DataType> implements ILoginProcessor
|
||||
public abstract class MiniDbClientPlugin<DataType> extends MiniClientPlugin<DataType> implements ILoginProcessor
|
||||
{
|
||||
|
||||
protected CoreClientManager ClientManager = null;
|
||||
protected final CoreClientManager ClientManager;
|
||||
|
||||
public MiniDbClientPlugin(String moduleName)
|
||||
{
|
||||
|
@ -0,0 +1,46 @@
|
||||
package mineplex.core.evolvedprogression;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum EvolvedCurrency
|
||||
{
|
||||
|
||||
LEATHER(1, "Leather", Material.LEATHER, 4),
|
||||
GOLD(2, "Gold", Material.GOLD_INGOT, 3),
|
||||
IRON(3, "Iron", Material.IRON_INGOT, 1),
|
||||
DIAMOND(4, "Diamond", Material.DIAMOND, 1),
|
||||
NETHER_STAR(5, "Nether Star", Material.NETHER_STAR, 1);
|
||||
|
||||
private final int _id;
|
||||
private final String _name;
|
||||
private final Material _material;
|
||||
private final int _maxPerRoll;
|
||||
|
||||
EvolvedCurrency(int id, String name, Material material, int maxPerRoll)
|
||||
{
|
||||
_id = id;
|
||||
_name = name;
|
||||
_material = material;
|
||||
_maxPerRoll = maxPerRoll;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public Material getMaterial()
|
||||
{
|
||||
return _material;
|
||||
}
|
||||
|
||||
public int getMaxPerRoll()
|
||||
{
|
||||
return _maxPerRoll;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package mineplex.core.evolvedprogression;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class EvolvedProgressionManager extends MiniClientPlugin<List<EvolvedTrack>>
|
||||
{
|
||||
|
||||
private EvolvedProgressionManager()
|
||||
{
|
||||
super("Evolved Progression");
|
||||
}
|
||||
|
||||
public EvolvedTrack get(Player player, String kitName)
|
||||
{
|
||||
List<EvolvedTrack> tracks = Get(player);
|
||||
|
||||
for (EvolvedTrack track : tracks)
|
||||
{
|
||||
if (track.getKitName().equals(kitName))
|
||||
{
|
||||
return track;
|
||||
}
|
||||
}
|
||||
|
||||
EvolvedTrack track = new EvolvedTrack(kitName, new HashMap<>(), new HashMap<>(), new HashMap<>());
|
||||
tracks.add(track);
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<EvolvedTrack> addPlayer(UUID uuid)
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package mineplex.core.evolvedprogression;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.common.util.UtilItem.ItemCategory;
|
||||
|
||||
public class EvolvedTrack
|
||||
{
|
||||
|
||||
// Assigns the price of an item based on its type. Integer[] { leather, gold, iron, diamond}
|
||||
private final static Map<Material, Integer[]> ITEM_COSTS;
|
||||
|
||||
static
|
||||
{
|
||||
ITEM_COSTS = new HashMap<>();
|
||||
|
||||
ITEM_COSTS.put(Material.LEATHER_HELMET, new Integer[] {3, 0, 0, 0});
|
||||
ITEM_COSTS.put(Material.LEATHER_CHESTPLATE, new Integer[] {7, 0, 0, 0});
|
||||
ITEM_COSTS.put(Material.LEATHER_LEGGINGS, new Integer[] {5, 0, 0, 0});
|
||||
ITEM_COSTS.put(Material.LEATHER_BOOTS, new Integer[] {3, 0, 0, 0});
|
||||
|
||||
ITEM_COSTS.put(Material.GOLD_HELMET, new Integer[] {25, 8, 0, 0});
|
||||
ITEM_COSTS.put(Material.GOLD_CHESTPLATE, new Integer[] {50, 12, 0, 0});
|
||||
ITEM_COSTS.put(Material.GOLD_LEGGINGS, new Integer[] {50, 10, 0, 0});
|
||||
ITEM_COSTS.put(Material.GOLD_BOOTS, new Integer[] {25, 8, 0, 0});
|
||||
|
||||
ITEM_COSTS.put(Material.IRON_HELMET, new Integer[] {50, 0, 5, 0});
|
||||
ITEM_COSTS.put(Material.IRON_CHESTPLATE, new Integer[] {100, 0, 10, 0});
|
||||
ITEM_COSTS.put(Material.IRON_LEGGINGS, new Integer[] {100, 0, 8, 0});
|
||||
ITEM_COSTS.put(Material.IRON_BOOTS, new Integer[] {50, 0, 5, 0});
|
||||
|
||||
ITEM_COSTS.put(Material.DIAMOND_HELMET, new Integer[] {100, 0, 0, 5});
|
||||
ITEM_COSTS.put(Material.DIAMOND_CHESTPLATE, new Integer[] {250, 0, 0, 10});
|
||||
ITEM_COSTS.put(Material.DIAMOND_LEGGINGS, new Integer[] {250, 0, 0, 9});
|
||||
ITEM_COSTS.put(Material.DIAMOND_BOOTS, new Integer[] {100, 0, 0, 5});
|
||||
|
||||
ITEM_COSTS.put(Material.STONE_SWORD, new Integer[] {5, 1, 0, 0});
|
||||
ITEM_COSTS.put(Material.IRON_SWORD, new Integer[] {5, 0, 8, 0});
|
||||
ITEM_COSTS.put(Material.DIAMOND_SWORD, new Integer[] {10, 0, 0, 10});
|
||||
}
|
||||
|
||||
public static Map<Material, Integer[]> getItemCosts()
|
||||
{
|
||||
return ITEM_COSTS;
|
||||
}
|
||||
|
||||
private final String _kitName;
|
||||
private final Map<EvolvedCurrency, Integer> _currencyMap;
|
||||
private final Map<ItemCategory, Integer> _itemLevelUnlocks;
|
||||
private final Map<ItemCategory, Integer> _itemLevelEquipped;
|
||||
|
||||
public EvolvedTrack(String kitName, Map<EvolvedCurrency, Integer> currencyMap, Map<ItemCategory, Integer> itemLevelUnlocks, Map<ItemCategory, Integer> itemLevelEquipped)
|
||||
{
|
||||
_kitName = kitName;
|
||||
_currencyMap = currencyMap;
|
||||
_itemLevelUnlocks = itemLevelUnlocks;
|
||||
_itemLevelEquipped = itemLevelEquipped;
|
||||
}
|
||||
|
||||
public int incrementCurrency(EvolvedCurrency currency, int amount)
|
||||
{
|
||||
int newAmount = _currencyMap.get(currency) + amount;
|
||||
|
||||
_currencyMap.put(currency, newAmount);
|
||||
|
||||
return newAmount;
|
||||
}
|
||||
|
||||
public String getKitName()
|
||||
{
|
||||
return _kitName;
|
||||
}
|
||||
}
|
@ -1,16 +1,70 @@
|
||||
package nautilus.game.arcade.game.modules.kitprogression;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.core.evolvedprogression.EvolvedCurrency;
|
||||
import mineplex.core.evolvedprogression.EvolvedProgressionManager;
|
||||
import mineplex.core.evolvedprogression.EvolvedTrack;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.modules.Module;
|
||||
|
||||
public class EvKitProgressionModule extends Module
|
||||
{
|
||||
|
||||
public EvKitProgressionModule()
|
||||
private final static EvolvedProgressionManager PROGRESSION_MANAGER;
|
||||
private final static WeightSet<EvolvedCurrency> CURRENCY_WEIGHT;
|
||||
|
||||
static
|
||||
{
|
||||
PROGRESSION_MANAGER = Managers.require(EvolvedProgressionManager.class);
|
||||
CURRENCY_WEIGHT = new WeightSet<>();
|
||||
|
||||
CURRENCY_WEIGHT.add(48, EvolvedCurrency.LEATHER);
|
||||
CURRENCY_WEIGHT.add(18, EvolvedCurrency.GOLD);
|
||||
CURRENCY_WEIGHT.add(9, EvolvedCurrency.IRON);
|
||||
CURRENCY_WEIGHT.add(4, EvolvedCurrency.DIAMOND);
|
||||
CURRENCY_WEIGHT.add(1, EvolvedCurrency.NETHER_STAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void gameEnd(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.End)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : getGame().GetPlayers(true))
|
||||
{
|
||||
EvolvedTrack track = PROGRESSION_MANAGER.get(player, getGame().GetKit(player).GetName());
|
||||
int rolls = 3;
|
||||
|
||||
if (getGame().WinnerTeam != null)
|
||||
{
|
||||
if (getGame().WinnerTeam.HasPlayer(player))
|
||||
{
|
||||
rolls++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < rolls + (Math.random() < 0.1 ? 1 : 0); i++)
|
||||
{
|
||||
EvolvedCurrency currency = CURRENCY_WEIGHT.generateRandom();
|
||||
int amount = UtilMath.r(currency.getMaxPerRoll()) + 1;
|
||||
|
||||
track.incrementCurrency(currency, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ public class GamePlayerManager implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
KitClick(player, kit);
|
||||
KitClick(player, kit, false);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -339,15 +339,15 @@ public class GamePlayerManager implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
KitClick(player, kit);
|
||||
KitClick(player, kit, true);
|
||||
}
|
||||
|
||||
public void KitClick(final Player player, final Kit kit)
|
||||
public void KitClick(final Player player, final Kit kit, boolean leftClick)
|
||||
{
|
||||
/**
|
||||
* Moved to {@link ProgressingKitManager#entityClick(Player, Kit)}
|
||||
*/
|
||||
Manager.getProgressionKitManager().entityClick(player, kit);
|
||||
Manager.getProgressionKitManager().entityClick(player, kit, leftClick);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -151,6 +151,11 @@ public class ProgressingKitManager implements Listener
|
||||
}
|
||||
|
||||
public void entityClick(Player player, Kit kit)
|
||||
{
|
||||
entityClick(player, kit, false);
|
||||
}
|
||||
|
||||
public void entityClick(Player player, Kit kit, boolean leftClick)
|
||||
{
|
||||
PlayerKitApplyEvent kitEvent = new PlayerKitApplyEvent(_manager.GetGame(), kit, player);
|
||||
UtilServer.CallEvent(kitEvent);
|
||||
@ -177,8 +182,15 @@ public class ProgressingKitManager implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
if (leftClick)
|
||||
{
|
||||
_manager.GetGame().SetKit(player, kit, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
new KitDisplayMenu((ProgressingKit) kit, _manager.getKitProgressionManager()).open(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAsyncPreLogin(AsyncPlayerPreLoginEvent event)
|
||||
|
Loading…
Reference in New Issue
Block a user