Changing some Achievement things, to allow double values and dividing, Adding WPM, fixing some bugs.
This commit is contained in:
parent
3f7eef35d5
commit
484dce18e1
@ -152,8 +152,9 @@ public enum AchievementCategory
|
||||
Material.ROTTEN_FLESH, 0, GameCategory.ARCADE, "SoonTM"),
|
||||
|
||||
TYPE_WARS("Type Wars", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED},
|
||||
Material.FEATHER, 0, GameCategory.ARCADE, "Alpha. Tactician");
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minons killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED},
|
||||
Material.FEATHER, 0, GameCategory.ARCADE, null);
|
||||
|
||||
private String _name;
|
||||
private String[] _statsToPull;
|
||||
private StatDisplay[] _statDisplays;
|
||||
@ -240,7 +241,7 @@ public enum AchievementCategory
|
||||
if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
|
||||
continue;
|
||||
|
||||
int statNumber = 0;
|
||||
double statNumber = 0;
|
||||
|
||||
|
||||
// This is so we could load stats from other games
|
||||
@ -253,14 +254,53 @@ public enum AchievementCategory
|
||||
else
|
||||
{
|
||||
for (String statToPull : _statsToPull)
|
||||
{
|
||||
for (String statName : _statDisplays[i].getStats())
|
||||
{
|
||||
if(_statDisplays[i].isDivideStats())
|
||||
{
|
||||
if(statNumber == 0)
|
||||
{
|
||||
statNumber = stats.getStat(statToPull + "." + statName);
|
||||
continue;
|
||||
}
|
||||
double stat = stats.getStat(statToPull + "." + statName);
|
||||
if(stat == 0)
|
||||
statNumber = statNumber / 1;
|
||||
else
|
||||
{
|
||||
if(statName.contentEquals("TimeInGame"))
|
||||
statNumber = (double) statNumber / (double) (stat / 60000);
|
||||
else
|
||||
statNumber = (double) statNumber / stat;
|
||||
}
|
||||
}
|
||||
else
|
||||
statNumber += stats.getStat(statToPull + "." + statName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String statString = C.cWhite + statNumber;
|
||||
String statString = C.cWhite + Math.round(statNumber);
|
||||
|
||||
// doubles
|
||||
// Special display for Words per Minute
|
||||
if (displayName.equalsIgnoreCase("Words Per Minute"))
|
||||
{
|
||||
statString = C.cWhite + statNumber;
|
||||
if(statString.length() > 7)
|
||||
statString.substring(0, 6);
|
||||
|
||||
lore.add(C.cYellow + displayName + ": " + statString);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// ints
|
||||
// Need to display special for time
|
||||
if (displayName.equalsIgnoreCase("Time In Game"))
|
||||
statString = C.cWhite + UtilTime.convertString(statNumber * 1000L, 0, UtilTime.TimeUnit.FIT);
|
||||
statString = C.cWhite + UtilTime.convertString(Math.round(statNumber) * 1000L, 0, UtilTime.TimeUnit.FIT);
|
||||
|
||||
|
||||
lore.add(C.cYellow + displayName + ": " + statString);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ public class StatDisplay
|
||||
private String[] _stats;
|
||||
private boolean _fullStat;
|
||||
private boolean _justDisplayName;
|
||||
private boolean _divideStats;
|
||||
|
||||
public StatDisplay(String stat)
|
||||
{
|
||||
@ -25,19 +26,26 @@ public class StatDisplay
|
||||
_displayName = stat;
|
||||
_stats = new String[] { stat };
|
||||
_fullStat = false;
|
||||
_divideStats = false;
|
||||
_justDisplayName = justDisplayName;
|
||||
}
|
||||
|
||||
public StatDisplay(String displayName, boolean divideStats, String... stats)
|
||||
{
|
||||
this(displayName, false, divideStats, stats);
|
||||
}
|
||||
|
||||
public StatDisplay(String displayName, String... stats)
|
||||
{
|
||||
this(displayName, false, stats);
|
||||
this(displayName, false, false, stats);
|
||||
}
|
||||
|
||||
public StatDisplay(String displayName, boolean fullStat, String... stats)
|
||||
public StatDisplay(String displayName, boolean fullStat, boolean divideStats, String... stats)
|
||||
{
|
||||
_displayName = displayName;
|
||||
_stats = stats;
|
||||
_fullStat = fullStat;
|
||||
_divideStats = divideStats;
|
||||
}
|
||||
|
||||
public String getDisplayName()
|
||||
@ -60,6 +68,11 @@ public class StatDisplay
|
||||
return _fullStat;
|
||||
}
|
||||
|
||||
public boolean isDivideStats()
|
||||
{
|
||||
return _divideStats;
|
||||
}
|
||||
|
||||
public static StatDisplay fromGame(String name, GameDisplay gameDisplay, String... stats)
|
||||
{
|
||||
String[] formattedStats = new String[stats.length];
|
||||
|
@ -37,6 +37,7 @@ import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything;
|
||||
import nautilus.game.arcade.game.games.typewars.stats.DemonStatsTracker;
|
||||
import nautilus.game.arcade.game.games.typewars.stats.DumbledontStatTracker;
|
||||
import nautilus.game.arcade.game.games.typewars.stats.HoarderStatTracker;
|
||||
import nautilus.game.arcade.game.games.typewars.stats.KillsStatTracker;
|
||||
import nautilus.game.arcade.game.games.typewars.stats.PerfectionistStatTracker;
|
||||
import nautilus.game.arcade.game.games.typewars.stats.WaitForItStatTracker;
|
||||
import nautilus.game.arcade.game.games.typewars.tutorial.TutorialTypeWars;
|
||||
@ -160,7 +161,9 @@ public class TypeWars extends TeamGame
|
||||
new DumbledontStatTracker(this),
|
||||
new HoarderStatTracker(this),
|
||||
new PerfectionistStatTracker(this),
|
||||
new WaitForItStatTracker(this));
|
||||
new WaitForItStatTracker(this),
|
||||
new KillsStatTracker(this)
|
||||
);
|
||||
|
||||
manager.GetCreature().SetDisableCustomDrops(true);
|
||||
}
|
||||
@ -288,7 +291,7 @@ public class TypeWars extends TeamGame
|
||||
public void Players(UpdateEvent event)
|
||||
{
|
||||
|
||||
if(GetState() != GameState.Live && GetState() != GameState.Prepare && GetState() != GameState.End)
|
||||
if(GetState() != GameState.Live && GetState() != GameState.End)
|
||||
return;
|
||||
|
||||
for(Player player : GetPlayers(true))
|
||||
@ -512,7 +515,7 @@ public class TypeWars extends TeamGame
|
||||
{
|
||||
if(getMinions(teams).size() >= 60)
|
||||
{
|
||||
UtilTextMiddle.display("", ChatColor.GRAY + "Your Team cant have more than 60 Minions", 5, 30, 5);
|
||||
UtilTextMiddle.display("", ChatColor.GRAY + "Your Team can't have more than 60 Minions", 5, 30, 5, event.getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -800,15 +803,6 @@ public class TypeWars extends TeamGame
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void titles(GameStateChangeEvent event)
|
||||
{
|
||||
if(event.GetState() == GameState.Live)
|
||||
{
|
||||
UtilTextMiddle.display("", "Type the names over mob's heads to kill them!", 20, Integer.MAX_VALUE, 20, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void chatCheck(PlayerChatEvent event)
|
||||
{
|
||||
@ -957,6 +951,11 @@ public class TypeWars extends TeamGame
|
||||
Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team");
|
||||
Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team)));
|
||||
Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60");
|
||||
String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000));
|
||||
if(wpm.length() > 4)
|
||||
wpm = wpm.substring(0, 4);
|
||||
|
||||
Scoreboard.Write(team.GetColor() + "WPM: " + wpm);
|
||||
Scoreboard.WriteBlank();
|
||||
}
|
||||
|
||||
@ -1152,6 +1151,11 @@ public class TypeWars extends TeamGame
|
||||
Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team");
|
||||
Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team)));
|
||||
Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60");
|
||||
String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000));
|
||||
if(wpm.length() > 4)
|
||||
wpm = wpm.substring(0, 4);
|
||||
|
||||
Scoreboard.Write(team.GetColor() + "WPM: " + wpm);
|
||||
Scoreboard.WriteBlank();
|
||||
}
|
||||
|
||||
@ -1242,6 +1246,32 @@ public class TypeWars extends TeamGame
|
||||
_nukeFrame++;
|
||||
}
|
||||
|
||||
public int getPlayerKills(Player player)
|
||||
{
|
||||
int kills = 0;
|
||||
for(Minion minion : _deadMinions)
|
||||
{
|
||||
if(minion.getPlayer() != null)
|
||||
{
|
||||
if(minion.getPlayer().getName().contentEquals(player.getName()))
|
||||
{
|
||||
kills++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return kills;
|
||||
}
|
||||
|
||||
public int getTeamKills(GameTeam team)
|
||||
{
|
||||
int kills = 0;
|
||||
for(Player player : team.GetPlayers(true))
|
||||
{
|
||||
kills = kills + getPlayerKills(player);
|
||||
}
|
||||
return kills;
|
||||
}
|
||||
|
||||
public HashMap<Player, Integer> getMoneyMap()
|
||||
{
|
||||
return _moneyMap;
|
||||
|
@ -0,0 +1,35 @@
|
||||
package nautilus.game.arcade.game.games.typewars.stats;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.typewars.TypeWars;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
public class KillsStatTracker extends StatTracker<TypeWars>
|
||||
{
|
||||
|
||||
private TypeWars _typeWars;
|
||||
|
||||
public KillsStatTracker(TypeWars game)
|
||||
{
|
||||
super(game);
|
||||
_typeWars = game;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void end(GameStateChangeEvent event)
|
||||
{
|
||||
if(event.GetState() != GameState.End)
|
||||
return;
|
||||
|
||||
for(Player player : _typeWars.GetPlayers(true))
|
||||
{
|
||||
addStat(player, "MinionKills", _typeWars.getPlayerKills(player), false, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -168,15 +168,15 @@ public class GameManager implements Listener
|
||||
if(!team.getTutorial().hasEnded())
|
||||
{
|
||||
finished = false;
|
||||
}
|
||||
if(checkForTimer)
|
||||
{
|
||||
if(team.getTutorial().ShowPrepareTimer)
|
||||
if(!team.getTutorial().ShowPrepareTimer)
|
||||
finished = false;
|
||||
else
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(prepTime <= timeUsage)
|
||||
prepTime = timeUsage;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user