Add lives limit for final event
This commit is contained in:
parent
827d1ba070
commit
160eb45f8d
2 changed files with 10 additions and 2 deletions
|
@ -55,7 +55,7 @@ public class EventRunner implements Runnable {
|
||||||
case 9 -> new KillMobs2Event(team, difficulty, dayScore);
|
case 9 -> new KillMobs2Event(team, difficulty, dayScore);
|
||||||
case 10 -> new RunToSpawnEvent(team, difficulty, dayScore);
|
case 10 -> new RunToSpawnEvent(team, difficulty, dayScore);
|
||||||
case 11 -> new LightningEvent(team, difficulty, dayScore);
|
case 11 -> new LightningEvent(team, difficulty, dayScore);
|
||||||
case 12 -> new EndEvent(team, difficulty, dayScore); // TODO: Move to last day
|
case 12 -> new EndEvent(team, difficulty, dayScore);
|
||||||
default -> throw new IllegalStateException("Unexpected day: " + (int) day);
|
default -> throw new IllegalStateException("Unexpected day: " + (int) day);
|
||||||
};
|
};
|
||||||
event.start();
|
event.start();
|
||||||
|
|
|
@ -19,6 +19,7 @@ import gent.zeus.mc13dtl.events.Event;
|
||||||
|
|
||||||
public class EndEvent extends Event {
|
public class EndEvent extends Event {
|
||||||
private PotionEffectType[] effects;
|
private PotionEffectType[] effects;
|
||||||
|
private int livesLeft = 5;
|
||||||
|
|
||||||
public EndEvent(Team team, Difficulty difficulty, int scoreOnSuccess) {
|
public EndEvent(Team team, Difficulty difficulty, int scoreOnSuccess) {
|
||||||
super(team, difficulty, scoreOnSuccess);
|
super(team, difficulty, scoreOnSuccess);
|
||||||
|
@ -60,8 +61,11 @@ public class EndEvent extends Event {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
if (event.getEntityType() == EntityType.ENDER_DRAGON) {
|
if (event.getEntityType() == EntityType.ENDER_DRAGON) {
|
||||||
if (!MC13DTL.board.getPlayers(team).isEmpty()) {
|
if (!MC13DTL.board.getPlayers(team).isEmpty() && livesLeft > 0) {
|
||||||
eventSuccess();
|
eventSuccess();
|
||||||
|
} else {
|
||||||
|
eventFailed();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +73,10 @@ public class EndEvent extends Event {
|
||||||
@Override
|
@Override
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
|
if (!MC13DTL.board.getPlayers(team).contains(event.getPlayer())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
livesLeft--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue