Leaderboards now sort properly, and update every 100 ticks. This will be customizable later.

This commit is contained in:
Garbage Mule 2011-10-02 23:16:47 +02:00
parent 34d2af6c14
commit f808b24464
7 changed files with 57 additions and 10 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: MobArena
main: com.garbagemule.MobArena.MobArena
version: 0.94.3.9
version: 0.94.3.10
softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells]
commands:
ma:

View File

@ -222,6 +222,7 @@ public class Arena
// Initialize leaderboards and start displaying info.
leaderboard.initialize();
leaderboard.startTracking();
// Announce and notify.
MAUtils.tellAll(this, Msg.ARENA_START);
@ -246,6 +247,7 @@ public class Arena
running = false;
// Stop tracking leaderboards
leaderboard.stopTracking();
leaderboard.update();
// Finish logging

View File

@ -34,29 +34,46 @@ public class ArenaPlayerStatistics
public int compare(ArenaPlayerStatistics s1, ArenaPlayerStatistics s2)
{
if (s1.kills > s2.kills)
return 1;
else if (s1.kills < s2.kills)
return -1;
else if (s1.kills < s2.kills)
return 1;
return 0;
}
};
}
private static int compareKills(ArenaPlayerStatistics s1, ArenaPlayerStatistics s2)
{
if (s1.kills > s2.kills)
return -1;
else if (s1.kills < s2.kills)
return 1;
return 0;
}
public static Comparator<ArenaPlayerStatistics> waveComparator()
{
return new Comparator<ArenaPlayerStatistics>()
{
public int compare(ArenaPlayerStatistics s1, ArenaPlayerStatistics s2)
{
if (s1.lastWave > s2.lastWave)
return 1;
else if (s1.lastWave < s2.lastWave)
return -1;
return 0;
int result = compareWaves(s1, s2);
if (result != 0) return result;
return compareKills(s1, s2);
}
};
}
private static int compareWaves(ArenaPlayerStatistics s1, ArenaPlayerStatistics s2)
{
if (s1.lastWave > s2.lastWave)
return -1;
else if (s1.lastWave < s2.lastWave)
return 1;
return 0;
}
public static Comparator<ArenaPlayerStatistics> dmgDoneComparator()
{
return new Comparator<ArenaPlayerStatistics>()
@ -64,9 +81,9 @@ public class ArenaPlayerStatistics
public int compare(ArenaPlayerStatistics s1, ArenaPlayerStatistics s2)
{
if (s1.dmgDone > s2.dmgDone)
return 1;
else if (s1.dmgDone < s2.dmgDone)
return -1;
else if (s1.dmgDone < s2.dmgDone)
return 1;
return 0;
}
};

View File

@ -77,6 +77,9 @@ public class MASpawnThread implements Runnable
// Find the wave to spawn
spawnWave(wave);
// Update stats
updateStats(wave);
wave++;
if (arena.monsters.isEmpty())
arena.resetIdleTimer();
@ -130,6 +133,13 @@ public class MASpawnThread implements Runnable
w.spawn(wave);
}
private void updateStats(int wave)
{
for (ArenaPlayer ap: arena.getArenaPlayerSet())
if (arena.getArenaPlayers().contains(ap.getPlayer()))
ap.getStats().lastWave++;
}
private SortedSet<Wave> getMatchingRecurrentWaves(int wave)
{
TreeSet<Wave> result = new TreeSet<Wave>(WaveUtils.getRecurrentComparator());

View File

@ -99,6 +99,13 @@ public class Leaderboard
initializeBoards();
initializeStats();
clear();
}
public void clear()
{
for (LeaderboardColumn column : boards)
column.clear();
}
public void update()

View File

@ -66,6 +66,17 @@ public class LeaderboardColumn
catch (Exception e) { e.printStackTrace(); }
}
public void clear()
{
for (Sign s : signs)
{
s.setLine(0, "");
s.setLine(1, "");
s.setLine(2, "");
s.setLine(3, "");
}
}
public Sign getHeader()
{
return header;