give enemy info about time before siege and after outpost is built, the health of the outpost

This commit is contained in:
NewGarbo 2016-02-10 13:01:31 +00:00
parent 69bdbdde70
commit 2be917e623
2 changed files with 36 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
@ -698,4 +699,18 @@ public class UtilText
return possesiveNoun.endsWith("s") ? possesiveNoun + "' " + noun : possesiveNoun + "'s " + noun;
}
public static String colorPercentage(int percentage)
{
Map<Integer, String> colors = new HashMap<>();
colors.put(Integer.valueOf(100), C.cGreen);
colors.put(Integer.valueOf(80), C.cDGreen);
colors.put(Integer.valueOf(60), C.cYellow);
colors.put(Integer.valueOf(40), C.cGold);
colors.put(Integer.valueOf(20), C.cRed);
colors.put(Integer.valueOf(0), C.cDRed);
return colors.get(Integer.valueOf(percentage / colors.size()));
}
}

View File

@ -49,6 +49,7 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.Hologram;
@ -311,6 +312,16 @@ public class Outpost implements Listener
protected void update()
{
if (_against != null && getPrepTimeLeft() > 0)
{
_against.getOnlinePlayers().forEach(this::informTimeToSiege);
_owner.getOnlinePlayers().forEach(this::informTimeToSiege);
}
else if (_against != null)
{
UtilTextBottom.display("Enemy Outpost Health: " + UtilText.colorPercentage(getHealthPercentage()) + "%", _against.getOnlinePlayersArray());
}
if (_state == OutpostState.AWAITING)
{
if (getLifetime() > 60000)
@ -608,6 +619,11 @@ public class Outpost implements Listener
// Health Management
public final int getHealthPercentage()
{
return ((int) ((_health / _maxHealth) * 100.d));
}
public final double getHealth()
{
return _health;
@ -669,6 +685,11 @@ public class Outpost implements Listener
}
}
public void informTimeToSiege(Player player)
{
UtilTextBottom.display("Time to Siege: " + F.time(UtilTime.MakeStr(getPrepTimeLeft())), player);
}
public long getPrepBegin()
{
return _prepBegin;