use score based on current day
This commit is contained in:
parent
d53f9461bf
commit
b5b1d500c2
4 changed files with 26 additions and 35 deletions
|
@ -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();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -8,8 +8,8 @@ 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
|
||||||
|
@ -25,8 +25,4 @@ public class TestEvent extends Event {
|
||||||
eventSuccess();
|
eventSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int scoreAwarded() {
|
|
||||||
return 20;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue