From facb2ea849d620fa19ad8ddc08e432c159483963 Mon Sep 17 00:00:00 2001 From: Demetre Beroshvili <69920861+Capnsockless@users.noreply.github.com> Date: Tue, 18 Jan 2022 15:44:24 -0800 Subject: [PATCH] Added Checkers (#6219) --- .../Tabletop/TabletopCheckerSetup.cs | 71 ++++++++++++++++ Resources/Locale/en-US/tabletop/tabletop.ftl | 3 + .../Prototypes/Catalog/Fills/Crates/fun.yml | 2 + .../Objects/Fun/Tabletop/checkers.yml | 76 ++++++++++++++++++ .../checker_pieces.rsi/b_checker_piece.png | Bin 0 -> 1578 bytes .../checker_pieces.rsi/b_checker_queen.png | Bin 0 -> 1587 bytes .../Fun/Tabletop/checker_pieces.rsi/meta.json | 23 ++++++ .../checker_pieces.rsi/w_checker_piece.png | Bin 0 -> 1601 bytes .../checker_pieces.rsi/w_checker_queen.png | Bin 0 -> 2124 bytes 9 files changed, 175 insertions(+) create mode 100644 Content.Server/Tabletop/TabletopCheckerSetup.cs create mode 100644 Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml create mode 100644 Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/b_checker_piece.png create mode 100644 Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/b_checker_queen.png create mode 100644 Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/meta.json create mode 100644 Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/w_checker_piece.png create mode 100644 Resources/Textures/Objects/Fun/Tabletop/checker_pieces.rsi/w_checker_queen.png 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 0000000000000000000000000000000000000000..a99768ad0baf10e9b54d8d3b64546554981ccc65 GIT binary patch literal 1578 zcmbVMTWB0r7@ksUO=_Uff^CH|PPSrA=en0ThfG4clV-O#F-^8j3c-4I=IrhvGjpah zXSz?aJpl%2aUclDzu`KWn2%R;A;aDI)ZH@C;5+Xh$DWa_? z8sD!=Y9^J+D7$z~(G*!p%c>@-8K9(q+RwK>fk_LU5|}Xev}CcJAyg<0fGpQ)HK~@A zNLZFtUDstrlQm6b2r-)TDXfcr)Z1n-QDlcWpqTi4%m|C5N)3T&+BCrnI<$V&auaiy zT!(?IN=j@}1L)WtTu=?&hH%H0k&8U!(}-c!4mPL|N}>w+7wXRSZ338UEvqAARb4!< zBO;V7QUl#a|8$p)1BxHh_cFC3J`D}JPBqi*!i_ttw#bOn^RKz|XO^oht z=xbRZ??)8+Hp-iZz`P@2>;PRy$z-~yiD^|&iJF}%in`A1)?pH696hb|>*@A;li1Zb z2iotQ|M~v$5VIPD?p^c5l^G`w$l-{Eb*@!Aljv}3W0O6~svYBQct=h?HmzhG@9VymiOKlbP~zT(M0%kPPrk>j51!AP!-d@OFHc?Tc}BU<{Al0$H$e8*t50v;cxL9}!pzd68`tmu z?$6>^8!o;5Tw?jdwVavQHE(>qyz{!(btuvG;Em0d9~Z@64^D0Fe&maVR~BD?HnEr9 z+&=T^xuZ+N!MdY+ZtmD}>{j9ezxIX1`+b+*(@vzX?nTRol%=1yU-3RZ{d@1Rv*L}) zfi-_j9!{LXB;4k1U9@)e{q)eA?_7TO#p|C9(reErKJW6+JaN(txS^TT;>oMuzV=jk Z@a({e2R=Ce*DrB5&yS3mZ|#0^;cvYB|KR`t literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..7140364d023df1a2bc28888f7554f5fc30d66bdd GIT binary patch literal 1587 zcmbVMU5Hdw9KVs7E-Gpd4c5c;8nUK$?#Is8J$T*LnQdpFS;uu`w+QUaxo2ihbMHO3 zd+#{2(}Oy1Zd8bDkV!!bK1iW58=0tKA5a?z`xFTwl=WocvXC!9=gt>vS&|pdJzu}` z`+xtB=Eld?4s06WIBsnwotj{CC>X0&vj5GRewR(Fo%D+y$F2J^7>~?uU-uNpJ@zEY zPx({X7XYGG7#g&I!*$DHXpY-CTz4R-Ei@~ z#&{kzDo8Vg;a&XBI$#7A_90)lOxpu>U1;+HwhoRZfp0_niY|-<0{N+Ij!#k-^Rcij zB3V}XxE5Aokw{G5!K<<=OLA0FR8ffmIRcb8-~9w8%{7W(BK3S%7Tf7U+4mhFNwr!n zTpJ2gwd=vtupF4w1{$c3bE>Y{7H%L3o7lp(?=h^>$2w)|Q?E?_g}Q%zj{xS{Y_>1s zzPeaeUxeq69%N>89dci^m!Ed9G=V)@brBvt$kf~tSmS`Ci=j{5Jf&tYP`RGUysCs% zesGf52CaG9mOa2J=wn@AQBy@(5tT$<83GXnsM>ZGJ6Y~Pv(zBP>3>2aKvjU8xChEo z#(+M2AlN{lNL>pugNX%8SaR%=!1vtJj~ zV)Nd_*zUHz*(}J|o)2w=GbvqQ-U$<8fI=b?mt`d;CQvLcYK4d@LJdYm7=vmef#Qic zM7{SZimE{l^xhl)^Zg!|uo{HsL-Pcc86*!#6OV;;x?4N@@N3w$?UG3BM8Vmo$7e>bsxx2(E*aMm({ zWxrRkO~2b=o3%KX^|C7`Z-2-7;I&L@B%eNdc~;x_1;1u=xPyO(!RtOIM%Uq5S&v`^JS8mk%7cFw>Iu&cC@ZkbrM*SemJvKYe8E<$1E^nLDkI zHd|-sSF|{3Zl&`?6yI8S_EqtdZ%!RvICcYF550Bjm$}D3xVXCIY}gfDe`jlD>pQ{^ z=%xKPk9_;*p5x+d+0oWFZ|`4fo-mKU-q^c%pI7ux(|Xz4`m;?LVYL)UJd m`{Q#Yd^K}OUHtycaP!fxsn>XSF)f_z7H2(sG1r167 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..8c1e50bcbdb8de03dd8463699da5936e9cf6ecd9 GIT binary patch literal 1601 zcmbVMTWB0r7@ley+gv16B_dMCDYc31%$%9MBr{|hw!7Qx8h4GGg{D@EvomLR51E-W z&YaC|B3cOw>02$8+ExlG)%ak2P@$lu7X>4xB1l2{QXfhl#8Mv$22}9O-bf`{?7*3G z`_A{@|3l;1(VosnIvIxPNv9GyIzJqYjUDv=b5&cR(jbuQ^jl(iZ&3bTR zHk&tQrwqm9Ms~5oHI)+Bkmzj9wj5urXZV{ zL>(s9bXSxF5SUa4nnoMvRy?aN+%!aJK^r>6r&y_tb<3Dwzl{Hdx_y0{0P5OIrY&Pl zU2MB8!Y9dTYDUu`Yoh)9j0?pa^l`;AU~-zOxizrHRpTDi3HI_BTdhEiw^U|jNs!t8 zy~r_f)gM^(048(-HI7D2=7GdZN*+k6EUQvv2aO#74QK|Ns5rAGbVv<_Z-dg5F?FKf z5o{W25qq{y4Mw(Jf}-n`IJWIZHI6OpQNdKZ(CYJaJU;H>BC_bkXqu*Cp@J;JBZu{K zqr2<+W-@Bp@rmvjFrCmi>Ky?gQw@U%C`uuPmj}%#Z@{q051F#gD+-8GokNBRVC#JX z8FT2Y*N>V)@je8*g3gxdghC=XXpmJ|x|{xv=i_uRFRIJ5uu- zdUK_P*~>3GH?HS>%`+r*T`>uJH^8vFI30St%JSm{U&t4%qe=c@k zWOLV+O;2qb7<%oEEsu^J`EFr*=-4l#2fzQ4c{h1#>gs_j(?OF@C$ot&yI-998#F=+ A{Qv*} literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a44f3011dffa5c21de15c7d4c5417ff44d33c76c GIT binary patch literal 2124 zcmb_de{2&~96zSxmyE8Xup}dhG$%41yznECH&a%`=HSYL zFZAUnlD2J#6qU(jTp71ZH`^)3=krlCOR+485TupUY>*{2tEy-r2rbD}4O`VU+_4A} zdZ+Ct5Yx#J(niUwW);$e5=Lc#K`}1c2`LYhr4r8QG*fx!vP8iYOhe7K5SA%njihet zR#Lx%>C*B|4p3@iv67Ezxunx27nU9BLSYmVGA-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