Refactor onChallengeUpdate method.
This commit is contained in:
parent
4c8292e7c9
commit
115508cf72
@ -144,7 +144,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
|
||||
private Challenge _challenge;
|
||||
private ArrayList<Block> _lastChallengeBlocks;
|
||||
private long _challengeTime;
|
||||
private long _delay;
|
||||
|
||||
private String _restrictCommand = "restrict";
|
||||
private String _skipCommand = "skip";
|
||||
@ -322,23 +322,21 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (_challenge == null)
|
||||
if (_challenge == null) // Triggered after the first challenge ends.
|
||||
{
|
||||
if (!UtilTime.elapsed(_delay, 1500))
|
||||
{
|
||||
if (!UtilTime.elapsed(_challengeTime, 1500))
|
||||
return;
|
||||
|
||||
resetDeadPlayers();
|
||||
|
||||
}
|
||||
_challenge = selectChallenge();
|
||||
|
||||
resetDeadPlayers();
|
||||
keepSearchingWhenNull();
|
||||
|
||||
resetLastChallengeMap();
|
||||
|
||||
_deathEffect.removeSpawnedEntities();
|
||||
|
||||
setupChallengeSpawnLocations();
|
||||
|
||||
_challenge.createMap();
|
||||
_challenge.markSpawnLocations(); // Debug
|
||||
|
||||
@ -351,20 +349,27 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
challengeWithRooms.assignRooms();
|
||||
}
|
||||
|
||||
_challengeTime = System.currentTimeMillis();
|
||||
_delay = System.currentTimeMillis();
|
||||
_settings.setWaiting(true);
|
||||
}
|
||||
else if (_settings.isWaiting())
|
||||
else if (_settings.isWaiting()) // Triggered when a challenge should start.
|
||||
{
|
||||
if (!UtilTime.elapsed(_delay, 1000))
|
||||
{
|
||||
if (!UtilTime.elapsed(_challengeTime, 1000))
|
||||
return;
|
||||
|
||||
if (!_settings.areMessagesBeingSent() && !_settings.areMessagesSent())
|
||||
{
|
||||
addEffectsToPlayers();
|
||||
startChallengeDescriptionThread();
|
||||
}
|
||||
else if (_settings.areMessagesSent())
|
||||
|
||||
displayDescriptionAndStartChallenge();
|
||||
}
|
||||
else // Triggered when a challenge should end.
|
||||
{
|
||||
checkChallengeEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayDescriptionAndStartChallenge()
|
||||
{
|
||||
if (_settings.areMessagesSent())
|
||||
{
|
||||
removeEffectsFromPlayers();
|
||||
|
||||
@ -377,8 +382,14 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
Manager.getPluginManager().registerEvents(_challenge, Manager.getPlugin());
|
||||
_settings.markMessagesAsSent(false);
|
||||
}
|
||||
else if (!_settings.areMessagesBeingSent())
|
||||
{
|
||||
addEffectsToPlayers();
|
||||
startChallengeDescriptionThread();
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
private void checkChallengeEnd()
|
||||
{
|
||||
if (_challenge.canFinish())
|
||||
{
|
||||
@ -405,7 +416,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
updateChallengeTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void announceCrumbling()
|
||||
{
|
||||
@ -418,39 +428,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Location> getBestSpawnLocations()
|
||||
{
|
||||
ArrayList<Location> available = setupChallengeSpawnLocations();
|
||||
ArrayList<Location> selected = new ArrayList<Location>();
|
||||
|
||||
for (int i = 0; i < available.size(); i++)
|
||||
{
|
||||
Location furthest = null;
|
||||
double furthestDist = 0;
|
||||
|
||||
for (Location spawn : available)
|
||||
{
|
||||
if (selected.contains(spawn))
|
||||
continue;
|
||||
|
||||
double dist = 0;
|
||||
|
||||
for (Location loc : selected)
|
||||
dist += loc.distance(spawn);
|
||||
|
||||
if (furthest == null || furthestDist < dist)
|
||||
{
|
||||
furthest = spawn;
|
||||
furthestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
selected.add(furthest);
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
private void resetDeadPlayers()
|
||||
{
|
||||
for (Player player : GetPlayers(false))
|
||||
@ -614,7 +591,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
|
||||
public void endCurrentChallenge()
|
||||
{
|
||||
_challengeTime = System.currentTimeMillis();
|
||||
_delay = System.currentTimeMillis();
|
||||
|
||||
resetPlayersOnChallengeEnding();
|
||||
|
||||
@ -1386,7 +1363,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
_challengeTime = System.currentTimeMillis();
|
||||
_delay = System.currentTimeMillis();
|
||||
|
||||
_chickenAttack = new ChickenAttack(this, _chickenAttackCenter);
|
||||
}
|
||||
@ -1545,9 +1522,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
return _challenge;
|
||||
}
|
||||
|
||||
public long getChallengeTime()
|
||||
public long getCurrentDelay()
|
||||
{
|
||||
return _challengeTime;
|
||||
return _delay;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user