mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 22:14:45 +00:00
feat(war): add battle interface
This commit is contained in:
3 files changed
+35
-23
No files matched your search
@@ -176,7 +176,7 @@ public class SiegeCommands {
|
||||
if (!(args.get("siege") instanceof final @NotNull Siege siege))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>Invalid siege.").build());
|
||||
|
||||
siege.noWinner();
|
||||
siege.equalWin();
|
||||
}
|
||||
|
||||
private static void siegeAbandon(Player p, @NotNull CommandArguments args, boolean asAdmin) throws WrapperCommandSyntaxException {
|
||||
|
||||
@@ -1,30 +1,42 @@
|
||||
package com.github.alathra.AlathranWars.conflict.battle;
|
||||
|
||||
public class Battle {
|
||||
/*private int attackerPoints;
|
||||
private int defenderPoints;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public int getAttackerPoints() {
|
||||
return this.attackerPoints;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Battle {
|
||||
void start(); // Initiates battle
|
||||
void stop(); // Ends battle
|
||||
void resume(); // Resume battle after server restart or plugin reload
|
||||
|
||||
void attackersWin(); // A Attacker victory
|
||||
void defendersWin(); // A Defender victory
|
||||
void equalWin(); // A Draw
|
||||
|
||||
|
||||
UUID uuid = null; // Battle UUID
|
||||
default @NotNull UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setAttackerPoints(int points) {
|
||||
this.attackerPoints = points;
|
||||
/**
|
||||
* Equals boolean.
|
||||
*
|
||||
* @param uuid the uuid
|
||||
* @return the boolean
|
||||
*/
|
||||
default boolean equals(UUID uuid) {
|
||||
return getUUID().equals(uuid);
|
||||
}
|
||||
|
||||
public int getDefenderPoints() {
|
||||
return this.defenderPoints;
|
||||
/**
|
||||
* Equals boolean.
|
||||
*
|
||||
* @param battle the battle
|
||||
* @return the boolean
|
||||
*/
|
||||
default boolean equals(@NotNull Battle battle) {
|
||||
return getUUID().equals(battle.getUUID());
|
||||
}
|
||||
|
||||
public void setDefenderPoints(int points) {
|
||||
this.defenderPoints = points;
|
||||
}
|
||||
|
||||
public void addPointsToAttackers(final int points) {
|
||||
this.attackerPoints += points;
|
||||
}
|
||||
|
||||
public void addPointsToDefenders(final int points) {
|
||||
this.defenderPoints += points;
|
||||
}*/
|
||||
}
|
||||
@@ -31,7 +31,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Siege extends Battle {
|
||||
public class Siege implements Battle {
|
||||
public static final Duration SIEGE_DURATION = Duration.ofMinutes(60);
|
||||
public static final int MAX_SIEGE_PROGRESS_MINUTES = 8; // How many minutes attackers will need to be on point uncontested for to reach 100%
|
||||
public static final int MAX_SIEGE_PROGRESS = 60 * 10 * MAX_SIEGE_PROGRESS_MINUTES; // On reaching this, the attackers win. 10 points is added per second
|
||||
@@ -284,7 +284,7 @@ public class Siege extends Battle {
|
||||
/**
|
||||
* No winner declared
|
||||
*/
|
||||
public void noWinner() {
|
||||
public void equalWin() {
|
||||
Bukkit.broadcast(
|
||||
ColorParser.of("<prefix>The siege of <town> has ended in a draw!")
|
||||
.parseMinimessagePlaceholder("prefix", UtilsChat.getPrefix())
|
||||
|
||||
Reference in new issue
Block a user