From b750433f91c7c5c6035b572fbc3344c1d7c140d2 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 8 Oct 2022 16:56:02 +0200 Subject: [PATCH] Add initial message --- .../de/steamwar/fightsystem/FightSystem.java | 1 + .../fightsystem/FightSystem.properties | 3 +++ .../fightsystem/FightSystem_de.properties | 3 +++ .../winconditions/WinconditionAmongUs.java | 21 ++++++++++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 1a94778..8d51340 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -118,6 +118,7 @@ public class FightSystem extends JavaPlugin { new HellsBells(); new Meteor(); + new WinconditionAmongUs(); new NoPlayersOnlineCountdown(); new PreSchemCountdown(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index 126d650..82662c0 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -238,3 +238,6 @@ WIN_LESS_DAMAGE={0} §7less damaged WIN_POINTS={0} has more points WIN_POINTS_EQUAL=§7Equal points WIN_TECHKO={0} §7is tech K.O. +# WIN_AMONG_US={0} §7is tech K.O. + +AMONG_US_IMPOSTER_MESSAGE = §4You are the Imposter§8! §7Kill all your teammates to win the game! diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties index 082f69f..b5994e0 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties @@ -223,3 +223,6 @@ WIN_LESS_DAMAGE={0} §7weniger beschädigt WIN_POINTS={0} hat mehr Punkte WIN_POINTS_EQUAL=§7Gleicher Punktestand WIN_TECHKO={0} §7ist Tech K.O. +# WIN_AMONG_US={0} §7is tech K.O. + +AMONG_US_IMPOSTER_MESSAGE = §4Du bist ein Imposter§8! §7Du musst alle Teammates töten, um zu gewinnen. \ No newline at end of file diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAmongUs.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAmongUs.java index 927ed90..720fec9 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAmongUs.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAmongUs.java @@ -19,15 +19,34 @@ package de.steamwar.fightsystem.winconditions; +import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Random; + public class WinconditionAmongUs extends Wincondition { + private final Random random = new Random(); + public WinconditionAmongUs() { super("AmongUs"); new OneShotStateDependent(Winconditions.AMONG_US, FightState.Ingame, () -> { - // TODO: Select 1 imposter from each team + FightPlayer redPlayer = getRandomPlayer(Fight.getRedTeam().getPlayers()); + FightPlayer bluePlayer = getRandomPlayer(Fight.getBlueTeam().getPlayers()); + + FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", redPlayer.getPlayer()); + FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", bluePlayer.getPlayer()); }); } + + private FightPlayer getRandomPlayer(Collection fightPlayers) { + List fightPlayerList = new ArrayList<>(fightPlayers); + return fightPlayerList.get(random.nextInt(fightPlayerList.size())); + } }