diff --git a/Content.Server/Tabletop/TabletopCheckerSetup.cs b/Content.Server/Tabletop/TabletopCheckerSetup.cs new file mode 100644 index 0000000000..6a112073ee --- /dev/null +++ b/Content.Server/Tabletop/TabletopCheckerSetup.cs @@ -0,0 +1,71 @@ +using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.Map; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; + +namespace Content.Server.Tabletop +{ + [UsedImplicitly] + public class TabletopCheckerSetup : TabletopSetup + { + [DataField("boardPrototype", customTypeSerializer:typeof(PrototypeIdSerializer))] + public string CheckerBoardPrototype { get; } = "CheckerBoardTabletop"; + + // TODO: Un-hardcode the rest of entity prototype IDs, probably. + + public override void SetupTabletop(TabletopSession session, IEntityManager entityManager) + { + var checkerboard = entityManager.SpawnEntity(CheckerBoardPrototype, session.Position.Offset(-1, 0)); + + session.Entities.Add(checkerboard); + + SpawnPieces(session, entityManager, session.Position.Offset(-4.5f, 3.5f)); + } + + private void SpawnPieces(TabletopSession session, IEntityManager entityManager, MapCoordinates topLeft, float separation = 1f) + { + var (mapId, x, y) = topLeft; + + // Spawn all black pieces + SpawnPieces(session, entityManager, "Black", topLeft, separation); + + // Spawn all white pieces + SpawnPieces(session, entityManager, "White", new MapCoordinates(x, y - 7 * separation, mapId), separation); + + // Queens + for (int i = 1; i < 4; i++) + { + EntityUid tempQualifier = entityManager.SpawnEntity("BlackCheckerQueen", new MapCoordinates(x + 9 * separation + 9f / 32, y - i * separation, mapId)); + session.Entities.Add(tempQualifier); + + EntityUid tempQualifier1 = entityManager.SpawnEntity("WhiteCheckerQueen", new MapCoordinates(x + 8 * separation + 9f / 32, y - i * separation, mapId)); + session.Entities.Add(tempQualifier1); + } + + } + + private void SpawnPieces(TabletopSession session, IEntityManager entityManager, string color, MapCoordinates left, float separation = 1f) + { + var (mapId, x, y) = left; + // If white is being placed it must go from bottom->up + var reversed = (color == "White") ? 1 : -1; + + for (int i = 0; i < 3; i++) + { + var x_offset = i % 2; + if (reversed == -1) x_offset = 1 - x_offset; // Flips it + + for (int j = 0; j < 8; j += 2) + { + // Prevents an extra piece on the middle row + if (x_offset + j > 8) continue; + + EntityUid tempQualifier4 = entityManager.SpawnEntity(color + "CheckerPiece", new MapCoordinates(x + (j + x_offset) * separation, y + i * reversed * separation, mapId)); + session.Entities.Add(tempQualifier4); + } + } + } + } +} diff --git a/Resources/Locale/en-US/tabletop/tabletop.ftl b/Resources/Locale/en-US/tabletop/tabletop.ftl index 73489e245b..1231b8bf24 100644 --- a/Resources/Locale/en-US/tabletop/tabletop.ftl +++ b/Resources/Locale/en-US/tabletop/tabletop.ftl @@ -11,3 +11,6 @@ tabletop-parchis-board-name = Parchís ## Backgammon tabletop-backgammon-board-name = Backgammon + +## Checkers +tabletop-checkers-board-name = Checkers diff --git a/Resources/Prototypes/Catalog/Fills/Crates/fun.yml b/Resources/Prototypes/Catalog/Fills/Crates/fun.yml index de46ea973a..864e30080e 100644 --- a/Resources/Prototypes/Catalog/Fills/Crates/fun.yml +++ b/Resources/Prototypes/Catalog/Fills/Crates/fun.yml @@ -82,5 +82,7 @@ amount: 1 - id: ParchisBoard amount: 1 + - id: CheckerBoard + amount: 1 - id: d6Dice amount: 4 diff --git a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml new file mode 100644 index 0000000000..28add02223 --- /dev/null +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml @@ -0,0 +1,76 @@ +# Uses the chessboard and generic pieces +- type: entity + parent: BaseItem + id: CheckerBoard + name: checkerboard + description: A checkerboard. Pieces included! + components: + - type: Sprite + sprite: Objects/Fun/Tabletop/chessboard.rsi + state: chessboard + - type: TabletopGame + boardName: tabletop-checkers-board-name + size: 338, 274 + setup: !type:TabletopCheckerSetup + +# Checkerboard tabletop item (item only visible in tabletop game) +- type: entity + id: CheckerBoardTabletop + name: checkerboard + abstract: true + components: + - type: Sprite + sprite: Objects/Fun/Tabletop/chessboard_tabletop.rsi + state: chessboard_tabletop + noRot: false + drawdepth: FloorTiles + +- type: entity + id: BaseCheckerPiece + parent: BaseItem + abstract: true + components: + - type: TabletopDraggable + - type: Sprite + netsync: false + noRot: true + - type: Appearance + visuals: + - type: TabletopItemVisualizer + +# The pieces +- type: entity + id: WhiteCheckerPiece + name: white piece + parent: BaseCheckerPiece + components: + - type: Sprite + sprite: Objects/Fun/Tabletop/checker_pieces.rsi + state: w_checker_piece + +- type: entity + id: WhiteCheckerQueen + name: white queen + parent: BaseCheckerPiece + components: + - type: Sprite + sprite: Objects/Fun/Tabletop/checker_pieces.rsi + state: w_checker_queen + +- type: entity + id: BlackCheckerPiece + name: black piece + parent: BaseCheckerPiece + components: + - type: Sprite + sprite: Objects/Fun/Tabletop/checker_pieces.rsi + state: b_checker_piece + +- type: entity + id: BlackCheckerQueen + name: black queen + parent: BaseCheckerPiece + components: + - type: Sprite + sprite: Objects/Fun/Tabletop/checker_pieces.rsi + state: b_checker_queen diff --git a/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/b_checker_piece.png b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/b_checker_piece.png new file mode 100644 index 0000000000..a99768ad0b Binary files /dev/null and b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/b_checker_piece.png differ diff --git a/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/b_checker_queen.png b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/b_checker_queen.png new file mode 100644 index 0000000000..7140364d02 Binary files /dev/null and b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/b_checker_queen.png differ diff --git a/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/meta.json b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/meta.json new file mode 100644 index 0000000000..ceb785d8bd --- /dev/null +++ b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/meta.json @@ -0,0 +1,23 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Zumorica, Fishfish458, Capnsockless", + "size": { + "x": 24, + "y": 24 + }, + "states": [ + { + "name": "w_checker_piece" + }, + { + "name": "w_checker_queen" + }, + { + "name": "b_checker_piece" + }, + { + "name": "b_checker_queen" + } + ] +} diff --git a/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/w_checker_piece.png b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/w_checker_piece.png new file mode 100644 index 0000000000..8c1e50bcbd Binary files /dev/null and b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/w_checker_piece.png differ diff --git a/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/w_checker_queen.png b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/w_checker_queen.png new file mode 100644 index 0000000000..a44f3011df Binary files /dev/null and b/Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/w_checker_queen.png differ