Skip to content

Commit

Permalink
Add paused game state and some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Cojomax99 committed Sep 26, 2024
1 parent 9b6a28c commit 4162872
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import java.util.function.IntFunction;

public enum GamePhaseType {
PLAYING,
WAITING,
PLAYING, // Players are loaded into and playing in a game world
PAUSED, // Game world is paused, but potentially child game worlds are now in PLAYING or WAITING
WAITING, // Players are loaded into the 'waiting world' before being loaded into a game world
;

private static final IntFunction<GamePhaseType> BY_ID = ByIdMap.continuous(Enum::ordinal, values(), ByIdMap.OutOfBoundsStrategy.ZERO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import com.lovetropics.minigames.common.util.Util;
import net.minecraft.world.phys.AABB;

/**
* For data driven game phase info
*/
public interface IGamePhaseDefinition {
IGameMapProvider getMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import javax.annotation.Nullable;
import java.util.Optional;

/**
* Stores data-driven info about a minigame
*/
public final class GameConfig implements IGameDefinition {
public final ResourceLocation id;
public final ResourceLocation backendId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

import java.util.UUID;

/**
* A unique instance of a specific minigame, stored in a GameLobby
*/
final class GameInstance implements IGame {
final GameLobby lobby;
final MinecraftServer server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
import javax.annotation.Nullable;

// TODO: do we want a different game lobby implementation for something like carnival games?
/**
* This is what is created when the command /game create is run - it is not the 'waiting room' lobby, it is a game lobby, as in
* basically a 'party' of players that will play games together.
*
* A game lobby can have many games in its queue, each will be given a GameInstance.
*/
final class GameLobby implements IGameLobby {
final MultiGameManager manager;
final MinecraftServer server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

/**
* Think of a GamePhase like an act in a play, where the play is a GameInstance
*/
public class GamePhase implements IGamePhase {
final GameInstance game;
final MinecraftServer server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import javax.annotation.Nullable;
import java.util.concurrent.atomic.AtomicInteger;

/**
* Essentially the data underlying a queued game which is stored in a game lobby
*/
public record QueuedGame(int networkId, IGameDefinition definition, BehaviorList playingBehaviors, @Nullable BehaviorList waitingBehaviors) {
private static final AtomicInteger NEXT_NETWORK_ID = new AtomicInteger();

Expand Down

0 comments on commit 4162872

Please sign in to comment.