use score based on current day

This commit is contained in:
Xander 2024-09-15 21:40:06 +02:00
parent d53f9461bf
commit b5b1d500c2
No known key found for this signature in database
GPG key ID: 79979C7BA303E003
4 changed files with 26 additions and 35 deletions

View file

@ -16,10 +16,13 @@ public abstract class Event implements Listener, Runnable {
protected Team team;
private int taskId;
protected final Difficulty difficulty;
private final int scoreOnSuccess;
public Event(Team team, Difficulty difficulty) {
public Event(Team team, Difficulty difficulty, int scoreOnSuccess) {
this.team = team;
this.difficulty = difficulty;
this.scoreOnSuccess = scoreOnSuccess;
MC13DTL.board.sendMessageToTeam(team, Component.text("Difficulty is " + this.difficulty.toString()));
MC13DTL.board.sendMessageToTeam(team, Component.text(getMessage()).color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC));
MC13DTL.instance.getServer().getPluginManager().registerEvents(this, MC13DTL.instance);
@ -39,7 +42,7 @@ public abstract class Event implements Listener, Runnable {
protected void eventSuccess() {
MC13DTL.board.sendMessageToTeam(team, Component.text("Congratulations! You survived this event").color(NamedTextColor.GREEN));
MC13DTL.board.addScore(team, scoreAwarded());
MC13DTL.board.addScore(team, scoreOnSuccess);
eventFinished();
}
@ -60,6 +63,4 @@ public abstract class Event implements Listener, Runnable {
}
protected abstract String getMessage();
protected abstract int scoreAwarded();
}

View file

@ -39,16 +39,16 @@ public class EventRunner implements Runnable {
Team team = teams.get(i);
Difficulty difficulty = difficulties.get(i);
switch ((int) day) {
case 0 -> new TestEvent(team, difficulty);
case 1 -> new TestEvent2(team, difficulty);
case 0 -> new TestEvent(team, difficulty, getDayScore());
case 1 -> new TestEvent2(team, difficulty, getDayScore());
}
}
world.getPersistentDataContainer().set(eventKey, PersistentDataType.LONG, day);
}
}
private long getDayScore() {
return this.day * 10 + 1;
private int getDayScore() {
return (int) Math.pow(2, this.day);
}
private List<Difficulty> getDifficulties(List<Team> teams) {

View file

@ -8,8 +8,8 @@ import org.bukkit.scoreboard.Team;
import gent.zeus.mc13dtl.events.Event;
public class TestEvent extends Event {
public TestEvent(Team team, Difficulty difficulty) {
super(team, difficulty);
public TestEvent(Team team, Difficulty difficulty, int scoreOnSuccess) {
super(team, difficulty, scoreOnSuccess);
}
@Override
@ -25,8 +25,4 @@ public class TestEvent extends Event {
eventSuccess();
}
@Override
protected int scoreAwarded() {
return 20;
}
}

View file

@ -8,8 +8,8 @@ import org.bukkit.scoreboard.Team;
import gent.zeus.mc13dtl.events.Event;
public class TestEvent2 extends Event {
public TestEvent2(Team team, Difficulty difficulty) {
super(team, difficulty);
public TestEvent2(Team team, Difficulty difficulty, int scoreOnSuccess) {
super(team, difficulty, scoreOnSuccess);
}
@Override
@ -24,10 +24,4 @@ public class TestEvent2 extends Event {
}
eventSuccess();
}
@Override
protected int scoreAwarded() {
return 200;
}
}