diff --git a/Content.Server/Tabletop/TabletopBackgammonSetup.cs b/Content.Server/Tabletop/TabletopBackgammonSetup.cs new file mode 100644 index 0000000000..06f7f16d8d --- /dev/null +++ b/Content.Server/Tabletop/TabletopBackgammonSetup.cs @@ -0,0 +1,71 @@ +using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Server.Tabletop +{ + [UsedImplicitly] + public class TabletopBackgammonSetup : TabletopSetup + { + [DataField("boardPrototype")] + public string BackgammonBoardPrototype { get; } = "BackgammonBoardTabletop"; + + [DataField("whitePiecePrototype")] + public string WhitePiecePrototype { get; } = "WhiteTabletopPiece"; + + [DataField("blackPiecePrototype")] + public string BlackPiecePrototype { get; } = "BlackTabletopPiece"; + public override void SetupTabletop(TabletopSession session, IEntityManager entityManager) + { + var board = entityManager.SpawnEntity(BackgammonBoardPrototype, session.Position); + + const float borderLengthX = 7.35f; //BORDER + const float borderLengthY = 5.60f; //BORDER + + const float boardDistanceX = 1.25f; + const float pieceDistanceY = 0.80f; + + float getXPosition(float distanceFromSide, bool isLeftSide) + { + var pos = borderLengthX - (distanceFromSide * boardDistanceX); + return isLeftSide ? -pos : pos; + } + + float getYPosition(float positionNumber, bool isTop) + { + var pos = borderLengthY - (pieceDistanceY * positionNumber); + return isTop ? pos : -pos; + } + + void addPieces( + float distanceFromSide, + int numberOfPieces, + bool isBlackPiece, + bool isTop, + bool isLeftSide) + { + for (int i = 0; i < numberOfPieces; i++) + { + session.Entities.Add(entityManager.SpawnEntity(isBlackPiece ? BlackPiecePrototype : WhitePiecePrototype, session.Position.Offset(getXPosition(distanceFromSide, isLeftSide), getYPosition(i, isTop)))); + } + } + + // Top left + addPieces(0, 5, true, true, true); + // top middle left + addPieces(4, 3, false, true, true); + // top middle right + addPieces(5, 5, false, true, false); + // top far right + addPieces(0, 2, true, true, false); + // bottom left + addPieces(0, 5, false, false, true); + // bottom middle left + addPieces(4, 3, true, false, true); + // bottom middle right + addPieces(5, 5, true, false, false); + // bottom far right + addPieces(0, 2, false, false, false); + } + } +} diff --git a/Content.Server/Tabletop/TabletopParchisSetup.cs b/Content.Server/Tabletop/TabletopParchisSetup.cs index 38b6f5a5d2..2814da1069 100644 --- a/Content.Server/Tabletop/TabletopParchisSetup.cs +++ b/Content.Server/Tabletop/TabletopParchisSetup.cs @@ -11,16 +11,16 @@ namespace Content.Server.Tabletop public string ParchisBoardPrototype { get; } = "ParchisBoardTabletop"; [DataField("redPiecePrototype")] - public string RedPiecePrototype { get; } = "RedParchisPiece"; + public string RedPiecePrototype { get; } = "RedTabletopPiece"; [DataField("greenPiecePrototype")] - public string GreenPiecePrototype { get; } = "GreenParchisPiece"; + public string GreenPiecePrototype { get; } = "GreenTabletopPiece"; [DataField("yellowPiecePrototype")] - public string YellowPiecePrototype { get; } = "YellowParchisPiece"; + public string YellowPiecePrototype { get; } = "YellowTabletopPiece"; [DataField("bluePiecePrototype")] - public string BluePiecePrototype { get; } = "BlueParchisPiece"; + public string BluePiecePrototype { get; } = "BlueTabletopPiece"; public override void SetupTabletop(TabletopSession session, IEntityManager entityManager) { diff --git a/Resources/Locale/en-US/tabletop/tabletop.ftl b/Resources/Locale/en-US/tabletop/tabletop.ftl index 854b71a020..73489e245b 100644 --- a/Resources/Locale/en-US/tabletop/tabletop.ftl +++ b/Resources/Locale/en-US/tabletop/tabletop.ftl @@ -8,3 +8,6 @@ tabletop-chess-flip = Flip ## Parchís tabletop-parchis-board-name = Parchís + +## Backgammon +tabletop-backgammon-board-name = Backgammon diff --git a/Resources/Prototypes/Catalog/Cargo/cargo_fun.yml b/Resources/Prototypes/Catalog/Cargo/cargo_fun.yml index 23496dd129..e91a4c53e3 100644 --- a/Resources/Prototypes/Catalog/Cargo/cargo_fun.yml +++ b/Resources/Prototypes/Catalog/Cargo/cargo_fun.yml @@ -33,3 +33,15 @@ cost: 5000 category: Fun group: market + +- type: cargoProduct + name: "board game crate" + id: FunBoardGames + description: "Game nights have been proven to either decrease boredom or increase murderous rage depending on the game" + icon: + sprite: Objects/Fun/dice.rsi + state: d66 + product: CrateFunBoardGames + cost: 1500 + category: Fun + group: market diff --git a/Resources/Prototypes/Catalog/Fills/Crates/fun.yml b/Resources/Prototypes/Catalog/Fills/Crates/fun.yml index 3b77597215..de46ea973a 100644 --- a/Resources/Prototypes/Catalog/Fills/Crates/fun.yml +++ b/Resources/Prototypes/Catalog/Fills/Crates/fun.yml @@ -68,3 +68,19 @@ amount: 1 - id: CrayonWhite amount: 1 + +- type: entity + id: CrateFunBoardGames + name: board game crate + parent: CrateGenericSteel + components: + - type: StorageFill + contents: + - id: ChessBoard + amount: 1 + - id: BackgammonBoard + amount: 1 + - id: ParchisBoard + amount: 1 + - id: d6Dice + amount: 4 diff --git a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/backgammon.yml b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/backgammon.yml new file mode 100644 index 0000000000..53414cb6e4 --- /dev/null +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/backgammon.yml @@ -0,0 +1,25 @@ +- type: entity + parent: BaseItem + id: BackgammonBoard + name: backgammon board + description: Old fashioned game of dice and pieces. + components: + - type: Sprite + sprite: Objects/Fun/Tabletop/backgammon.rsi + state: board + - type: TabletopGame + boardName: tabletop-backgammon-board-name + size: 550, 410 + setup: + !type:TabletopBackgammonSetup + +- type: entity + id: BackgammonBoardTabletop + name: backgammon + abstract: true + components: + - type: Sprite + sprite: Objects/Fun/Tabletop/backgammon_tabletop.rsi + state: backgammonBoard + noRot: false + drawdepth: FloorTiles diff --git a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/parchis.yml b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/parchis.yml index 43f694a529..058c1baa4d 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/parchis.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/parchis.yml @@ -26,49 +26,3 @@ noRot: false drawdepth: FloorTiles -# Parchís pieces -- type: entity - id: BaseParchisPiece - parent: BaseItem - abstract: true - components: - - type: TabletopDraggable - - type: Sprite - netsync: false - noRot: true - sprite: Objects/Fun/Tabletop/parchis_pieces.rsi - - type: Appearance - visuals: - - type: TabletopItemVisualizer - -- type: entity - id: RedParchisPiece - name: red piece - parent: BaseParchisPiece - components: - - type: Sprite - state: red - -- type: entity - id: GreenParchisPiece - name: green piece - parent: BaseParchisPiece - components: - - type: Sprite - state: green - -- type: entity - id: YellowParchisPiece - name: yellow piece - parent: BaseParchisPiece - components: - - type: Sprite - state: yellow - -- type: entity - id: BlueParchisPiece - name: blue piece - parent: BaseParchisPiece - components: - - type: Sprite - state: blue diff --git a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml new file mode 100644 index 0000000000..edf7bcf93d --- /dev/null +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml @@ -0,0 +1,61 @@ +- type: entity + id: BaseTabletopPiece + parent: BaseItem + abstract: true + components: + - type: TabletopDraggable + - type: Sprite + netsync: false + noRot: true + sprite: Objects/Fun/Tabletop/generic_pieces.rsi + - type: Appearance + visuals: + - type: TabletopItemVisualizer + +- type: entity + id: RedTabletopPiece + name: red piece + parent: BaseTabletopPiece + components: + - type: Sprite + state: red + +- type: entity + id: GreenTabletopPiece + name: green piece + parent: BaseTabletopPiece + components: + - type: Sprite + state: green + +- type: entity + id: YellowTabletopPiece + name: yellow piece + parent: BaseTabletopPiece + components: + - type: Sprite + state: yellow + +- type: entity + id: BlueTabletopPiece + name: blue piece + parent: BaseTabletopPiece + components: + - type: Sprite + state: blue + +- type: entity + id: WhiteTabletopPiece + name: white piece + parent: BaseTabletopPiece + components: + - type: Sprite + state: white + +- type: entity + id: BlackTabletopPiece + name: black piece + parent: BaseTabletopPiece + components: + - type: Sprite + state: black diff --git a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml index 92810ff79e..f967d3ed2a 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml @@ -292,6 +292,7 @@ - FunPlushies - FunArtSupplies - FunInstruments + - FunBoardGames - MaterialSteel - MaterialGlass - MaterialPlastic diff --git a/Resources/Textures/Objects/Fun/Tabletop/backgammon.rsi/board.png b/Resources/Textures/Objects/Fun/Tabletop/backgammon.rsi/board.png new file mode 100644 index 0000000000..a37fd743b4 Binary files /dev/null and b/Resources/Textures/Objects/Fun/Tabletop/backgammon.rsi/board.png differ diff --git a/Resources/Textures/Objects/Fun/Tabletop/backgammon.rsi/meta.json b/Resources/Textures/Objects/Fun/Tabletop/backgammon.rsi/meta.json new file mode 100644 index 0000000000..3a4aac93f1 --- /dev/null +++ b/Resources/Textures/Objects/Fun/Tabletop/backgammon.rsi/meta.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Fishfish458", + "size": { + "x": 23, + "y": 16 + }, + "states": [ + { + "name": "board" + } + ] +} diff --git a/Resources/Textures/Objects/Fun/Tabletop/backgammon_tabletop.rsi/backgammonBoard.png b/Resources/Textures/Objects/Fun/Tabletop/backgammon_tabletop.rsi/backgammonBoard.png new file mode 100644 index 0000000000..0514e6662b Binary files /dev/null and b/Resources/Textures/Objects/Fun/Tabletop/backgammon_tabletop.rsi/backgammonBoard.png differ diff --git a/Resources/Textures/Objects/Fun/Tabletop/backgammon_tabletop.rsi/meta.json b/Resources/Textures/Objects/Fun/Tabletop/backgammon_tabletop.rsi/meta.json new file mode 100644 index 0000000000..1ada42708a --- /dev/null +++ b/Resources/Textures/Objects/Fun/Tabletop/backgammon_tabletop.rsi/meta.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Fishfish458", + "size": { + "x": 550, + "y": 410 + }, + "states": [ + { + "name": "backgammonBoard" + } + ] +} diff --git a/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/black.png b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/black.png new file mode 100644 index 0000000000..0a30689b9a Binary files /dev/null and b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/black.png differ diff --git a/Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/blue.png b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/blue.png similarity index 100% rename from Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/blue.png rename to Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/blue.png diff --git a/Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/green.png b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/green.png similarity index 100% rename from Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/green.png rename to Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/green.png diff --git a/Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/meta.json b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/meta.json similarity index 69% rename from Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/meta.json rename to Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/meta.json index 5412a69967..1fb44fb537 100644 --- a/Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/meta.json +++ b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/meta.json @@ -1,7 +1,7 @@ { "version": 1, "license": "CC-BY-SA-3.0", - "copyright": "Zumorica", + "copyright": "Zumorica, Fishfish458", "size": { "x": 24, "y": 24 @@ -18,6 +18,12 @@ }, { "name": "blue" + }, + { + "name": "white" + }, + { + "name": "black" } ] } diff --git a/Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/red.png b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/red.png similarity index 100% rename from Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/red.png rename to Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/red.png diff --git a/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/white.png b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/white.png new file mode 100644 index 0000000000..61d55b4ef0 Binary files /dev/null and b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/white.png differ diff --git a/Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/yellow.png b/Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/yellow.png similarity index 100% rename from Resources/Textures/Objects/Fun/Tabletop/parchis_pieces.rsi/yellow.png rename to Resources/Textures/Objects/Fun/Tabletop/generic_pieces.rsi/yellow.png