Bridges Tourney stuff
This commit is contained in:
parent
21314afabe
commit
fa73ab5335
@ -68,7 +68,7 @@ public class UtilTime
|
||||
|
||||
public static String MakeStr(long time, int trim)
|
||||
{
|
||||
return convertString(time, trim, TimeUnit.FIT);
|
||||
return convertString(Math.max(0, time), trim, TimeUnit.FIT);
|
||||
}
|
||||
|
||||
public static String convertString(long time, int trim, TimeUnit type)
|
||||
|
@ -1030,4 +1030,9 @@ public abstract class Game implements Listener
|
||||
if (team != null)
|
||||
team.SetPlacement(event.GetPlayer(), event.GetState());
|
||||
}
|
||||
|
||||
public void HandleTimeout()
|
||||
{
|
||||
SetState(GameState.End);
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.bridge.kits.*;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.ore.OreHider;
|
||||
@ -102,9 +103,8 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
//Tourney Mode
|
||||
private boolean _tournament;
|
||||
private HashMap<GameTeam, Integer> _tournamentKills = new HashMap<GameTeam, Integer>();
|
||||
private long _tournamentKillMessageTimer = 0;
|
||||
|
||||
//Scoreboard
|
||||
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
|
||||
|
||||
public Bridge(ArcadeManager manager)
|
||||
{
|
||||
@ -130,15 +130,15 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
_ore = new OreHider();
|
||||
|
||||
// Flags
|
||||
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 1800000;
|
||||
|
||||
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000;
|
||||
|
||||
DamageSelf = true;
|
||||
|
||||
ItemDrop = true;
|
||||
ItemPickup = true;
|
||||
|
||||
InventoryClick = true;
|
||||
|
||||
|
||||
PrivateBlocks = true;
|
||||
BlockBreak = true;
|
||||
BlockPlace = true;
|
||||
@ -155,14 +155,14 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
DeathDropItems = true;
|
||||
|
||||
GemMultiplier = 2.5;
|
||||
|
||||
|
||||
PrepareFreeze = false;
|
||||
|
||||
|
||||
//Tournament
|
||||
if (Manager.IsTournamentServer())
|
||||
{
|
||||
QuitOut = false;
|
||||
|
||||
|
||||
_gameDesc = new String[]
|
||||
{
|
||||
"Gather resources and prepare for combat.",
|
||||
@ -171,8 +171,8 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
"Team with the most kills wins!"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
_tournament = Manager.IsTournamentServer();
|
||||
}
|
||||
|
||||
@ -313,22 +313,22 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
|
||||
return ItemStackFactory.Instance.CreateStack(stack.getTypeId(), amount);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void ChestDeny(PlayerInteractEvent event)
|
||||
{
|
||||
if (_bridgesDown)
|
||||
return;
|
||||
|
||||
|
||||
if (event.getClickedBlock() == null)
|
||||
return;
|
||||
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
return;
|
||||
|
||||
|
||||
for (Location loc : WorldData.GetCustomLocs("54"))
|
||||
{
|
||||
if (loc.getBlock().equals(event.getClickedBlock()))
|
||||
@ -338,16 +338,16 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void ChestDeny(BlockBreakEvent event)
|
||||
{
|
||||
if (_bridgesDown)
|
||||
return;
|
||||
|
||||
|
||||
if (event.getBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
|
||||
for (Location loc : WorldData.GetCustomLocs("54"))
|
||||
{
|
||||
if (loc.getBlock().equals(event.getBlock()))
|
||||
@ -525,11 +525,11 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
|
||||
BlockFace faceXZ = BlockFace.SELF;
|
||||
BlockFace faceY = BlockFace.SELF;
|
||||
|
||||
|
||||
if (Math.random() > 0.20)
|
||||
{
|
||||
int rFace = UtilMath.r(6);
|
||||
|
||||
|
||||
if (rFace == 0) faceY = BlockFace.UP;
|
||||
else if (rFace == 1) faceY = BlockFace.DOWN;
|
||||
else if (rFace == 2) faceXZ = BlockFace.NORTH;
|
||||
@ -541,16 +541,16 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
{
|
||||
//Height
|
||||
int rFace = UtilMath.r(3);
|
||||
|
||||
|
||||
if (rFace == 0) faceY = BlockFace.SELF;
|
||||
else if (rFace == 1) faceY = BlockFace.UP;
|
||||
else faceY = BlockFace.DOWN;
|
||||
|
||||
|
||||
//Flat
|
||||
if (faceY == BlockFace.SELF)
|
||||
{
|
||||
rFace = UtilMath.r(4);
|
||||
|
||||
|
||||
if (rFace == 0) faceXZ = BlockFace.NORTH_EAST;
|
||||
else if (rFace == 1) faceXZ = BlockFace.NORTH_WEST;
|
||||
else if (rFace == 2) faceXZ = BlockFace.SOUTH_EAST;
|
||||
@ -559,17 +559,17 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
else
|
||||
{
|
||||
rFace = UtilMath.r(4);
|
||||
|
||||
|
||||
if (rFace == 0) faceXZ = BlockFace.NORTH;
|
||||
else if (rFace == 1) faceXZ = BlockFace.SOUTH;
|
||||
else if (rFace == 2) faceXZ = BlockFace.EAST;
|
||||
else faceXZ = BlockFace.WEST;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (loc.getBlock().getRelative(faceY).getRelative(faceXZ).getType() != Material.STONE)
|
||||
continue;
|
||||
|
||||
|
||||
loc = loc.getBlock().getRelative(faceY).getRelative(faceXZ).getLocation();
|
||||
|
||||
_ore.AddOre(loc, type);
|
||||
@ -1113,13 +1113,13 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
if (this.GetPlayers(true).size() < 10)
|
||||
{
|
||||
Scoreboard.WriteBlank();
|
||||
|
||||
|
||||
for (Player player : team.GetPlayers(true))
|
||||
{
|
||||
Scoreboard.Write(team.GetColor() + player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Display Players Alive
|
||||
else
|
||||
{
|
||||
@ -1139,15 +1139,15 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
kills = _tournamentKills.get(team);
|
||||
|
||||
Scoreboard.WriteBlank();
|
||||
|
||||
|
||||
Scoreboard.Write(team.GetColor() + " " + team.GetPlayers(true).size() + " Players");
|
||||
Scoreboard.Write(team.GetColor() + " " + kills + " Kills");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Scoreboard.WriteBlank();
|
||||
|
||||
|
||||
|
||||
|
||||
long time = _bridgeTime
|
||||
- (System.currentTimeMillis() - this.GetStateTime());
|
||||
|
||||
@ -1158,9 +1158,10 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
else
|
||||
{
|
||||
Scoreboard.Write(C.cYellow + C.Bold + "FIGHT!");
|
||||
Scoreboard.Write(C.cYellow + C.Bold + "Time Left");
|
||||
Scoreboard.Write(UtilTime.MakeStr(5400000 - this.GetStateTime(), 0));
|
||||
}
|
||||
|
||||
|
||||
Scoreboard.Draw();
|
||||
}
|
||||
|
||||
@ -1199,7 +1200,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void EndCheck()
|
||||
{
|
||||
@ -1218,7 +1219,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
for (GameTeam team : RejoinTeam.values())
|
||||
teamsAlive.add(team);
|
||||
}
|
||||
|
||||
|
||||
if (teamsAlive.size() <= 1)
|
||||
{
|
||||
//Announce Winner
|
||||
@ -1231,13 +1232,13 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
{
|
||||
GameTeam bestTeam = null;
|
||||
int bestKills = 0;
|
||||
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (_tournamentKills.containsKey(team))
|
||||
{
|
||||
int kills = _tournamentKills.get(team);
|
||||
|
||||
|
||||
if (bestTeam == null || bestKills < kills)
|
||||
{
|
||||
bestTeam = team;
|
||||
@ -1245,12 +1246,12 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (bestTeam != null)
|
||||
AnnounceEnd(bestTeam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (WinnerTeam != null && team.equals(WinnerTeam))
|
||||
@ -1258,14 +1259,85 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
for (Player player : team.GetPlayers(false))
|
||||
AddGems(player, 10, "Winning Team", false);
|
||||
}
|
||||
|
||||
|
||||
for (Player player : team.GetPlayers(false))
|
||||
if (player.isOnline())
|
||||
AddGems(player, 10, "Participation", false);
|
||||
}
|
||||
|
||||
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleTimeout()
|
||||
{
|
||||
if (!_tournament)
|
||||
{
|
||||
SetState(GameState.End);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<GameTeam> bestTeams = new ArrayList<GameTeam>();
|
||||
int bestKills = 0;
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (_tournamentKills.containsKey(team))
|
||||
{
|
||||
int kills = _tournamentKills.get(team);
|
||||
|
||||
if (bestTeams == null || kills > bestKills)
|
||||
{
|
||||
bestTeams.clear();
|
||||
bestTeams.add(team);
|
||||
bestKills = kills;
|
||||
}
|
||||
|
||||
else if (kills == bestKills)
|
||||
{
|
||||
bestTeams.add(team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Many Teams Alive
|
||||
if (bestTeams.size() > 1)
|
||||
{
|
||||
if (UtilTime.elapsed(_tournamentKillMessageTimer, 15000))
|
||||
{
|
||||
_tournamentKillMessageTimer = System.currentTimeMillis();
|
||||
|
||||
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "FIRST TEAM TO TAKE THE LEAD WINS!");
|
||||
}
|
||||
}
|
||||
|
||||
//Team Won
|
||||
else if (bestTeams.size() == 1)
|
||||
{
|
||||
AnnounceEnd(bestTeams.get(0));
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (WinnerTeam != null && team.equals(WinnerTeam))
|
||||
{
|
||||
for (Player player : team.GetPlayers(false))
|
||||
AddGems(player, 10, "Winning Team", false);
|
||||
}
|
||||
|
||||
for (Player player : team.GetPlayers(false))
|
||||
if (player.isOnline())
|
||||
AddGems(player, 10, "Participation", false);
|
||||
}
|
||||
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
//No One Wins :'(
|
||||
else
|
||||
{
|
||||
SetState(GameState.End);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public class GameManager implements Listener
|
||||
{
|
||||
if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout))
|
||||
{
|
||||
game.SetState(GameState.End);
|
||||
game.HandleTimeout();
|
||||
}
|
||||
}
|
||||
else if (game.GetState() == GameState.End)
|
||||
|
Loading…
Reference in New Issue
Block a user