Fix level display for real this time
This commit is contained in:
parent
ddf0666ba6
commit
a70be6ffd8
@ -29,6 +29,7 @@ import nautilus.game.arcade.game.games.moba.fountain.MobaFountain;
|
||||
import nautilus.game.arcade.game.games.moba.general.ArrowKBManager;
|
||||
import nautilus.game.arcade.game.games.moba.general.BetaManager;
|
||||
import nautilus.game.arcade.game.games.moba.general.EnderPearlManager;
|
||||
import nautilus.game.arcade.game.games.moba.general.HotJoiningManager;
|
||||
import nautilus.game.arcade.game.games.moba.general.MobaDamageManager;
|
||||
import nautilus.game.arcade.game.games.moba.gold.GoldManager;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
|
||||
@ -312,7 +313,7 @@ public class Moba extends TeamGame
|
||||
|
||||
private void cleanupLobby()
|
||||
{
|
||||
if (_mapManager != null && _board != null)
|
||||
if (_board != null)
|
||||
{
|
||||
_mapManager.cleanupBoard(_board);
|
||||
_selector.cleanup();
|
||||
|
@ -6,6 +6,7 @@ import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
|
||||
import nautilus.game.arcade.game.games.moba.general.HotJoiningManager;
|
||||
import nautilus.game.arcade.game.games.moba.prepare.PrepareManager;
|
||||
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
|
||||
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
|
||||
@ -47,6 +48,9 @@ public class MobaClassic extends Moba
|
||||
registerManager(new PrepareManager(this));
|
||||
registerManager(new PrepareSelection(this));
|
||||
|
||||
// Hot joining
|
||||
registerManager(new HotJoiningManager(this));
|
||||
|
||||
// new GameStatisticsModule()
|
||||
// .register(this);
|
||||
|
||||
|
@ -0,0 +1,88 @@
|
||||
package nautilus.game.arcade.game.games.moba.general;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.moba.Moba;
|
||||
import nautilus.game.arcade.game.games.moba.progression.MobaExperienceCalculateEvent;
|
||||
import nautilus.game.arcade.game.games.moba.structure.tower.Tower;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HotJoiningManager implements Listener
|
||||
{
|
||||
|
||||
private static final int HOT_JOIN_EXP_REWARD = 100;
|
||||
|
||||
private final Moba _host;
|
||||
private final List<Player> _hotJoined;
|
||||
|
||||
public HotJoiningManager(Moba host)
|
||||
{
|
||||
_host = host;
|
||||
_hotJoined = new ArrayList<>();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (!_host.IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
GameTeam team = _host.ChooseTeam(player);
|
||||
|
||||
if (team == null || _host.getArcadeManager().isVanished(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Tower tower : _host.getTowerManager().getTowers())
|
||||
{
|
||||
// If the team's second tower is dead
|
||||
if (tower.getOwner().equals(team) && !tower.isFirstTower() && tower.isDead())
|
||||
{
|
||||
player.sendMessage(F.main("Game", "Sorry but you can only join a game in progress if they have at least " + F.elem(1) + " tower alive."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
team.AddPlayer(player, true);
|
||||
team.SpawnTeleport(player);
|
||||
_hotJoined.add(player);
|
||||
|
||||
_host.getArcadeManager().runSyncLater(() ->
|
||||
{
|
||||
Kit kit = _host.getFirstKit(player);
|
||||
|
||||
player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game "));
|
||||
_host.SetKit(player, kit, true);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
_hotJoined.remove(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void expCalculate(MobaExperienceCalculateEvent event)
|
||||
{
|
||||
if (_hotJoined.contains(event.getPlayer()))
|
||||
{
|
||||
event.getExpEarned().getAndAdd(HOT_JOIN_EXP_REWARD);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,11 @@
|
||||
package nautilus.game.arcade.game.games.moba.prepare;
|
||||
|
||||
import mineplex.core.common.entity.ClientArmorStand;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
|
||||
@ -80,9 +84,6 @@ public class PrepareManager implements Listener
|
||||
}
|
||||
|
||||
HeroKit heroKit = _host.getFirstKit(player);
|
||||
MobaPlayer mobaPlayer = _host.getMobaData(player);
|
||||
|
||||
mobaPlayer.setRole(heroKit.getRole());
|
||||
|
||||
_host.SetKit(player, heroKit, true);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package nautilus.game.arcade.game.games.moba.progression;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MobaExperienceCalculateEvent extends PlayerEvent
|
||||
{
|
||||
|
||||
private static final HandlerList _handlers = new HandlerList();
|
||||
|
||||
private AtomicInteger _expEarned;
|
||||
|
||||
public MobaExperienceCalculateEvent(Player player, AtomicInteger expEarned)
|
||||
{
|
||||
super(player);
|
||||
|
||||
_expEarned = expEarned;
|
||||
}
|
||||
|
||||
public AtomicInteger getExpEarned()
|
||||
{
|
||||
return _expEarned;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
}
|
@ -26,6 +26,11 @@ public class MobaLevelData
|
||||
return _level;
|
||||
}
|
||||
|
||||
public int getDisplayLevel()
|
||||
{
|
||||
return _level + 1;
|
||||
}
|
||||
|
||||
public int getExpThisLevel()
|
||||
{
|
||||
return _thisLevel;
|
||||
@ -36,6 +41,11 @@ public class MobaLevelData
|
||||
return _nextLevel - _thisLevel;
|
||||
}
|
||||
|
||||
public int getExpLevelProgress()
|
||||
{
|
||||
return _exp - _thisLevel;
|
||||
}
|
||||
|
||||
public int getExpReminder()
|
||||
{
|
||||
return _nextLevel - _exp;
|
||||
@ -43,6 +53,6 @@ public class MobaLevelData
|
||||
|
||||
public double getPercentageComplete()
|
||||
{
|
||||
return (double) (_exp - _thisLevel) / (double) (getExpJustThisLevel());
|
||||
return (double) (getExpLevelProgress()) / (double) (getExpJustThisLevel());
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class MobaProgression implements Listener
|
||||
|
||||
public static int getExpFor(int level)
|
||||
{
|
||||
return EXP_PER_LEVEL * (level - 1);
|
||||
return EXP_PER_LEVEL * level;
|
||||
}
|
||||
|
||||
public static int getLevel(long exp)
|
||||
@ -82,9 +82,9 @@ public class MobaProgression implements Listener
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
MobaRole role = MobaRole.valueOf(args[0].toUpperCase());
|
||||
int exp = getExpFor(Integer.parseInt(args[1])) - 1;
|
||||
int exp = getExpFor(Integer.parseInt(args[1]) - 1);
|
||||
_host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp);
|
||||
caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp)) + "."));
|
||||
caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp) + 1) + "."));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -206,9 +206,6 @@ public class MobaProgression implements Listener
|
||||
// Level before earning
|
||||
int currentLevel = getLevel(currentExp);
|
||||
|
||||
player.sendMessage("currentExp = " + currentExp);
|
||||
player.sendMessage("currentLevel = " + currentLevel);
|
||||
|
||||
AtomicInteger earnedExp = new AtomicInteger();
|
||||
|
||||
for (GemData data : _host.GetGems(player).values())
|
||||
@ -217,14 +214,11 @@ public class MobaProgression implements Listener
|
||||
}
|
||||
|
||||
earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR);
|
||||
MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get());
|
||||
|
||||
player.sendMessage("exp = " + levelData.getExp());
|
||||
player.sendMessage("level = " + levelData.getLevel());
|
||||
player.sendMessage("thisLevel = " + levelData.getExpThisLevel());
|
||||
player.sendMessage("justThisLevel = " + levelData.getExpJustThisLevel());
|
||||
player.sendMessage("reminder = " + levelData.getExpReminder());
|
||||
player.sendMessage("percentage = " + levelData.getPercentageComplete());
|
||||
MobaExperienceCalculateEvent event = new MobaExperienceCalculateEvent(player, earnedExp);
|
||||
UtilServer.CallEvent(event);
|
||||
|
||||
MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get());
|
||||
|
||||
AtomicBoolean levelUp = new AtomicBoolean(levelData.getLevel() > currentLevel);
|
||||
|
||||
@ -237,8 +231,8 @@ public class MobaProgression implements Listener
|
||||
|
||||
player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : ""));
|
||||
player.sendMessage("");
|
||||
player.sendMessage(MobaUtil.getProgressBar(currentExp, levelData.getExp(), levelData.getExpThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel());
|
||||
player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D) + C.cWhite + "% complete for Level " + currentLevel));
|
||||
player.sendMessage(MobaUtil.getProgressBar(levelData.getExpLevelProgress() - earnedExp.get(), levelData.getExpLevelProgress(), levelData.getExpJustThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel());
|
||||
player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D)) + C.cWhite + "% complete for Level " + levelData.getDisplayLevel());
|
||||
|
||||
player.sendMessage("");
|
||||
player.sendMessage(ArcadeFormat.Line);
|
||||
@ -247,7 +241,7 @@ public class MobaProgression implements Listener
|
||||
{
|
||||
for (HeroKit kit : _host.getKits())
|
||||
{
|
||||
if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getLevel())
|
||||
if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getDisplayLevel())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ public class MobaRolePage extends ShopPageBase<ArcadeManager, MobaRoleShop>
|
||||
"Every " + F.elem(10) + " levels you unlock a new",
|
||||
"hero within the " + F.name(_role.getName()) + " category.",
|
||||
"",
|
||||
"Your Level: " + C.cGreen + levelData.getLevel(),
|
||||
"Next Level: " + C.cGreen + levelData.getExpReminder() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)"
|
||||
"Your Level: " + C.cGreen + levelData.getDisplayLevel(),
|
||||
"Next Level: " + C.cGreen + levelData.getExpLevelProgress() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)"
|
||||
)
|
||||
.build());
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class MobaUtil
|
||||
}
|
||||
else
|
||||
{
|
||||
out.append(C.cGrayB).append("|");
|
||||
out.append(C.cGray).append("|");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user