Skip to content

Commit

Permalink
Remove unused imports and add grace period countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ellieisjelly committed Jan 4, 2024
1 parent e71278b commit 6dc849a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
15 changes: 12 additions & 3 deletions src/main/java/me/ellieis/Sabotage/game/phase/SabotageActive.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package me.ellieis.Sabotage.game.phase;

import com.google.common.collect.ImmutableSet;
import eu.pb4.sidebars.api.Sidebar;
import eu.pb4.sidebars.api.lines.SidebarLine;
import me.ellieis.Sabotage.game.SabotageConfig;
import me.ellieis.Sabotage.game.map.SabotageMap;
import net.minecraft.network.packet.s2c.play.PositionFlag;
Expand Down Expand Up @@ -102,6 +104,7 @@ public void pickRoles() {
this.detectives.showTitle(Text.translatable("sabotage.role_reveal", Text.translatable("sabotage.detective").formatted(Formatting.DARK_BLUE)), 10, 80, 10);
this.detectives.playSound(SoundEvents.BLOCK_AMETHYST_BLOCK_CHIME);
this.saboteurs.showTitle(Text.translatable("sabotage.role_reveal", Text.translatable("sabotage.saboteur").formatted(Formatting.RED)), 10, 80, 10);
this.saboteurs.playSound(SoundEvents.ENTITY_ILLUSIONER_CAST_SPELL);
this.saboteurs.playSound(SoundEvents.AMBIENT_SOUL_SAND_VALLEY_MOOD.value());
}
public void Start() {
Expand All @@ -114,8 +117,11 @@ public static void Open(GameSpace gameSpace, ServerWorld world, SabotageMap map,
SabotageActive game = new SabotageActive(config, gameSpace, map, world);
game.startTime = world.getTime();
game.countdown = true;
game.activity = activity;
game.widgets = GlobalWidgets.addTo(activity);
game.globalSidebar = game.widgets.addSidebar(Text.translatable("gameType.sabotage.sabotage"));
game.globalSidebar = game.widgets.addSidebar(Text.translatable("gameType.sabotage.sabotage").formatted(Formatting.GOLD));
game.globalSidebar.setPriority(Sidebar.Priority.LOW);
game.globalSidebar.setLine(SidebarLine.create(0, Text.translatable("sabotage.sidebar.countdown")));
rules(activity);
activity.listen(GameActivityEvents.TICK, game::onTick);

Expand All @@ -127,7 +133,6 @@ public static void Open(GameSpace gameSpace, ServerWorld world, SabotageMap map,
game.map.spawnEntity(world, plr);
game.globalSidebar.addPlayer(plr);
});

});
}

Expand Down Expand Up @@ -160,8 +165,12 @@ public void onTick() {
} else {
// to-do: implement grace period
int secondsSinceStart = (int) Math.floor((time / 20) - (this.startTime / 20)) - this.config.getCountdownTime();
if (secondsSinceStart >= this.config.getGracePeriod()) {
int gracePeriod = this.config.getGracePeriod();
if (secondsSinceStart >= gracePeriod) {
Start();
} else {
int secondsLeft = gracePeriod - secondsSinceStart;
this.globalSidebar.setLine(SidebarLine.create(0, Text.translatable("sabotage.sidebar.grace_period." + ((secondsLeft == 1) ? "singular" : "plural"), secondsLeft)));
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
package me.ellieis.Sabotage.game.phase;

import eu.pb4.sidebars.api.lines.SidebarLine;
import me.ellieis.Sabotage.game.SabotageConfig;
import me.ellieis.Sabotage.game.map.SabotageMap;
import me.ellieis.Sabotage.game.map.SabotageMapBuilder;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameMode;
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
import xyz.nucleoid.plasmid.game.*;

import xyz.nucleoid.plasmid.game.GameActivity;
import xyz.nucleoid.plasmid.game.GameOpenContext;
import xyz.nucleoid.plasmid.game.GameOpenProcedure;
import xyz.nucleoid.plasmid.game.GameSpace;
import xyz.nucleoid.plasmid.game.GameResult;
import xyz.nucleoid.plasmid.game.common.GameWaitingLobby;
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.game.common.widget.SidebarWidget;
import xyz.nucleoid.plasmid.game.event.GameActivityEvents;
import xyz.nucleoid.plasmid.game.event.GamePlayerEvents;
import xyz.nucleoid.plasmid.game.player.PlayerOffer;
import xyz.nucleoid.plasmid.game.player.PlayerOfferResult;
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
import xyz.nucleoid.stimuli.Stimuli;

public class SabotageWaiting {
private final SabotageConfig config;
private final GameSpace gameSpace;
private final SabotageMap map;
private final ServerWorld world;
private int playerCount;

public SabotageWaiting(SabotageConfig config, GameSpace gameSpace, SabotageMap map, ServerWorld world) {
this.config = config;
this.gameSpace = gameSpace;
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/data/sabotage/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"gameType.sabotage.sabotage": "Sabotage",
"sabotage.waiting": "Waiting for players.",
"sabotage.full": "Game is full.",
"sabotage.sidebar.countdown": "Get ready!",
"sabotage.sidebar.grace_period.plural": "You have %s seconds left.",
"sabotage.sidebar.grace_period.singular": "You have %s second left.",
"sabotage.game_start": "The game has started! You have %s seconds to collect items, gear, or hide. Your roles will be selected after the grace period.",
"sabotage.role_reveal": "You are a %s",
"sabotage.innocent": "Innocent",
Expand Down

0 comments on commit 6dc849a

Please sign in to comment.