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

View file

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

View file

@ -8,25 +8,21 @@ import org.bukkit.scoreboard.Team;
import gent.zeus.mc13dtl.events.Event; import gent.zeus.mc13dtl.events.Event;
public class TestEvent extends Event { public class TestEvent extends Event {
public TestEvent(Team team, Difficulty difficulty) { public TestEvent(Team team, Difficulty difficulty, int scoreOnSuccess) {
super(team, difficulty); super(team, difficulty, scoreOnSuccess);
} }
@Override @Override
protected String getMessage() { protected String getMessage() {
return "test"; return "test";
} }
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getPlayer() == null) { if (event.getPlayer() == null) {
return; return;
}
eventSuccess();
} }
eventSuccess();
}
@Override
protected int scoreAwarded() {
return 20;
}
} }

View file

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